summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/target_set.exp
diff options
context:
space:
mode:
authorPrzemyslaw Pawelczyk <przemyslaw@pawelczyk.it>2009-06-20 15:08:18 +0200
committerJosh Stone <jistone@redhat.com>2009-06-22 11:21:50 -0700
commit854e786e804c6dac927465ebcaac7fca724256cb (patch)
treef0738cea37d91736a337c6dac6a89c59afd4e908 /testsuite/systemtap.base/target_set.exp
parent4116c576d5654287b0af598aee4a14eb2af73224 (diff)
downloadsystemtap-steved-854e786e804c6dac927465ebcaac7fca724256cb.tar.gz
systemtap-steved-854e786e804c6dac927465ebcaac7fca724256cb.tar.xz
systemtap-steved-854e786e804c6dac927465ebcaac7fca724256cb.zip
Add test for target_set tapset.
Signed-off-by: Josh Stone <jistone@redhat.com>
Diffstat (limited to 'testsuite/systemtap.base/target_set.exp')
-rw-r--r--testsuite/systemtap.base/target_set.exp67
1 files changed, 67 insertions, 0 deletions
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