From: Nicholas Nethercote Date: Sun, 13 Mar 2005 05:10:08 +0000 (+0000) Subject: Add test case for forking threaded programs. X-Git-Tag: svn/VALGRIND_3_0_0~992 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d55a69372953691085352e63884042c3c869a993;p=thirdparty%2Fvalgrind.git Add test case for forking threaded programs. MERGED FROM CVS HEAD git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3326 --- diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index eb4628fe19..fc3d3f3759 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -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 index 0000000000..cf71b6956e --- /dev/null +++ b/none/tests/threaded-fork.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include +#include + +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 index 0000000000..b28b04f643 --- /dev/null +++ b/none/tests/threaded-fork.stderr.exp @@ -0,0 +1,3 @@ + + + diff --git a/none/tests/threaded-fork.stdout.exp b/none/tests/threaded-fork.stdout.exp new file mode 100644 index 0000000000..7ef22e9a43 --- /dev/null +++ b/none/tests/threaded-fork.stdout.exp @@ -0,0 +1 @@ +PASS diff --git a/none/tests/threaded-fork.vgtest b/none/tests/threaded-fork.vgtest new file mode 100644 index 0000000000..f84cefd570 --- /dev/null +++ b/none/tests/threaded-fork.vgtest @@ -0,0 +1 @@ +prog: threaded-fork