]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/msan/sigwait.cc
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / msan / sigwait.cc
1 // RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t && %run %t
2 // RUN: %clangxx_msan -DPOSITIVE -std=c++11 -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
3
4 #include <assert.h>
5 #include <signal.h>
6 #include <sys/time.h>
7 #include <unistd.h>
8
9 #include <sanitizer/msan_interface.h>
10
11 void test_sigwait() {
12 sigset_t s;
13 #ifndef POSITIVE
14 sigemptyset(&s);
15 sigaddset(&s, SIGUSR1);
16 #endif
17 sigprocmask(SIG_BLOCK, &s, 0);
18 // CHECK: MemorySanitizer: use-of-uninitialized-value
19
20 if (pid_t pid = fork()) {
21 kill(pid, SIGUSR1);
22 _exit(0);
23 } else {
24 int sig;
25 int res = sigwait(&s, &sig);
26 assert(!res);
27 // The following checks that sig is initialized.
28 assert(sig == SIGUSR1);
29 }
30 }
31
32 int main(void) {
33 test_sigwait();
34 return 0;
35 }