From: Ivo Raisr Date: Sun, 20 Nov 2016 15:06:08 +0000 (+0000) Subject: Fix test none/tests/pth_2sig on Solaris. X-Git-Tag: svn/VALGRIND_3_13_0~274 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b25f61d6ffa5ddaac96fc040d1e824ac07a7e54a;p=thirdparty%2Fvalgrind.git 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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16147 --- diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index ad52d45297..198d5ff2bc 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -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 \ diff --git a/none/tests/pth_2sig.c b/none/tests/pth_2sig.c index 500e168daf..f296c75af4 100644 --- a/none/tests/pth_2sig.c +++ b/none/tests/pth_2sig.c @@ -1,45 +1,41 @@ -#include -#include -#include #include -#include +#include #include - +#include +#include +#include #include -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 index 0000000000..e45928c44e --- /dev/null +++ b/none/tests/pth_2sig.stderr.exp-linux @@ -0,0 +1 @@ +Terminated diff --git a/none/tests/pth_2sig.stderr.exp b/none/tests/pth_2sig.stderr.exp-solaris similarity index 100% rename from none/tests/pth_2sig.stderr.exp rename to none/tests/pth_2sig.stderr.exp-solaris diff --git a/none/tests/pth_2sig.vgtest b/none/tests/pth_2sig.vgtest index f1949de776..b7c2b14d61 100644 --- a/none/tests/pth_2sig.vgtest +++ b/none/tests/pth_2sig.vgtest @@ -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