Debian Codegraph @

testsuite/modules.30-cache/043-cache-use-limited-access.exp

raw
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/17
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 files and directories
19 # declared as 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
58 set no_ar_perms ugo-r
59 set no_ax_perms ugo-x
60 set no_arx_perms ugo-rx
61 set no_or_perms o-r
62 set no_ox_perms o-x
63 set no_orx_perms o-rx
64
65
66 # limit access to some files and dirs for others
67 change_file_perms $mp1/foo $no_or_perms
68 change_file_perms $mp1/quux/oth $no_ox_perms
69 change_file_perms $mp1/.modulerc $no_orx_perms
70 change_file_perms $mp1/empty $no_orx_perms
71 change_file_perms $mp1/anotherempty $no_or_perms
72 change_file_perms $mp1/bar/.version $no_or_perms
73 change_file_perms $mp1/quxa/.modulerc $no_orx_perms
74 change_file_perms $mp1/baz/.1.10 $no_orx_perms
75 change_file_perms $mp1/quxc/1.0 $no_orx_perms
76 change_file_perms $mp1/quxc/1.0~ $no_orx_perms
77 change_file_perms $mp1/.svn $no_orx_perms
78 change_file_perms $mp1/.sos/ignmod $no_orx_perms
79
80 # create file cache for test
81 set tserr [msg_create $mp1cache]
82 testouterr_cmd sh cachebuild OK $tserr
83
84 set tserr {}
85 set tserr_long {}
86 set tserr_mcookie {}
87 set tserr_mcookie_vers {}
88 foreach f [lsort [array names file_arr]] {
89 switch -glob -- $f {
90 */.modulerc - */.version - quux/nok/5.0 - .modulerc - .version -\
91 .git/ignmod - quux/SCCS/ignmod - {w s/1.0~} - foo/1.0,v - quxc/1.0~ -\
92 .svn/ignmod - .sos/ignmod {}
93 foo/1.0 - empty/notamodule - empty/deep/notadeepmodule {
94 lappend tserr_mcookie $f
95 }
96 foo/3.0 {
97 lappend tserr_mcookie $f
98 lappend tserr_mcookie_vers $f
99 }
100 {* *} {
101 lappend tserr '$f'
102 lappend tserr_long "'$f'.*\[0-9:\/ \]*"
103 lappend tserr_mcookie '$f'
104 lappend tserr_mcookie_vers '$f'
105 }
106 default {
107 lappend tserr $f
108 lappend tserr_long "$f.*\[0-9:\/ \]*"
109 lappend tserr_mcookie $f
110 lappend tserr_mcookie_vers $f
111 }
112 }
113 }
114 set tserr_avail1 [join $tserr \n]
115 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
116 set tserr_avail1_long .*[join $tserr_long \n]
117 testouterr_cmd_re sh {avail -a -l} OK $tserr_avail1_long
118 set tserr_avail2 [join {foo/2.0 foo/4.0 foo/5.0 foo/6.0 foobar} \n]
119 testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2
120
121 set tserr_whatis1 "$modlin [escre $mp1] $modlin
122 \\s+bar/1.0: bar/1.0
123 \\s+bar/2.0: bar/2.0
124 \\s+baz/w s: baz/w s
125 \\s+baz/w\"s: baz/w\"s
126 \\s+baz/w#s: baz/w#s
127 \\s+foo/2.0: foo/2.0
128 \\s+foobar: foobar
129 \\s+quux/oth/3.0: quux/oth/3.0
130 \\s+quux/oth/4.0: quux/oth/4.0
131 \\s+quux/sub/1.0: quux/sub/1.0
132 \\s+quux/sub/2.0: quux/sub/2.0
133 \\s+quuxbar: quuxbar
134 \\s+quxa/1.0: quxa/1.0
135 \\s+quxb/1.0: quxb/1.0
136 \\s+quxc/1.0: quxc/1.0
137 \\s+quxd/1.0: quxd/1.0
138 \\s+quxe/1.0: quxe/1.0
139 \\s+w s/1.0: w s/1.0
140 \\s+w\"s/1.0: w\"s/1.0
141 \\s+w#s/1.0: w#s/1.0"
142 testouterr_cmd_re sh whatis OK $tserr_whatis1
143 set tserr_whatis2 "$modlin [escre $mp1] $modlin
144 \\s+baz/w s: baz/w s
145 \\s+baz/w\"s: baz/w\"s
146 \\s+baz/w#s: baz/w#s"
147 testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
148
149 set ans_load1 [list]
150 lappend ans_load1 [list set __MODULES_LMALTNAME bar/1.0&bar/default&bar]
151 lappend ans_load1 [list set _LMFILES_ $mp1/bar/1.0]
152 lappend ans_load1 [list set LOADEDMODULES bar/1.0]
153 testouterr_cmd sh {load bar} $ans_load1 {}
154
155 # load two module specifications of same root in a single command: module
156 # search of second specification walks down again the limited access
157 # elements from cache and finds the 'bar/.version' rc file already
158 # evaluated during the module search of first specification
159 set ans_load1b [list]
160 lappend ans_load1b [list set __MODULES_LMALTNAME\
161 bar/1.0&bar/default&bar:bar/2.0&as|bar/latest]
162 lappend ans_load1b [list set _LMFILES_ $mp1/bar/1.0:$mp1/bar/2.0]
163 lappend ans_load1b [list set LOADEDMODULES bar/1.0:bar/2.0]
164 testouterr_cmd sh {load bar bar/2.0} $ans_load1b {}
165
166 set tserr_load2 "$err_magic'$mp1/foo/.modulerc'\n$err_contact
167 $err_magic'$mp1/foo/1.0'\n$err_contact"
168 testouterr_cmd sh {load foo/1.0} ERR $tserr_load2
169
170 set tserr_load3 "$err_magic'$mp1/foo/.modulerc'\n$err_contact
171 [moderr_minverreq $mp1/foo/3.0 99]"
172 testouterr_cmd sh {load foo/3.0} ERR $tserr_load3
173
174 set tserr_load4 "$err_magic'[escre $mp1]/foo/.modulerc'\n$err_contact
175
176 [escre [msg_load foo/5.0 [msg_moderr {missing close-brace} if\ \{<EXM> $mp1/foo/5.0 2]]]"
177 testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4
178
179 set ans_load5 [list]
180 lappend ans_load5 [list set __MODULES_LMALTNAME .hid/1.0&as|.hid/default&as|.hid/latest]
181 lappend ans_load5 [list set _LMFILES_ $mp1/.hid/1.0]
182 lappend ans_load5 [list set LOADEDMODULES .hid/1.0]
183 testouterr_cmd sh {load .hid} $ans_load5 {}
184
185
186 # test indepth/noindepth resolution
187 set tserr "$mp1:
188 bar/
189 baz/
190 foo/
191 foobar
192 quux/
193 quuxbar
194 quxa/
195 quxb/
196 quxc/
197 quxd/
198 quxe/
199 'w s'/
200 w\"s/
201 w#s/"
202 testouterr_cmd sh {avail -t --no-indepth} OK $tserr
203 set tserr "$mp1:
204 quux/
205 quuxbar"
206 testouterr_cmd sh {avail -t --no-indepth quux} OK $tserr
207 set tserr "$mp1:
208 quux/oth/(default)
209 quux/sub/"
210 testouterr_cmd sh {avail -t --no-indepth quux/} OK $tserr
211 testouterr_cmd sh {avail -t --no-indepth quux/*} OK $tserr
212 set tserr "$mp1:
213 quux/oth/(default)"
214 testouterr_cmd sh {avail -t --no-indepth quux/o} OK $tserr
215 set tserr ""
216 testouterr_cmd sh {avail -t --no-indepth quux/nok} OK $tserr
217 testouterr_cmd sh {avail -t --no-indepth quux/no} OK $tserr
218
219
220 # cache usage when mcookie_check is set to eval (same result as if option
221 # is set to always unless for limited-acces elements that are lived checked)
222 setenv_var MODULES_MCOOKIE_CHECK eval
223 set tserr_avail1_mcookie [join $tserr_mcookie \n]
224 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1_mcookie
225 set tserr_avail2_mcookie [join {foo/1.0 foo/2.0 foo/3.0 foo/4.0 foo/5.0 foo/6.0 foobar} \n]
226 testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2_mcookie
227 testouterr_cmd_re sh whatis OK $tserr_whatis1
228 testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
229 testouterr_cmd sh {load bar} $ans_load1 {}
230 set tserr_load2_mcookie "$err_magic'$mp1/foo/.modulerc'\n$err_contact
231
232 [msg_load foo/1.0 $err_magicns'$mp1/foo/1.0'\n$err_contactns]"
233 testouterr_cmd sh {load foo/1.0} ERR $tserr_load2_mcookie
234 set tserr_load3_mcookie "$err_magic'$mp1/foo/.modulerc'\n$err_contact
235
236 [msg_load foo/3.0 [moderr_minverreqns $mp1/foo/3.0 99]]"
237 testouterr_cmd sh {load foo/3.0} ERR $tserr_load3_mcookie
238 testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4
239 testouterr_cmd sh {load .hid} $ans_load5 {}
240 setenv_var MODULES_MCOOKIE_CHECK always
241
242 # cache usage when mcookie_version_check is disabled (same result as if
243 # option is enabled unless for limited-access elements that are lived checked)
244 setenv_var MODULES_MCOOKIE_VERSION_CHECK 0
245 # quux/nok/5.0 is not part of the results as it was already recorded as invalid in cache
246 set tserr_avail1_mcookie_vers [join $tserr_mcookie_vers \n]
247 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1_mcookie_vers
248 set tserr_avail2_mcookie_vers [join {foo/2.0 foo/3.0 foo/4.0 foo/5.0 foo/6.0 foobar} \n]
249 testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2_mcookie_vers
250 set tserr_whatis1_mcookie_vers "$modlin [escre $mp1] $modlin
251 \\s+bar/1.0: bar/1.0
252 \\s+bar/2.0: bar/2.0
253 \\s+baz/w s: baz/w s
254 \\s+baz/w\"s: baz/w\"s
255 \\s+baz/w#s: baz/w#s
256 \\s+foo/2.0: foo/2.0
257 \\s+foo/3.0: foo
258 \\s+foobar: foobar
259 \\s+quux/oth/3.0: quux/oth/3.0
260 \\s+quux/oth/4.0: quux/oth/4.0
261 \\s+quux/sub/1.0: quux/sub/1.0
262 \\s+quux/sub/2.0: quux/sub/2.0
263 \\s+quuxbar: quuxbar
264 \\s+quxa/1.0: quxa/1.0
265 \\s+quxb/1.0: quxb/1.0
266 \\s+quxc/1.0: quxc/1.0
267 \\s+quxd/1.0: quxd/1.0
268 \\s+quxe/1.0: quxe/1.0
269 \\s+w s/1.0: w s/1.0
270 \\s+w\"s/1.0: w\"s/1.0
271 \\s+w#s/1.0: w#s/1.0"
272 testouterr_cmd_re sh whatis OK $tserr_whatis1_mcookie_vers
273 testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
274 testouterr_cmd sh {load bar} $ans_load1 {}
275 testouterr_cmd sh {load foo/1.0} ERR $tserr_load2
276 set ans_load3_mcookie_vers [list]
277 lappend ans_load3_mcookie_vers [list set __MODULES_LMALTNAME bar/1.0&bar/default&bar]
278 lappend ans_load3_mcookie_vers [list set __MODULES_LMPREREQ foo/3.0&bar]
279 lappend ans_load3_mcookie_vers [list set _LMFILES_ $mp1/bar/1.0:$mp1/foo/3.0]
280 lappend ans_load3_mcookie_vers [list set LOADEDMODULES bar/1.0:foo/3.0]
281 lappend ans_load3_mcookie_vers [list set __MODULES_LMTAG bar/1.0&auto-loaded]
282 lappend ans_load3_mcookie_vers [list ERR]
283 set tserr_load3_mcookie_vers "$err_magic'$mp1/foo/.modulerc'\n$err_contact
284
285 [msg_top_load foo/3.0 {} bar/1.0 {}]"
286 testouterr_cmd sh {load foo/3.0} $ans_load3_mcookie_vers $tserr_load3_mcookie_vers
287 testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4
288 testouterr_cmd sh {load .hid} $ans_load5 {}
289 setenv_var MODULES_MCOOKIE_VERSION_CHECK 1
290
291
292 # second limited set (for others)
293 change_file_perms $mp1/quux $no_or_perms
294 restore_file_perms $mp1/foo
295 restore_file_perms $mp1/.modulerc
296 restore_file_perms $mp1/bar/.version
297 change_file_perms $mp1/.version $no_or_perms
298 change_file_perms $mp1/foo/1.0 $no_or_perms
299 change_file_perms $mp1/foo/.modulerc $no_orx_perms
300 change_file_perms $mp1/othhid/.deep $no_orx_perms
301 change_file_perms $mp1/othhid2 $no_orx_perms
302 change_file_perms $mp1/.hid/1.0 $no_or_perms
303
304 # create file cache for test
305 set tserr [msg_create $mp1cache]
306 testouterr_cmd sh cachebuild OK $tserr
307
308 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
309 testouterr_cmd_re sh {avail -a -l} OK $tserr_avail1_long
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
319 restore_file_perms $mp1/quux
320 restore_file_perms $mp1/quux/oth
321 restore_file_perms $mp1/empty
322 restore_file_perms $mp1/anotherempty
323 restore_file_perms $mp1/quxa/.modulerc
324 restore_file_perms $mp1/baz/.1.10
325 restore_file_perms $mp1/quxc/1.0
326 restore_file_perms $mp1/quxc/1.0~
327 restore_file_perms $mp1/.svn
328 restore_file_perms $mp1/.sos/ignmod
329 restore_file_perms $mp1/.version
330 restore_file_perms $mp1/foo/1.0
331 restore_file_perms $mp1/foo/.modulerc
332 restore_file_perms $mp1/othhid/.deep
333 restore_file_perms $mp1/othhid2
334 restore_file_perms $mp1/.hid/1.0
335
336
337 # limit access to some files and dirs for all
338 change_file_perms $mp1/foo $no_ar_perms
339 change_file_perms $mp1/quux/oth $no_ax_perms
340 change_file_perms $mp1/.modulerc $no_arx_perms
341 change_file_perms $mp1/empty $no_orx_perms
342 change_file_perms $mp1/anotherempty $no_ar_perms
343 change_file_perms $mp1/bar/.version $no_ar_perms
344 change_file_perms $mp1/quxa/.modulerc $no_arx_perms
345 change_file_perms $mp1/baz/.1.10 $no_arx_perms
346 change_file_perms $mp1/quxc/1.0 $no_arx_perms
347 change_file_perms $mp1/quxc/1.0~ $no_arx_perms
348 change_file_perms $mp1/.svn $no_arx_perms
349 change_file_perms $mp1/.sos/ignmod $no_arx_perms
350
351 # create file cache for test
352 set tserr [msg_create $mp1cache]
353 testouterr_cmd sh cachebuild OK $tserr
354
355 set tserr {}
356 set tserr_long {}
357 set tserr_mcookie {}
358 foreach f [lsort [array names file_arr]] {
359 switch -glob -- $f {
360 */.modulerc - */.version - foo/1.0 - foo/3.0 - quux/nok/5.0 -\
361 .modulerc - .version - foo/* - .git/ignmod - quux/SCCS/ignmod -\
362 {w s/1.0~} - foo/1.0,v - quxc/1.0~ - .svn/ignmod - .sos/ignmod {}
363 empty/notamodule - empty/deep/notadeepmodule - quux/oth/* -\
364 baz/.1.10 - quxc/1.0 {
365 lappend tserr_mcookie $f
366 }
367 {* *} {
368 lappend tserr '$f'
369 lappend tserr_long "'$f'.*\[0-9:\/ \]*"
370 lappend tserr_mcookie '$f'
371 }
372 default {
373 lappend tserr $f
374 lappend tserr_long "$f.*\[0-9:\/ \]*"
375 lappend tserr_mcookie $f
376 }
377 }
378 }
379 set tserr_avail1 [join $tserr \n]
380 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
381 set tserr_avail1_long .*[join $tserr_long \n]
382 testouterr_cmd_re sh {avail -a -l} OK $tserr_avail1_long
383 set tserr_avail2 [join {foobar} \n]
384 testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2
385
386 set tserr_whatis1 "$modlin [escre $mp1] $modlin
387 \\s+bar/1.0: bar/1.0
388 \\s+bar/2.0: bar/2.0
389 \\s+baz/w s: baz/w s
390 \\s+baz/w\"s: baz/w\"s
391 \\s+baz/w#s: baz/w#s
392 \\s+foobar: foobar
393 \\s+quux/sub/1.0: quux/sub/1.0
394 \\s+quux/sub/2.0: quux/sub/2.0
395 \\s+quuxbar: quuxbar
396 \\s+quxa/1.0: quxa/1.0
397 \\s+quxb/1.0: quxb/1.0
398 \\s+quxd/1.0: quxd/1.0
399 \\s+quxe/1.0: quxe/1.0
400 \\s+w s/1.0: w s/1.0
401 \\s+w\"s/1.0: w\"s/1.0
402 \\s+w#s/1.0: w#s/1.0"
403 testouterr_cmd_re sh whatis OK $tserr_whatis1
404 set tserr_whatis2 "$modlin [escre $mp1] $modlin
405 \\s+baz/w s: baz/w s
406 \\s+baz/w\"s: baz/w\"s
407 \\s+baz/w#s: baz/w#s"
408 testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
409
410 set ans_load1_b [list]
411 lappend ans_load1_b [list set __MODULES_LMALTNAME bar/2.0&as|bar/default&as|bar/latest]
412 lappend ans_load1_b [list set _LMFILES_ $mp1/bar/2.0]
413 lappend ans_load1_b [list set LOADEDMODULES bar/2.0]
414 testouterr_cmd sh {load bar} $ans_load1_b {}
415
416 set tserr_load2_b "$err_path'foo/1.0'"
417 testouterr_cmd sh {load foo/1.0} ERR $tserr_load2_b
418
419 set tserr_load3_b "$err_path'foo/3.0'"
420 testouterr_cmd sh {load foo/3.0} ERR $tserr_load3_b
421
422 set tserr_load4_b "$err_path'foo/5.0'"
423 testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4_b
424
425 testouterr_cmd sh {load .hid} $ans_load5 {}
426
427
428 # test indepth/noindepth resolution
429 set tserr "$mp1:
430 bar/
431 baz/
432 foobar
433 quux/
434 quuxbar
435 quxa/
436 quxb/
437 quxd/
438 quxe/
439 'w s'/
440 w\"s/
441 w#s/"
442 testouterr_cmd sh {avail -t --no-indepth} OK $tserr
443 set tserr "$mp1:
444 quux/
445 quuxbar"
446 testouterr_cmd sh {avail -t --no-indepth quux} OK $tserr
447 set tserr "$mp1:
448 quux/sub/"
449 testouterr_cmd sh {avail -t --no-indepth quux/} OK $tserr
450 testouterr_cmd sh {avail -t --no-indepth quux/*} OK $tserr
451 set tserr ""
452 testouterr_cmd sh {avail -t --no-indepth quux/o} OK $tserr
453 testouterr_cmd sh {avail -t --no-indepth quux/nok} OK $tserr
454 testouterr_cmd sh {avail -t --no-indepth quux/no} OK $tserr
455
456
457 # cache usage when mcookie_check is set to eval (same result as if option
458 # is set to always unless for limited-acces elements that are lived resolved)
459 setenv_var MODULES_MCOOKIE_CHECK eval
460 set tserr_avail1_mcookie [join $tserr_mcookie \n]
461 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1_mcookie
462 testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2
463 testouterr_cmd_re sh whatis OK $tserr_whatis1
464 testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
465 testouterr_cmd sh {load bar} $ans_load1_b {}
466 testouterr_cmd sh {load foo/1.0} ERR $tserr_load2_b
467 testouterr_cmd sh {load foo/3.0} ERR $tserr_load3_b
468 testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4_b
469 testouterr_cmd sh {load .hid} $ans_load5 {}
470 setenv_var MODULES_MCOOKIE_CHECK always
471
472 # cache usage when mcookie_version_check is disabled (same result as if
473 # option is enabled unless for limited-access elements that are lived checked)
474 setenv_var MODULES_MCOOKIE_VERSION_CHECK 0
475 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
476 testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2
477 testouterr_cmd_re sh whatis OK $tserr_whatis1
478 testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
479 testouterr_cmd sh {load bar} $ans_load1_b {}
480 testouterr_cmd sh {load foo/1.0} ERR $tserr_load2_b
481 testouterr_cmd sh {load foo/3.0} ERR $tserr_load3_b
482 testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4_b
483 testouterr_cmd sh {load .hid} $ans_load5 {}
484 setenv_var MODULES_MCOOKIE_VERSION_CHECK 1
485
486
487 # second limited set (for all)
488 change_file_perms $mp1/quux $no_ar_perms
489 restore_file_perms $mp1/foo
490 restore_file_perms $mp1/.modulerc
491 restore_file_perms $mp1/bar/.version
492 change_file_perms $mp1/.version $no_ar_perms
493 change_file_perms $mp1/foo/1.0 $no_ar_perms
494 change_file_perms $mp1/foo/.modulerc $no_arx_perms
495 change_file_perms $mp1/othhid/.deep $no_arx_perms
496 change_file_perms $mp1/othhid2 $no_arx_perms
497 change_file_perms $mp1/.hid/1.0 $no_ar_perms
498
499 # create file cache for test
500 set tserr [msg_create $mp1cache]
501 testouterr_cmd sh cachebuild OK $tserr
502
503 set tserr {}
504 set tserr_long {}
505 foreach f [lsort [array names file_arr]] {
506 switch -glob -- $f {
507 */.modulerc - */.version - foo/1.0 - foo/3.0 - quux/nok/5.0 -\
508 empty/notamodule - empty/deep/notadeepmodule - .modulerc -\
509 .version - .git/ignmod - quux/SCCS/ignmod - {w s/1.0~} -\
510 foo/1.0,v - quxc/1.0~ - .svn/ignmod - .sos/ignmod {}
511 foo/1.0 - quux/* - baz/.1.10 - quxc/1.0 - othhid/.deep/* -\
512 othhid2/* - .hid/1.0 {}
513 {* *} {
514 lappend tserr '$f'
515 lappend tserr_long "'$f'.*\[0-9:\/ \]*"
516 }
517 default {
518 lappend tserr $f
519 lappend tserr_long "$f.*\[0-9:\/ \]*"
520 }
521 }
522 }
523 set tserr_avail1 [join $tserr \n]
524 testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
525 set tserr_avail1_long .*[join $tserr_long \n]
526 testouterr_cmd_re sh {avail -a -l} OK $tserr_avail1_long
527 set tserr_avail2 [join {foo/2.0 foo/4.0 foo/5.0 foo/6.0 foobar} \n]
528 testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2
529
530 set tserr_whatis1 "$modlin [escre $mp1] $modlin
531 \\s+bar/1.0: bar/1.0
532 \\s+bar/2.0: bar/2.0
533 \\s+baz/w s: baz/w s
534 \\s+baz/w\"s: baz/w\"s
535 \\s+baz/w#s: baz/w#s
536 \\s+foo/2.0: foo/2.0
537 \\s+foobar: foobar
538 \\s+quuxbar: quuxbar
539 \\s+quxa/1.0: quxa/1.0
540 \\s+quxb/1.0: quxb/1.0
541 \\s+quxd/1.0: quxd/1.0
542 \\s+quxe/1.0: quxe/1.0
543 \\s+w s/1.0: w s/1.0
544 \\s+w\"s/1.0: w\"s/1.0
545 \\s+w#s/1.0: w#s/1.0"
546 testouterr_cmd_re sh whatis OK $tserr_whatis1
547 set tserr_whatis2 "$modlin [escre $mp1] $modlin
548 \\s+baz/w s: baz/w s
549 \\s+baz/w\"s: baz/w\"s
550 \\s+baz/w#s: baz/w#s"
551 testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
552
553 testouterr_cmd sh {load bar} $ans_load1 {}
554
555 set tserr_load2_c [err_permdenied $mp1/foo/1.0]
556 testouterr_cmd sh {load foo/1.0} ERR $tserr_load2_c
557
558 set tserr_load3_c "[moderr_minverreq $mp1/foo/3.0 99]"
559 testouterr_cmd sh {load foo/3.0} ERR $tserr_load3_c
560
561 set tserr_load4_c "[escre [msg_load foo/5.0 [msg_moderr {missing close-brace} if\ \{<EXM> $mp1/foo/5.0 2]]]"
562 testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4_c
563
564 set tserr_load5_c $err_path'.hid'
565 testouterr_cmd sh {load .hid} ERR $tserr_load5_c
566
567 restore_file_perms $mp1/quux
568 restore_file_perms $mp1/quux/oth
569 restore_file_perms $mp1/empty
570 restore_file_perms $mp1/anotherempty
571 restore_file_perms $mp1/quxa/.modulerc
572 restore_file_perms $mp1/baz/.1.10
573 restore_file_perms $mp1/quxc/1.0
574 restore_file_perms $mp1/quxc/1.0~
575 restore_file_perms $mp1/.svn
576 restore_file_perms $mp1/.sos/ignmod
577 restore_file_perms $mp1/.version
578 restore_file_perms $mp1/foo/1.0
579 restore_file_perms $mp1/foo/.modulerc
580 restore_file_perms $mp1/othhid/.deep
581 restore_file_perms $mp1/othhid2
582 restore_file_perms $mp1/.hid/1.0
583
584
585 # test potential double cache evaluation situation
586 setenv_var MODULEPATH $mp2
587 file mkdir $mp2
588 set fid [open $mp2/foo w]
589 puts $fid {#%Module
590 if {[is-avail bar]} {
591 module load bar
592 }
593 }
594 close $fid
595 create_dummy_modulefile $mp2/bar
596 change_file_perms $mp2/foo $no_or_perms
597 change_file_perms $mp2/bar $no_or_perms
598 set tserr [msg_create $mp2cache]
599 testouterr_cmd sh cachebuild OK $tserr
600
601 set ans [list]
602 lappend ans [list set __MODULES_LMPREREQ foo&bar]
603 lappend ans [list set _LMFILES_ $mp2/bar:$mp2/foo]
604 lappend ans [list set LOADEDMODULES bar:foo]
605 lappend ans [list set __MODULES_LMTAG bar&auto-loaded]
606 set tserr ".*
607 DEBUG findModulesInCacheFile: cache file '[escre $mp2cache]' exists and is readable
608 .*
609 DEBUG findModulesInCacheFile: 0 elements are cached for '[escre $mp2]'
610 DEBUG findModulesInCacheFile: 2 limited access files for '[escre $mp2]'
611 DEBUG findModulesInCacheFile: 0 limited access dirs for '[escre $mp2]'
612 .*
613 DEBUG findModulesInCacheFile: found foo \\(1\\)
614 .*
615 DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: cache file '[escre $mp2cache]' has already been evaluated
616 DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: 0 elements are cached for '[escre $mp2]'
617 DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: 2 limited access files for '[escre $mp2]'
618 DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: 0 limited access dirs for '[escre $mp2]'
619 DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: found bar \\(1\\)
620 .*"
621 testouterr_cmd_re sh {load foo -D} $ans $tserr
622
623 # also test that only matching limited-access module is checked
624 set tserr ".*
625 DEBUG findModulesInCacheFile: findModulesFromDirsAndFiles [escre $mp2] [escre $mp2]/foo 0 0 cache_arr modfile_indir hidden_list flimited_arr dlimited_arr
626 .*"
627 testouterr_cmd_re sh {avail foo -DD} OK $tserr
628
629 restore_file_perms $mp2/foo
630 restore_file_perms $mp2/bar
631 file delete $mp2cache
632 file delete $mp2/bar
633 file delete $mp2/foo
634 file delete $mp2
635
636 setenv_var MODULEPATH $mp1
637
638
639 # test symbol/tag resolution (with limited access rc for others)
640 change_file_perms $mp1/quux/.modulerc $no_or_perms
641 set tserr [msg_create $mp1cache]
642 testouterr_cmd sh cachebuild OK $tserr
643 set tserr "$mp1:
644 quux/oth/(default)
645 quux/oth/3.0(sym) <bar>
646 quux/oth/4.0
647 quux/sub/1.0 <foo>
648 quux/sub/2.0
649 quuxbar"
650 testouterr_cmd sh {avail -t quux} OK $tserr
651
652 # test symbol/tag resolution (with limited access rc for all)
653 restore_file_perms $mp1/quux/.modulerc
654 change_file_perms $mp1/quux/.modulerc $no_ar_perms
655 set tserr [msg_create $mp1cache]
656 testouterr_cmd sh cachebuild OK $tserr
657 set tserr "$mp1:
658 quux/oth/3.0
659 quux/oth/4.0
660 quux/sub/1.0
661 quux/sub/2.0
662 quuxbar"
663 testouterr_cmd sh {avail -t quux} OK $tserr
664 restore_file_perms $mp1/quux/.modulerc
665
666
667 # test debug output
668 setenv_var MODULEPATH $mp2
669 lassign [create_simple_module_setup $mp2] other_dir_list other_file_list
670 array set other_file_arr $other_file_list
671
672 change_file_perms $mp2/foo $no_orx_perms
673 set tserr [msg_create $mp2cache]
674 testouterr_cmd sh cachebuild OK $tserr
675
676 set tserr ".*
677 DEBUG findModulesInCacheFile: cache file '[escre $mp2]/.modulecache' exists and is readable
678 .*
679 DEBUG findModulesInCacheFile: 2 elements are cached for '[escre $mp2]'
680 DEBUG findModulesInCacheFile: 0 limited access files for '[escre $mp2]'
681 DEBUG findModulesInCacheFile: 1 limited access dirs for '[escre $mp2]'
682 .*
683 DEBUG findModulesInCacheFile: found foo/.modulerc foo/1.0 \\(2\\)
684 .*"
685 testouterr_cmd_re sh {avail -D -t foo/1.0} OK $tserr
686 set tserr ".*
687 DEBUG findModulesInCacheFile: cache file '[escre $mp2]/.modulecache' exists and is readable
688 DEBUG setConf: cache_expiry_secs set to '0'
689 DEBUG findModulesInCacheFile: execute-cachefile [escre $mp2]/.modulecache [escre $mp2]
690 .*
691 DEBUG findModulesInCacheFile: 2 elements are cached for '[escre $mp2]'
692 DEBUG findModulesInCacheFile: 0 limited access files for '[escre $mp2]'
693 DEBUG findModulesInCacheFile: 1 limited access dirs for '[escre $mp2]'
694 .*
695 DEBUG findModulesInCacheFile: found foo/.modulerc foo/1.0 \\(2\\)
696 .*"
697 testouterr_cmd_re sh {avail -DD -t foo/1.0} OK $tserr
698 set tserr ".*
699 TIMER findModulesInCacheFile [escre $mp2] foo 0 0 \\(.* ms\\)
700 .*
701 [escre $mp2]:
702 foo/1.0
703 .*"
704 testouterr_cmd_re sh {avail -D --timer -t foo/1.0} OK $tserr
705 testouterr_cmd_re sh {avail -DD --timer -t foo/1.0} OK $tserr
706
707 set tserr ".*
708 Get modules: {} matching 'foo/1.0' in ''
709 Evaluate cache file: '[escre $mp2cache]'
710 Evaluate modulerc: '[escre $mp2]/foo/.modulerc'
711 Get modules: {foo/1.0} matching 'foo/1.0' in '[escre $mp2]'
712 [escre $mp2]:
713 foo/1.0"
714 testouterr_cmd_re sh {avail -T -t foo/1.0} OK $tserr
715
716 file delete $mp2cache
717 set tserr ".*
718 Get modules: {} matching 'foo/1.0' in ''
719 Evaluate modulerc: '[escre $mp2]/foo/.modulerc'
720 Get modules: {foo/1.0} matching 'foo/1.0' in '[escre $mp2]'
721 [escre $mp2]:
722 foo/1.0"
723 testouterr_cmd_re sh {avail -T -t foo/1.0} OK $tserr
724
725 restore_file_perms $mp2/foo
726
727
728 #
729 # Cleanup
730 #
731
732 # delete generated cache file
733 file delete $mp1cache
734 file delete $mp2cache
735
736 # delete created files and dirs
737 delete_module_setup $mp1 [array names file_arr] $dir_list
738 delete_module_setup $mp2 [array names other_file_arr] $other_dir_list
739
740 reset_test_env
741
742 }