]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix test none/tests/pth_2sig on Solaris.
authorIvo Raisr <ivosh@ivosh.net>
Sun, 20 Nov 2016 15:06:08 +0000 (15:06 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Sun, 20 Nov 2016 15:06:08 +0000 (15:06 +0000)
When signal SIGINT was used, it got propagated to the parent shell
and therefore the regression test suite was terminated.
With SIGTERM only the parent exits, as is supposed.
Verified that this changed test case still reproduces the original problem
on Linux and Solaris, when r16140 is temporarily undone.
Follow up to r16140 and r16143 and BZ#372600.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16147

none/tests/Makefile.am
none/tests/pth_2sig.c
none/tests/pth_2sig.stderr.exp-linux [new file with mode: 0644]
none/tests/pth_2sig.stderr.exp-solaris [moved from none/tests/pth_2sig.stderr.exp with 100% similarity]
none/tests/pth_2sig.vgtest

index ad52d452979c61e66c4a7f3c3295a13d10b14762..198d5ff2bce64e1ca997445cf8f391d7aa08e3ca 100644 (file)
@@ -168,7 +168,7 @@ EXTRA_DIST = \
        pth_rwlock.stderr.exp pth_rwlock.vgtest \
        pth_stackalign.stderr.exp \
        pth_stackalign.stdout.exp pth_stackalign.vgtest \
-       pth_2sig.stderr.exp pth_2sig.vgtest \
+       pth_2sig.stderr.exp-linux pth_2sig.stderr.exp-solaris pth_2sig.vgtest \
        pth_term_signal.stderr.exp pth_term_signal.vgtest \
        rcrl.stderr.exp rcrl.stdout.exp rcrl.vgtest \
        readline1.stderr.exp readline1.stdout.exp \
index 500e168daf6ef27c5301184579935591ae6a1145..f296c75af477b74e767b70d86c893293ff1a473f 100644 (file)
@@ -1,45 +1,41 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
 #include <pthread.h>
-#include <assert.h>
+#include <signal.h>
 #include <stdlib.h>
-
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
 #include <sys/wait.h>
-void *
-slavethread(void *arg)
+
+void *slavethread(void *arg)
 {
-   char c;
-   while (1)
-      (void)read(0, &c, 1);
+    while (1)
+        pause();
 }
 
 int main(int argc, char **argv)
 {
-    pthread_t slave;
-    int i = 0;
-    int pid = getpid();
+    for (int i = 0; i < 10; i++) {
+        pthread_t slave;
+        if (pthread_create(&slave, 0, slavethread, 0)) {
+            perror("pthread_create");
+            exit(2);
+        }
+    }
 
-    for (i = 0; i < 10; i++)
-       if (pthread_create(&slave, 0, &slavethread, 0))
-          {
-             perror("slave2");
-             exit(2);
-          }
-    switch (fork())
-       {
-       case 0: // child
-          sleep(2); // Should be enough to ensure (some) threads are created
-          for (i = 0; i < 20 && kill(pid, 2) == 0; i++)
-             ;
-          exit(0);
-       case -1:
-          perror("fork");
-          exit(4);
-       }
+    pid_t pid = getpid();
+    switch (fork()) {
+        case 0: // child
+            sleep(2); // Should be enough to ensure (some) threads are created
+            for (int i = 0; i < 20 && kill(pid, SIGTERM) == 0; i++)
+                ;
+            exit(0);
+        case -1:
+            perror("fork");
+            exit(4);
+    }
 
-    while (rand() >= 0)
-       i++;
-    fprintf(stderr, "strange, this program is supposed to be killed !!!!\n");
+    while (1)
+        pause(); 
+    fprintf(stderr, "strange, this program is supposed to be killed!\n");
     return 1;
 }
diff --git a/none/tests/pth_2sig.stderr.exp-linux b/none/tests/pth_2sig.stderr.exp-linux
new file mode 100644 (file)
index 0000000..e45928c
--- /dev/null
@@ -0,0 +1 @@
+Terminated
index f1949de776a5345ae4e3b1cfc8da995831de29e4..b7c2b14d61134955023f50de1e5a44aae524d6ed 100644 (file)
@@ -1,5 +1,2 @@
-# Disable this test on Solaris for now until it is investigated
-# why it messes badly with the regression test suite.
-prereq: (! ../../tests/os_test solaris)
 prog: pth_2sig
 vgopts: -q