diff options
-rw-r--r-- | compiler-rt/lib/asan/lit_tests/TestCases/Darwin/unset-insert-libraries-on-exec.cc | 12 | ||||
-rw-r--r-- | compiler-rt/lib/asan/lit_tests/TestCases/Helpers/echo-env.cc | 19 |
2 files changed, 25 insertions, 6 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/Darwin/unset-insert-libraries-on-exec.cc b/compiler-rt/lib/asan/lit_tests/TestCases/Darwin/unset-insert-libraries-on-exec.cc index 3b2ab9e2ee4..fa0dd4f9df8 100644 --- a/compiler-rt/lib/asan/lit_tests/TestCases/Darwin/unset-insert-libraries-on-exec.cc +++ b/compiler-rt/lib/asan/lit_tests/TestCases/Darwin/unset-insert-libraries-on-exec.cc @@ -2,19 +2,19 @@ // executing other programs. // RUN: %clangxx_asan %s -o %t +// RUN: %clangxx %p/../Helpers/echo-env.cc -o %T/echo-env // RUN: %clangxx %p/../SharedLibs/darwin-dummy-shared-lib-so.cc \ // RUN: -dynamiclib -o %t-darwin-dummy-shared-lib-so.dylib // Make sure DYLD_INSERT_LIBRARIES doesn't contain the runtime library before // execl(). -// RUN: %t >/dev/null 2>&1 +// RUN: %t %T/echo-env >/dev/null 2>&1 // RUN: DYLD_INSERT_LIBRARIES=%t-darwin-dummy-shared-lib-so.dylib \ -// RUN: %t 2>&1 | FileCheck %s || exit 1 +// RUN: %t %T/echo-env 2>&1 | FileCheck %s || exit 1 #include <unistd.h> -int main() { - execl("/bin/bash", "/bin/bash", "-c", - "echo DYLD_INSERT_LIBRARIES=$DYLD_INSERT_LIBRARIES", NULL); - // CHECK: {{DYLD_INSERT_LIBRARIES=.*darwin-dummy-shared-lib-so.dylib.*}} +int main(int argc, char *argv[]) { + execl(argv[1], argv[1], "DYLD_INSERT_LIBRARIES", NULL); + // CHECK: {{DYLD_INSERT_LIBRARIES = .*darwin-dummy-shared-lib-so.dylib.*}} return 0; } diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/Helpers/echo-env.cc b/compiler-rt/lib/asan/lit_tests/TestCases/Helpers/echo-env.cc new file mode 100644 index 00000000000..65e91c155c8 --- /dev/null +++ b/compiler-rt/lib/asan/lit_tests/TestCases/Helpers/echo-env.cc @@ -0,0 +1,19 @@ +// Helper binary for +// lit_tests/TestCases/Darwin/unset-insert-libraries-on-exec.cc +// Prints the environment variable with the given name. +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) { + if (argc != 2) { + printf("Usage: %s ENVNAME\n", argv[0]); + exit(1); + } + const char *value = getenv(argv[1]); + if (value) { + printf("%s = %s\n", argv[1], value); + } else { + printf("%s not set.\n", argv[1]); + } + return 0; +} |