| 1 |
########### Startup Server ############# |
| 2 |
# Don't attempt these tests if the client/server are not available or |
| 3 |
# we aren't doing 'make installcheck' |
| 4 |
if {! [installtest_p]} { untested "Server Locale Tests"; return } |
| 5 |
if {! [setup_server]} then { |
| 6 |
untested "Server Locale Tests" |
| 7 |
return |
| 8 |
} |
| 9 |
###################################################### |
| 10 |
################# General Tests ###################### |
| 11 |
###################################################### |
| 12 |
|
| 13 |
set valid_script {{probe begin{printf("Hello\n"); exit();}}} |
| 14 |
set french_script {{probe begin{printf("Bonjour\n"); exit();}}} |
| 15 |
set invalid_script {{probe begin{printf("Hello); exit();}}} |
| 16 |
|
| 17 |
###### Embedded '\n' in Environment Variables ######## |
| 18 |
# Should not allow embedded '\n' in Environment Variables |
| 19 |
set test "Embedded '\\n' in Env Vars" |
| 20 |
set cmd [concat env \"LANG=en_US\\n.utf8\" stap -e $valid_script $use_server] |
| 21 |
send_log "executing: $cmd\n" |
| 22 |
eval spawn $cmd |
| 23 |
expect { |
| 24 |
-timeout 150 |
| 25 |
-re {^Server: Localization key=value line [^\r\n]*\r\n} { |
| 26 |
pass $test |
| 27 |
} |
| 28 |
-re {^[^\r\n]*\r\n} { |
| 29 |
exp_continue |
| 30 |
} |
| 31 |
eof { |
| 32 |
fail "$test (eof)" |
| 33 |
} |
| 34 |
timeout { |
| 35 |
kill -INT -[exp_pid] 2 |
| 36 |
fail "$test (timeout)" |
| 37 |
} |
| 38 |
} |
| 39 |
catch {close}; catch {wait} |
| 40 |
|
| 41 |
|
| 42 |
###### Embedded ';' in Environment Variables ######## |
| 43 |
# Should not allow embedded ';' in Environment Variables |
| 44 |
# There are many disallowed chars, but let's just try one |
| 45 |
set test "Embedded ';' in Env Vars" |
| 46 |
set cmd [concat env \"LANG=en_US\;.utf8\" stap -e $valid_script $use_server] |
| 47 |
send_log "executing: $cmd\n" |
| 48 |
eval spawn $cmd |
| 49 |
expect { |
| 50 |
-timeout 150 |
| 51 |
-re "^Server: Localization value '\[^'\]*' contains illegal characters\r\n" { |
| 52 |
pass $test |
| 53 |
} |
| 54 |
-re {^[^\r\n]*\r\n} { |
| 55 |
exp_continue |
| 56 |
} |
| 57 |
eof { |
| 58 |
fail "$test (eof)" |
| 59 |
} |
| 60 |
timeout { |
| 61 |
kill -INT -[exp_pid] 2 |
| 62 |
fail "$test (timeout)" |
| 63 |
} |
| 64 |
} |
| 65 |
catch {close}; catch {wait} |
| 66 |
|
| 67 |
|
| 68 |
###### Use of "_.-@=" in Environment Variables ######## |
| 69 |
# Should allow "_.-@=" in Environment Variables |
| 70 |
set test "Use of '_.-@=' in Env Vars" |
| 71 |
set cmd [concat env LANG=en_US.utf-8@toronto=test stap -e $valid_script $use_server] |
| 72 |
send_log "executing: $cmd\n" |
| 73 |
eval spawn $cmd |
| 74 |
expect { |
| 75 |
-timeout 150 |
| 76 |
-re "^Hello\r\n" { |
| 77 |
pass $test |
| 78 |
} |
| 79 |
-re {^[^\r\n]*\r\n} { |
| 80 |
exp_continue |
| 81 |
} |
| 82 |
eof { |
| 83 |
fail "$test (eof)" |
| 84 |
} |
| 85 |
timeout { |
| 86 |
kill -INT -[exp_pid] 2 |
| 87 |
fail "$test (timeout)" |
| 88 |
} |
| 89 |
} |
| 90 |
catch {close}; catch {wait} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
###################################################### |
| 95 |
################### LANG TESTS ####################### |
| 96 |
###################################################### |
| 97 |
|
| 98 |
########### LANG French Sniff Test ########### |
| 99 |
# |
| 100 |
# Note that on newer versions of Fedora, setting LANG to French isn't |
| 101 |
# enough, you also need the French langpack installed. To do so, |
| 102 |
# you'll need to do (as root): |
| 103 |
# |
| 104 |
# dnf install langpacks-fr |
| 105 |
# |
| 106 |
# In theory, we could test the system to see if has the French |
| 107 |
# langpacks installed, but in practice the command to do that varies |
| 108 |
# between distros. |
| 109 |
# |
| 110 |
# So, let's test and see if the French locale seems to work. Run stap |
| 111 |
# locally and see if we get French output. If we don't get French |
| 112 |
# output when run locally, we won't get it from the server on this |
| 113 |
# system either. |
| 114 |
|
| 115 |
set test "French LANG Sniff Test" |
| 116 |
set french_supported -1 |
| 117 |
set cmd [concat env LANG=fr_FR.utf8 stap -V] |
| 118 |
send_log "executing: $cmd\n" |
| 119 |
eval spawn $cmd |
| 120 |
expect { |
| 121 |
-timeout 150 |
| 122 |
-re {^options activées :[^\r\n][^\r\n]*\r\n} { |
| 123 |
set french_supported 1 |
| 124 |
pass $test |
| 125 |
} |
| 126 |
-re {^enabled features:[^\r\n][^\r\n]*\r\n} { |
| 127 |
set french_supported 0 |
| 128 |
xfail $test |
| 129 |
} |
| 130 |
-re {^[^\r\n]*\r\n} { |
| 131 |
exp_continue |
| 132 |
} |
| 133 |
eof { |
| 134 |
fail "$test (eof)" |
| 135 |
} |
| 136 |
timeout { |
| 137 |
kill -INT -[exp_pid] 2 |
| 138 |
fail "$test (timeout)" |
| 139 |
} |
| 140 |
} |
| 141 |
catch {close}; catch {wait} |
| 142 |
if {$french_supported == -1} { |
| 143 |
fail "$test - no expected output seen" |
| 144 |
} |
| 145 |
|
| 146 |
########### LANG Proper Syntax Test (French) ############## |
| 147 |
# Run a basic execution test in French. Should return only "Bonjour". |
| 148 |
set test "LANG Proper Syntax Test (French)" |
| 149 |
set cmd [concat env LANG=fr_FR.utf8 stap -e $french_script $use_server] |
| 150 |
send_log "executing: $cmd\n" |
| 151 |
eval spawn $cmd |
| 152 |
expect { |
| 153 |
-timeout 150 |
| 154 |
-re "^Bonjour\r\n" { |
| 155 |
pass $test |
| 156 |
} |
| 157 |
-re {^[^\r\n]*\r\n} { |
| 158 |
exp_continue |
| 159 |
} |
| 160 |
eof { |
| 161 |
fail "$test (eof)" |
| 162 |
} |
| 163 |
timeout { |
| 164 |
kill -INT -[exp_pid] 2 |
| 165 |
fail "$test (timeout)" |
| 166 |
} |
| 167 |
} |
| 168 |
catch {close}; catch {wait} |
| 169 |
|
| 170 |
|
| 171 |
########### LANG Proper Syntax Test (English) ############# |
| 172 |
# Run a basic execution test in English. Should return only "Hello". |
| 173 |
set test "LANG Proper Syntax Test (English)" |
| 174 |
set cmd [concat env LANG=en_US.utf8 stap -e $valid_script $use_server] |
| 175 |
send_log "executing: $cmd\n" |
| 176 |
eval spawn $cmd |
| 177 |
expect { |
| 178 |
-timeout 150 |
| 179 |
-re "^Hello\r\n" { |
| 180 |
pass $test |
| 181 |
} |
| 182 |
-re {^[^\r\n]*\r\n} { |
| 183 |
exp_continue |
| 184 |
} |
| 185 |
eof { |
| 186 |
fail "$test (eof)" |
| 187 |
} |
| 188 |
timeout { |
| 189 |
kill -INT -[exp_pid] 2 |
| 190 |
fail "$test (timeout)" |
| 191 |
} |
| 192 |
} |
| 193 |
catch {close}; catch {wait} |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
########### LANG Bad Syntax Test (French) ############# |
| 198 |
# Run an execution test with a syntax error, in French. |
| 199 |
# |
| 200 |
# Note that we can't test for exact output here, since we may not have |
| 201 |
# up to date French translations. So, if we get anything in French, we |
| 202 |
# pass. |
| 203 |
set test "LANG Bad Syntax Test (French)" |
| 204 |
if {$french_supported != 1} { |
| 205 |
setup_xfail *-*-* |
| 206 |
} |
| 207 |
set cmd [concat env LANG=fr_FR.utf8 stap -e $invalid_script $use_server] |
| 208 |
send_log "executing: $cmd\n" |
| 209 |
eval spawn $cmd |
| 210 |
expect { |
| 211 |
-timeout 150 |
| 212 |
-re {Ne peut trouver la guillemet} { |
| 213 |
pass $test |
| 214 |
} |
| 215 |
-re {^[^\r\n]*\r\n} { |
| 216 |
exp_continue |
| 217 |
} |
| 218 |
eof { |
| 219 |
fail "$test (eof)" |
| 220 |
} |
| 221 |
timeout { |
| 222 |
kill -INT -[exp_pid] 2 |
| 223 |
fail "$test (timeout)" |
| 224 |
} |
| 225 |
} |
| 226 |
catch {close}; catch {wait} |
| 227 |
|
| 228 |
|
| 229 |
########### LANG Bad Syntax Test (English) ############# |
| 230 |
# Run an execution test with a syntax error, in English. |
| 231 |
set test "LANG Bad Syntax Test (English)" |
| 232 |
set cmd [concat env LANG=en_US.utf8 stap -e $invalid_script $use_server] |
| 233 |
send_log "executing: $cmd\n" |
| 234 |
eval spawn $cmd |
| 235 |
expect { |
| 236 |
-timeout 150 |
| 237 |
-re {^parse error: Could not find matching closing quote\r\n} { |
| 238 |
pass $test |
| 239 |
} |
| 240 |
-re {^1 parse error\.\r\n} { |
| 241 |
pass $test |
| 242 |
} |
| 243 |
-re {^[^\r\n]*\r\n} { |
| 244 |
exp_continue |
| 245 |
} |
| 246 |
eof { |
| 247 |
fail "$test (eof)" |
| 248 |
} |
| 249 |
timeout { |
| 250 |
kill -INT -[exp_pid] 2 |
| 251 |
fail "$test (timeout)" |
| 252 |
} |
| 253 |
} |
| 254 |
catch {close}; catch {wait} |
| 255 |
|
| 256 |
|
| 257 |
###################################################### |
| 258 |
################ LC_CTYPE Tests ###################### |
| 259 |
###################################################### |
| 260 |
# NOT YET TESTED - NO APPARENT EFFECT |
| 261 |
|
| 262 |
###################################################### |
| 263 |
############### LC_COLLATE Tests ##################### |
| 264 |
###################################################### |
| 265 |
# NOT YET TESTED - NO APPARENT EFFECT |
| 266 |
|
| 267 |
###################################################### |
| 268 |
############## LC_MESSAGES Tests ##################### |
| 269 |
###################################################### |
| 270 |
# NOT YET TESTED - NO APPARENT EFFECT |
| 271 |
|
| 272 |
###################################################### |
| 273 |
################# LC_TIME Tests ###################### |
| 274 |
###################################################### |
| 275 |
# NOT YET TESTED - NO APPARENT EFFECT |
| 276 |
|
| 277 |
###################################################### |
| 278 |
############### LC_MONETARY Tests #################### |
| 279 |
###################################################### |
| 280 |
# NOT YET TESTED - NO APPARENT EFFECT |
| 281 |
|
| 282 |
###################################################### |
| 283 |
################ LC_NUMERIC Tests #################### |
| 284 |
###################################################### |
| 285 |
# NOT YET TESTED - NO APPARENT EFFECT |
| 286 |
|
| 287 |
########### Shutdown Server ############# |
| 288 |
# Shudown the server. |
| 289 |
shutdown_server |