aboutsummaryrefslogtreecommitdiff
path: root/lib/msan/lit_tests/sigwait.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/msan/lit_tests/sigwait.cc')
-rw-r--r--lib/msan/lit_tests/sigwait.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/msan/lit_tests/sigwait.cc b/lib/msan/lit_tests/sigwait.cc
new file mode 100644
index 000000000000..29aa86c938f2
--- /dev/null
+++ b/lib/msan/lit_tests/sigwait.cc
@@ -0,0 +1,30 @@
+// RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t && %t
+
+#include <assert.h>
+#include <sanitizer/msan_interface.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+void test_sigwait() {
+ sigset_t s;
+ sigemptyset(&s);
+ sigaddset(&s, SIGUSR1);
+ sigprocmask(SIG_BLOCK, &s, 0);
+
+ if (pid_t pid = fork()) {
+ kill(pid, SIGUSR1);
+ _exit(0);
+ } else {
+ int sig;
+ int res = sigwait(&s, &sig);
+ assert(!res);
+ // The following checks that sig is initialized.
+ assert(sig == SIGUSR1);
+ }
+}
+
+int main(void) {
+ test_sigwait();
+ return 0;
+}