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