File: 040-cache-use.exp

package info (click to toggle)
modules 5.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,492; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (533 lines) | stat: -rw-r--r-- 18,168 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.30-cache/%M%
#   Revision:		%I%
#   First Edition:	2022/11/24
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:		avail, whatis, load
#   Modulefiles:
#   Sub-Command:
#
#   Comment:	%C{
#           Test use of cachefiles
#		}C%
#
##############################################################################

# filesystem on Cygwin platform is responding in an unexpected way
# skip these tests on this platform for now
skip_if_os_in cygwin

# ensure avail tests are made using in depth mode
setenv_var MODULES_AVAIL_INDEPTH 1

# ensure avail tests have implicit default enabled
setenv_var MODULES_IMPLICIT_DEFAULT 1

# ensure auto symbolic versions are set for these tests
setenv_var MODULES_ADVANCED_VERSION_SPEC 1

# ensure regular avail search match is set for these tests
setenv_var MODULES_SEARCH_MATCH starts_with

# generate content in modulepaths
lassign [create_diverse_module_setup $mp1] dir_list file_list
array set file_arr $file_list

setenv_var MODULEPATH $mp1

# create file cache for test
set tserr [msg_create $mp1cache]
testouterr_cmd sh cachebuild OK $tserr

set tserr {}
foreach f [lsort [array names file_arr]] {
    switch -glob -- $f {
        */.modulerc - */.version - foo/1.0 - foo/3.0 - quux/nok/5.0 -\
        .git/ignmod - quux/SCCS/ignmod - {w s/1.0~} - foo/1.0,v -\
        quxc/1.0~ - .svn/ignmod - .sos/ignmod {}
        {* *}   {lappend tserr '$f'}
        default {lappend tserr $f}
    }
}
set tserr_avail1 [join $tserr \n]
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
set tserr_avail2 [join {foo/2.0 foo/4.0 foo/5.0 foo/6.0} \n]
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2

set tserr_whatis1 "$modlin [escre $mp1] $modlin
\\s+bar/1.0: bar/1.0
\\s+bar/2.0: bar/2.0
\\s+baz/w s: baz/w s
\\s+baz/w\"s: baz/w\"s
\\s+baz/w#s: baz/w#s
\\s+foo/2.0: foo/2.0
\\s+quux/oth/3.0: quux/oth/3.0
\\s+quux/oth/4.0: quux/oth/4.0
\\s+quux/sub/1.0: quux/sub/1.0
\\s+quux/sub/2.0: quux/sub/2.0
\\s+quxa/1.0: quxa/1.0
\\s+quxb/1.0: quxb/1.0
\\s+quxc/1.0: quxc/1.0
\\s+quxd/1.0: quxd/1.0
\\s+quxe/1.0: quxe/1.0
\\s+w s/1.0: w s/1.0
\\s+w\"s/1.0: w\"s/1.0
\\s+w#s/1.0: w#s/1.0"
testouterr_cmd_re sh whatis OK $tserr_whatis1
set tserr_whatis2 "$modlin [escre $mp1] $modlin
\\s+baz/w s: baz/w s
\\s+baz/w\"s: baz/w\"s
\\s+baz/w#s: baz/w#s"
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2

set ans_load1 [list]
lappend ans_load1 [list set __MODULES_LMALTNAME bar/1.0&bar/default&bar]
lappend ans_load1 [list set _LMFILES_ $mp1/bar/1.0]
lappend ans_load1 [list set LOADEDMODULES bar/1.0]
testouterr_cmd sh {load bar} $ans_load1 {}

set tserr_load2 "$err_magic'$mp1/foo/.modulerc'\n$err_contact
$err_magic'$mp1/foo/1.0'\n$err_contact"
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2

set tserr_load3 "$err_magic'$mp1/foo/.modulerc'\n$err_contact
[moderr_minverreq $mp1/foo/3.0 99]"
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3

set tserr_load4 "$err_magic'[escre $mp1]/foo/.modulerc'\n$err_contact

[escre [msg_load foo/5.0 [msg_moderr {missing close-brace} if\ \{<EXM> $mp1/foo/5.0 2]]]"
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4

set ans_load5 [list]
lappend ans_load5 [list set __MODULES_LMALTNAME .hid/1.0&as|.hid/default&as|.hid/latest]
lappend ans_load5 [list set _LMFILES_ $mp1/.hid/1.0]
lappend ans_load5 [list set LOADEDMODULES .hid/1.0]
testouterr_cmd sh {load .hid} $ans_load5 {}

# delete generated cache file
file delete $mp1cache

# clean setup prior quitting if quick mode
if {[is_quick_mode]} {
    delete_module_setup $mp1 [array names file_arr] $dir_list
}
skip_if_quick_mode

# same tests without a cache (should get same result)
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2
testouterr_cmd_re sh whatis OK $tserr_whatis1
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
testouterr_cmd sh {load bar} $ans_load1 {}
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4
testouterr_cmd sh {load .hid} $ans_load5 {}

# tests with empty cache file
create_dummy_cachefile $mp1
testouterr_cmd sh {avail -a -t -o } OK {}
testouterr_cmd sh {avail -a -t -o  foo} OK {}
testouterr_cmd_re sh whatis OK {}
testouterr_cmd_re sh {whatis baz} ERR $err_path'baz'
testouterr_cmd sh {load bar} ERR $err_path'bar'
testouterr_cmd sh {load foo/1.0} ERR $err_path'foo/1.0'
testouterr_cmd sh {load foo/3.0} ERR $err_path'foo/3.0'
testouterr_cmd sh {load foo/5.0} ERR $err_path'foo/5.0'
testouterr_cmd sh {load .hid} ERR $err_path'.hid'
file delete $mp1cache

# tests with a cache containing only few elements
set fid [open $mp1cache w]
puts $fid "#%Module$::cache_mcookie_version
modulefile-content bar/1.0 1664035017 #%Module #%Module"
close $fid
testouterr_cmd sh {avail -a -t -o } OK bar/1.0
testouterr_cmd sh {avail -a -t -o  foo} OK {}
set tserr "- Package/Alias $modlin.- Versions $modlin.- Last mod. $modlin
[escre $mp1]:
bar/1.0\\s+[clock format 1664035017 -format {%Y/%m/%d %H:%M:%S}]"
testouterr_cmd_re sh {avail -l} OK $tserr
testouterr_cmd_re sh whatis OK {}
testouterr_cmd_re sh {whatis baz} ERR $err_path'baz'
set ans [list]
lappend ans [list set __MODULES_LMALTNAME bar/1.0&as|bar/default&as|bar/latest]
lappend ans [list set _LMFILES_ $mp1/bar/1.0]
lappend ans [list set LOADEDMODULES bar/1.0]
testouterr_cmd sh {load bar} $ans {}
testouterr_cmd sh {load foo/1.0} ERR $err_path'foo/1.0'
testouterr_cmd sh {load foo/3.0} ERR $err_path'foo/3.0'
testouterr_cmd sh {load foo/5.0} ERR $err_path'foo/5.0'
testouterr_cmd sh {load .hid} ERR $err_path'.hid'
file delete $mp1cache

# test with an empty file (no module header)
close [open $mp1cache w]
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2
testouterr_cmd_re sh whatis OK $tserr_whatis1
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
set ans_load1b [list]
lappend ans_load1b [list set __MODULES_LMALTNAME bar/1.0&bar/default&bar]
lappend ans_load1b [list set _LMFILES_ $mp1/bar/1.0]
lappend ans_load1b [list set LOADEDMODULES bar/1.0]
lappend ans_load1b [list ERR]
testouterr_cmd sh {load bar} $ans_load1b [cacheerr_magic $mp1cache]
testouterr_cmd sh {load foo/1.0} ERR [cacheerr_magic $mp1cache]\n$tserr_load2
testouterr_cmd sh {load foo/3.0} ERR [cacheerr_magic $mp1cache]\n$tserr_load3
testouterr_cmd_re sh {load foo/5.0} ERR [cacheerr_magic [escre $mp1cache]]\n$tserr_load4
set ans_load5b [list]
lappend ans_load5b [list set __MODULES_LMALTNAME .hid/1.0&as|.hid/default&as|.hid/latest]
lappend ans_load5b [list set _LMFILES_ $mp1/.hid/1.0]
lappend ans_load5b [list set LOADEDMODULES .hid/1.0]
lappend ans_load5b [list ERR]
testouterr_cmd sh {load .hid} $ans_load5b [cacheerr_magic $mp1cache]
file delete $mp1cache

# test with a module header without version specification
set fid [open $mp1cache w]
puts $fid "#%Module
modulefile-content bar/1.0 1664035017 #%Module #%Module"
close $fid
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2
testouterr_cmd sh {load bar} $ans_load1b [cacheerr_misverreq $mp1cache]
file delete $mp1cache

# test with a module header with required version too high
set fid [open $mp1cache w]
puts $fid "#%Module99
modulefile-content bar/1.0 1664035017 #%Module #%Module"
close $fid
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2
testouterr_cmd sh {load bar} $ans_load1 {}
file delete $mp1cache

# test with a module header with required version below current version
set fid [open $mp1cache w]
puts $fid "#%Module5.2
modulefile-content bar/1.0 1664035017 #%Module #%Module"
close $fid
testouterr_cmd sh {avail -a -t -o } OK bar/1.0
testouterr_cmd sh {avail -a -t -o  foo} OK {}
set ans [list]
lappend ans [list set __MODULES_LMALTNAME bar/1.0&as|bar/default&as|bar/latest]
lappend ans [list set _LMFILES_ $mp1/bar/1.0]
lappend ans [list set LOADEDMODULES bar/1.0]
testouterr_cmd sh {load bar} $ans {}
file delete $mp1cache

# tests with a cache containing element that does not exists anymore in modulepath
set fid [open $mp1cache w]
puts $fid "#%Module$::cache_mcookie_version
modulefile-content bar/5.0 1664035017 #%Module #%Module"
close $fid
testouterr_cmd sh {avail -a -t -o } OK bar/5.0
set tserr "- Package/Alias $modlin.- Versions $modlin.- Last mod. $modlin
[escre $mp1]:
bar/5.0\\s+[clock format 1664035017 -format {%Y/%m/%d %H:%M:%S}]"
testouterr_cmd_re sh {avail -l} OK $tserr
set ans [list]
lappend ans [list set __MODULES_LMALTNAME bar/5.0&as|bar/default&as|bar/latest]
lappend ans [list set _LMFILES_ $mp1/bar/5.0]
lappend ans [list set LOADEDMODULES bar/5.0]
testouterr_cmd sh {load bar} $ans {}
file delete $mp1cache


# test potential double cache evaluation situation
setenv_var MODULEPATH $mp2
file mkdir $mp2
set fid [open $mp2/foo w]
puts $fid {#%Module
if {[is-avail bar]} {
    module load bar
}
}
close $fid
create_dummy_modulefile $mp2/bar
set tserr [msg_create $mp2cache]
testouterr_cmd sh cachebuild OK $tserr

set ans [list]
lappend ans [list set __MODULES_LMPREREQ foo&bar]
lappend ans [list set _LMFILES_ $mp2/bar:$mp2/foo]
lappend ans [list set LOADEDMODULES bar:foo]
lappend ans [list set __MODULES_LMTAG bar&auto-loaded]
set tserr ".*
DEBUG findModulesInCacheFile: cache file '[escre $mp2cache]' exists and is readable
.*
DEBUG findModulesInCacheFile: 2 elements are cached for '[escre $mp2]'
DEBUG findModulesInCacheFile: 0 limited access files for '[escre $mp2]'
DEBUG findModulesInCacheFile: 0 limited access dirs for '[escre $mp2]'
.*
DEBUG findModulesInCacheFile: found foo \\(1\\)
.*
DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: cache file '[escre $mp2cache]' has already been evaluated
DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: 2 elements are cached for '[escre $mp2]'
DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: 0 limited access files for '[escre $mp2]'
DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: 0 limited access dirs for '[escre $mp2]'
DEBUG \\\[#1:load:foo\\\] findModulesInCacheFile: found bar \\(1\\)
.*"
testouterr_cmd_re sh {load foo -D} $ans $tserr

file delete $mp2cache
file delete $mp2/bar
file delete $mp2/foo
file delete $mp2


# test over a modulepath containing a space character
# skip test on MSYS platform or if symlink creation is not supported
if {$is_symlink_supported && $os_name ne {msys}} {
set mpws "$env(HOME)/mp ws"
set mpwscache $mpws/.modulecache
file link -symbolic $mpws $mp1
setenv_var MODULEPATH $mpws

set tserr [msg_create '$mpwscache']
testouterr_cmd sh cachebuild OK $tserr

testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2

set tserr "$modlin [escre $mpws] $modlin
\\s+bar/1.0: bar/1.0
\\s+bar/2.0: bar/2.0
\\s+baz/w s: baz/w s
\\s+baz/w\"s: baz/w\"s
\\s+baz/w#s: baz/w#s
\\s+foo/2.0: foo/2.0
\\s+quux/oth/3.0: quux/oth/3.0
\\s+quux/oth/4.0: quux/oth/4.0
\\s+quux/sub/1.0: quux/sub/1.0
\\s+quux/sub/2.0: quux/sub/2.0
\\s+quxa/1.0: quxa/1.0
\\s+quxb/1.0: quxb/1.0
\\s+quxc/1.0: quxc/1.0
\\s+quxd/1.0: quxd/1.0
\\s+quxe/1.0: quxe/1.0
\\s+w s/1.0: w s/1.0
\\s+w\"s/1.0: w\"s/1.0
\\s+w#s/1.0: w#s/1.0"
testouterr_cmd_re sh whatis OK $tserr
set tserr "$modlin [escre $mpws] $modlin
\\s+baz/w s: baz/w s
\\s+baz/w\"s: baz/w\"s
\\s+baz/w#s: baz/w#s"
testouterr_cmd_re sh {whatis baz} OK $tserr

set ans [list]
lappend ans [list set __MODULES_LMALTNAME bar/1.0&bar/default&bar]
lappend ans [list set _LMFILES_ $mpws/bar/1.0]
lappend ans [list set LOADEDMODULES bar/1.0]
testouterr_cmd sh {load bar} $ans {}

set tserr "$err_magic'$mpws/foo/.modulerc'\n$err_contact
$err_magic'$mpws/foo/1.0'\n$err_contact"
testouterr_cmd sh {load foo/1.0} ERR $tserr

set tserr "$err_magic'$mpws/foo/.modulerc'\n$err_contact
[moderr_minverreq $mpws/foo/3.0 99]"
testouterr_cmd sh {load foo/3.0} ERR $tserr

set tserr "$err_magic'[escre $mpws]/foo/.modulerc'\n$err_contact

[escre [msg_load foo/5.0 [msg_moderr {missing close-brace} if\ \{<EXM> $mpws/foo/5.0 2]]]"
testouterr_cmd_re sh {load foo/5.0} ERR $tserr

set ans [list]
lappend ans [list set __MODULES_LMALTNAME .hid/1.0&as|.hid/default&as|.hid/latest]
lappend ans [list set _LMFILES_ $mpws/.hid/1.0]
lappend ans [list set LOADEDMODULES .hid/1.0]
testouterr_cmd sh {load .hid} $ans {}

file delete $mpwscache
file delete $mpws
}


# test symbol/tag resolution
setenv_var MODULEPATH $mp1

set tserr [msg_create $mp1cache]
testouterr_cmd sh cachebuild OK $tserr
set tserr "$mp1:
quux/oth/(default)
quux/oth/3.0(sym) <bar>
quux/oth/4.0
quux/sub/1.0 <foo>
quux/sub/2.0"
testouterr_cmd sh {avail -t quux} OK $tserr


# test indepth/noindepth resolution
set tserr "$mp1:
bar/
baz/
foo/
quux/
quxa/
quxb/
quxc/
quxd/
quxe/
'w s'/
w\"s/
w#s/"
testouterr_cmd sh {avail -t --no-indepth} OK $tserr
set tserr "$mp1:
quux/"
testouterr_cmd sh {avail -t --no-indepth quux} OK $tserr
set tserr "$mp1:
quux/oth/(default)
quux/sub/"
testouterr_cmd sh {avail -t --no-indepth quux/} OK $tserr
testouterr_cmd sh {avail -t --no-indepth quux/*} OK $tserr
set tserr "$mp1:
quux/oth/(default)"
testouterr_cmd sh {avail -t --no-indepth quux/o} OK $tserr
set tserr ""
testouterr_cmd sh {avail -t --no-indepth quux/nok} OK $tserr
testouterr_cmd sh {avail -t --no-indepth quux/no} OK $tserr

file delete $mp1cache


# test debug output
setenv_var MODULEPATH $mp2
lassign [create_simple_module_setup $mp2] other_dir_list other_file_list
array set other_file_arr $other_file_list

set tserr [msg_create $mp2cache]
testouterr_cmd sh cachebuild OK $tserr

set tserr ".*
DEBUG findModulesInCacheFile: cache file '[escre $mp2]/.modulecache' exists and is readable
.*
DEBUG findModulesInCacheFile: 4 elements are cached for '[escre $mp2]'
DEBUG findModulesInCacheFile: 0 limited access files for '[escre $mp2]'
DEBUG findModulesInCacheFile: 0 limited access dirs for '[escre $mp2]'
.*
DEBUG findModulesInCacheFile: found foo/.modulerc foo/1.0 \\(2\\)
.*"
testouterr_cmd_re sh {avail -D -t foo/1.0} OK $tserr
set tserr ".*
DEBUG findModulesInCacheFile: cache file '[escre $mp2]/.modulecache' exists and is readable
DEBUG setConf: cache_expiry_secs set to '0'
DEBUG findModulesInCacheFile: execute-cachefile [escre $mp2]/.modulecache [escre $mp2]
.*
DEBUG findModulesInCacheFile: 4 elements are cached for '[escre $mp2]'
.*
DEBUG findModulesInCacheFile: found foo/.modulerc foo/1.0 \\(2\\)
.*"
testouterr_cmd_re sh {avail -DD -t foo/1.0} OK $tserr
set tserr ".*
TIMER findModulesInCacheFile [escre $mp2] foo 0 0 \\(.* ms\\)
.*
[escre $mp2]:
foo/1.0
.*"
testouterr_cmd_re sh {avail -D --timer -t foo/1.0} OK $tserr
testouterr_cmd_re sh {avail -DD --timer -t foo/1.0} OK $tserr

set tserr ".*
Get modules: {} matching 'foo/1.0' in ''
Evaluate cache file: '[escre $mp2cache]'
Evaluate modulerc: '[escre $mp2]/foo/.modulerc'
Get modules: {foo/1.0} matching 'foo/1.0' in '[escre $mp2]'
[escre $mp2]:
foo/1.0"
testouterr_cmd_re sh {avail -T -t foo/1.0} OK $tserr

file delete $mp2cache
set tserr ".*
Get modules: {} matching 'foo/1.0' in ''
Evaluate modulerc: '[escre $mp2]/foo/.modulerc'
Get modules: {foo/1.0} matching 'foo/1.0' in '[escre $mp2]'
[escre $mp2]:
foo/1.0"
testouterr_cmd_re sh {avail -T -t foo/1.0} OK $tserr


# cache usage when mcookie_check is set to eval (same result as if
# option is set to always)
setenv_path_var MODULEPATH $mp1
set tserr [msg_create $mp1cache]
testouterr_cmd sh cachebuild OK $tserr
setenv_var MODULES_MCOOKIE_CHECK eval
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2
testouterr_cmd_re sh whatis OK $tserr_whatis1
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
testouterr_cmd sh {load bar} $ans_load1 {}
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4
testouterr_cmd sh {load .hid} $ans_load5 {}
setenv_var MODULES_MCOOKIE_CHECK always

# cache usage when mcookie_version_check is disabled (same result as if
# option is enabled)
setenv_var MODULES_MCOOKIE_VERSION_CHECK 0
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o  foo} OK $tserr_avail2
testouterr_cmd_re sh whatis OK $tserr_whatis1
testouterr_cmd_re sh {whatis baz} OK $tserr_whatis2
testouterr_cmd sh {load bar} $ans_load1 {}
testouterr_cmd sh {load foo/1.0} ERR $tserr_load2
testouterr_cmd sh {load foo/3.0} ERR $tserr_load3
testouterr_cmd_re sh {load foo/5.0} ERR $tserr_load4
testouterr_cmd sh {load .hid} $ans_load5 {}
setenv_var MODULES_MCOOKIE_VERSION_CHECK 1
file delete $mp1cache


# cannot test access if cannot change file permission
if {!$is_file_perms_editable} {
    send_user "\tskipping access tests as file permissions cannot be changed\n"
# cannot test access if superuser privileges are in use
} elseif {$tcl_platform(user) eq "root"} {
    send_user "\tskipping access tests as tests are run by superuser\n"
# cannot test access if restricted file permissions have no effect
} elseif {$is_locked_dir_file_readable && $is_locked_file_readable} {
    send_user "\tskipping access tests as locked files or directories are still readable\n"
} else {

set noread_perms ugo-r

# check expected siteconfig file is installed
set is_stderr_tty [siteconfig_isStderrTty]
if {$is_stderr_tty} {
    # test a cache read failure by faking cache file is readable
    setenv_var TESTSUITE_ENABLE_SITECONFIG_CACHE_READ 1
    create_dummy_cachefile $mp1
    change_file_perms $mp1cache $noread_perms
    testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
    testouterr_cmd sh {load bar} $ans_load1b [err_permdenied $mp1cache]
    restore_file_perms $mp1cache
    file delete $mp1cache
    unsetenv_var TESTSUITE_ENABLE_SITECONFIG_CACHE_READ
}

}


#
#  Cleanup
#

# delete created files and dirs
delete_module_setup $mp1 [array names file_arr] $dir_list
delete_module_setup $mp2 [array names other_file_arr] $other_dir_list

reset_test_env