| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.70-maint/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2017/11/26 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: is-loaded |
| 14 |
# Modulefiles: |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Test 'is-loaded' module command |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
set module "setenv/1.0" |
| 24 |
set modname "setenv" |
| 25 |
set modpart "setenv/1" |
| 26 |
set modulefile "$modpath/$module" |
| 27 |
set modulefile_reld "$reldmodpath/$module" |
| 28 |
set modulefile_reldd "$relddmodpath/$module" |
| 29 |
|
| 30 |
testouterr_cmd "ALL" "is-loaded $module" "ERR" "" |
| 31 |
|
| 32 |
skip_if_quick_mode |
| 33 |
|
| 34 |
testouterr_cmd "sh" "is-loaded" "ERR" "" |
| 35 |
testouterr_cmd "sh" "is-loaded $modname foo" "ERR" "" |
| 36 |
testouterr_cmd "sh" "is-loaded foo $modpart" "ERR" "" |
| 37 |
|
| 38 |
# test with full path module name |
| 39 |
testouterr_cmd "sh" "is-loaded $modulefile" "ERR" "" |
| 40 |
testouterr_cmd "sh" "is-loaded $modulefile_reld" "ERR" "" |
| 41 |
testouterr_cmd "sh" "is-loaded $modulefile_reldd" "ERR" "" |
| 42 |
|
| 43 |
|
| 44 |
# setup LOADEDMODULES/_LMFILES_ with an empty element |
| 45 |
setenv_loaded_module [list {} {}] [list {} {}] |
| 46 |
|
| 47 |
testouterr_cmd "sh" "is-loaded $module" "ERR" "" |
| 48 |
testouterr_cmd "sh" "is-loaded" "ERR" "" |
| 49 |
|
| 50 |
|
| 51 |
setenv_loaded_module $module $modulefile |
| 52 |
|
| 53 |
testouterr_cmd "ALL" "is-loaded $module" "OK" "" |
| 54 |
testouterr_cmd "sh" "is-loaded" "OK" "" |
| 55 |
testouterr_cmd "sh" "is-loaded $modname foo" "OK" "" |
| 56 |
testouterr_cmd "sh" "is-loaded foo $modpart" "ERR" "" |
| 57 |
|
| 58 |
# test with full path module name |
| 59 |
testouterr_cmd "sh" "is-loaded $modulefile" "OK" "" |
| 60 |
testouterr_cmd "sh" "is-loaded $modulefile_reld" "OK" "" |
| 61 |
testouterr_cmd "sh" "is-loaded $modulefile_reldd" "OK" "" |
| 62 |
|
| 63 |
|
| 64 |
# setup LOADEDMODULES/_LMFILES_ with an empty element |
| 65 |
setenv_loaded_module [list {} $module] [list {} $modulefile] |
| 66 |
|
| 67 |
testouterr_cmd "sh" "is-loaded" "OK" "" |
| 68 |
testouterr_cmd "sh" "is-loaded $modname foo" "OK" "" |
| 69 |
testouterr_cmd "sh" "is-loaded foo $modpart" "ERR" "" |
| 70 |
|
| 71 |
# restore LOADEDMODULES/_LMFILES_ |
| 72 |
setenv_loaded_module $module $modulefile |
| 73 |
|
| 74 |
|
| 75 |
# unset MODULEPATH |
| 76 |
unsetenv_path_var MODULEPATH |
| 77 |
|
| 78 |
testouterr_cmd "sh" "is-loaded $module" "OK" "" |
| 79 |
testouterr_cmd "sh" "is-loaded" "OK" "" |
| 80 |
testouterr_cmd "sh" "is-loaded $modname foo" "OK" "" |
| 81 |
testouterr_cmd "sh" "is-loaded foo $modpart" "ERR" "" |
| 82 |
|
| 83 |
# test with full path module name |
| 84 |
testouterr_cmd "sh" "is-loaded $modulefile" "OK" "" |
| 85 |
testouterr_cmd "sh" "is-loaded $modulefile_reld" "OK" "" |
| 86 |
testouterr_cmd "sh" "is-loaded $modulefile_reldd" "OK" "" |
| 87 |
|
| 88 |
|
| 89 |
# test with short path name whereas full path name loaded |
| 90 |
setenv_path_var MODULEPATH "$modpath.2" $modpath |
| 91 |
setenv_loaded_module $modulefile $modulefile |
| 92 |
|
| 93 |
testouterr_cmd "sh" "is-loaded $module" "OK" "" |
| 94 |
testouterr_cmd "sh" "is-loaded $modname" "OK" "" |
| 95 |
|
| 96 |
# same test without MODULEPATH set anymore |
| 97 |
unsetenv_path_var MODULEPATH |
| 98 |
|
| 99 |
testouterr_cmd "sh" "is-loaded $module" "ERR" "" |
| 100 |
testouterr_cmd "sh" "is-loaded $modname" "ERR" "" |
| 101 |
|
| 102 |
# test when loaded environment is inconsistent |
| 103 |
setenv_path_var MODULEPATH $modpath |
| 104 |
setenv_loaded_module [list foo bar] "/path/to/foo" |
| 105 |
|
| 106 |
# error raised only if correlation between LOADEDMODULES and _LMFILES_ is attempted |
| 107 |
# but correlation is attempted most of the time with alternative names match |
| 108 |
set tserr "$err_loinconsist\n LOADEDMODULES=foo bar\n _LMFILES_=/path/to/foo" |
| 109 |
testouterr_cmd "sh" "is-loaded foo" ERR $tserr |
| 110 |
testouterr_cmd "sh" "is-loaded /foo" ERR $tserr |
| 111 |
|
| 112 |
|
| 113 |
# |
| 114 |
# Cleanup |
| 115 |
# |
| 116 |
|
| 117 |
reset_test_env |