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