Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/process_by_pid.exp

raw
1 set test_name "process_by_pid"
2
3 if {! [installtest_p]} {
4 untested $test_name
5 return
6 }
7
8 # building the test program
9 set compile_result [target_compile $srcdir/$subdir/$test_name.c ./$test_name executable "additional_flags=-g [sdt_includes]"]
10
11 proc sleep_twenty_secs {} {
12 wait_n_secs 20;
13 return 0;
14 }
15
16 # expected output
17 set output_string "pass\r\n"
18
19 # running multiple instances of the test program
20 # the idea behind this is that in the stap script, it will check the pid it is
21 # probing against the one that we told it to probe. if all goes well, then we
22 # know that process(PID).* probes will probe processes based on their PID and
23 # not the program it is runnning.
24 set pid1 [exec ./$test_name &]
25 set pid2 [exec ./$test_name &]
26 set pid3 [exec ./$test_name &]
27
28 # There are two different versions of the test script. One for
29 # platforms that support .plt probes (process_by_pid.stp) and one for
30 # platforms that don't support .plt probes
31 # (process_by_pid_no_plt.stp).
32 if {[plt_probes_p]} {
33 set test_script "${test_name}.stp"
34 } else {
35 set test_script "${test_name}_no_plt.stp"
36 }
37
38 # running the script
39 foreach runtime [get_runtime_list] {
40 verbose -log "starting the stap script"
41 if {$runtime != ""} {
42 if {$runtime == "dyninst"} {
43 # PR17352 (dyninst: process probes require a target -c/-x)
44 setup_kfail 17352 "*-*-*"
45 }
46 set cur_test_name "$test_name ($runtime)"
47 stap_run $cur_test_name sleep_twenty_secs $output_string --runtime=$runtime $srcdir/$subdir/${test_script} $pid2
48 } elseif {[uprobes_p]} {
49 stap_run $test_name sleep_twenty_secs $output_string $srcdir/$subdir/${test_script} $pid2
50 } else {
51 untested $test_name
52 continue
53 }
54 }
55
56 # kill all the instances of the test program.
57 kill -INT $pid1 2
58 kill -INT $pid2 2
59 kill -INT $pid3 2
60
61 # remove the executable
62 exec rm -f ./$test_name