This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH v2.5][DRAFT] Add test for target_set tapset.
- From: Przemyslaw Pawelczyk <przemyslaw at pawelczyk dot it>
- To: systemtap at sourceware dot org
- Date: Sat, 20 Jun 2009 02:20:03 +0200
- Subject: [PATCH v2.5][DRAFT] Add test for target_set tapset.
- References: <1244936781.212635.16785@debian>
Requires: Support OR (using ||) in preprocessor's conditions.
---
testsuite/systemtap.base/target_set.exp | 67 +++++++++++++++++++++++++++++++
testsuite/systemtap.base/target_set.stp | 24 +++++++++++
2 files changed, 91 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..998fd4a
--- /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 0000000..4d87114
--- /dev/null
+++ b/testsuite/systemtap.base/target_set.stp
@@ -0,0 +1,24 @@
+probe begin
+{
+ stp_pid = stp_pid()
+ printf("%d\n%d begat %d\n", stp_pid, stp_pid, target())
+}
+
+probe nd_syscall.nanosleep
+{
+ if (target_set_pid(pid()) && @cast(req_uaddr, "timespec", "kernel<linux/time.h>")->tv_sec == $1)
+ target_set_report()
+}
+
+%( arch == "x86_64" || arch == "ppc64" || arch == "ia64" %?
+probe nd_syscall.compat_nanosleep
+{
+ if (target_set_pid(pid()) && @cast(req_uaddr, "compat_timespec", "kernel<linux/compat.h>")->tv_sec == $1)
+ target_set_report()
+}
+%)
+
+probe end
+{
+ target_set_report()
+}
--
1.5.6.5