diff options
author | Fangrui Song <maskray@google.com> | 2019-08-02 06:07:05 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-08-02 06:07:05 +0000 |
commit | 871e3822d6679af8f7cfa763b65258e47f2d8d69 (patch) | |
tree | 10a44a1d29f910a8a20395f949d24063021d4651 /test/msan/sigaction.cpp | |
parent | 47a529b8d28fde062f77140eaf027047150fed8e (diff) | |
download | compiler-rt-871e3822d6679af8f7cfa763b65258e47f2d8d69.tar.gz |
compiler-rt: Rename .cc file in test/msan to .cpp
Like r367463, but for test/msan.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/msan/sigaction.cpp')
-rw-r--r-- | test/msan/sigaction.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/msan/sigaction.cpp b/test/msan/sigaction.cpp new file mode 100644 index 000000000..0c69f115f --- /dev/null +++ b/test/msan/sigaction.cpp @@ -0,0 +1,47 @@ +// RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t +// RUN: %run %t __ +// RUN: not %run %t A_ 2>&1 | FileCheck %s +// RUN: not %run %t AH 2>&1 | FileCheck %s +// RUN: not %run %t B_ 2>&1 | FileCheck %s +// RUN: not %run %t BH 2>&1 | FileCheck %s +// RUN: not %run %t C_ 2>&1 | FileCheck %s +// RUN: not %run %t CH 2>&1 | FileCheck %s + +#include <assert.h> +#include <signal.h> +#include <string.h> +#include <sys/time.h> +#include <unistd.h> + +#include <sanitizer/msan_interface.h> + +void handler(int) {} +void action(int, siginfo_t *, void *) {} + +int main(int argc, char **argv) { + char T = argv[1][0]; + char H = argv[1][1]; + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + if (H == 'H') { + sa.sa_handler = handler; + } else { + sa.sa_sigaction = action; + sa.sa_flags = SA_SIGINFO; + } + + if (T == 'A') { + if (H == 'H') + __msan_poison(&sa.sa_handler, sizeof(sa.sa_handler)); + else + __msan_poison(&sa.sa_sigaction, sizeof(sa.sa_sigaction)); + } + if (T == 'B') + __msan_poison(&sa.sa_flags, sizeof(sa.sa_flags)); + if (T == 'C') + __msan_poison(&sa.sa_mask, sizeof(sa.sa_mask)); + // CHECK: use-of-uninitialized-value + int res = sigaction(SIGUSR1, &sa, nullptr); + assert(res == 0); + return 0; +} |