Debian Codegraph @

testsuite/systemtap.server/client_args.exp

raw
1 set test "Invalid Server Client Arguments"
2 if {! [nss_p]} { unsupported $test; return }
3
4 # Test that stap on the server side will correctly accept/reject certain
5 # arguments in unprivileged mode.
6 set test_file $srcdir/systemtap.server/test.stp
7
8 set uname [exec uname -r]
9
10 # Test invalid combinations.
11 set invalid_options [list \
12 "--unprivileged --client-options -B X=Y" \
13 "--unprivileged --client-options -D X=Y" \
14 "--unprivileged --client-options -I foo" \
15 "--unprivileged --client-options -m test" \
16 "--unprivileged --client-options -R foo" \
17 "--unprivileged --client-options -k" \
18 "--unprivileged --client-options -B X=Y -D X=Y -I foo -m test -R foo -k -r $uname" \
19 "--client-options --unprivileged -B X=Y" \
20 "--client-options --unprivileged -D X=Y" \
21 "--client-options --unprivileged -I foo" \
22 "--client-options --unprivileged -m test" \
23 "--client-options --unprivileged -R foo" \
24 "--client-options --unprivileged -k" \
25 "--client-options --unprivileged -B X=Y -D X=Y -I foo -m test -R foo -k -r $uname" \
26 "--client-options -B X=Y --unprivileged" \
27 "--client-options -D X=Y --unprivileged" \
28 "--client-options -I foo --unprivileged" \
29 "--client-options -m test --unprivileged" \
30 "--client-options -R foo --unprivileged" \
31 "--client-options -k --unprivileged" \
32 "--client-options -B X=Y -D X=Y -I foo -m test -R foo -k -r $uname --unprivileged" \
33 "--client-options -R /path" \
34 "--client-options --ldd" \
35 "--client-options --tmpdir=/tmp" \
36 "--client-options --use-server" \
37 "--client-options --use-server-on-error" \
38 "--client-options --list-servers" \
39 "--client-options --trust-servers" \
40 "--client-options --disable-cache" \
41 "--client-options --poison-cache" \
42 "--client-options --clean-cache" \
43 "--client-options --all-modules" \
44 "--client-options --remote=foo" \
45 "--client-options --remote-prefix" \
46 "--client-options --modinfo=foo" \
47 "-D \"foo;bar\"" \
48 "-D 2=4" \
49 "--client-options -r /path" \
50 "-S /path" \
51 "--client-options -q" \
52 "--client-options -k" \
53 ]
54
55 foreach options $invalid_options {
56 set error_regexp ".*(ERROR)|(You can't specify .* when --privilege=stapusr is specified).*"
57 verbose -log "eval exec stap $options"
58 catch {eval exec stap $test_file -p1 $options} res_stap
59 verbose -log $res_stap
60 # Replace the `uname -r` substring, which varies from run to run, with a generic
61 # one, for reporting/regression purposes
62 set options2 [string map "$uname UNAME" $options]
63 if {[regexp $error_regexp $res_stap]} {
64 pass "$test: $options2"
65 } else {
66 fail "$test: $options2"
67 }
68
69 # We should get the same result substituting --unprivileged with --privilege=stapusr
70 if {[regsub -all {\-\-unprivileged} $options "--privilege=stapusr" options]} {
71 verbose -log "eval exec stap $options"
72 catch {eval exec stap $test_file -p1 $options} res_stap
73 verbose -log $res_stap
74 # Replace the `uname -r` substring, which varies from run to run, with a generic
75 # one, for reporting/regression purposes
76 set options2 [string map "$uname UNAME" $options]
77 if {[regexp $error_regexp $res_stap]} {
78 pass "$test: $options2"
79 } else {
80 fail "$test: $options2"
81 }
82
83 # We should get the same result substituting --privilege=stapusr with --privilege=stapsys
84 if {[regsub -all {\-\-privilege=stapusr} $options "--privilege=stapsys" options]} {
85 set error_regexp ".*(ERROR)|(You can't specify .* when --privilege=stapsys is specified).*"
86 verbose -log "eval exec stap $options"
87 catch {eval exec stap $test_file -p1 $options} res_stap
88 verbose -log $res_stap
89 # Replace the `uname -r` substring, which varies from run to run, with a generic
90 # one, for reporting/regression purposes
91 set options2 [string map "$uname UNAME" $options]
92 if {[regexp $error_regexp $res_stap]} {
93 pass "$test: $options2"
94 } else {
95 fail "$test: $options2"
96 }
97 }
98 }
99 }
100
101 # Test valid combinations
102 set test "Valid Server Client Arguments"
103
104 # stap_run_exact (used below) only works for 'make installcheck'
105 if {[info procs installtest_p] != "" && ![installtest_p]} { untested $test; return }
106
107 set no_error_result "# parse tree dump
108 # file $test_file
109 probe begin{
110 exit();
111 }
112
113 "
114
115 set valid_options [list \
116 "-a i386" \
117 "-B X=Y" \
118 "-D X=Y" \
119 "-I foo" \
120 "-m test" \
121 "-r $uname" \
122 "-a i386 -B X=Y -D X=Y -I foo -m test -r $uname" \
123 "--unprivileged" \
124 "--unprivileged -a i386" \
125 "--unprivileged -B X=Y" \
126 "--unprivileged -D X=Y" \
127 "--unprivileged -I foo" \
128 "--unprivileged -m test" \
129 "--unprivileged -R foo" \
130 "--unprivileged -r $uname" \
131 "--unprivileged -a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname" \
132 "--client-options" \
133 "--client-options -a i386" \
134 "--client-options -D X=Y" \
135 "--client-options -I foo" \
136 "--client-options -m test" \
137 "--client-options -r $uname" \
138 "--client-options -a i386 -D X=Y -I foo -m test -r $uname" \
139 "--unprivileged --client-options" \
140 "--client-options --unprivileged" \
141 "--unprivileged -a i386 --client-options" \
142 "--unprivileged -B X=Y --client-options" \
143 "--unprivileged -D X=Y --client-options" \
144 "--unprivileged -I foo --client-options" \
145 "--unprivileged -m test --client-options" \
146 "--unprivileged -R foo --client-options" \
147 "--unprivileged -r $uname --client-options" \
148 "--unprivileged -a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname --client-options" \
149 "-a i386 --unprivileged --client-options" \
150 "-B X=Y --unprivileged --client-options" \
151 "-D X=Y --unprivileged --client-options" \
152 "-I foo --unprivileged --client-options" \
153 "-m test --unprivileged --client-options" \
154 "-R foo --unprivileged --client-options" \
155 "-r $uname --unprivileged --client-options" \
156 "-a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname --unprivileged --client-options" \
157 "-a i386 --client-options --unprivileged" \
158 "-B X=Y --client-options --unprivileged" \
159 "-D X=Y --client-options --unprivileged" \
160 "-I foo --client-options --unprivileged" \
161 "-m test --client-options --unprivileged" \
162 "-R foo --client-options --unprivileged" \
163 "-r $uname --client-options --unprivileged" \
164 "-a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname --client-options --unprivileged" \
165 ]
166
167 set ::result_string "$no_error_result"
168
169 # avoid propagating issue similar to PR17301
170 set origdir $env(SYSTEMTAP_DIR)
171 catch {exec mktemp -d} tmpdir
172 set env(SYSTEMTAP_DIR) $tmpdir
173
174 foreach options $valid_options {
175 # Replace the `uname -r` substring, which varies from run to run, with a generic
176 # one, for reporting/regression purposes
177 set options2 [string map "$uname UNAME" $options]
178 eval stap_run_exact {"$test: $options2"} $test_file -p1 $options
179
180 # We should get the same result substituting --unprivileged with --privilege=stapusr
181 if {[regsub -all {\-\-unprivileged} $options "--privilege=stapusr" options]} {
182 # Replace the `uname -r` substring, which varies from run to run, with a generic
183 # one, for reporting/regression purposes
184 set options2 [string map "$uname UNAME" $options]
185 eval stap_run_exact {"$test: $options2"} $test_file -p1 $options
186
187 # We should get the same result substituting --privilege=stapusr with --privilege=stapsys
188 if {[regsub -all {\-\-privilege=stapusr} $options "--privilege=stapsys" options]} {
189 # Replace the `uname -r` substring, which varies from run to run, with a generic
190 # one, for reporting/regression purposes
191 set options2 [string map "$uname UNAME" $options]
192 eval stap_run_exact {"$test: $options2"} $test_file -p1 $options
193 }
194 }
195 }
196
197 set env(SYSTEMTAP_DIR) $origdir
198 catch {exec rm -rf $tmpdir}