| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.30-cache/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2022/12/23 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: avail, whatis, load |
| 14 |
# Modulefiles: |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Test use of cachefiles with inconsistent definition of |
| 19 |
# files and directories and their limited access |
| 20 |
# }C% |
| 21 |
# |
| 22 |
############################################################################## |
| 23 |
|
| 24 |
skip_if_quick_mode |
| 25 |
|
| 26 |
# cannot test access if cannot change file permission |
| 27 |
if {!$is_file_perms_editable} { |
| 28 |
send_user "\tskipping access tests as file permissions cannot be changed\n" |
| 29 |
# cannot test access if superuser privileges are in use |
| 30 |
} elseif {$tcl_platform(user) eq "root"} { |
| 31 |
send_user "\tskipping access tests as tests are run by superuser\n" |
| 32 |
# cannot test access if restricted file permissions have no effect |
| 33 |
} elseif {$is_locked_dir_file_readable && $is_locked_file_readable} { |
| 34 |
send_user "\tskipping access tests as locked files or directories are still readable\n" |
| 35 |
} else { |
| 36 |
|
| 37 |
# ensure avail tests are made using in depth mode |
| 38 |
setenv_var MODULES_AVAIL_INDEPTH 1 |
| 39 |
|
| 40 |
# ensure avail tests have implicit default enabled |
| 41 |
setenv_var MODULES_IMPLICIT_DEFAULT 1 |
| 42 |
|
| 43 |
# ensure auto symbolic versions are set for these tests |
| 44 |
setenv_var MODULES_ADVANCED_VERSION_SPEC 1 |
| 45 |
|
| 46 |
# ensure regular avail search match is set for these tests |
| 47 |
setenv_var MODULES_SEARCH_MATCH starts_with |
| 48 |
|
| 49 |
# generate content in modulepaths |
| 50 |
lassign [create_diverse_module_setup $mp1] dir_list file_list |
| 51 |
lassign [extend_diverse_module_setup $mp1] other_dir_list other_file_list |
| 52 |
lappend dir_list {*}$other_dir_list |
| 53 |
array set file_arr [concat $file_list $other_file_list] |
| 54 |
|
| 55 |
setenv_var MODULEPATH $mp1 |
| 56 |
|
| 57 |
# create file cache for test, no limitation recorded at that point |
| 58 |
set tserr [msg_create $mp1cache] |
| 59 |
testouterr_cmd sh cachebuild OK $tserr |
| 60 |
|
| 61 |
|
| 62 |
set no_ar_perms ugo-r |
| 63 |
set no_ax_perms ugo-x |
| 64 |
set no_arx_perms ugo-rx |
| 65 |
set no_or_perms o-r |
| 66 |
set no_ox_perms o-x |
| 67 |
set no_orx_perms o-rx |
| 68 |
|
| 69 |
|
| 70 |
# limit access to some files and dirs for others |
| 71 |
change_file_perms $mp1/foo $no_or_perms |
| 72 |
change_file_perms $mp1/quux/oth $no_ox_perms |
| 73 |
change_file_perms $mp1/.modulerc $no_orx_perms |
| 74 |
change_file_perms $mp1/empty $no_orx_perms |
| 75 |
change_file_perms $mp1/anotherempty $no_or_perms |
| 76 |
change_file_perms $mp1/bar/.version $no_or_perms |
| 77 |
change_file_perms $mp1/quxa/.modulerc $no_orx_perms |
| 78 |
change_file_perms $mp1/baz/.1.10 $no_orx_perms |
| 79 |
change_file_perms $mp1/quxc/1.0 $no_orx_perms |
| 80 |
change_file_perms $mp1/quxc/1.0~ $no_orx_perms |
| 81 |
change_file_perms $mp1/.svn $no_orx_perms |
| 82 |
change_file_perms $mp1/.sos/ignmod $no_orx_perms |
| 83 |
|
| 84 |
set tserr {} |
| 85 |
foreach f [lsort [array names file_arr]] { |
| 86 |
switch -glob -- $f { |
| 87 |
*/.modulerc - */.version - foo/1.0 - foo/3.0 - quux/nok/5.0 -\ |
| 88 |
.git/ignmod - quux/SCCS/ignmod - {w s/1.0~} - foo/1.0,v -\ |
| 89 |
quxc/1.0~ - .svn/ignmod - .sos/ignmod - .modulerc -\ |
| 90 |
.version - empty/notamodule - empty/deep/notadeepmodule {} |
| 91 |
{* *} {lappend tserr '$f'} |
| 92 |
default {lappend tserr $f} |
| 93 |
} |
| 94 |
} |
| 95 |
set tserr_avail1 [join $tserr \n] |
| 96 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 97 |
set tserr_avail2 [join {foo/2.0 foo/4.0 foo/5.0 foo/6.0 foobar} \n] |
| 98 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 99 |
|
| 100 |
set tserr_whatis1 "$modlin [escre $mp1] $modlin |
| 101 |
\\s+bar/1.0: bar/1.0 |
| 102 |
\\s+bar/2.0: bar/2.0 |
| 103 |
\\s+baz/w s: baz/w s |
| 104 |
\\s+baz/w\"s: baz/w\"s |
| 105 |
\\s+baz/w#s: baz/w#s |
| 106 |
\\s+foo/2.0: foo/2.0 |
| 107 |
\\s+foobar: foobar |
| 108 |
\\s+quux/oth/3.0: quux/oth/3.0 |
| 109 |
\\s+quux/oth/4.0: quux/oth/4.0 |
| 110 |
\\s+quux/sub/1.0: quux/sub/1.0 |
| 111 |
\\s+quux/sub/2.0: quux/sub/2.0 |
| 112 |
\\s+quuxbar: quuxbar |
| 113 |
\\s+quxa/1.0: quxa/1.0 |
| 114 |
\\s+quxb/1.0: quxb/1.0 |
| 115 |
\\s+quxc/1.0: quxc/1.0 |
| 116 |
\\s+quxd/1.0: quxd/1.0 |
| 117 |
\\s+quxe/1.0: quxe/1.0 |
| 118 |
\\s+w s/1.0: w s/1.0 |
| 119 |
\\s+w\"s/1.0: w\"s/1.0 |
| 120 |
\\s+w#s/1.0: w#s/1.0" |
| 121 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 122 |
set tserr_whatis2 "$modlin [escre $mp1] $modlin |
| 123 |
\\s+baz/w s: baz/w s |
| 124 |
\\s+baz/w\"s: baz/w\"s |
| 125 |
\\s+baz/w#s: baz/w#s" |
| 126 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 127 |
|
| 128 |
set ans_load1 [list] |
| 129 |
lappend ans_load1 [list set __MODULES_LMALTNAME bar/1.0&bar/default&bar] |
| 130 |
lappend ans_load1 [list set _LMFILES_ $mp1/bar/1.0] |
| 131 |
lappend ans_load1 [list set LOADEDMODULES bar/1.0] |
| 132 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 133 |
|
| 134 |
set tserr_load2 "$err_magic'$mp1/foo/.modulerc'\n$err_contact |
| 135 |
$err_magic'$mp1/foo/1.0'\n$err_contact" |
| 136 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 137 |
|
| 138 |
set tserr_load3 "$err_magic'$mp1/foo/.modulerc'\n$err_contact |
| 139 |
[moderr_minverreq $mp1/foo/3.0 99]" |
| 140 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 141 |
|
| 142 |
set tserr_load4 "$err_magic'[escre $mp1]/foo/.modulerc'\n$err_contact |
| 143 |
|
| 144 |
[escre [msg_load foo/5.0 [msg_moderr {missing close-brace} if\ \{<EXM> $mp1/foo/5.0 2]]]" |
| 145 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 146 |
|
| 147 |
set ans_load5 [list] |
| 148 |
lappend ans_load5 [list set __MODULES_LMALTNAME .hid/1.0&as|.hid/default&as|.hid/latest] |
| 149 |
lappend ans_load5 [list set _LMFILES_ $mp1/.hid/1.0] |
| 150 |
lappend ans_load5 [list set LOADEDMODULES .hid/1.0] |
| 151 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 152 |
|
| 153 |
|
| 154 |
# test indepth/noindepth resolution |
| 155 |
set tserr_noindepth1 "$mp1: |
| 156 |
bar/ |
| 157 |
baz/ |
| 158 |
foo/ |
| 159 |
foobar |
| 160 |
quux/ |
| 161 |
quuxbar |
| 162 |
quxa/ |
| 163 |
quxb/ |
| 164 |
quxc/ |
| 165 |
quxd/ |
| 166 |
quxe/ |
| 167 |
'w s'/ |
| 168 |
w\"s/ |
| 169 |
w#s/" |
| 170 |
testouterr_cmd sh {avail -t --no-indepth} OK $tserr_noindepth1 |
| 171 |
set tserr_noindepth2 "$mp1: |
| 172 |
quux/ |
| 173 |
quuxbar" |
| 174 |
testouterr_cmd sh {avail -t --no-indepth quux} OK $tserr_noindepth2 |
| 175 |
set tserr_noindepth3 "$mp1: |
| 176 |
quux/oth/(default) |
| 177 |
quux/sub/" |
| 178 |
testouterr_cmd sh {avail -t --no-indepth quux/} OK $tserr_noindepth3 |
| 179 |
testouterr_cmd sh {avail -t --no-indepth quux/*} OK $tserr_noindepth3 |
| 180 |
set tserr_noindepth4 "$mp1: |
| 181 |
quux/oth/(default)" |
| 182 |
testouterr_cmd sh {avail -t --no-indepth quux/o} OK $tserr_noindepth4 |
| 183 |
set tserr_noindepth5 "" |
| 184 |
testouterr_cmd sh {avail -t --no-indepth quux/nok} OK $tserr_noindepth5 |
| 185 |
testouterr_cmd sh {avail -t --no-indepth quux/no} OK $tserr_noindepth5 |
| 186 |
|
| 187 |
|
| 188 |
# cache usage when mcookie_check is set to eval (same result as if option |
| 189 |
# is set to always) |
| 190 |
setenv_var MODULES_MCOOKIE_CHECK eval |
| 191 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 192 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 193 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 194 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 195 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 196 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 197 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 198 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 199 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 200 |
setenv_var MODULES_MCOOKIE_CHECK always |
| 201 |
|
| 202 |
# cache usage when mcookie_version_check is disabled (same result as if |
| 203 |
# option is enabled unless) |
| 204 |
setenv_var MODULES_MCOOKIE_VERSION_CHECK 0 |
| 205 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 206 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 207 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 208 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 209 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 210 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 211 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 212 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 213 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 214 |
setenv_var MODULES_MCOOKIE_VERSION_CHECK 1 |
| 215 |
|
| 216 |
|
| 217 |
# second limited set (for others) |
| 218 |
change_file_perms $mp1/quux $no_or_perms |
| 219 |
restore_file_perms $mp1/foo |
| 220 |
restore_file_perms $mp1/.modulerc |
| 221 |
restore_file_perms $mp1/bar/.version |
| 222 |
change_file_perms $mp1/.version $no_or_perms |
| 223 |
change_file_perms $mp1/foo/1.0 $no_or_perms |
| 224 |
change_file_perms $mp1/foo/.modulerc $no_orx_perms |
| 225 |
change_file_perms $mp1/othhid/.deep $no_orx_perms |
| 226 |
change_file_perms $mp1/othhid2 $no_orx_perms |
| 227 |
change_file_perms $mp1/.hid/1.0 $no_or_perms |
| 228 |
|
| 229 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 230 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 231 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 232 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 233 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 234 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 235 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 236 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 237 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 238 |
|
| 239 |
restore_file_perms $mp1/quux |
| 240 |
restore_file_perms $mp1/quux/oth |
| 241 |
restore_file_perms $mp1/empty |
| 242 |
restore_file_perms $mp1/anotherempty |
| 243 |
restore_file_perms $mp1/quxa/.modulerc |
| 244 |
restore_file_perms $mp1/baz/.1.10 |
| 245 |
restore_file_perms $mp1/quxc/1.0 |
| 246 |
restore_file_perms $mp1/quxc/1.0~ |
| 247 |
restore_file_perms $mp1/.svn |
| 248 |
restore_file_perms $mp1/.sos/ignmod |
| 249 |
restore_file_perms $mp1/.version |
| 250 |
restore_file_perms $mp1/foo/1.0 |
| 251 |
restore_file_perms $mp1/foo/.modulerc |
| 252 |
restore_file_perms $mp1/othhid/.deep |
| 253 |
restore_file_perms $mp1/othhid2 |
| 254 |
restore_file_perms $mp1/.hid/1.0 |
| 255 |
|
| 256 |
|
| 257 |
# limit access to some files and dirs for all |
| 258 |
change_file_perms $mp1/foo $no_ar_perms |
| 259 |
change_file_perms $mp1/quux/oth $no_ax_perms |
| 260 |
change_file_perms $mp1/.modulerc $no_arx_perms |
| 261 |
change_file_perms $mp1/empty $no_orx_perms |
| 262 |
change_file_perms $mp1/anotherempty $no_ar_perms |
| 263 |
change_file_perms $mp1/bar/.version $no_ar_perms |
| 264 |
change_file_perms $mp1/quxa/.modulerc $no_arx_perms |
| 265 |
change_file_perms $mp1/baz/.1.10 $no_arx_perms |
| 266 |
change_file_perms $mp1/quxc/1.0 $no_arx_perms |
| 267 |
change_file_perms $mp1/quxc/1.0~ $no_arx_perms |
| 268 |
change_file_perms $mp1/.svn $no_arx_perms |
| 269 |
change_file_perms $mp1/.sos/ignmod $no_arx_perms |
| 270 |
|
| 271 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 272 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 273 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 274 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 275 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 276 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 277 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 278 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 279 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 280 |
|
| 281 |
|
| 282 |
# test indepth/noindepth resolution |
| 283 |
testouterr_cmd sh {avail -t --no-indepth} OK $tserr_noindepth1 |
| 284 |
testouterr_cmd sh {avail -t --no-indepth quux} OK $tserr_noindepth2 |
| 285 |
testouterr_cmd sh {avail -t --no-indepth quux/} OK $tserr_noindepth3 |
| 286 |
testouterr_cmd sh {avail -t --no-indepth quux/*} OK $tserr_noindepth3 |
| 287 |
testouterr_cmd sh {avail -t --no-indepth quux/o} OK $tserr_noindepth4 |
| 288 |
testouterr_cmd sh {avail -t --no-indepth quux/nok} OK $tserr_noindepth5 |
| 289 |
testouterr_cmd sh {avail -t --no-indepth quux/no} OK $tserr_noindepth5 |
| 290 |
|
| 291 |
|
| 292 |
# cache usage when mcookie_check is set to eval (same result as if option |
| 293 |
# is set to always) |
| 294 |
setenv_var MODULES_MCOOKIE_CHECK eval |
| 295 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 296 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 297 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 298 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 299 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 300 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 301 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 302 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 303 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 304 |
setenv_var MODULES_MCOOKIE_CHECK always |
| 305 |
|
| 306 |
# cache usage when mcookie_version_check is disabled (same result as if |
| 307 |
# option is enabled) |
| 308 |
setenv_var MODULES_MCOOKIE_VERSION_CHECK 0 |
| 309 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 310 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 311 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 312 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 313 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 314 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 315 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 316 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 317 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 318 |
setenv_var MODULES_MCOOKIE_VERSION_CHECK 1 |
| 319 |
|
| 320 |
|
| 321 |
# second limited set (for all) |
| 322 |
change_file_perms $mp1/quux $no_ar_perms |
| 323 |
restore_file_perms $mp1/foo |
| 324 |
restore_file_perms $mp1/.modulerc |
| 325 |
restore_file_perms $mp1/bar/.version |
| 326 |
change_file_perms $mp1/.version $no_ar_perms |
| 327 |
change_file_perms $mp1/foo/1.0 $no_ar_perms |
| 328 |
change_file_perms $mp1/foo/.modulerc $no_arx_perms |
| 329 |
change_file_perms $mp1/othhid/.deep $no_arx_perms |
| 330 |
change_file_perms $mp1/othhid2 $no_arx_perms |
| 331 |
change_file_perms $mp1/.hid/1.0 $no_ar_perms |
| 332 |
|
| 333 |
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1 |
| 334 |
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2 |
| 335 |
testouterr_cmd_re sh whatis OK $tserr_whatis1 |
| 336 |
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2 |
| 337 |
testouterr_cmd sh {load bar} $ans_load1 {} |
| 338 |
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2 |
| 339 |
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3 |
| 340 |
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4 |
| 341 |
testouterr_cmd sh {load .hid} $ans_load5 {} |
| 342 |
|
| 343 |
restore_file_perms $mp1/quux |
| 344 |
restore_file_perms $mp1/quux/oth |
| 345 |
restore_file_perms $mp1/empty |
| 346 |
restore_file_perms $mp1/anotherempty |
| 347 |
restore_file_perms $mp1/quxa/.modulerc |
| 348 |
restore_file_perms $mp1/baz/.1.10 |
| 349 |
restore_file_perms $mp1/quxc/1.0 |
| 350 |
restore_file_perms $mp1/quxc/1.0~ |
| 351 |
restore_file_perms $mp1/.svn |
| 352 |
restore_file_perms $mp1/.sos/ignmod |
| 353 |
restore_file_perms $mp1/.version |
| 354 |
restore_file_perms $mp1/foo/1.0 |
| 355 |
restore_file_perms $mp1/foo/.modulerc |
| 356 |
restore_file_perms $mp1/othhid/.deep |
| 357 |
restore_file_perms $mp1/othhid2 |
| 358 |
restore_file_perms $mp1/.hid/1.0 |
| 359 |
|
| 360 |
|
| 361 |
# |
| 362 |
# Cleanup |
| 363 |
# |
| 364 |
|
| 365 |
# delete generated cache file |
| 366 |
file delete $mp1cache |
| 367 |
|
| 368 |
# delete created files and dirs |
| 369 |
delete_module_setup $mp1 [array names file_arr] $dir_list |
| 370 |
|
| 371 |
reset_test_env |
| 372 |
|
| 373 |
} |