File: client_args.exp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (198 lines) | stat: -rw-r--r-- 7,696 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
set test "Invalid Server Client Arguments"
if {! [nss_p]} { unsupported $test; return }

# Test that stap on the server side will correctly accept/reject certain
# arguments in unprivileged mode.
set test_file $srcdir/systemtap.server/test.stp

set uname [exec uname -r]

# Test invalid combinations.
set invalid_options [list \
  "--unprivileged --client-options -B X=Y" \
  "--unprivileged --client-options -D X=Y" \
  "--unprivileged --client-options -I foo" \
  "--unprivileged --client-options -m test" \
  "--unprivileged --client-options -R foo" \
  "--unprivileged --client-options -k" \
  "--unprivileged --client-options -B X=Y -D X=Y -I foo -m test -R foo -k -r $uname" \
  "--client-options --unprivileged -B X=Y" \
  "--client-options --unprivileged -D X=Y" \
  "--client-options --unprivileged -I foo" \
  "--client-options --unprivileged -m test" \
  "--client-options --unprivileged -R foo" \
  "--client-options --unprivileged -k" \
  "--client-options --unprivileged -B X=Y -D X=Y -I foo -m test -R foo -k -r $uname" \
  "--client-options -B X=Y --unprivileged" \
  "--client-options -D X=Y --unprivileged" \
  "--client-options -I foo --unprivileged" \
  "--client-options -m test --unprivileged" \
  "--client-options -R foo --unprivileged" \
  "--client-options -k --unprivileged" \
  "--client-options -B X=Y -D X=Y -I foo -m test -R foo -k -r $uname --unprivileged" \
  "--client-options -R /path" \
  "--client-options --ldd" \
  "--client-options --tmpdir=/tmp" \
  "--client-options --use-server" \
  "--client-options --use-server-on-error" \
  "--client-options --list-servers" \
  "--client-options --trust-servers" \
  "--client-options --disable-cache" \
  "--client-options --poison-cache" \
  "--client-options --clean-cache" \
  "--client-options --all-modules" \
  "--client-options --remote=foo" \
  "--client-options --remote-prefix" \
  "--client-options --modinfo=foo" \
  "-D \"foo;bar\"" \
  "-D 2=4" \
  "--client-options -r /path" \
  "-S /path" \
  "--client-options -q" \
  "--client-options -k" \
]

foreach options $invalid_options {
    set error_regexp ".*(ERROR)|(You can't specify .* when --privilege=stapusr is specified).*"
    verbose -log "eval exec stap $options"
    catch {eval exec stap $test_file -p1 $options} res_stap
    verbose -log $res_stap
    # Replace the `uname -r` substring, which varies from run to run, with a generic
    # one, for reporting/regression purposes
    set options2 [string map "$uname UNAME" $options]
    if {[regexp $error_regexp $res_stap]} {
	pass "$test: $options2"
    } else {
	fail "$test: $options2"
    }

    # We should get the same result substituting --unprivileged with --privilege=stapusr
    if {[regsub -all {\-\-unprivileged} $options "--privilege=stapusr" options]} {
	verbose -log "eval exec stap $options"
	catch {eval exec stap $test_file -p1 $options} res_stap
	verbose -log $res_stap
        # Replace the `uname -r` substring, which varies from run to run, with a generic
        # one, for reporting/regression purposes
        set options2 [string map "$uname UNAME" $options]
	if {[regexp $error_regexp $res_stap]} {
	    pass "$test: $options2"
	} else {
	    fail "$test: $options2"
	}

	# We should get the same result substituting --privilege=stapusr with --privilege=stapsys
	if {[regsub -all {\-\-privilege=stapusr} $options "--privilege=stapsys" options]} {
	    set error_regexp ".*(ERROR)|(You can't specify .* when --privilege=stapsys is specified).*"
	    verbose -log "eval exec stap $options"
	    catch {eval exec stap $test_file -p1 $options} res_stap
	    verbose -log $res_stap
            # Replace the `uname -r` substring, which varies from run to run, with a generic
            # one, for reporting/regression purposes
            set options2 [string map "$uname UNAME" $options]
	    if {[regexp $error_regexp $res_stap]} {
		pass "$test: $options2"
	    } else {
		fail "$test: $options2"
	    }
	}
    }
}

# Test valid combinations
set test "Valid Server Client Arguments"

# stap_run_exact (used below) only works for 'make installcheck'
if {[info procs installtest_p] != "" && ![installtest_p]} { untested $test; return }

set no_error_result "# parse tree dump
# file $test_file
probe begin{
exit();
}

"

set valid_options [list \
  "-a i386" \
  "-B X=Y" \
  "-D X=Y" \
  "-I foo" \
  "-m test" \
  "-r $uname" \
  "-a i386 -B X=Y -D X=Y -I foo -m test -r $uname" \
  "--unprivileged" \
  "--unprivileged -a i386" \
  "--unprivileged -B X=Y" \
  "--unprivileged -D X=Y" \
  "--unprivileged -I foo" \
  "--unprivileged -m test" \
  "--unprivileged -R foo" \
  "--unprivileged -r $uname" \
  "--unprivileged -a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname" \
  "--client-options" \
  "--client-options -a i386" \
  "--client-options -D X=Y" \
  "--client-options -I foo" \
  "--client-options -m test" \
  "--client-options -r $uname" \
  "--client-options -a i386 -D X=Y -I foo -m test -r $uname" \
  "--unprivileged --client-options" \
  "--client-options --unprivileged" \
  "--unprivileged -a i386 --client-options" \
  "--unprivileged -B X=Y --client-options" \
  "--unprivileged -D X=Y --client-options" \
  "--unprivileged -I foo --client-options" \
  "--unprivileged -m test --client-options" \
  "--unprivileged -R foo --client-options" \
  "--unprivileged -r $uname --client-options" \
  "--unprivileged -a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname --client-options" \
  "-a i386 --unprivileged --client-options" \
  "-B X=Y --unprivileged --client-options" \
  "-D X=Y --unprivileged --client-options" \
  "-I foo --unprivileged --client-options" \
  "-m test --unprivileged --client-options" \
  "-R foo --unprivileged --client-options" \
  "-r $uname --unprivileged --client-options" \
  "-a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname --unprivileged --client-options" \
  "-a i386 --client-options --unprivileged" \
  "-B X=Y --client-options --unprivileged" \
  "-D X=Y --client-options --unprivileged" \
  "-I foo --client-options --unprivileged" \
  "-m test --client-options --unprivileged" \
  "-R foo --client-options --unprivileged" \
  "-r $uname --client-options --unprivileged" \
  "-a i386 -B X=Y -D X=Y -I foo -m test -R foo -r $uname --client-options --unprivileged" \
]

set ::result_string "$no_error_result"

# avoid propagating issue similar to PR17301
set origdir $env(SYSTEMTAP_DIR)
catch {exec mktemp -d} tmpdir
set env(SYSTEMTAP_DIR) $tmpdir

foreach options $valid_options {
    # Replace the `uname -r` substring, which varies from run to run, with a generic
    # one, for reporting/regression purposes
    set options2 [string map "$uname UNAME" $options]
    eval stap_run_exact {"$test: $options2"} $test_file -p1 $options

    # We should get the same result substituting --unprivileged with --privilege=stapusr
    if {[regsub -all {\-\-unprivileged} $options "--privilege=stapusr" options]} {
        # Replace the `uname -r` substring, which varies from run to run, with a generic
        # one, for reporting/regression purposes
        set options2 [string map "$uname UNAME" $options]
	eval stap_run_exact {"$test: $options2"} $test_file -p1 $options

	# We should get the same result substituting --privilege=stapusr with --privilege=stapsys
	if {[regsub -all {\-\-privilege=stapusr} $options "--privilege=stapsys" options]} {
            # Replace the `uname -r` substring, which varies from run to run, with a generic
            # one, for reporting/regression purposes
            set options2 [string map "$uname UNAME" $options]
	    eval stap_run_exact {"$test: $options2"} $test_file -p1 $options
	}
    }
}

set env(SYSTEMTAP_DIR) $origdir
catch {exec rm -rf $tmpdir}