]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add test case for forking threaded programs.
authorNicholas Nethercote <njn@valgrind.org>
Sun, 13 Mar 2005 05:10:08 +0000 (05:10 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 13 Mar 2005 05:10:08 +0000 (05:10 +0000)
MERGED FROM CVS HEAD

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

none/tests/Makefile.am
none/tests/threaded-fork.c [new file with mode: 0644]
none/tests/threaded-fork.stderr.exp [new file with mode: 0644]
none/tests/threaded-fork.stdout.exp [new file with mode: 0644]
none/tests/threaded-fork.vgtest [new file with mode: 0644]

index eb4628fe195e9380b6164453d540075a1460fc11..fc3d3f3759cd7af790a2608f589f6b5cd3cfcca6 100644 (file)
@@ -62,6 +62,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        syscall-restart2.vgtest syscall-restart2.stdout.exp syscall-restart2.stderr.exp \
        system.stderr.exp system.vgtest \
        thread-exits.stderr.exp thread-exits.stdout.exp thread-exits.vgtest \
+       threaded-fork.stderr.exp threaded-fork.stdout.exp threaded-fork.vgtest \
        tls.stderr.exp tls.stdout.exp  \
        yield.stderr.exp yield.stdout.exp yield.vgtest
 
@@ -76,7 +77,7 @@ check_PROGRAMS = \
        stackgrowth sigstackgrowth \
        smc1 susphello pending pth_blockedsig pth_stackalign \
        syscall-restart1 syscall-restart2 system \
-       thread-exits \
+       thread-exits threaded-fork \
        tls tls.so tls2.so \
        coolo_sigaction gxx304 yield
 
@@ -102,12 +103,18 @@ floored_LDADD             = -lm
 fucomip_SOURCES        = fucomip.c
 getseg_SOURCES                 = getseg.c
 pending_SOURCES                = pending.c
+manythreads_SOURCES    = manythreads.c
+manythreads_LDADD      = -lpthread
 map_unaligned_SOURCES  = map_unaligned.c
 map_unmap_SOURCES      = map_unmap.c
 mq_SOURCES             = mq.c
 mq_LDADD               = -lrt
 mremap_SOURCES         = mremap.c
 munmap_exe_SOURCES     = munmap_exe.c
+pth_blockedsig_SOURCES = pth_blockedsig.c
+pth_blockedsig_LDADD   = -lpthread
+pth_stackalign_SOURCES = pth_stackalign.c
+pth_stackalign_LDADD   = -lpthread
 rcrl_SOURCES           = rcrl.c
 readline1_SOURCES      = readline1.c
 resolv_SOURCES                 = resolv.c
@@ -130,6 +137,8 @@ syscall_restart2_SOURCES = syscall-restart2.c
 system_SOURCES                 = system.c
 thread_exits_SOURCES   = thread-exits.c
 thread_exits_LDADD     = -lpthread
+threaded_fork_SOURCES  = threaded-fork.c
+threaded_fork_LDADD    = -lpthread
 tls_SOURCES            = tls.c tls2.c
 tls_DEPENDENCIES       = tls.so
 tls_LDFLAGS            = -Wl,-rpath,$(top_builddir)/none/tests
@@ -144,14 +153,6 @@ yield_SOURCES              = yield.c
 yield_CFLAGS           = $(AM_CFLAGS) -D__$(VG_ARCH)__
 yield_LDADD            = -lpthread
 
-# pthread C ones
-manythreads_SOURCES    = manythreads.c
-manythreads_LDADD      = -lpthread
-pth_blockedsig_SOURCES = pth_blockedsig.c
-pth_blockedsig_LDADD   = -lpthread
-pth_stackalign_SOURCES = pth_stackalign.c
-pth_stackalign_LDADD   = -lpthread
-
 # generic C++ ones
 coolo_sigaction_SOURCES        = coolo_sigaction.cpp
 gxx304_SOURCES         = gxx304.cpp
diff --git a/none/tests/threaded-fork.c b/none/tests/threaded-fork.c
new file mode 100644 (file)
index 0000000..cf71b69
--- /dev/null
@@ -0,0 +1,47 @@
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+
+static void *threadmain( void *dummy )
+{
+       sleep( (int)dummy );
+       return NULL;
+}
+
+int main( int argc, char **argv )
+{
+       pid_t childpid;
+       pthread_t childthread;
+       void *res;
+       int status;
+
+       pthread_create( &childthread, NULL, threadmain, (void *)2 );
+
+       childpid = fork();
+       switch( childpid ) {
+       case 0:
+               pthread_create( &childthread, NULL, threadmain, 0 );
+               pthread_join( childthread, &res );
+               exit(0);
+               break;
+       case -1:
+               perror( "FAILED: fork failed\n" );
+               break;
+       default:
+               break;
+       }
+
+       pthread_join( childthread, &res );
+       while(waitpid(childpid, &status, 0) != childpid)
+               ;
+
+       printf("PASS\n");
+
+       return 0;
+}
+
+
diff --git a/none/tests/threaded-fork.stderr.exp b/none/tests/threaded-fork.stderr.exp
new file mode 100644 (file)
index 0000000..b28b04f
--- /dev/null
@@ -0,0 +1,3 @@
+
+
+
diff --git a/none/tests/threaded-fork.stdout.exp b/none/tests/threaded-fork.stdout.exp
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/none/tests/threaded-fork.vgtest b/none/tests/threaded-fork.vgtest
new file mode 100644 (file)
index 0000000..f84cefd
--- /dev/null
@@ -0,0 +1 @@
+prog: threaded-fork