This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH v2] 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 22:59:55 +0200
- Subject: [PATCH v2] Add test for target_set tapset.
- Mail-from: 1346e322b8c2f23f7e39a89668a199c3963f0331 Mon Sep 17 00:00:00 2001
- References: <1244936781.212635.16785@debian>
---
testsuite/systemtap.base/target_set.exp | 67 +++++++++++++++++++++++++++++++
testsuite/systemtap.base/target_set.stp | 22 ++++++++++
2 files changed, 89 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..1971ab6
--- /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 {
+ -timeout 0
+ -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 }
+}
+
+pass $test
diff --git a/testsuite/systemtap.base/target_set.stp b/testsuite/systemtap.base/target_set.stp
new file mode 100644
index 0000000..fa31cfa
--- /dev/null
+++ b/testsuite/systemtap.base/target_set.stp
@@ -0,0 +1,22 @@
+probe begin
+{
+ stp_pid = stp_pid()
+ printf("%d\n%d begat %d\n", stp_pid, stp_pid, target())
+}
+
+probe nd_syscall.compat_nanosleep
+{
+ if (target_set_pid(pid()) && @cast(req_uaddr, "timespec", "<linux/time.h>")->tv_sec == $1)
+ target_set_report()
+}
+
+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