############################################################################## # 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\" (file \"$siteconfig_file\" line 2)"] 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\"\]\" (file \"$siteconfig_file\" line 2)"] 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\"\" (file \"$siteconfig_file\" line 2)"] 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 $extra"} lappend ans { (procedure "displayElementList" line 19)} lappend ans { invoked from within} lappend ans { "displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx 1 $display_list $len_list $max_len $via"} lappend ans { (procedure "reportModules" line 155)} lappend ans { invoked from within} lappend ans { "reportModules $args $dir mp $hstyle $show_mtime 0 $one_per_line $theader_cols hidden-loaded"} lappend ans { (procedure "cmdModuleAvail" line 43)} lappend ans { invoked from within} lappend ans { "$cmdprocname {*}$cmdopts {*}$parsed_args"} lappend ans { (procedure "module" line 190)} 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 setenv_var TESTSUITE_ENABLE_SITECONFIG_UNKNOWNSTATE 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_UNKNOWNSTATE setenv_var TESTSUITE_ENABLE_SITECONFIG_RELEASESTATE 1 set ans [list] lappend ans $install_release lappend ans $vers_reportre testouterr_cmd_re sh -V OK [join $ans \n] unsetenv_var TESTSUITE_ENABLE_SITECONFIG_RELEASESTATE setenv_var TESTSUITE_ENABLE_SITECONFIG_GETHELPLINES 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_GETHELPLINES setenv_var TESTSUITE_ENABLE_SITECONFIG_GETCMPSPECFROMVERSSPEC 1 set ans [list] lappend ans eq lappend ans $vers_reportre testouterr_cmd_re sh -V OK [join $ans \n] unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETCMPSPECFROMVERSSPEC } 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 {}