Debian Codegraph @

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

raw
1 # We've got 3 main tests:
2 # (1) uprobes_call, which probes function entry
3 # (2) uprobes_return, which probes function exit
4 # (3) uprobes, which combines the above two tests
5
6 # 'test_array' holds the name of each test and its expected number of
7 # output lines
8 set test_array(uprobes_call) 5
9 set test_array(uprobes_return) 5
10 set test_array(uprobes) 10
11
12 set test uprobes
13 catch {exec gcc -g -o jennie $srcdir/$subdir/jennie.c} err
14 if {$err == "" && [file exists jennie]} then {
15 pass "$test compile"
16 } else {
17 fail "$test compile"
18 }
19
20 foreach test [lsort [array names test_array]] {
21 foreach runtime [get_runtime_list] {
22 # Try to compile the script
23 set test_xtra ""
24 if {$runtime != ""} {
25 set test_xtra " ($runtime)"
26 set rc [stap_run_batch $srcdir/$subdir/${test}.stp \
27 --runtime=$runtime]
28 } else {
29 if {! [uprobes_p]} {
30 foreach test [lsort [array names test_array]] {
31 untested "$test -p4"; untested "$test -p5"
32 }
33 continue
34 }
35 set rc [stap_run_batch $srcdir/$subdir/${test}.stp]
36 }
37 if {$rc == 0} then {
38 pass "$test -p4${test_xtra}"
39 } else {
40 fail "$test -p4${test_xtra}"
41 }
42
43 if {! [installtest_p]} {
44 untested "$test -p5${test_xtra}";
45 continue
46 } elseif {$rc != 0} {
47 # If the compile failed, don't bother trying to run it.
48 fail "$test -p5${test_xtra}";
49 continue
50 }
51
52 # Try to run the script
53 if {$runtime != ""} {
54 spawn stap $srcdir/$subdir/${test}.stp --runtime=$runtime \
55 -w -c "./jennie 1 2 3 4"
56 } else {
57 spawn stap $srcdir/$subdir/${test}.stp -w -c "./jennie 1 2 3 4"
58 }
59 set ok 0
60 expect {
61 -re {^process[^\r\n]+jennie[^\r\n]+main[^\r\n]+arg[cv]=0x[0-9a-f]+\ +arg[cv]=0x[0-9a-f]+\r\n} { incr ok; exp_continue }
62 -re {^process[^\r\n]+jennie[^\r\n]+main[^\r\n]+return=0x0\r\n} {
63 incr ok; exp_continue }
64 -timeout 30
65 timeout { }
66 eof { }
67 }
68 catch { close }; catch { wait }
69 if {$ok == $test_array($test)} then { pass "$test -p5${test_xtra}"
70 } else { fail "$test -p5${test_xtra} ($ok)" }
71 }
72 }
73
74 catch {exec rm -f jennie}