This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH 2/2] Add test for target_set tapset.
- From: Przemyslaw Pawelczyk <przemyslaw at pawelczyk dot it>
- To: systemtap at sourceware dot org
- Date: Fri, 19 Jun 2009 00:33:13 +0200
- Subject: [PATCH 2/2] Add test for target_set tapset.
- Mail-from: 70ec30d3420c69b69ef083b5553aff0ddb4efac1 Mon Sep 17 00:00:00 2001
- References: <1244936781.212635.16785@debian>
---
testsuite/systemtap.base/target_set.exp | 63 +++++++++++++++++++++++++++++++
testsuite/systemtap.base/target_set.stp | 16 ++++++++
2 files changed, 79 insertions(+), 0 deletions(-)
create mode 100644 testsuite/systemtap.base/target_set.exp
create mode 100644 testsuite/systemtap.base/target_set.stp
diff --git a/testsuite/systemtap.base/target_set.exp b/testsuite/systemtap.base/target_set.exp
new file mode 100644
index 0000000..1b80839
--- /dev/null
+++ b/testsuite/systemtap.base/target_set.exp
@@ -0,0 +1,63 @@
+# Test for target_set tapset
+
+set test target_set
+
+if {![installtest_p]} { untested $test; continue }
+
+set file $srcdir/$subdir/target_set.stp
+set time 1
+set stap_cmd "( ( /bin/sleep $time ) && ( /bin/sleep $time ) )"
+set stap_cmd_child_level 3
+
+proc abort {} {
+ global test
+ fail $test
+ exit
+}
+
+proc expect_target_set generations {
+ expect {
+ "^target set:\r\n" { expect_target_set_pids $generations }
+ timeout { abort }
+ }
+}
+
+proc expect_target_set_pids generations {
+ global test
+ global stp_pid
+ for {set i 0} {$i < $generations} {incr i} {
+ expect {
+ -timeout 0
+ -re {^([0-9]+) begat ([0-9]+)\r\n} { set pid_array($expect_out(1,string)) $expect_out(2,string) }
+ timeout { abort }
+ }
+ }
+ set pid_it $stp_pid
+ while {[info exists pid_array($pid_it)]} {
+ if {[exec pgrep -P $pid_it] != $pid_array($pid_it)} {
+ abort
+ }
+ set pid_it $pid_array($pid_it)
+ }
+}
+
+spawn stap $file $time -c "$stap_cmd"
+
+expect {
+ -re {^(\d+)\r\n} { set stp_pid $expect_out(1,string) }
+ timeout { abort }
+}
+
+set timeout [expr $time + 1]
+
+expect_target_set_pids 1
+expect_target_set $stap_cmd_child_level
+expect_target_set $stap_cmd_child_level
+expect_target_set 0
+
+expect {
+ eof {}
+ timeout { abort }
+}
+
+pass $test
diff --git a/testsuite/systemtap.base/target_set.stp b/testsuite/systemtap.base/target_set.stp
new file mode 100644
index 0000000..c48040b
--- /dev/null
+++ b/testsuite/systemtap.base/target_set.stp
@@ -0,0 +1,16 @@
+probe begin
+{
+ println(stp_pid())
+ printf("%d begat %d\n", stp_pid(), target())
+}
+
+probe nd_syscall.nanosleep
+{
+ if (target_set_pid(pid()) && @cast(req_uaddr, "timespec", "<linux/time.h>")->tv_sec == $1)
+ target_set_report()
+}
+
+probe end
+{
+ target_set_report()
+}
--
1.5.6.5