Debian Codegraph @

testsuite/modules.00-init/120-siteconfig.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2018/02/22
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # Check siteconfig superseding mechanism
18 # }C%
19 #
20 ##############################################################################
21
22 skip_if_quick_mode
23
24 proc test_getSiteConfig {siteconfig isvalid islocked} {
25 set siteconfigre [regsub -all "\(\[.+?\]\)" $siteconfig {\\\1}]
26 set siteconfigdbg [expr {$isvalid && !$islocked ? "DEBUG sourceSiteConfig: Source site configuration \\($siteconfigre\\)\\nDEBUG setState: extra_siteconfig_loaded set to '1'\\n" : {}}]
27 set getextrasiteconfigre [expr {!$islocked ? $siteconfigre : {}}]
28 if {[info exists ::env(TESTSUITE_ENABLE_SITECONFIG_NOEXTRASITECONFIG)]} {
29 set mainconfigdbg [expr {[file readable $::siteconfig_file] ? "DEBUG sourceSiteConfig: Source site configuration \\($::siteconfig_filere\\)\\n" : {}}]
30 } else {
31 set mainconfigdbg [expr {[file readable $::siteconfig_file] ? "DEBUG sourceSiteConfig: Source site configuration \\($::siteconfig_filere\\)\\nDEBUG setState: siteconfig_loaded set to '1'\\n" : {}}]
32 }
33
34 set ans [list]
35 if {$isvalid && !$islocked} {
36 lappend ans "someUserProc"
37 }
38 lappend ans "DEBUG setState: cmdline set to '$::MODULECMD sh --no-pager -D -V'"
39 if {$::install_libtclenvmodules ne {n}} {
40 if {$::install_multilibsupport eq {y}} {
41 lappend ans "DEBUG setState: machine set to '$::tcl_platform(machine)'"
42 }
43 lappend ans "DEBUG setConf: tcl_ext_lib set to '$::tclextlib_file'(\\nDEBUG Load Tcl extension library \\(.+\\))?(\\nDEBUG setState: tcl_ext_lib_loaded set to '1')?"
44 }
45 lappend ans "DEBUG setConf: siteconfig set to '$::siteconfig_filere'"
46 lappend ans "${mainconfigdbg}DEBUG setConf: locked_configs set to '$::install_lockedconfigs'"
47 if {[info exists ::env(TESTSUITE_ENABLE_SITECONFIG_NOEXTRASITECONFIG)]} {
48 lappend ans "DEBUG setConf: locked_configs set to 'extra_siteconfig'"
49 lappend ans "DEBUG setState: siteconfig_loaded set to '1'"
50 } elseif {!$islocked} {
51 lappend ans "DEBUG setConf: extra_siteconfig set to '$getextrasiteconfigre'"
52 }
53 lappend ans "${siteconfigdbg}DEBUG setState: supported_shells set to 'sh bash ksh zsh csh tcsh fish cmd tcl perl python ruby lisp cmake r pwsh'"
54 lappend ans "DEBUG setState: shell set to 'sh'"
55 lappend ans "DEBUG setState: subcmd set to ''"
56 lappend ans "DEBUG setState: subcmd_args set to ''"
57 lappend ans "DEBUG setState: init_error_report set to '1'"
58 lappend ans "DEBUG setConf: verbosity set to 'debug'"
59 lappend ans "DEBUG setConf: term_background set to '$::install_termbg'"
60 lappend ans "(DEBUG initConfColors: Ignore invalid default.*\\n)?DEBUG setConf: colors set to '.*'"
61 lappend ans "DEBUG setConf: color set to '0'"
62 lappend ans "DEBUG setConf: pager set to '$::install_pagercmd'"
63 if {$::pager_dfl_use} {
64 lappend ans "DEBUG setState: shelltype set to 'sh'"
65 }
66 lappend ans "DEBUG setState: paginate set to '0'"
67 lappend ans "DEBUG setState: report_format set to 'regular'"
68 lappend ans "DEBUG setState: reportfd set to 'stderr'"
69 lappend ans "DEBUG setState: timer set to '0'"
70 lappend ans $::vers_reportre
71 lappend ans "DEBUG setConf: logger set to '$::install_loggercmd'"
72 lappend ans "DEBUG setState: logging set to '0'"
73 lappend ans "DEBUG setState: logfd set to ''"
74 lappend ans "DEBUG setState: error_count set to '0'"
75
76 setenv_var MODULES_SITECONFIG $siteconfig
77 testouterr_cmd_re sh {--no-pager -D -V} {} [join $ans \n]
78 unsetenv_var MODULES_SITECONFIG
79 }
80
81 # check excepted siteconfig file is installed
82 set is_stderr_tty [siteconfig_isStderrTty]
83 if {$is_stderr_tty} {
84
85 # no procedure superseding test, already handled in 100-pager tests
86
87 # test variable superseding
88 setenv_var TESTSUITE_ENABLE_SITECONFIG_DEBUG 1
89
90 set ans [list]
91 lappend ans "DEBUG setState: cmdline set to '$MODULECMD sh -V'"
92 if {$::install_multilibsupport eq {y}} {
93 lappend ans "DEBUG setState: machine set to '$::tcl_platform(machine)'"
94 }
95 lappend ans "DEBUG setConf: tcl_ext_lib set to '$tclextlib_file'(\\nDEBUG Load Tcl extension library \\(.+\\))?(\\nDEBUG setState: tcl_ext_lib_loaded set to '1')?"
96 lappend ans "DEBUG setConf: siteconfig set to '$siteconfig_filere'"
97 lappend ans "DEBUG sourceSiteConfig: Source site configuration \\($siteconfig_filere\\)"
98 lappend ans "DEBUG setState: siteconfig_loaded set to '1'"
99 lappend ans "DEBUG setConf: locked_configs set to '$install_lockedconfigs'"
100 lappend ans "DEBUG setState: supported_shells set to 'sh bash ksh zsh csh tcsh fish cmd tcl perl python ruby lisp cmake r pwsh'"
101 lappend ans "DEBUG setState: shell set to 'sh'"
102 lappend ans "DEBUG setState: subcmd set to ''"
103 lappend ans "DEBUG setState: subcmd_args set to ''"
104 lappend ans "DEBUG setState: init_error_report set to '1'"
105 lappend ans "DEBUG setConf: verbosity set to 'debug'"
106 lappend ans "DEBUG setConf: term_background set to '$install_termbg'"
107 lappend ans "(DEBUG initConfColors: Ignore invalid default.*\\n)?DEBUG setConf: colors set to '.*'"
108 lappend ans "DEBUG setConf: color set to '0'"
109 lappend ans "DEBUG setConf: pager set to '$install_pagercmd'"
110 if {$pager_dfl_use} {
111 lappend ans "DEBUG setState: shelltype set to 'sh'"
112 }
113 lappend ans "DEBUG setState: is_stderr_tty set to '1'"
114 lappend ans "DEBUG setState: paginate set to '1'"
115 lappend ans "DEBUG setState: report_format set to 'regular'"
116 lappend ans "DEBUG setState: reportfd set to 'file\\d'"
117 lappend ans "DEBUG setState: timer set to '0'"
118 lappend ans $vers_reportre
119 lappend ans "DEBUG setConf: logger set to '$install_loggercmd'"
120 lappend ans "DEBUG setState: logging set to '0'"
121 lappend ans "DEBUG setState: logfd set to ''"
122 testouterr_cmd_re "sh" "-V" "" [join $ans "\n"]
123
124 # test variable superseding of regular siteconfig file by additional siteconfig file if enabled
125 if {![is_config_locked extra_siteconfig]} {
126 setenv_var MODULES_SITECONFIG testsuite/example/siteconfig.tcl-2
127 testouterr_cmd_re sh {-V} {} $vers_reportre
128 unsetenv_var MODULES_SITECONFIG
129 }
130
131 # restore environment
132 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_DEBUG
133
134
135 # test broken siteconfig file
136 if {$verbose} {
137 send_user "\tSetup TESTSUITE_ENABLE_SITECONFIG_BROKEN = '1'\n"
138 }
139 set env(TESTSUITE_ENABLE_SITECONFIG_BROKEN) 1
140
141 set tserr [escre "$error_msgs: Site configuration source failed
142 invalid command name \"unk_foo\"
143 while executing
144 \"unk_foo<EXM>\"
145 (file \"$siteconfig_file\" line 2)<EXM>"]
146 testouterr_cmd_re sh -V ERR $tserr
147
148 # restore environment
149 if {$verbose} {
150 send_user "\tUnset TESTSUITE_ENABLE_SITECONFIG_BROKEN\n"
151 }
152 unset env(TESTSUITE_ENABLE_SITECONFIG_BROKEN)
153
154
155 # test siteconfig that breaks modulecmd.tcl code
156 setenv_var TESTSUITE_ENABLE_SITECONFIG_BROKEN2 1
157 set ans [list]
158 lappend ans "$error_msgs: invalid command name \"unk_foo\""
159 lappend ans { while executing}
160 lappend ans { "unk_foo"}
161 lappend ans { (procedure "reportVersion" line 2)}
162 lappend ans { invoked from within}
163 lappend ans { "reportVersion"}
164 lappend ans { Please report this issue at https://github.com/envmodules/modules/issues}
165 testouterr_cmd sh {-V} ERR [join $ans \n]
166 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_BROKEN2
167 setenv_var TESTSUITE_ENABLE_SITECONFIG_BROKEN3 1
168 set ans [list]
169 lappend ans "$error_msgs: invalid command name \"reportVersion\""
170 lappend ans { while executing}
171 lappend ans { "reportVersion"}
172 lappend ans { Please report this issue at https://github.com/envmodules/modules/issues}
173 testouterr_cmd sh {-V} ERR [join $ans \n]
174 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_BROKEN3
175
176
177 # test siteconfig file raising error
178 # test parseAccessIssue with custom error code by the way
179 if {$verbose} {
180 send_user "\tSetup TESTSUITE_ENABLE_SITECONFIG_ACCESSERR = '1'\n"
181 }
182 set env(TESTSUITE_ENABLE_SITECONFIG_ACCESSERR) 1
183
184 set tserr [escre "$error_msgs: Site configuration source failed
185 Cannot access 'foo'
186 while executing
187 \"error \[parseAccessIssue \"foo\"\]<EXM>\"
188 (file \"$siteconfig_file\" line 2)<EXM>"]
189 testouterr_cmd_re sh -V ERR $tserr
190
191 # restore environment
192 if {$verbose} {
193 send_user "\tUnset TESTSUITE_ENABLE_SITECONFIG_ACCESSERR\n"
194 }
195 unset env(TESTSUITE_ENABLE_SITECONFIG_ACCESSERR)
196
197
198 # test displayElementList procedure in terse+numbered mode
199 if {$verbose} {
200 send_user "\tSetup TESTSUITE_ENABLE_SITECONFIG_TERSENUM = '1'\n"
201 }
202 set env(TESTSUITE_ENABLE_SITECONFIG_TERSENUM) 1
203
204 set ans [list]
205 lappend ans "test:"
206 lappend ans " 1\\\) elt1 "
207 lappend ans " 2\\\) elt2 "
208 lappend ans " 3\\\) elt3 "
209 lappend ans {}
210 lappend ans $vers_reportre
211 testouterr_cmd_re "sh" "-V" "OK" [join $ans "\n"]
212
213 # restore environment
214 if {$verbose} {
215 send_user "\tUnset TESTSUITE_ENABLE_SITECONFIG_TERSENUM\n"
216 }
217 unset env(TESTSUITE_ENABLE_SITECONFIG_TERSENUM)
218
219 # test displayElementList procedure with a tricky list that triggers unusual condition
220 setenv_var TESTSUITE_ENABLE_SITECONFIG_TRICKYLISTDISP 1
221 set ans "test:
222 1\\) abc/def 22\\) abcdefgh/ij-k-lmno.pq
223 2\\) abcdefgh/ijklmnop 23\\) abcdefgh/ijk-l-mnop.qr-stu
224 3\\) abc/defg 24\\) abcdefgh/ijklmnop-qr.st
225 4\\) abcd/ef 25\\) abcdef/ghijklmno-pq.rs
226 5\\) abc/defg-hijkl.mn.op 26\\) abcdef/ghi-jklm_no_pqrstuv
227 6\\) abcdefgh/ijklm.nopqrst 27\\) abcdefgh/ijk-lm-n-opqr.st
228 7\\) abcdefg/hijklmnop-qr.st.uvw 28\\) abcdefgh/ijklm-n-opqr.st-uvw
229 8\\) abcdefgh/ijklmnopqrst-u-vwxy.zA-BCD-E 29\\) abcdef/ghijklm-nopq_r
230 9\\) abcdef/ghijklm-nopq.r_st.uv 30\\) abcdefg/hijkl-mn.op.qzs
231 10\\) abcdefgh/ijklmnop-q-rstu.vw-xyz-A 31\\) abcdefg/hijklmn-op.qr.stz
232 11\\) abcdefg/hijklmn-op.qr.stu 32\\) abcdefgh/ijklmn
233 12\\) abcdefg/hijkl-mn.op.qrs
234 13\\) abcd/efgh-ij.k
235 14\\) abcdefg/hijk-lmnop_qr.st.uvw
236 15\\) abcdef/ghijklmno-p.q.r
237 16\\) abcdefgh/ijklmn-o-pqrs.tu
238 17\\) abcdefgh/ijklmnop-q-rstu.vw-xyz
239 18\\) abcdefg/hij-klm.nopq
240 19\\) abcdefg/hij-kl.mn.opq
241 20\\) abcdefgh/ijklmnopq_rstuv-w-xyzA.BC-DEF
242 21\\) abcdefgh/ijklmnopqrstuv-w-xyzA.BC
243
244 $vers_reportre"
245 testouterr_cmd_re "sh" "-V" "OK" $ans
246 # restore environment
247 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TRICKYLISTDISP
248
249 # test loaded module accessor procedures on non-loaded module
250 # does not happened currently within modulecmd.tcl as there is always a
251 # 'getLoadedModulePropertyList name' retrieval or a isModuleLoaded call prior
252 # use of get accessor
253 if {$verbose} {
254 send_user "\tSetup TESTSUITE_ENABLE_SITECONFIG_LMACCESSOR = '1'\n"
255 }
256 set env(TESTSUITE_ENABLE_SITECONFIG_LMACCESSOR) 1
257
258 set ans [list]
259 lappend ans ""
260 lappend ans ""
261 lappend ans ""
262 lappend ans $vers_reportre
263 testouterr_cmd_re "sh" "-V" "OK" [join $ans "\n"]
264
265 # restore environment
266 if {$verbose} {
267 send_user "\tUnset TESTSUITE_ENABLE_SITECONFIG_LMACCESSOR\n"
268 }
269 unset env(TESTSUITE_ENABLE_SITECONFIG_LMACCESSOR)
270
271
272 # test path variable handling on Windows platform (';' separator is used
273 # instead of ':')
274 if {$verbose} {
275 send_user "\tSetup TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM = '1'\n"
276 }
277 set env(TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM) 1
278
279 set env(PATH) "/path/to/dir1"
280 set module "append/2.0"
281 set modulefile "$modpath/$module"
282
283 set ans [list]
284 lappend ans [list set PATH "/path/to/dir1;/this/is/the/modules/testsuite"]
285 lappend ans [list set _LMFILES_ $modulefile]
286 lappend ans [list set LOADEDMODULES $module]
287 testouterr_cmd "cmd" "load $module" $ans ""
288
289 set env(PATH) "/path/to/dir1;/this/is/the/modules/testsuite"
290
291 set ans [list]
292 lappend ans [list set __MODULES_SHARE_PATH "/this/is/the/modules/testsuite;2"]
293 lappend ans [list set PATH "/path/to/dir1;/this/is/the/modules/testsuite"]
294 lappend ans [list set _LMFILES_ $modulefile]
295 lappend ans [list set LOADEDMODULES $module]
296 testouterr_cmd "cmd" "load $module" $ans ""
297
298 set env(__MODULES_SHARE_PATH) "/this/is/the/modules/testsuite;2"
299
300 set ans [list]
301 lappend ans [list set __MODULES_SHARE_PATH "/this/is/the/modules/testsuite;3"]
302 lappend ans [list set PATH "/path/to/dir1;/this/is/the/modules/testsuite"]
303 lappend ans [list set _LMFILES_ $modulefile]
304 lappend ans [list set LOADEDMODULES $module]
305 testouterr_cmd "cmd" "load $module" $ans ""
306
307 setenv_path_var PATH $ORIG_PATH
308
309 set tserr "$error_msgs: No autoinit mode available for 'pwsh' shell on Windows"
310 testouterr_cmd pwsh autoinit ERR $tserr
311
312 # restore environment
313 if {$verbose} {
314 send_user "\tUnset TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM\n"
315 }
316 unset env(TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM)
317
318
319 # test getDiffBetweenList procedure with element of second list arg not in first list arg
320 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETDIFFBETWEENLIST 1
321
322 set ans [list]
323 lappend ans "{foo foo2} {bar bar2}"
324 lappend ans $vers_reportre
325 testouterr_cmd_re sh -V OK [join $ans \n]
326
327 # restore environment
328 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETDIFFBETWEENLIST
329
330
331 # test getDiffBetweenArray procedure with element of first list arg with empty value
332 # not in second list arg (notset_equals_empty option enabled)
333 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETDIFFBETWEENARRAY 1
334
335 set ans [list]
336 lappend ans "{} {} {}"
337 lappend ans $vers_reportre
338 testouterr_cmd_re sh -V OK [join $ans \n]
339
340 # restore environment
341 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETDIFFBETWEENARRAY
342
343
344 # test clear sub-command confirmation message without waiting indefinitely
345 if {$is_stdin_tty} {
346 setenv_var TESTSUITE_ENABLE_SITECONFIG_EXITONGETSSTDIN 1
347
348 set tserr "(Are you sure you want to clear all loaded modules\\!\\? \\\[n\\\] )"
349 testouterr_cmd_re sh clear {} $tserr
350
351 # restore environment
352 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_EXITONGETSSTDIN
353 } elseif {$verbose} {
354 send_user "\tSkip tests relying on a stdin channel attached to a tty\n"
355 }
356
357 # test extra siteconfig disablement
358 setenv_var TESTSUITE_ENABLE_SITECONFIG_NOEXTRASITECONFIG 1
359
360 test_getSiteConfig testsuite/example/siteconfig.tcl-2 0 1
361
362 # restore environment
363 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_NOEXTRASITECONFIG
364
365
366 # test tcl ext lib load on an incompatible interp if available
367 if {[info exists tclextlib_file] && [file executable ./tclsh83]} {
368 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBLOAD83 1
369
370 set tserr [escre "$error_msgs: Site configuration source failed
371 version conflict for package \"Tcl\": have 8.3, need 8.5-
372 while executing
373 \"exec ./tclsh83 << \"load \[getConf tcl_ext_lib\] Envmodules\"<EXM>\"
374 (file \"$siteconfig_file\" line 2)<EXM>"]
375 testouterr_cmd_re sh -V ERR $tserr
376
377 # restore environment
378 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBLOAD83
379 } elseif {$verbose} {
380 send_user "\tSkip tcl ext lib load tests with tclsh83 as either ext lib or tclsh83 is not available\n"
381 }
382
383 # test tcl ext lib procedures against erroneous calls
384 if {[info exists tclextlib_file]} {
385 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBBADCALL 1
386 set ans [list]
387 lappend ans "$error_msgs: wrong # args: should be \"readFile filename \\?firstline\\? \\?must_have_cookie\\?\""
388 lappend ans "$error_msgs: expected boolean value but got \"bar\""
389 lappend ans "$error_msgs: expected boolean value but got \"bar\""
390 lappend ans "$error_msgs: wrong # args: should be \"readFile filename \\?firstline\\? \\?must_have_cookie\\?\""
391 lappend ans "$error_msgs: wrong # args: should be \"getFilesInDirectory dir fetch_dotversion\""
392 lappend ans "$error_msgs: expected boolean value but got \"bar\""
393 lappend ans $vers_reportre
394 testouterr_cmd_re sh -V OK [join $ans \n]
395
396 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBBADCALL
397 } elseif {$verbose} {
398 send_user "\tSkip tcl ext lib erroneous procedure calls as ext lib is not available\n"
399 }
400
401 # test tcl ext lib procedures against a failed closedir call
402 if {[info exists closedirlib_file] && [file exists $closedirlib_file]} {
403 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDCLOSEDIR 1
404 setenv_var LD_PRELOAD $closedirlib_file
405 set ans [list]
406 lappend ans "$error_msgs: couldn't close directory \"$modpathre\": Success"
407 lappend ans $vers_reportre
408 testouterr_cmd_re sh -V OK [join $ans \n]
409
410 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDCLOSEDIR
411 unsetenv_var LD_PRELOAD
412 } elseif {$verbose} {
413 send_user "\tSkip tcl ext lib erroneous procedure calls as closedir test lib is not available\n"
414 }
415
416 # test tcl ext lib procedures against a failed getpwuid call
417 if {[info exists getpwuidlib_file] && [file exists $getpwuidlib_file]} {
418 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDGETPWUID 1
419 setenv_var LD_PRELOAD $getpwuidlib_file
420 set ans [list]
421 lappend ans "$error_msgs: couldn't find name for user id \"$userid\": .*"
422 lappend ans $vers_reportre
423 testouterr_cmd_re sh -V OK [join $ans \n]
424
425 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDGETPWUID
426 unsetenv_var LD_PRELOAD
427 } elseif {$verbose} {
428 send_user "\tSkip tcl ext lib erroneous procedure calls as getpwuid test lib is not available\n"
429 }
430
431 # test tcl ext lib procedures against a failed getgroups call
432 if {[info exists getgroupslib_file] && [file exists $getgroupslib_file]} {
433 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDGETGROUPS 1
434 setenv_var LD_PRELOAD $getgroupslib_file
435 set ans [list]
436 lappend ans "$error_msgs: couldn't get supplementary groups: .*"
437 lappend ans $vers_reportre
438 testouterr_cmd_re sh -V OK [join $ans \n]
439
440 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDGETGROUPS
441 unsetenv_var LD_PRELOAD
442 } elseif {$verbose} {
443 send_user "\tSkip tcl ext lib erroneous procedure calls as getgroups test lib is not available\n"
444 }
445
446 # test tcl ext lib procedures against a zero result getgroups call
447 if {[info exists 0getgroupslib_file] && [file exists $0getgroupslib_file]} {
448 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIB0GETGROUPS 1
449 setenv_var LD_PRELOAD $0getgroupslib_file
450 set ans [list]
451 lappend ans [exec id -g -n]
452 lappend ans $vers_reportre
453 testouterr_cmd_re sh -V OK [join $ans \n]
454
455 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIB0GETGROUPS
456 unsetenv_var LD_PRELOAD
457 } elseif {$verbose} {
458 send_user "\tSkip tcl ext lib erroneous procedure calls as 0getgroups test lib is not available\n"
459 }
460
461 # test tcl ext lib procedures against a duplicate entries in result getgroups call
462 if {[info exists dupgetgroupslib_file] && [file exists $dupgetgroupslib_file]} {
463 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBDUPGETGROUPS 1
464 setenv_var LD_PRELOAD $dupgetgroupslib_file
465 set ans [list]
466 lappend ans [exec id -g -n]
467 lappend ans $vers_reportre
468 testouterr_cmd_re sh -V OK [join $ans \n]
469
470 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBDUPGETGROUPS
471 unsetenv_var LD_PRELOAD
472 } elseif {$verbose} {
473 send_user "\tSkip tcl ext lib erroneous procedure calls as dupgetgroups test lib is not available\n"
474 }
475
476 # test tcl ext lib procedures against a failed getgrgid call
477 if {[info exists getgrgidlib_file] && [file exists $getgrgidlib_file]} {
478 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDGETGRGID 1
479 setenv_var LD_PRELOAD $getgrgidlib_file
480 set ans [list]
481 lappend ans "$error_msgs: couldn't find name for group id \".*\": .*"
482 lappend ans $vers_reportre
483 testouterr_cmd_re sh -V OK [join $ans \n]
484
485 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDGETGRGID
486 unsetenv_var LD_PRELOAD
487 } elseif {$verbose} {
488 send_user "\tSkip tcl ext lib erroneous procedure calls as getgrgid test lib is not available\n"
489 }
490
491 # test tcl ext lib procedures against a failed time call
492 if {[info exists timelib_file] && [file exists $timelib_file]} {
493 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDTIME 1
494 setenv_var LD_PRELOAD $timelib_file
495 set ans [list]
496 lappend ans "$error_msgs: couldn't get Epoch time: .*"
497 lappend ans $vers_reportre
498 testouterr_cmd_re sh -V OK [join $ans \n]
499
500 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDTIME
501 unsetenv_var LD_PRELOAD
502 } elseif {$verbose} {
503 send_user "\tSkip tcl ext lib erroneous procedure calls as time test lib is not available\n"
504 }
505
506 # test tcl ext lib procedures called without argument
507 setenv_var TESTSUITE_ENABLE_SITECONFIG_PARSEDATETIMEARG_NOARG 1
508 set ans [list]
509 lappend ans "$error_msgs: wrong # args: should be \"parseDateTimeArg opt datetime\""
510 lappend ans $vers_reportre
511 testouterr_cmd_re sh -V OK [join $ans \n]
512 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_PARSEDATETIMEARG_NOARG
513
514 # test tcl ext lib procedures against a failed mktime call
515 if {[info exists mktimelib_file] && [file exists $mktimelib_file]} {
516 setenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDMKTIME 1
517 setenv_var LD_PRELOAD $mktimelib_file
518 set ans [list]
519 lappend ans "$error_msgs: couldn't convert to Epoch time: .*"
520 lappend ans $vers_reportre
521 testouterr_cmd_re sh -V OK [join $ans \n]
522
523 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_TCLEXTLIBFAILEDMKTIME
524 unsetenv_var LD_PRELOAD
525 } elseif {$verbose} {
526 send_user "\tSkip tcl ext lib erroneous procedure calls as mktime test lib is not available\n"
527 }
528
529 # test tcl ext lib procedures called with badly formatted date
530 setenv_var TESTSUITE_ENABLE_SITECONFIG_PARSEDATETIMEARG_BADDATE 1
531 set ans [list]
532 lappend ans "$error_msgs: Incorrect --before value '2020-09-19U20:00' \\\(valid date time format is 'YYYY-MM-DD\\\[THH:MM\\\]'\\\)"
533 lappend ans $vers_reportre
534 testouterr_cmd_re sh -V OK [join $ans \n]
535 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_PARSEDATETIMEARG_BADDATE
536
537 # specific tests to improve modEq procs coverage
538 setenv_var TESTSUITE_ENABLE_SITECONFIG_MODEQ 1
539 setenv_var MODULES_ADVANCED_VERSION_SPEC 1
540 set ans [list]
541 lappend ans 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1
542 lappend ans 1 0 1 1 0 1 1 0 1 1 0 1
543 lappend ans 1 0 0 1 0 0 1 0 0 1 0 0
544 lappend ans 1 0 1 1 0 1 1 0 1 1 0 1
545 lappend ans $vers_reportre
546 testouterr_cmd_re sh -V OK [join $ans \n]
547 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
548 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_MODEQ
549
550 # test redefinition of on-the-fly procedures
551 setenv_var TESTSUITE_ENABLE_SITECONFIG_REDEFONTHEFLYPROCS 1
552 set ans [list]
553 lappend ans 0 1 0 0 1 0 0 1 1 0 1 1
554 lappend ans 1 0 0 1 0 0 1 0 1 1 0 1
555 lappend ans 1 0 0 1 0 0 1 0 1 1 0 1
556 lappend ans $vers_reportre
557 testouterr_cmd_re sh -V OK [join $ans \n]
558 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_REDEFONTHEFLYPROCS
559
560 # specific tests to improve formatErrStackTrace proc coverage
561 setenv_var TESTSUITE_ENABLE_SITECONFIG_FORMATERRSTACKTRACE 1
562 set ans [list]
563 lappend ans {error message
564 while executing
565 foo call
566 invoked from within
567 foo
568 \(file "foo"\)}
569 lappend ans $vers_reportre
570 testouterr_cmd_re sh -V OK [join $ans \n]
571 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_FORMATERRSTACKTRACE
572
573 # produce an unknown error in a modulecmd.tcl procedure during a modulefile evaluation
574 setenv_var TESTSUITE_ENABLE_SITECONFIG_UNKINTERRDURINGMODEVAL 1
575 set ans [msg_moderr {invalid command name "foo"} {foo} $modpath/setenv/1.0 30 {} {} {} { (procedure "getModshareVarName" line 2)
576 invoked from within
577 "getModshareVarName $var"
578 (procedure "setenv" line 6)
579 invoked from within
580 "setenv testsuite "yes""}]
581 testouterr_cmd sh {load setenv/1.0} ERR [msg_load setenv/1.0 $ans]
582 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_UNKINTERRDURINGMODEVAL
583
584
585 # getModuleDesignation coverage test
586 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEDESIGNATION 1
587 setenv_var MODULES_ADVANCED_VERSION_SPEC 1
588 setenv_loaded_module [list variant/1.0] [list $modpath.3/variant/1.0]
589 setenv_var __MODULES_LMVARIANT variant/1.0&foo|val1|0&bar|val3|0
590 set ans [list]
591 lappend ans variant/1.0{bar=val3:foo=val1}
592 lappend ans $vers_reportre
593 testouterr_cmd_re sh -V OK [join $ans \n]
594 unsetenv_loaded_module
595 unsetenv_var __MODULES_LMVARIANT
596 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
597 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEDESIGNATION
598
599 # unsetModuleTag/unsetModuleExtraTag coverage test
600 setenv_var TESTSUITE_ENABLE_SITECONFIG_UNSETMODULETAG 1
601 set ans [list]
602 lappend ans $vers_reportre
603 testouterr_cmd_re sh -V OK [join $ans \n]
604 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_UNSETMODULETAG
605
606 # readCollectionContent coverage test
607 setenv_var TESTSUITE_ENABLE_SITECONFIG_READCOLLCONTENT 1
608 set tserr "$error_msgs: Collection unk cannot be read.\n [couldnotopen_nofile /path/to/unk]"
609 testouterr_cmd_re sh -V ERR $tserr
610 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_READCOLLCONTENT
611
612 # getInterpVar coverage test
613 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETINTERPVAR 1
614 set ans [list]
615 lappend ans undef
616 lappend ans value
617 lappend ans $vers_reportre
618 testouterr_cmd_re sh -V OK [join $ans \n]
619 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETINTERPVAR
620
621 # getLoadingModuleFileList coverage test
622 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETLOADINGMODULEFILELIST 1
623 set ans [list]
624 lappend ans {/path/to/foo/1.0 /path/to/qux/1.0}
625 lappend ans $vers_reportre
626 testouterr_cmd_re sh -V OK [join $ans \n]
627 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETLOADINGMODULEFILELIST
628
629 # getModuleFromLoadingModulefile coverage test
630 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEFROMLOADINGMODULEFILE 1
631 set ans [list]
632 lappend ans qux/1.0
633 lappend ans $vers_reportre
634 testouterr_cmd_re sh -V OK [join $ans \n]
635 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEFROMLOADINGMODULEFILE
636
637 # reportFinalError coverage tests
638 if {[info exists tclextlib_file]} {
639 setenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORTCLCOMPAT 1
640 set ans [list]
641 lappend ans "$error_msgs: interpreter uses an incompatible stubs mechanism"
642 lappend ans { while executing}
643 lappend ans { "error {interpreter uses an incompatible stubs mechanism}"}
644 lappend ans { (procedure "reportVersion" line 2)}
645 lappend ans { invoked from within}
646 lappend ans { "reportVersion"}
647 testouterr_cmd sh {-V} ERR [join $ans \n]
648 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORTCLCOMPAT
649
650 setenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORLIBCOMPAT 1
651 set ans [list]
652 lappend ans "$error_msgs: dlopen(/usr/local/Modules/lib/libtclenvmodules.dylib, 0x000A): tried: '/usr/local/Modules/lib/libtclenvmodules.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))"
653 lappend ans { while executing}
654 lappend ans " \"error \{dlopen(/usr/local/Modules/lib/libtclenvmodules.dylib, 0x000A): tried: '/usr/local/Modules/lib/libtclenvmodules.dylib' (mach-o file, but is an i...\""
655 lappend ans { (procedure "reportVersion" line 2)}
656 lappend ans { invoked from within}
657 lappend ans { "reportVersion"}
658 testouterr_cmd sh {-V} ERR [join $ans \n]
659 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORLIBCOMPAT
660
661 setenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORTCLINSTALL 1
662 set ans [list]
663 lappend ans "$error_msgs: Can't find a usable init.tcl in the following directories:
664 /root/lib/tcl8.6 /usr/lib/tcl8.6 /lib/tcl8.6 /usr/library /library /tcl8.6.14/library /tcl8.6.14/library
665
666 This probably means that Tcl wasn't installed properly."
667 lappend ans { while executing}
668 lappend ans " \"error \{Can't find a usable init.tcl in the following directories:
669 /root/lib/tcl8.6 /usr/lib/tcl8.6 /lib/tcl8.6 /usr/library /library /tcl8.6.14/librar...\""
670 lappend ans { (procedure "reportVersion" line 2)}
671 lappend ans { invoked from within}
672 lappend ans { "reportVersion"}
673 testouterr_cmd sh {-V} ERR [join $ans \n]
674 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORTCLINSTALL
675 }
676 setenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORTCLINIT 1
677 set ans [list]
678 lappend ans "$error_msgs: invalid command name \"tcl::mathfunc::max\""
679 lappend ans { while executing}
680 lappend ans { "tcl::mathfunc::max [expr {($tty_cols - $len - 2)/2}] 1"}
681 lappend ans { (procedure "displaySeparatorLine" line 10)}
682 lappend ans { invoked from within}
683 lappend ans { "displaySeparatorLine $header $sgrkey $extra"}
684 lappend ans { (procedure "displayElementList" line 19)}
685 lappend ans { invoked from within}
686 lappend ans { "displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx 1 $display_list $len_list $max_len $via"}
687 lappend ans { (procedure "reportModules" line 155)}
688 lappend ans { invoked from within}
689 lappend ans { "reportModules $args $dir mp $hstyle $show_mtime 0 $one_per_line $theader_cols hidden-loaded"}
690 lappend ans { (procedure "cmdModuleAvail" line 43)}
691 lappend ans { invoked from within}
692 lappend ans { "$cmdprocname {*}$cmdopts {*}$parsed_args"}
693 lappend ans { (procedure "module" line 190)}
694 lappend ans { invoked from within}
695 lappend ans { "{*}$execcmdlist"}
696 testouterr_cmd sh {avail} ERR [join $ans \n]
697 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORTCLINIT
698
699 setenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORRESSOURCEUNAVAIL 1
700 set ans [list]
701 lappend ans "$error_msgs: couldn't fork child process: resource temporarily unavailable"
702 lappend ans { while executing}
703 lappend ans { "error {couldn't fork child process: resource temporarily unavailable}"}
704 lappend ans { (procedure "reportVersion" line 2)}
705 lappend ans { invoked from within}
706 lappend ans { "reportVersion"}
707 testouterr_cmd sh {-V} ERR [join $ans \n]
708 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_EXTERNALERRORRESSOURCEUNAVAIL
709
710 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEFROMEVALID 1
711 set ans [list]
712 lappend ans 0
713 lappend ans $vers_reportre
714 testouterr_cmd_re sh -V OK [join $ans \n]
715 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEFROMEVALID
716
717 setenv_var TESTSUITE_ENABLE_SITECONFIG_CHANGECONTEXTOFMODULEEVAL 1
718 set ans [list]
719 lappend ans 0
720 lappend ans $vers_reportre
721 testouterr_cmd_re sh -V OK [join $ans \n]
722
723 setenv_var TESTSUITE_ENABLE_SITECONFIG_CHANGECONTEXTOFMODULEEVAL 2
724 set ans [list]
725 lappend ans 0
726 lappend ans $vers_reportre
727 testouterr_cmd_re sh -V OK [join $ans \n]
728 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_CHANGECONTEXTOFMODULEEVAL
729
730 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETLOADEDPREREQPATH 1
731 set ans [list]
732 lappend ans 0
733 lappend ans $vers_reportre
734 testouterr_cmd_re sh -V OK [join $ans \n]
735 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETLOADEDPREREQPATH
736
737 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEFILEFROMLOADINGMODULE 1
738 set ans [list]
739 lappend ans 0
740 lappend ans $vers_reportre
741 testouterr_cmd_re sh -V OK [join $ans \n]
742 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETMODULEFILEFROMLOADINGMODULE
743
744 setenv_var TESTSUITE_ENABLE_SITECONFIG_UNKNOWNSTATE 1
745 set ans [list]
746 lappend ans 0
747 lappend ans $vers_reportre
748 testouterr_cmd_re sh -V OK [join $ans \n]
749 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_UNKNOWNSTATE
750
751 setenv_var TESTSUITE_ENABLE_SITECONFIG_RELEASESTATE 1
752 set ans [list]
753 lappend ans $install_release
754 lappend ans $vers_reportre
755 testouterr_cmd_re sh -V OK [join $ans \n]
756 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_RELEASESTATE
757
758 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETHELPLINES 1
759 set ans [list]
760 lappend ans 0
761 lappend ans $vers_reportre
762 testouterr_cmd_re sh -V OK [join $ans \n]
763 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETHELPLINES
764
765 setenv_var TESTSUITE_ENABLE_SITECONFIG_GETCMPSPECFROMVERSSPEC 1
766 set ans [list]
767 lappend ans eq
768 lappend ans $vers_reportre
769 testouterr_cmd_re sh -V OK [join $ans \n]
770 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETCMPSPECFROMVERSSPEC
771
772 } elseif {$verbose} {
773 send_user "\tSkip tests relying on an excepted siteconfig file installed\n"
774 }
775
776 # test siteconfig override using MODULES_SITECONFIG
777 # when set to an unexistent file
778 test_getSiteConfig /path/to/unexistent/file 0 [is_config_locked extra_siteconfig]
779 test_getSiteConfig {} 0 [is_config_locked extra_siteconfig]
780 # when set to a valid Tcl script (depends if extra siteconfig is allowed)
781 test_getSiteConfig $env(TESTSUITEDIR)/example/siteconfig.tcl-2 1 [is_config_locked extra_siteconfig]
782 test_getSiteConfig testsuite/example/siteconfig.tcl-2 1 [is_config_locked extra_siteconfig]
783
784
785 #
786 # Clean up variables used in this test case
787 #
788
789 reset_test_env
790
791 # remove test procedure
792 rename test_getSiteConfig {}