]> sourceware.org Git - systemtap.git/commitdiff
process_by_pid.* : test case for PR17131
authorAbegail Jakop <ajakop@redhat.com>
Tue, 15 Jul 2014 15:47:40 +0000 (11:47 -0400)
committerAbegail Jakop <ajakop@redhat.com>
Tue, 15 Jul 2014 15:47:40 +0000 (11:47 -0400)
testsuite/systemtap.base/process_by_pid.c [new file with mode: 0644]
testsuite/systemtap.base/process_by_pid.exp [new file with mode: 0644]
testsuite/systemtap.base/process_by_pid.stp [new file with mode: 0644]

diff --git a/testsuite/systemtap.base/process_by_pid.c b/testsuite/systemtap.base/process_by_pid.c
new file mode 100644 (file)
index 0000000..056d8eb
--- /dev/null
@@ -0,0 +1,14 @@
+#include "sys/sdt.h"
+
+void sleeper () {
+    sleep (5);
+}
+
+int main () {
+    while (1) {  
+        sleeper();
+        marker_here:
+            STAP_PROBE(tmp_test_file, while_start);
+    }
+    return 0;
+}
diff --git a/testsuite/systemtap.base/process_by_pid.exp b/testsuite/systemtap.base/process_by_pid.exp
new file mode 100644 (file)
index 0000000..aba8de3
--- /dev/null
@@ -0,0 +1,48 @@
+set test_name "process_by_pid"
+
+if {! [installtest_p]} {
+    untested $test_name
+    return
+}
+
+# building the test program
+set compile_result [target_compile $srcdir/$subdir/$test_name.c ./$test_name executable "additional_flags=-g [sdt_includes]"]
+
+proc sleep_twenty_secs {} {
+    wait_n_secs 20;
+    return 0;
+}
+
+# expected output
+set output_string "pass"
+
+# running multiple instances of the test program
+# the idea behind this is that in the stap script, it will check the pid it is
+# probing against the one that we told it to probe. if all goes well, then we
+# know that process(PID).* probes will probe processes based on their PID and
+# not the program it is runnning.
+set pid1 [exec ./$test_name &]
+set pid2 [exec ./$test_name &]
+set pid3 [exec ./$test_name &]
+
+# running the script
+foreach runtime [get_runtime_list] {
+    verbose -log "starting the stap script"
+    if {$runtime != ""} {
+        set cur_test_name "$test_name ($runtime)"
+        stap_run $cur_test_name sleep_twenty_secs $output_string --runtime=$runtime $srcdir/$subdir/$test_name.stp $pid2
+    } elseif {[uprobes_p]} {
+        stap_run $test_name sleep_twenty_secs $output_string $srcdir/$subdir/$test_name.stp $pid2        
+    } else {
+        untested $test_name
+        continue
+    }
+}
+
+# kill all the instances of the test program.
+kill -INT $pid1 2
+kill -INT $pid2 2
+kill -INT $pid3 2
+
+# remove the executable
+exec rm -f ./$test_name
diff --git a/testsuite/systemtap.base/process_by_pid.stp b/testsuite/systemtap.base/process_by_pid.stp
new file mode 100644 (file)
index 0000000..c58acaa
--- /dev/null
@@ -0,0 +1,67 @@
+global probed
+
+probe begin {
+  probed["function"] = 0;
+  probed["statement"] = 0;
+  probed["plt"] = 0;
+  probed["provider"] = 0;
+  probed["mark"] = 0;
+  printf("systemtap starting probe\n");
+}
+
+probe process($1).function("*") {
+  if ($1 != pid()) {
+    error("failed in process(PID).function(\"*\")");
+  } else if (!probed["function"]){
+    probed["function"] ++;
+  }
+}
+
+probe process($1).function("main").label("marker_here") ? {
+  if ($1 != pid())
+    error("failed in process(PID).function(main).label(marker_here)");
+  // gcc may not provide enough information to for stap to see this point, hence
+  // why it's optional. since it's optional, don't keep track of whether it's
+  // been seen.
+}
+
+probe process($1).statement("*") {
+  if ($1 != pid()) {
+    error("failed in process(PID).statement\"*\")");
+  } else if (!probed["statement"]){
+    probed["statement"]++;
+  }
+}
+
+probe process($1).plt {
+  if ($1 != pid()) {
+    error("failed in process(PID).plt");
+  } else if (!probed["plt"]){
+    probed["plt"] ++;
+  }
+}
+
+probe process($1).provider("*").mark("*") {
+  if ($1 != pid()) {
+    error("failed in process(PID).provider(\"*\").mark(\"*\")");
+  } else if (!probed["provider"]){
+    probed["provider"] ++;
+  }
+}
+
+probe process($1).mark("*") {
+  if ($1 != pid()) {
+    error("failed in process(PID).mark(\"*\")");
+  } else if (!probed["mark"]){
+    probed["mark"] ++;
+  }
+}
+
+probe end {
+  printf("systemtap ending probe\n");
+  if (probed["function"] > 0 && probed["plt"] > 0 && probed["mark"] > 0
+      && probed["statement"] > 0 && probed["provider"] > 0)
+    printf("pass\n");
+  else
+    printf("fail: did not hit all probe points successfully.\n");
+}
This page took 0.032647 seconds and 5 git commands to generate.