From 854e786e804c6dac927465ebcaac7fca724256cb Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Sat, 20 Jun 2009 15:08:18 +0200 Subject: Add test for target_set tapset. Signed-off-by: Josh Stone --- testsuite/systemtap.base/target_set.exp | 67 +++++++++++++++++++++++++++++++++ testsuite/systemtap.base/target_set.stp | 16 ++++++++ 2 files changed, 83 insertions(+) create mode 100644 testsuite/systemtap.base/target_set.exp create mode 100644 testsuite/systemtap.base/target_set.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/target_set.exp b/testsuite/systemtap.base/target_set.exp new file mode 100644 index 00000000..998fd4a1 --- /dev/null +++ b/testsuite/systemtap.base/target_set.exp @@ -0,0 +1,67 @@ +# Test for target_set tapset + +set test target_set + +if {![installtest_p]} { untested $test; continue } + +set file $srcdir/$subdir/target_set.stp +set time 12345 +set stap_cmd "( ( /bin/sleep $time ) ; ( /bin/sleep $time ) ; ( /bin/sleep $time ) )" +set stap_cmd_sleep_count 3 +set stap_cmd_child_level 3 + +proc failtest {} { + global test + fail $test +} + +proc expect_target_set_string {} { + expect { + "^target set:\r\n" { } + timeout { failtest; return -code return } + } +} + +proc expect_target_set_pids generations { + global test + global stp_pid + for {set i 0} {$i < $generations} {incr i} { + expect { + -re {^([0-9]+) begat ([0-9]+)\r\n} { set pid_array($expect_out(1,string)) $expect_out(2,string) } + timeout { failtest; return -code return } + } + } + set pid_it $stp_pid + while {[info exists pid_array($pid_it)]} { + if {[exec pgrep -P $pid_it] != $pid_array($pid_it)} { + failtest; return -code return + } + set pid_it $pid_array($pid_it) + } + if {$generations > 1} { + exec kill -INT $pid_it + } +} + +spawn stap $file $time -c "$stap_cmd" + +expect { + -re {^(\d+)\r\n} { set stp_pid $expect_out(1,string) } + timeout { failtest; return } +} + +expect_target_set_pids 1 +for {set i 0} {$i < $stap_cmd_sleep_count} {incr i} { + expect_target_set_string + expect_target_set_pids $stap_cmd_child_level +} +expect_target_set_string +expect_target_set_pids 0 + +expect { + eof {} + timeout { failtest; return } +} + +wait +pass $test diff --git a/testsuite/systemtap.base/target_set.stp b/testsuite/systemtap.base/target_set.stp new file mode 100644 index 00000000..002ba897 --- /dev/null +++ b/testsuite/systemtap.base/target_set.stp @@ -0,0 +1,16 @@ +probe begin +{ + stp_pid = stp_pid() + printf("%d\n%d begat %d\n", stp_pid, stp_pid, target()) +} + +probe syscall.nanosleep, syscall.compat_nanosleep ? +{ + if (target_set_pid(pid()) && $rqtp->tv_sec == $1) + target_set_report() +} + +probe end +{ + target_set_report() +} -- cgit From 595d75d80e0301fe7dca9b0614ce58b1e0a5d474 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 22 Jun 2009 13:59:58 -0700 Subject: Bump up the default timeout for target_set test Starting the test with a cold cache can take easily longer than dejagnu's default 10 second timeout. I'm bumping it to 180 seconds, the same as in the stap_run library functions. --- testsuite/systemtap.base/target_set.exp | 1 + 1 file changed, 1 insertion(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/target_set.exp b/testsuite/systemtap.base/target_set.exp index 998fd4a1..4b6e0a5d 100644 --- a/testsuite/systemtap.base/target_set.exp +++ b/testsuite/systemtap.base/target_set.exp @@ -46,6 +46,7 @@ proc expect_target_set_pids generations { spawn stap $file $time -c "$stap_cmd" expect { + -timeout 180 -re {^(\d+)\r\n} { set stp_pid $expect_out(1,string) } timeout { failtest; return } } -- cgit