diff options
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/.gitignore | 2 | ||||
-rw-r--r-- | testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_p5.exp | 70 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_p5_multi.c | 39 |
4 files changed, 116 insertions, 3 deletions
diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 34a4e8d0..19b30bf1 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1,4 +1,4 @@ -.systemtap +.systemtap-* site.exp systemtap.log systemtap.sum diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 58f9baff..bf2f7cca 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2008-06-11 David Smith <dsmith@redhat.com> + + * systemtap.base/utrace_p5.exp: Added 'process().thread.begin' and + 'process().thread.end' tests. + * systemtap.base/utrace_p5_multi.c: Added multi-threaded test + program for utrace_p5.exp. + * .gitignore: Updated. + 2008-06-10 Stan Cox <scox@redhat.com> * systemtap.base/warnings.exp: Adjust for duplicate warning elimination. diff --git a/testsuite/systemtap.base/utrace_p5.exp b/testsuite/systemtap.base/utrace_p5.exp index 46e3181b..1185f015 100644 --- a/testsuite/systemtap.base/utrace_p5.exp +++ b/testsuite/systemtap.base/utrace_p5.exp @@ -3,6 +3,9 @@ # Initialize variables set utrace_support_found 0 set exepath "[pwd]/cat_[pid]" +set multi_srcpath "systemtap.base/utrace_p5_multi.c" +set multi_exepath "[pwd]/utrace_p5_multi_[pid]" +set multi_flags "libs=-lpthread" set end_script { global end_probes_fired = 0 @@ -46,6 +49,30 @@ set syscall_return_script { } set syscall_return_script_output "syscall_returns = \\d+\r\n" +set thread_begin_script { + global thread_begin_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process("%s").thread.begin { thread_begin_probes_fired++ } + probe end { printf("systemtap ending probe\n") + if (thread_begin_probes_fired > 0) { + printf("thread_begins = %%d\n", thread_begin_probes_fired) + } + } +} +set thread_begin_script_output "thread_begins = \\d+\r\n" + +set thread_end_script { + global thread_end_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process("%s").thread.end { thread_end_probes_fired++ } + probe end { printf("systemtap ending probe\n") + if (thread_end_probes_fired > 0) { + printf("thread_ends = %%d\n", thread_end_probes_fired) + } + } +} +set thread_end_script_output "thread_ends = \\d+\r\n" + # Try to find utrace_attach symbol in /proc/kallsyms set path "/proc/kallsyms" if {! [catch {exec grep -q utrace_attach $path} dummy]} { @@ -74,6 +101,25 @@ proc run_cat_5_sec {} { return 0; } +# Compile our multi-threaded test program. +set res [target_compile $multi_srcpath $multi_exepath executable $multi_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "unable to compile $multi_srcpath" + return +} + +# "load" generation function for stap_run. It spawns our +# multi-threaded test program and waits for it to finish. +proc run_utrace_p5_multi {} { + global multi_exepath + + if {[catch {exec $multi_exepath} res]} { + verbose "unable to run $multi_exepath: $res" + } + return 0; +} + set TEST_NAME "UTRACE_P5_01" if {$utrace_support_found == 0} { untested "$TEST_NAME : no kernel utrace support found" @@ -114,7 +160,27 @@ if {$utrace_support_found == 0} { stap_run $TEST_NAME run_cat_5_sec $syscall_return_script_output -e $script } -# We need thread.begin and thread.end tests! +set TEST_NAME "UTRACE_P5_05" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $thread_begin_script $multi_exepath] + stap_run $TEST_NAME run_utrace_p5_multi $thread_begin_script_output \ + -e $script +} + +set TEST_NAME "UTRACE_P5_06" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $thread_end_script $multi_exepath] + stap_run $TEST_NAME run_utrace_p5_multi $thread_end_script_output \ + -e $script +} # Cleanup -exec rm -f $exepath +exec rm -f $exepath $multi_exepath diff --git a/testsuite/systemtap.base/utrace_p5_multi.c b/testsuite/systemtap.base/utrace_p5_multi.c new file mode 100644 index 00000000..03c6eea0 --- /dev/null +++ b/testsuite/systemtap.base/utrace_p5_multi.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <stdlib.h> +#include <pthread.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +void *thread_function( void *ptr ); + +int +main() +{ + pthread_t thread1, thread2; + int iret1, iret2; + + /* Create independent threads each of which will execute function */ + iret1 = pthread_create(&thread1, NULL, thread_function, (void*) 1); + iret2 = pthread_create(&thread2, NULL, thread_function, (void*) 2); + + /* Wait till threads are complete before main continues. Unless we + * wait we run the risk of executing an exit which will terminate + * the process and all threads before the threads have + * completed. */ + pthread_join(thread1, NULL); + pthread_join(thread2, NULL); + + printf("Thread 1 returns: %d\n", iret1); + printf("Thread 2 returns: %d\n", iret2); + exit(0); +} + +void *thread_function(void *ptr) +{ + int tnum = (int)ptr; + if (tnum == 1) { + int fd = open("/dev/null", O_RDONLY); + close(fd); + } +} |