Debian Codegraph @

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

raw
1 set test_name additional_scripts
2
3 # test scripts and arguments
4 set script1 { "probe begin\{printf(\"beginning\")\}" }
5 set script2 { "probe process.begin\{printf(\"%s\", \$1)\}" }
6 set timeout_script { "probe timer.s(15) \{ printf(\"ending\") exit ()\}" }
7 set script_alias { "probe pb=process.begin {exit();} probe process.end{exit();}" }
8 set bad_script { "probe pppppppp.begin { exit(); }" }
9 set script_file "$srcdir/$subdir/$test_name.stp"
10 set arg1 { "\"hello\"" }
11
12 # running test scripts
13 # -E and no -e or script file
14 # -E is for additional scripts. a "main" script or script file must be given
15 eval spawn stap -p4 -v -E $timeout_script
16 expect {
17 -timeout 60
18 -re {A script must be specified} { pass "$test_name (no script)" }
19 eof { fail "$test_name (no script)" }
20 }
21 catch { close }; catch { wait }
22
23 # -E BAD_SCRIPT, where BAD_SCRIPT causes a semantic error
24 eval spawn stap -p4 -v -e $script1 -E $bad_script
25 set success 0
26 expect {
27 -timeout 120
28 -re {semantic error[ A-Za-z:]+'pppppppp'} { set success 1 }
29 }
30 if { $success == 1 } { pass "$test_name (-E BAD_SCRIPT) " } { fail "$test_name (-E BAD_SCRIPT)" }
31 catch { close }; catch { wait }
32
33 # -E, with probe point listing
34 eval spawn stap -l "pb" -E $script_alias
35 set success 0
36 expect {
37 -timeout 120
38 -re {pb} { if { $success == 0 } { set success 1 } }
39 -re {process.begin} { if { $success == 0 } { set success 1 } }
40 -re {process.end} { set success 4 }
41 }
42 if { $success == 1 } { pass "$test_name (-E listing probes) " } { fail "$test_name (-E listing probes)" }
43 catch { close }; catch { wait }
44
45 # -E BAD_SCRIPT when listing probes. should still list the proper probe pts
46 eval spawn stap -l "pb" -E $script_alias -E $bad_script
47 set success 0
48 expect {
49 -timeout 120
50 -re {pb} { if { $success == 0 } { set success 1 } }
51 -re {process.begin} { if { $success == 0 } { set success 1 } }
52 -re {process.end} { set success 4 }
53 }
54 if { $success == 1 } { pass "$test_name (-E BAD_SCRIPT listing probes) " } { fail "$test_name (-E BAD_SCRIPT listing probes)" }
55 catch { close }; catch { wait }
56
57 # part 2: actually running stap with -e/-E
58 if {! [installtest_p]} then { return }
59
60
61 # -E SCRIPT,
62 eval spawn stap -v -e $script1 -E $timeout_script
63 set success 0
64 expect {
65 -timeout 120
66 -re {beginning} {
67 set success 1
68 verbose -log "saw:beginning"
69 exp_continue
70 }
71 -re {ending} {
72 if { $success == 1 } {
73 verbose -log "saw:ending"
74 set success 2
75 }
76 exp_continue
77 }
78 }
79 if { $success == 2 } { pass "$test_name (-e and -E ) " } { fail "$test_name (-e and -E)" }
80 catch { close }; catch { wait }
81
82 # script file and -E
83 eval spawn stap -v $script_file -E $timeout_script
84 set success 0
85 expect {
86 -timeout 120
87 -re {a process began} {
88 if { $success == 0 } {
89 verbose -log "\nsaw:a process began"
90 set success 1
91 }
92 exp_continue
93 }
94 -re {ending} {
95 if { $success == 1 } {
96 set success 2
97 verbose -log "\nsaw:ending"
98 }
99 exp_continue
100 }
101 }
102 if { $success == 2 } { pass "$test_name (file and -E ) " } { fail "$test_name (file and -E)" }
103 catch { close }; catch { wait }
104
105 # multiple -E, with an argument mixed in there
106 eval spawn stap -v -e $script2 -E $script1 -E $timeout_script $arg1
107 set success 0
108 expect {
109 -timeout 120
110 -re {beginning} {
111 set success 1
112 verbose -log "\nsaw:beginning"
113 exp_continue
114 }
115 -re {hello} {
116 if { $success == 1 } {
117 verbose -log "\nsaw:hello"
118 set success 2
119 }
120 exp_continue
121 }
122 -re {ending} {
123 if { $success == 2 } {
124 set success 3
125 verbose -log "\nsaw:ending"
126 }
127 exp_continue
128 }
129 }
130 if { $success == 3 } { pass "$test_name (multiple -E ) " } { fail "$test_name (multiple -E)" }
131 catch { close }; catch { wait }