| 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: 2017/05/06 |
| 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 basic set of module commands on all shells |
| 18 |
# }C% |
| 19 |
# |
| 20 |
############################################################################## |
| 21 |
|
| 22 |
|
| 23 |
set bad_cmd "$error_msgs: Invalid command 'foo'" |
| 24 |
set bad_cmd_re "(envmodule: )?$bad_cmd" |
| 25 |
|
| 26 |
# |
| 27 |
# The tests |
| 28 |
# |
| 29 |
|
| 30 |
if {$verbose} { |
| 31 |
send_user "\tChecking basic set of module commands\n" |
| 32 |
} |
| 33 |
|
| 34 |
foreach shell $shell_list { |
| 35 |
testall_cmd_re "$shell" "module --version" {} "Modules Release \\S+ (\\S+)" 0 |
| 36 |
testall_cmd "$shell" "module foo" "" "$bad_cmd\n$type_help" 1 |
| 37 |
testall_cmd "$shell" "module use $share_modpath\; module purge\; module load null\; module list -t" "" "$cur_loaded\nnull" 0 |
| 38 |
testall_cmd "$shell" "module use $share_modpath\; module purge\; module load null\; module unload null\; module list -t" "" "$no_loaded" 0 |
| 39 |
testall_cmd "$shell" "module is-loaded unk" "" "" 1 |
| 40 |
testall_cmd "$shell" "module use $share_modpath\; module load null\; module is-loaded null" "" "" 0 |
| 41 |
testall_cmd "$shell" "module info-loaded unk" "" "" 0 |
| 42 |
testall_cmd "$shell" "module use $share_modpath\; module load null\; module info-loaded null" "null" "" 0 |
| 43 |
} |
| 44 |
|
| 45 |
# ensure tools used in complex shell alias definition are available |
| 46 |
if {[find_bin grep] ne "" && [find_bin tr] ne "" && [find_bin awk] ne ""} { |
| 47 |
foreach shell $shell_list { |
| 48 |
if {$shell eq {csh} || $shell eq {tcsh}} { |
| 49 |
# alias evaluation leads to a syntax error if wa_277 is enabled |
| 50 |
testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite; ts2; ts3" [expr {$install_wa277 eq {y} ? {} : "Release\nhttp://an.example.web\\?¶m=one\nselect\\\[type==BAR && osrel==FOO\\\] myapp"}] ".*" [expr {$install_wa277 eq {y} ? 1 : 0}] |
| 51 |
} else { |
| 52 |
testall_cmd_re "$shell" "module load $testsuite_modpath/alias/3.0\; testsuite; ts2; ts3" "Release\nhttp://an.example.web\\?¶m=one\nselect\\\[type==BAR && osrel==FOO\\\] myapp" ".*" 0 |
| 53 |
} |
| 54 |
} |
| 55 |
} elseif {$verbose} { |
| 56 |
send_user "\tSkipping shell alias definition tests\n" |
| 57 |
} |
| 58 |
|
| 59 |
foreach shell $othlang_list { |
| 60 |
testall_cmd_re "$shell" "--version" {} "Modules Release \\S+ (\\S+)" 0 |
| 61 |
testall_cmd_re "$shell" "foo" {} "$bad_cmd_re\n$type_help.*" 1 |
| 62 |
testall_cmd "$shell" "use,$share_modpath:purge:load,null:list,-t" "" "$cur_loaded\nnull" 0 |
| 63 |
testall_cmd "$shell" "use,$share_modpath:purge:load,null:unload,null:list,-t" "" "$no_loaded" 0 |
| 64 |
switch -- $shell { |
| 65 |
cmake - r { |
| 66 |
testall_cmd_re "$shell" "is-loaded,unk" "" ".*" 1 |
| 67 |
} |
| 68 |
default { |
| 69 |
testall_cmd_re "$shell" "is-loaded,unk" "" "" 1 |
| 70 |
} |
| 71 |
} |
| 72 |
testall_cmd "$shell" "use,$share_modpath:load,null:is-loaded,null" "" "" 0 |
| 73 |
switch -- $shell { |
| 74 |
r { |
| 75 |
testall_cmd "$shell" "info-loaded,unk" "\[1\] \"\"" {} 0 |
| 76 |
} |
| 77 |
python - ruby { |
| 78 |
testall_cmd "$shell" "info-loaded,unk" "\n" "" 0 |
| 79 |
} |
| 80 |
default { |
| 81 |
testall_cmd "$shell" "info-loaded,unk" "" "" 0 |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
switch -- $shell { |
| 86 |
{cmake} { |
| 87 |
set anstxt "-- null" |
| 88 |
} |
| 89 |
{r} { |
| 90 |
set anstxt "\[1\] \"null\"" |
| 91 |
} |
| 92 |
default { |
| 93 |
set anstxt "null" |
| 94 |
} |
| 95 |
} |
| 96 |
testall_cmd "$shell" "use,$share_modpath:load,null:info-loaded,null" $anstxt "" 0 |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
# test unload of previously loaded modulefile |
| 101 |
if {$verbose} { |
| 102 |
send_user "\tSetup LOADEDMODULES = 'null'\n" |
| 103 |
send_user "\tSetup _LMFILES_ = '$share_modpath/null'\n" |
| 104 |
} |
| 105 |
set env(LOADEDMODULES) "null" |
| 106 |
set env(_LMFILES_) "$share_modpath/null" |
| 107 |
|
| 108 |
foreach shell $shell_list { |
| 109 |
testall_cmd "$shell" "module use $share_modpath\; module unload null\; module list -t" "" "$no_loaded" 0 |
| 110 |
} |
| 111 |
|
| 112 |
foreach shell $othlang_list { |
| 113 |
testall_cmd "$shell" "use,$share_modpath:unload,null:list,-t" "" "$no_loaded" 0 |
| 114 |
} |
| 115 |
|
| 116 |
# ensure advanced_version_spec is efficient on all shells |
| 117 |
set loadunloadout "Loading advvers6/1.3\n Loading requirement: advvers7/1.0\nUnloading advvers7/1.0 <aL>\n Unloading dependent: advvers6/1.3" |
| 118 |
if {![is_config_locked implicit_default]} { |
| 119 |
foreach shell $shell_list { |
| 120 |
testall_cmd $shell "module use $testsuite_modpath.2\; module config implicit_default 1\; module config verbosity normal\; module config advanced_version_spec 1\; module load --auto [email protected]\; module unload --auto [email protected]" {} $loadunloadout 0 |
| 121 |
} |
| 122 |
foreach shell $othlang_list { |
| 123 |
testall_cmd $shell "use,$testsuite_modpath.2:config,implicit_default,1:config,verbosity,normal:config,advanced_version_spec,1:load,--auto,[email protected]:unload,--auto,[email protected]" {} $loadunloadout 0 |
| 124 |
} |
| 125 |
} elseif {$verbose} { |
| 126 |
send_user "\tSkipping advanced_version_spec tests as implicit_default config is locked\n" |
| 127 |
} |
| 128 |
|
| 129 |
# test modulepath and module names containing space |
| 130 |
if {!$is_symlink_supported} { |
| 131 |
send_user "\tskipping tests over '$testsuite_modpath wspace' modulepath as symbolic links are not supported on filesystem\n" |
| 132 |
} else { |
| 133 |
|
| 134 |
set loadunloadout "Loading 'space yc/4'\nUnloading 'space yc/4'" |
| 135 |
foreach shell $shell_list { |
| 136 |
testall_cmd $shell "module use \"$testsuite_modpath wspace\"\; module load -v \"space yc/4\"\; module unload -v \"space yc/4\"" {} $loadunloadout 0 |
| 137 |
} |
| 138 |
foreach shell $othlang_list { |
| 139 |
testall_cmd $shell "use,$testsuite_modpath wspace:load,-v,space yc/4:unload,-v,space yc/4" {} $loadunloadout 0 |
| 140 |
} |
| 141 |
|
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
# test complete command |
| 146 |
setenv_var TESTSUITE_COMPLETE comp3 |
| 147 |
foreach shell $shell_list { |
| 148 |
if {$shell in {bash tcsh fish}} { |
| 149 |
testall_cmd $shell "module use \"$testsuite_modpath.3\"\; module load complete/1.0\; cmd" cmd {} 0 |
| 150 |
testall_cmd $shell "module use \"$testsuite_modpath.3\"\; module load complete/1.0 complete/1.1\; cmd" cmd {} 0 |
| 151 |
} |
| 152 |
} |
| 153 |
unsetenv_var TESTSUITE_COMPLETE |
| 154 |
|
| 155 |
|
| 156 |
# test noglob eval on sh-kind shells |
| 157 |
foreach shell $shell_list { |
| 158 |
if {$shell in {sh bash ksh zsh}} { |
| 159 |
set tsout {foo} |
| 160 |
if {$shell eq {sh} && $sh_strict} { |
| 161 |
set tserr {.*eval: \[\[: not found.*} |
| 162 |
} else { |
| 163 |
set tserr {} |
| 164 |
} |
| 165 |
testouterr_cmd_re $shell "module use \"$testsuite_modpath.3\"\; module load noglobeval/1.0\; foo" $tsout $tserr |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
# test unset undefined elements on shells |
| 171 |
foreach shell $shell_list { |
| 172 |
foreach elt {variable alias function complete} { |
| 173 |
setenv_var TESTSUITE_UNSET $elt |
| 174 |
testall_cmd $shell "module use \"$testsuite_modpath.4\"\; module load unset/1.0" {} {} 0 |
| 175 |
} |
| 176 |
} |
| 177 |
unsetenv_var TESTSUITE_UNSET |
| 178 |
|
| 179 |
|
| 180 |
# test special characters in environment variable |
| 181 |
foreach shell $shell_list { |
| 182 |
if {$shell in {csh tcsh}} { |
| 183 |
if {$install_wa277 eq {y}} { |
| 184 |
set tsout "abc : \\|<>!#$^&'\"()@x%y\\z:sh* -" |
| 185 |
} else { |
| 186 |
set tsout "abc : {}|<>!#$^&'\"()@x%y\\z:sh* -" |
| 187 |
} |
| 188 |
} else { |
| 189 |
set tsout "abc : {}|<>!#$^&'\"()@x%y\\z:sh*\n -" |
| 190 |
} |
| 191 |
testouterr_cmd $shell "module use \"$testsuite_modpath\"\; module load eschars/1.0\; echo \"\$pathelogical -\"" $tsout {} |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
# |
| 196 |
# Clean up variables used in this test case |
| 197 |
# |
| 198 |
|
| 199 |
reset_test_env |
| 200 |
|
| 201 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |