| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.50-cmds/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2017/06/19 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: load, unload, switch, help, display, test, whatis |
| 14 |
# Modulefiles: spread, spreadrc |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Tests how modulefile and modulerc interpreter let spread |
| 19 |
# variable and procedure definitions from one interpretation |
| 20 |
# to another. |
| 21 |
# }C% |
| 22 |
# |
| 23 |
############################################################################## |
| 24 |
|
| 25 |
skip_if_quick_mode |
| 26 |
|
| 27 |
# ensure avail tests are made using in depth mode |
| 28 |
setenv_var MODULES_AVAIL_INDEPTH 1 |
| 29 |
|
| 30 |
# ensure auto symbolic versions are not set for these tests |
| 31 |
setenv_var MODULES_ADVANCED_VERSION_SPEC 0 |
| 32 |
|
| 33 |
set mod "spread" |
| 34 |
set mod1 "$mod/1.0" |
| 35 |
set mod2 "$mod/2.0" |
| 36 |
set modfile1 "$modpath/$mod1" |
| 37 |
set modfilere1 "$modpathre/$mod1" |
| 38 |
set modfile2 "$modpath/$mod2" |
| 39 |
set modfilere2 "$modpathre/$mod2" |
| 40 |
|
| 41 |
# mod1 and mod2 are designed to output any incorrect behavior detected |
| 42 |
# so when nothing is displayed it means test went as expected |
| 43 |
set spreadres "" |
| 44 |
|
| 45 |
set mod1disph "$modlin\n$modfilere1:\n" |
| 46 |
set mod2disph "$modlin\n$modfilere2:\n" |
| 47 |
set mod1dispres "$mod" |
| 48 |
|
| 49 |
set mod1helph "$modlin\nModule Specific Help for $modfilere1:\n" |
| 50 |
set mod2helph "$modlin\nModule Specific Help for $modfilere2:\n" |
| 51 |
set mod1helpres "$mod" |
| 52 |
set mod2helpres "$warn_msgs: Unable to find ModulesHelp in $modfilere2." |
| 53 |
|
| 54 |
set mod1testh "$modlin\nModule Specific Test for $modfilere1:\n" |
| 55 |
set mod2testh "$modlin\nModule Specific Test for $modfilere2:\n" |
| 56 |
set mod1testres "$mod\nTest result: PASS" |
| 57 |
set mod2testres "$warn_msgs: Unable to find ModulesTest in $modfilere2." |
| 58 |
|
| 59 |
# |
| 60 |
# For sh shell only (no need to check every shells) |
| 61 |
# |
| 62 |
|
| 63 |
lappend ans [list set _LMFILES_ "$modfile1:$modfile2"] |
| 64 |
lappend ans [list set LOADEDMODULES "$mod1:$mod2"] |
| 65 |
|
| 66 |
|
| 67 |
# |
| 68 |
# The tests |
| 69 |
# |
| 70 |
|
| 71 |
testouterr_cmd_re "sh" "load $mod1 $mod2" $ans "$spreadres" |
| 72 |
testouterr_cmd_re "sh" "display $mod1 $mod2" "OK" "$mod1disph\n$mod1dispres\n$mod2disph\n$spreadres$modlin" |
| 73 |
testouterr_cmd_re "sh" "help $mod1 $mod2" "OK" "$mod1helph\n$mod1helpres\n$mod2helph\n$spreadres$mod2helpres\n$modlin" |
| 74 |
testouterr_cmd_re "sh" "test $mod1 $mod2" "OK" "$mod1testh\n$mod1testres\n$mod2testh\n$spreadres$mod2testres\n$modlin" |
| 75 |
testouterr_cmd_re "sh" "whatis $mod" "OK" "$spreadres" |
| 76 |
testouterr_cmd_re "sh" "avail -t $mod/" "OK" "$modpathre:\n$mod1\n$mod2\n$mod/3.0\n$mod/4.0\n$mod/5.0\n$mod/6.0\n$mod/7.0\n$mod/8.0" |
| 77 |
|
| 78 |
# tests looping on same modulefile |
| 79 |
testouterr_cmd_re "sh" "display $mod1 $mod1" "OK" "$mod1disph\n$mod1dispres\n$mod1disph\n$spreadres$mod1dispres\n$modlin" |
| 80 |
testouterr_cmd_re "sh" "help $mod1 $mod1" "OK" "$mod1helph\n$mod1helpres\n$mod1helph\n$spreadres$mod1helpres\n$modlin" |
| 81 |
testouterr_cmd_re "sh" "test $mod1 $mod1" "OK" "$mod1testh\n$mod1testres\n$mod1testh\n$spreadres$mod1testres\n$modlin" |
| 82 |
|
| 83 |
# Set up the environment for test that require mod1 to be loaded |
| 84 |
setenv_loaded_module $mod1 $modfile1 |
| 85 |
|
| 86 |
# test switching |
| 87 |
set ans [list] |
| 88 |
lappend ans [list set _LMFILES_ $modfile2] |
| 89 |
lappend ans [list set LOADEDMODULES $mod2] |
| 90 |
testouterr_cmd_re "sh" "switch $mod1 $mod2" $ans "$spreadres" |
| 91 |
|
| 92 |
# Set up the environment for test that require mod1 and mod2 to be loaded |
| 93 |
setenv_loaded_module [list $mod1 $mod2] [list $modfile1 $modfile2] |
| 94 |
|
| 95 |
testouterr_cmd "sh" "list -t" "OK" "$cur_loaded\n$mod1\n$mod2" |
| 96 |
# test unloading |
| 97 |
set ans [list] |
| 98 |
lappend ans [list unset _LMFILES_] |
| 99 |
lappend ans [list unset LOADEDMODULES] |
| 100 |
|
| 101 |
testouterr_cmd_re "sh" "unload $mod1 $mod2" $ans "$spreadres" |
| 102 |
|
| 103 |
# Clean up the environment |
| 104 |
unsetenv_loaded_module |
| 105 |
|
| 106 |
|
| 107 |
# |
| 108 |
# Test spreading with modulerc and modulefile |
| 109 |
# |
| 110 |
|
| 111 |
set mod "spreadrc" |
| 112 |
set mod1 "$mod/dir1/1.0" |
| 113 |
set mod2 "$mod/dir2/1.0" |
| 114 |
set modfile1 "$modpath/$mod1" |
| 115 |
set modfilere1 "$modpathre/$mod1" |
| 116 |
set modfile2 "$modpath/$mod2" |
| 117 |
set modfilere2 "$modpathre/$mod2" |
| 118 |
|
| 119 |
# mod1 and mod2 are designed to output any incorrect behavior detected |
| 120 |
# so when nothing is displayed it means test went as expected |
| 121 |
set spreadres "" |
| 122 |
|
| 123 |
set mod1disph "$modlin\n$modfilere1:\n" |
| 124 |
set mod2disph "$modlin\n$modfilere2:\n" |
| 125 |
set mod1dispres "spreadmod" |
| 126 |
|
| 127 |
set mod1helph "$modlin\nModule Specific Help for $modfilere1:\n" |
| 128 |
set mod2helph "$modlin\nModule Specific Help for $modfilere2:\n" |
| 129 |
set mod1helpres "spreadmod" |
| 130 |
set mod2helpres "$warn_msgs: Unable to find ModulesHelp in $modfilere2." |
| 131 |
|
| 132 |
set mod1testh "$modlin\nModule Specific Test for $modfilere1:\n" |
| 133 |
set mod2testh "$modlin\nModule Specific Test for $modfilere2:\n" |
| 134 |
set mod1testres "spreadmod\nTest result: PASS" |
| 135 |
set mod2testres "$warn_msgs: Unable to find ModulesTest in $modfilere2." |
| 136 |
|
| 137 |
# |
| 138 |
# For sh shell only (no need to check every shells) |
| 139 |
# |
| 140 |
|
| 141 |
set ans [list] |
| 142 |
lappend ans [list set _LMFILES_ "$modfile1:$modfile2"] |
| 143 |
lappend ans [list set LOADEDMODULES "$mod1:$mod2"] |
| 144 |
|
| 145 |
|
| 146 |
# |
| 147 |
# The tests |
| 148 |
# |
| 149 |
|
| 150 |
testouterr_cmd_re "sh" "load $mod1 $mod2" $ans "$spreadres" |
| 151 |
testouterr_cmd_re "sh" "display $mod1 $mod2" "OK" "$mod1disph\n$mod1dispres\n$mod2disph\n$spreadres$modlin" |
| 152 |
testouterr_cmd_re "sh" "help $mod1 $mod2" "OK" "$mod1helph\n$mod1helpres\n$mod2helph\n$spreadres$mod2helpres\n$modlin" |
| 153 |
testouterr_cmd_re "sh" "test $mod1 $mod2" "OK" "$mod1testh\n$mod1testres\n$mod2testh\n$spreadres$mod2testres\n$modlin" |
| 154 |
testouterr_cmd_re "sh" "whatis $mod" "OK" "$spreadres" |
| 155 |
testouterr_cmd_re "sh" "avail -t $mod/" "OK" "$modpathre:\n$mod1\n$mod2\n$mod/dir3/1.0\n$mod/dir4/1.0\n$mod/dir5/1.0\n$mod/dir6/1.0\n$mod/dir7/1.0\n$mod/dir8/1.0" |
| 156 |
|
| 157 |
# tests looping on same modulefile |
| 158 |
testouterr_cmd_re "sh" "display $mod1 $mod1" "OK" "$mod1disph\n$mod1dispres\n$mod1disph\n$spreadres$mod1dispres\n$modlin" |
| 159 |
testouterr_cmd_re "sh" "help $mod1 $mod1" "OK" "$mod1helph\n$mod1helpres\n$mod1helph\n$spreadres$mod1helpres\n$modlin" |
| 160 |
testouterr_cmd_re "sh" "test $mod1 $mod1" "OK" "$mod1testh\n$mod1testres\n$mod1testh\n$spreadres$mod1testres\n$modlin" |
| 161 |
|
| 162 |
# Set up the environment for test that require mod1 to be loaded |
| 163 |
setenv_loaded_module $mod1 $modfile1 |
| 164 |
|
| 165 |
# test switching |
| 166 |
set ans [list] |
| 167 |
lappend ans [list set _LMFILES_ $modfile2] |
| 168 |
lappend ans [list set LOADEDMODULES $mod2] |
| 169 |
testouterr_cmd_re "sh" "switch $mod1 $mod2" $ans "$spreadres" |
| 170 |
|
| 171 |
# Set up the environment for test that require mod1 and mod2 to be loaded |
| 172 |
setenv_loaded_module [list $mod1 $mod2] [list $modfile1 $modfile2] |
| 173 |
|
| 174 |
testouterr_cmd "sh" "list -t" "OK" "$cur_loaded\n$mod1\n$mod2" |
| 175 |
# test unloading |
| 176 |
set ans [list] |
| 177 |
lappend ans [list unset _LMFILES_] |
| 178 |
lappend ans [list unset LOADEDMODULES] |
| 179 |
testouterr_cmd_re "sh" "unload $mod1 $mod2" $ans "$spreadres" |
| 180 |
|
| 181 |
|
| 182 |
# |
| 183 |
# Cleanup |
| 184 |
# |
| 185 |
|
| 186 |
reset_test_env |