]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/Linux/activation-options.cc
1 // Test for ASAN_OPTIONS=start_deactivated=1 mode.
2 // Main executable is uninstrumented, but linked to ASan runtime. The shared
3 // library is instrumented.
5 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
6 // RUN: %clangxx -O0 %s -c -o %t.o
7 // RUN: %clangxx_asan -O0 %t.o %libdl -o %t
9 // RUN: rm -f %t.asan.options.activation-options.cc.tmp
10 // RUN: rm -f %t.asan.options.ABCDE
11 // RUN: echo "help=1" >%t.asan.options.activation-options.cc.tmp
13 // RUN: %env_asan_opts=start_deactivated=1 \
14 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options.%b %run %t 2>&1 | \
15 // RUN: FileCheck %s --check-prefix=CHECK-HELP --check-prefix=CHECK-FOUND
17 // RUN: %env_asan_opts=start_deactivated=1 \
18 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options not %run %t 2>&1 | \
19 // RUN: FileCheck %s --check-prefix=CHECK-NO-HELP --check-prefix=CHECK-MISSING
21 // RUN: %env_asan_opts=start_deactivated=1 \
22 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options.%b not %run %t --fix-name 2>&1 | \
23 // RUN: FileCheck %s --check-prefix=CHECK-NO-HELP --check-prefix=CHECK-MISSING
25 // RUN: echo "help=1" >%t.asan.options.ABCDE
27 // RUN: %env_asan_opts=start_deactivated=1 \
28 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options.%b %run %t --fix-name 2>&1 | \
29 // RUN: FileCheck %s --check-prefix=CHECK-HELP --check-prefix=CHECK-FOUND
31 // XFAIL: arm-linux-gnueabi
34 #if !defined(SHARED_LIB)
44 #include "sanitizer/asan_interface.h"
48 int main(int argc
, char *argv
[]) {
49 std::string path
= std::string(argv
[0]) + "-so.so";
51 if (argc
> 1 && strcmp(argv
[1], "--fix-name") == 0) {
52 assert(strlen(argv
[0]) > 5);
53 strcpy(argv
[0], "ABCDE");
56 void *dso
= dlopen(path
.c_str(), RTLD_NOW
);
58 fprintf(stderr
, "dlopen failed: %s\n", dlerror());
65 // Empty: all we need is an ASan shared library constructor.
68 // CHECK-HELP: Available flags for {{.*}}Sanitizer:
69 // CHECK-NO-HELP-NOT: Available flags for {{.*}}Sanitizer:
70 // CHECK-FOUND-NOT: Failed to read options
71 // CHECK-MISSING: Failed to read options