Author: iraisr
Date: Sun Nov 20 15:06:08 2016
New Revision: 16147
Log:
Fix test none/tests/pth_2sig on Solaris.
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.
Added:
trunk/none/tests/pth_2sig.stderr.exp-linux
- copied, changed from r16146, trunk/none/tests/pth_2sig.stderr.exp
trunk/none/tests/pth_2sig.stderr.exp-solaris
Removed:
trunk/none/tests/pth_2sig.stderr.exp
Modified:
trunk/none/tests/ (props changed)
trunk/none/tests/Makefile.am
trunk/none/tests/pth_2sig.c
trunk/none/tests/pth_2sig.vgtest
Modified: trunk/none/tests/Makefile.am
==============================================================================
--- trunk/none/tests/Makefile.am (original)
+++ trunk/none/tests/Makefile.am Sun Nov 20 15:06:08 2016
@@ -168,7 +168,7 @@
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 \
Modified: trunk/none/tests/pth_2sig.c
==============================================================================
--- trunk/none/tests/pth_2sig.c (original)
+++ trunk/none/tests/pth_2sig.c Sun Nov 20 15:06:08 2016
@@ -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;
}
Removed: trunk/none/tests/pth_2sig.stderr.exp
==============================================================================
(empty)
Copied: trunk/none/tests/pth_2sig.stderr.exp-linux (from r16146, trunk/none/tests/pth_2sig.stderr.exp)
==============================================================================
--- trunk/none/tests/pth_2sig.stderr.exp (original)
+++ trunk/none/tests/pth_2sig.stderr.exp-linux Sun Nov 20 15:06:08 2016
@@ -0,0 +1 @@
+Terminated
Added: trunk/none/tests/pth_2sig.stderr.exp-solaris
==============================================================================
(empty)
Modified: trunk/none/tests/pth_2sig.vgtest
==============================================================================
--- trunk/none/tests/pth_2sig.vgtest (original)
+++ trunk/none/tests/pth_2sig.vgtest Sun Nov 20 15:06:08 2016
@@ -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
|