| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.20-locate/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2017/05/27 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: use, unuse, load, display, whatis, avail, aliases |
| 14 |
# Modulefiles: |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Modulepath handling when access rights to get to it does not |
| 19 |
# allow it |
| 20 |
# }C% |
| 21 |
# |
| 22 |
############################################################################## |
| 23 |
|
| 24 |
# cannot test access if cannot change file permission |
| 25 |
if {!$is_file_perms_editable} { |
| 26 |
send_user "\tskipping access tests as file permissions cannot be changed\n" |
| 27 |
# cannot test access if superuser privileges are in use |
| 28 |
} elseif {$tcl_platform(user) eq "root"} { |
| 29 |
send_user "\tskipping access tests as tests are run by superuser\n" |
| 30 |
} else { |
| 31 |
|
| 32 |
# |
| 33 |
# Variables for this test |
| 34 |
# |
| 35 |
|
| 36 |
set module "loc_rc6" |
| 37 |
|
| 38 |
set hide_perms "ugo-rx" |
| 39 |
|
| 40 |
# |
| 41 |
# Test enabling modulepath when access not granted to it |
| 42 |
# |
| 43 |
|
| 44 |
unsetenv_path_var MODULEPATH |
| 45 |
|
| 46 |
change_file_perms $modpath $hide_perms |
| 47 |
|
| 48 |
# normal enabling, as no directory access |
| 49 |
lappend ans [list set MODULEPATH $modpath] |
| 50 |
testouterr_cmd "sh" "use $modpath" $ans "" |
| 51 |
|
| 52 |
|
| 53 |
setenv_path_var MODULEPATH $modpath |
| 54 |
|
| 55 |
|
| 56 |
# |
| 57 |
# Test global access to the modulefiles of a modulepath when access not |
| 58 |
# granted on this modulepath |
| 59 |
# |
| 60 |
|
| 61 |
# no test if files or dirs in a locked directory are still readable on this system |
| 62 |
if {!$is_locked_dir_file_readable} { |
| 63 |
# nothing found |
| 64 |
testouterr_cmd "sh" "whatis" "OK" "" |
| 65 |
testouterr_cmd "sh" "avail" "OK" "" |
| 66 |
testouterr_cmd "sh" "aliases" "OK" "" |
| 67 |
} |
| 68 |
|
| 69 |
restore_file_perms $modpath |
| 70 |
skip_if_quick_mode |
| 71 |
change_file_perms $modpath $hide_perms |
| 72 |
|
| 73 |
# |
| 74 |
# Test access to modulefile when access not granted on modulepath |
| 75 |
# |
| 76 |
|
| 77 |
# different result if a file in a locked directory still readable on this system |
| 78 |
if {$is_locked_dir_file_readable} { |
| 79 |
setenv_var MODULES_ADVANCED_VERSION_SPEC 1 |
| 80 |
set lm "$module/1.2" |
| 81 |
set lmf "$modpath/$lm" |
| 82 |
set lmfre "$modpathre/$lm" |
| 83 |
set ans [list] |
| 84 |
lappend ans [list set __MODULES_LMALTNAME $lm&loc_rc6/default&loc_rc6&loc_rc6/new&al|loc_rc6/1&al|loc_rc6/bar&as|loc_rc6/latest] |
| 85 |
lappend ans [list set _LMFILES_ $lmf] |
| 86 |
lappend ans [list set LOADEDMODULES $lm] |
| 87 |
lappend ans [list set testsuite yes] |
| 88 |
|
| 89 |
testouterr_cmd "sh" "load $module" $ans "" |
| 90 |
testouterr_cmd_re "sh" "display $module" "OK" "$modlin\n$lmfre:\n\nmodule-whatis\t$lm\nsetenv\t\ttestsuite yes\n$modlin" |
| 91 |
testouterr_cmd_re "sh" "whatis $module" "OK" "$modlin $modpathre $modlin\n\\s+$module/0.9: $module/0.9\n\\s+$lm: $lm" |
| 92 |
|
| 93 |
unset lm |
| 94 |
unset lmf |
| 95 |
unset lmfre |
| 96 |
unsetenv_var MODULES_ADVANCED_VERSION_SPEC |
| 97 |
} else { |
| 98 |
# nothing found |
| 99 |
testouterr_cmd "sh" "load $module" "ERR" "$err_path'$module'" |
| 100 |
testouterr_cmd "sh" "display $module" "ERR" "$err_path'$module'" |
| 101 |
testouterr_cmd "sh" "whatis $module" "ERR" "$err_path'$module'" |
| 102 |
testouterr_cmd "sh" "avail -t $module" "OK" "" |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
# |
| 107 |
# Test disabling modulepath when access not granted to it |
| 108 |
# |
| 109 |
|
| 110 |
# normal disabling, as no directory access |
| 111 |
set ans [list] |
| 112 |
lappend ans [list unset MODULEPATH] |
| 113 |
testouterr_cmd "sh" "unuse $modpath" $ans "" |
| 114 |
|
| 115 |
restore_file_perms $modpath |
| 116 |
|
| 117 |
|
| 118 |
# |
| 119 |
# Cleanup |
| 120 |
# |
| 121 |
|
| 122 |
reset_test_env |
| 123 |
|
| 124 |
} |