From 80ab9f712667317379a836d14c9efe070aca1edc Mon Sep 17 00:00:00 2001
From: Steve Muckle <smuckle@google.com>
Date: Mon, 9 Oct 2017 14:35:11 -0700
Subject: [PATCH 06/20] execveat: build exec kselftest for Android

The Makefile for the exec kselftest creates a script, symlink, copy of
the binary, etc. Rather than have VTS copy all these items to the
target, create a wrapper script to create these on the target. Note that
the test also tries to access its Makefile.

(cherry picked from commit ea307c2e597a51f6cf60a786f2f2839413571e61)
Bug: 67016227
Test: run vts-kernel -m VtsKernelLinuxKselftestStaging
Signed-off-by: Steve Muckle <smuckle@google.com>
---
 tools/testing/selftests/exec/execveat.sh | 33 ++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100755 tools/testing/selftests/exec/execveat.sh

diff --git a/tools/testing/selftests/exec/execveat.sh b/tools/testing/selftests/exec/execveat.sh
new file mode 100755
index 000000000000..dc049eaef690
--- /dev/null
+++ b/tools/testing/selftests/exec/execveat.sh
@@ -0,0 +1,33 @@
+#!/system/bin/sh
+
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# These are normally created as part of the kselftest build but for VTS
+# it is probably easier to use a wrapper script that creates them
+# at runtime, on target, as part of the test.
+
+DIR=$(dirname "$0")
+cd $DIR && \
+mkdir -p subdir && \
+echo '#!/system/bin/sh' > script && \
+echo 'exit $*' >> script && \
+chmod +x script && \
+touch Makefile && \
+ln -s -f execveat execveat.symlink && \
+cp execveat execveat.denatured && \
+chmod -x execveat.denatured && \
+./execveat
-- 
2.42.0.609.gbb76f46606-goog

