Debian Codegraph @

testsuite/modules.50-cmds/376-deps7.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.50-cmds/%M%
6 # Revision: %I%
7 # First Edition: 2018/09/15
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: load, unload, switch, purge, reload
14 # Modulefiles:
15 # Sub-Command: module load, module unload
16 #
17 # Comment: %C{
18 # Test automatic resolution of modulefile dependencies defined
19 # through 'module load' and 'module unload' commands in modulefiles
20 # }C%
21 #
22 ##############################################################################
23
24 set mp $modpath.deps
25
26 # setup specific environment
27 setenv_path_var MODULEPATH $mp
28
29 #
30 # 'module load' tests
31 #
32
33 # load test in case 'module load' target is not loaded already
34 set ans [list]
35 lappend ans [list set __MODULES_LMPREREQ m2&m1]
36 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
37 lappend ans [list set LOADEDMODULES m1:m2]
38 lappend ans [list set __MODULES_LMTAG m1&auto-loaded]
39 set tserr [list {load m1} {load m2} \n[msg_top_load m2 {} m1 {}]]
40 testouterr_cmd_re sh {load --auto m2} $ans [join $tserr \n]
41 testouterr_cmd_re sh {load --no-auto m2} $ans [join $tserr \n]
42
43 skip_if_quick_mode
44
45 # load test in case 'module load' target is already loaded
46 setenv_loaded_module [list m1] [list $mp/m1]
47 set ans [list]
48 lappend ans [list set __MODULES_LMPREREQ m2&m1]
49 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
50 lappend ans [list set LOADEDMODULES m1:m2]
51 set tserr [list {load m2}]
52 testouterr_cmd_re sh {load --auto m2} $ans [join $tserr \n]
53 testouterr_cmd_re sh {load --no-auto m2} $ans [join $tserr \n]
54
55 # load test in force mode in case 'module load' target is already loaded
56 testouterr_cmd_re sh {load --force --auto m2} $ans [join $tserr \n]
57 testouterr_cmd_re sh {load --force --no-auto m2} $ans [join $tserr \n]
58
59
60 # unload test where 'module load' target is loaded, user asked and not required by another loaded module
61 # target is not unloaded as it has not been automatically loaded
62 setenv_loaded_module [list m1 m2] [list $mp/m1 $mp/m2]
63 setenv_var __MODULES_LMPREREQ m2&m1
64 set ans [list]
65 lappend ans [list unset __MODULES_LMPREREQ]
66 lappend ans [list set _LMFILES_ $mp/m1]
67 lappend ans [list set LOADEDMODULES m1]
68 set tserr [list {unload m2}]
69 testouterr_cmd_re sh {unload --auto m2} $ans [join $tserr \n]
70 testouterr_cmd_re sh {unload --no-auto m2} $ans [join $tserr \n]
71
72 # unload test where 'module load' target is loaded, not user asked and not required by another loaded module
73 # target is unloaded as it has been automatically loaded, but unload order vary depending on auto_handling state
74 setenv_loaded_module [list m1 m2] [list $mp/m1 $mp/m2] [list m1]
75 setenv_var __MODULES_LMPREREQ m2&m1
76 set ans [list]
77 lappend ans [list unset __MODULES_LMPREREQ]
78 lappend ans [list unset _LMFILES_]
79 lappend ans [list unset LOADEDMODULES]
80 lappend ans [list unset __MODULES_LMTAG]
81 set tserr [list {unload m2} {unload m1} \n[msg_top_unload m2 {} m1 {}]]
82 testouterr_cmd_re sh {unload --auto m2} $ans [join $tserr \n]
83 set tserr [list {unload m1} {unload m2} \n[msg_top_unload m2 {} m1 {}]]
84 testouterr_cmd_re sh {unload --no-auto m2} $ans [join $tserr \n]
85
86 # unload test where 'module load' target is loaded, user asked and required by another loaded module
87 # target is not unloaded as it is still required and it has been explicitly asked
88 setenv_loaded_module [list m1 m2 m3] [list $mp/m1 $mp/m2 $mp/m3]
89 setenv_var __MODULES_LMPREREQ m2&m1:m3&m1
90 set ans [list]
91 lappend ans [list set __MODULES_LMPREREQ m3&m1]
92 lappend ans [list set _LMFILES_ $mp/m1:$mp/m3]
93 lappend ans [list set LOADEDMODULES m1:m3]
94 set tserr [list {unload m2}]
95 testouterr_cmd_re sh {unload --auto m2} $ans [join $tserr \n]
96 # force mode does not change a thing
97 testouterr_cmd_re sh {unload --auto --force m2} $ans [join $tserr \n]
98 testouterr_cmd_re sh {unload --no-auto m2} $ans [join $tserr \n]
99 testouterr_cmd_re sh {unload --no-auto --force m2} $ans [join $tserr \n]
100
101 # unload test where 'module load' target is loaded, not user asked and required by another loaded module
102 # target is not unloaded as it is still required by another loaded module
103 setenv_loaded_module [list m1 m2 m3] [list $mp/m1 $mp/m2 $mp/m3] [list m1]
104 testouterr_cmd_re sh {unload --auto m2} $ans [join $tserr \n]
105 # force mode does not change a thing
106 testouterr_cmd_re sh {unload --auto --force m2} $ans [join $tserr \n]
107 testouterr_cmd_re sh {unload --no-auto m2} $ans [join $tserr \n]
108 testouterr_cmd_re sh {unload --no-auto --force m2} $ans [join $tserr \n]
109
110 # same situation than above but with __MODULES_LMPREREQ not set, should not happen but just
111 # check here the behavior
112 unsetenv_var __MODULES_LMPREREQ
113 set ans [list]
114 lappend ans [list set _LMFILES_ $mp/m1:$mp/m3]
115 lappend ans [list set LOADEDMODULES m1:m3]
116 set tserr [list {unload m2}]
117 # missing prereq information, no m1 unload is attempted
118 testouterr_cmd_re sh {unload --auto m2} $ans [join $tserr \n]
119 testouterr_cmd_re sh {unload --auto --force m2} $ans [join $tserr \n]
120 set ans [list]
121 lappend ans [list set _LMFILES_ $mp/m3]
122 lappend ans [list set LOADEDMODULES m3]
123 lappend ans [list unset __MODULES_LMTAG]
124 set tserr [list {unload m1} {unload m2} \n[msg_top_unload m2 {} m1 {}]]
125 # unload is directly attempted in no-auto mode, m1 is unload as nothing says m3 requires it
126 testouterr_cmd_re sh {unload --no-auto m2} $ans [join $tserr \n]
127 testouterr_cmd_re sh {unload --no-auto --force m2} $ans [join $tserr \n]
128
129 # unload 'module load' target, starts by DepUn modules when auto_handling is enabled
130 setenv_var __MODULES_LMPREREQ m2&m1:m3&m1
131 set ans [list]
132 lappend ans [list unset __MODULES_LMPREREQ]
133 lappend ans [list unset _LMFILES_]
134 lappend ans [list unset LOADEDMODULES]
135 lappend ans [list unset __MODULES_LMTAG]
136 set tserr [list {unload m3} {unload m2} {unload m1} \n[msg_top_unload {m1 <aL>} [list m3 m2] {} {}]]
137 testouterr_cmd_re sh {unload --auto m1} $ans [join $tserr \n]
138 # raise an error to keep consistency and no unload if auto_handling is disabled
139 set tserr [list [msg_unload {m1 <aL>} [err_prerequn m2 m3]]]
140 testouterr_cmd_re sh {unload --no-auto m1} ERR [join $tserr \n]
141
142 # unload test where 'module load' targets are loaded and are inter-connected
143 # targets are unloaded, but unload order vary depending on auto_handling state
144 setenv_loaded_module [list m1 m2 m4] [list $mp/m1 $mp/m2 $mp/m4] [list m1 m2]
145 setenv_var __MODULES_LMPREREQ m2&m1:m4&m1&m2
146 set ans [list]
147 lappend ans [list unset __MODULES_LMPREREQ]
148 lappend ans [list unset _LMFILES_]
149 lappend ans [list unset LOADEDMODULES]
150 lappend ans [list unset __MODULES_LMTAG]
151 set tserr [list {unload m4} {unload m2} {unload m1} \n[msg_top_unload m4 {} [list m2 m1] {}]]
152 testouterr_cmd_re sh {unload --auto m4} $ans [join $tserr \n]
153 # module unload is recorded prior its evaluation start, that is why even if m1 finishes to unload prior m2,
154 # it is reported after m2 as m2 unload has started prior m1 unload
155 set tserr [list {unload m1} {unload m2} {unload m4} \n[msg_top_unload m4 {} [list m2 m1] {}]]
156 testouterr_cmd_re sh {unload --no-auto m4} $ans [join $tserr \n]
157
158 # same test than above but with user asked variation, so the 'module load' targets are
159 # not unloaded as one target is user asked and requires the other target
160 setenv_loaded_module [list m1 m2 m4] [list $mp/m1 $mp/m2 $mp/m4] [list m1]
161 setenv_var __MODULES_LMPREREQ m2&m1:m4&m1&m2
162 set ans [list]
163 lappend ans [list set __MODULES_LMPREREQ m2&m1]
164 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
165 lappend ans [list set LOADEDMODULES m1:m2]
166 set tserr [list {unload m4}]
167 testouterr_cmd_re sh {unload --auto m4} $ans [join $tserr \n]
168 testouterr_cmd_re sh {unload --no-auto m4} $ans [join $tserr \n]
169
170 # load test where 'module load' target conflicts with an already loaded module
171 setenv_loaded_module [list m5] [list $mp/m5]
172 setenv_var __MODULES_LMCONFLICT m5&m1
173 unsetenv_var __MODULES_LMPREREQ
174 # evaluation is attempted prior conflict violation check
175 set tserr [list {load m1} \n[msg_load m1 [err_conflict m5]] \n[msg_load m2 [err_reqlo m1]]]
176 testouterr_cmd_re sh {load --no-auto m2} ERR [join $tserr \n]
177 if {[is_conf_enabled conflictunload]} {
178 set ans [list]
179 lappend ans [list unset __MODULES_LMCONFLICT]
180 lappend ans [list set __MODULES_LMPREREQ m2&m1]
181 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
182 lappend ans [list set LOADEDMODULES m1:m2]
183 lappend ans [list set __MODULES_LMTAG m1&auto-loaded]
184 set tserr [list {unload m5} {load m1} {load m2} \n[msg_top_load m2 m5 m1 {}]]
185 } else {
186 set ans ERR
187 }
188 testouterr_cmd_re sh {load --auto m2} $ans [join $tserr \n]
189 set ans [list]
190 lappend ans [list set __MODULES_LMPREREQ m2&m1]
191 lappend ans [list set _LMFILES_ $mp/m5:$mp/m1:$mp/m2]
192 lappend ans [list set LOADEDMODULES m5:m1:m2]
193 lappend ans [list set __MODULES_LMTAG m1&auto-loaded]
194 set tserr [list {load m1} \n[msg_load {m1 <aL>} [err_conlof m5]] "\nload m2" \n[msg_top_load m2 {} m1 {}]]
195 testouterr_cmd_re sh {load --force --no-auto m2} $ans [join $tserr \n]
196 if {[is_conf_enabled conflictunload]} {
197 set ans [list]
198 lappend ans [list unset __MODULES_LMCONFLICT]
199 lappend ans [list set __MODULES_LMPREREQ m2&m1]
200 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
201 lappend ans [list set LOADEDMODULES m1:m2]
202 lappend ans [list set __MODULES_LMTAG m1&auto-loaded]
203 set tserr [list {unload m5} {load m1} {load m2} \n[msg_top_load m2 m5 m1 {}]]
204 }
205 testouterr_cmd_re sh {load --force --auto m2} $ans [join $tserr \n]
206
207 # load test where 'module load' target does not exist
208 unsetenv_loaded_module
209 unsetenv_var __MODULES_LMCONFLICT
210 set tserr [list [msg_load m7 "$err_path'm8'" [err_reqlo m8]]]
211 testouterr_cmd_re sh {load --auto m7} ERR [join $tserr \n]
212 testouterr_cmd_re sh {load --no-auto m7} ERR [join $tserr \n]
213 set ans [list]
214 lappend ans [list set __MODULES_LMPREREQ m7&m8]
215 lappend ans [list set _LMFILES_ $mp/m7]
216 lappend ans [list set LOADEDMODULES m7]
217 lappend ans [list ERR]
218 set tserr [list {load m7} \n[msg_load m7 "$err_path'm8'" [err_reqlof m8]]]
219 testouterr_cmd_re sh {load --force --auto m7} $ans [join $tserr \n]
220 testouterr_cmd_re sh {load --force --no-auto m7} $ans [join $tserr \n]
221
222 # load test where 'module load' has multiple module args
223 set ans [list]
224 lappend ans [list set __MODULES_LMPREREQ m12&m10&m11]
225 lappend ans [list set _LMFILES_ $mp/m10:$mp/m11:$mp/m12]
226 lappend ans [list set LOADEDMODULES m10:m11:m12]
227 lappend ans [list set __MODULES_LMTAG m10&auto-loaded:m11&auto-loaded]
228 set tserr [list [msg_top_load m12 {} {m10 m11} {}]]
229 testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
230 testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]
231 setenv_loaded_module [list m10] [list $mp/m10]
232 set ans [list]
233 lappend ans [list set __MODULES_LMPREREQ m12&m10&m11]
234 lappend ans [list set _LMFILES_ $mp/m10:$mp/m11:$mp/m12]
235 lappend ans [list set LOADEDMODULES m10:m11:m12]
236 lappend ans [list set __MODULES_LMTAG m11&auto-loaded]
237 set tserr [list [msg_top_load m12 {} {m11} {}]]
238 testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
239 testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]
240 setenv_loaded_module [list m11] [list $mp/m11]
241 set ans [list]
242 lappend ans [list set __MODULES_LMPREREQ m12&m10&m11]
243 lappend ans [list set _LMFILES_ $mp/m11:$mp/m10:$mp/m12]
244 lappend ans [list set LOADEDMODULES m11:m10:m12]
245 lappend ans [list set __MODULES_LMTAG m10&auto-loaded]
246 set tserr [list [msg_top_load m12 {} {m10} {}]]
247 testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
248 testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]
249 setenv_loaded_module [list m10 m11] [list $mp/m10 $mp/m11]
250 set ans [list]
251 lappend ans [list set __MODULES_LMPREREQ m12&m10&m11]
252 lappend ans [list set _LMFILES_ $mp/m10:$mp/m11:$mp/m12]
253 lappend ans [list set LOADEDMODULES m10:m11:m12]
254 set tserr {}
255 testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
256 testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]
257
258
259 #
260 # 'module unload' tests
261 #
262
263 # load test in case 'module unload' target is not loaded
264 unsetenv_loaded_module
265 unsetenv_var __MODULES_LMPREREQ
266 unsetenv_var __MODULES_LMCONFLICT
267 set ans [list]
268 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
269 lappend ans [list set _LMFILES_ $mp/m5]
270 lappend ans [list set LOADEDMODULES m5]
271 set tserr [list {load m5}]
272 testouterr_cmd_re sh {load --auto m5} $ans [join $tserr \n]
273 testouterr_cmd_re sh {load --no-auto m5} $ans [join $tserr \n]
274
275 # load test in case 'module unload' target is loaded, user asked, and not required by another loaded module
276 setenv_loaded_module [list m1] [list $mp/m1]
277 set ans [list]
278 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
279 lappend ans [list set _LMFILES_ $mp/m5]
280 lappend ans [list set LOADEDMODULES m5]
281 set tserr [list {unload m1} {load m5} \n[msg_top_load m5 m1 {} {}]]
282 testouterr_cmd_re sh {load --auto m5} $ans [join $tserr \n]
283 testouterr_cmd_re sh {load --no-auto m5} $ans [join $tserr \n]
284
285 # load test in force mode in case 'module unload' target is loaded
286 testouterr_cmd_re sh {load --force --auto m5} $ans [join $tserr \n]
287 testouterr_cmd_re sh {load --force --no-auto m5} $ans [join $tserr \n]
288
289 # load test in case 'module unload' target is loaded, user asked, and required by another loaded module
290 setenv_loaded_module [list m1 m2] [list $mp/m1 $mp/m2]
291 setenv_var __MODULES_LMPREREQ m2&m1
292 set tserr [list [msg_unload m1 [err_prerequn m2]] \n[msg_load m5 [err_conun m1]]]
293 testouterr_cmd_re sh {load --no-auto m5} ERR [join $tserr \n]
294 if {[is_conf_enabled conflictunload]} {
295 set ans [list]
296 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
297 lappend ans [list unset __MODULES_LMPREREQ]
298 lappend ans [list set _LMFILES_ $mp/m5]
299 lappend ans [list set LOADEDMODULES m5]
300 set tserr [list {unload m2} {unload m1} {load m5} \n[msg_top_load m5 m1 {} {m2 {}}]]
301 testouterr_cmd_re sh {load --auto m5} $ans [join $tserr \n]
302 } else {
303 testouterr_cmd_re sh {load --auto m5} ERR [join $tserr \n]
304 }
305 # no auto or no conflict_unload: force mode will by-pass unload/conflict to guarantee m2&m1 prereq
306 set ans [list]
307 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
308 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2:$mp/m5]
309 lappend ans [list set LOADEDMODULES m1:m2:m5]
310 lappend ans [list ERR]
311 set tserr [list [msg_unload m1 [err_prerequn m2]] "\nload m5" \n[msg_load m5 [err_conunf m1]]]
312 testouterr_cmd_re sh {load --no-auto --force m5} $ans [join $tserr \n]
313 if {[is_conf_enabled conflictunload]} {
314 set ans [list]
315 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
316 lappend ans [list unset __MODULES_LMPREREQ]
317 lappend ans [list set _LMFILES_ $mp/m5]
318 lappend ans [list set LOADEDMODULES m5]
319 set tserr [list {unload m2} {unload m1} {load m5} \n[msg_top_load m5 m1 {} {m2 {}}]]
320 testouterr_cmd_re sh {load --auto --force m5} $ans [join $tserr \n]
321 } else {
322 testouterr_cmd_re sh {load --auto --force m5} $ans [join $tserr \n]
323 }
324
325 # load test in case 'module unload' target is loaded, not user asked, and required by another loaded module
326 setenv_loaded_module [list m1 m2] [list $mp/m1 $mp/m2] [list m1]
327 # evaluation is attempted prior conflict violation check
328 set tserr [list [msg_unload {m1 <aL>} [err_prerequn m2]] \n[msg_load m5 [err_conun m1]]]
329 testouterr_cmd_re sh {load --no-auto m5} ERR [join $tserr \n]
330 if {[is_conf_enabled conflictunload]} {
331 set ans [list]
332 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
333 lappend ans [list unset __MODULES_LMPREREQ]
334 lappend ans [list set _LMFILES_ $mp/m5]
335 lappend ans [list set LOADEDMODULES m5]
336 lappend ans [list unset __MODULES_LMTAG]
337 set tserr [list {unload m2} {unload m1} {load m5} \n[msg_top_load m5 m1 {} {m2 {}}]]
338 testouterr_cmd_re sh {load --auto m5} $ans [join $tserr \n]
339 } else {
340 testouterr_cmd_re sh {load --auto m5} ERR [join $tserr \n]
341 }
342 # no auto or no conflict_unload: force mode will by-pass unload/conflict to guarantee m2&m1 prereq
343 set ans [list]
344 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
345 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2:$mp/m5]
346 lappend ans [list set LOADEDMODULES m1:m2:m5]
347 lappend ans [list ERR]
348 set tserr [list [msg_unload {m1 <aL>} [err_prerequn m2]] "\nload m5" \n[msg_load m5 [err_conunf m1]]]
349 testouterr_cmd_re sh {load --no-auto --force m5} $ans [join $tserr \n]
350 if {[is_conf_enabled conflictunload]} {
351 set ans [list]
352 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
353 lappend ans [list unset __MODULES_LMPREREQ]
354 lappend ans [list set _LMFILES_ $mp/m5]
355 lappend ans [list set LOADEDMODULES m5]
356 lappend ans [list unset __MODULES_LMTAG]
357 set tserr [list {unload m2} {unload m1} {load m5} \n[msg_top_load m5 m1 {} {m2 {}}]]
358 testouterr_cmd_re sh {load --auto --force m5} $ans [join $tserr \n]
359 } else {
360 testouterr_cmd_re sh {load --auto --force m5} $ans [join $tserr \n]
361 }
362
363
364 # unload test in case 'module unload' target is not loaded
365 setenv_loaded_module [list m5] [list $mp/m5]
366 setenv_var __MODULES_LMCONFLICT m5&m1
367 set ans [list]
368 lappend ans [list unset __MODULES_LMCONFLICT]
369 lappend ans [list unset _LMFILES_]
370 lappend ans [list unset LOADEDMODULES]
371 set tserr [list {unload m5}]
372 testouterr_cmd_re sh {unload --auto m5} $ans [join $tserr \n]
373 testouterr_cmd_re sh {unload --no-auto m5} $ans [join $tserr \n]
374
375 # unload test in case 'module unload' target is loaded
376 # as conflict vanishes, target is reloaded if auto_handling enabled
377 setenv_loaded_module [list m5 m1] [list $mp/m5 $mp/m1]
378 setenv_var __MODULES_LMCONFLICT m5&m1
379 set ans [list]
380 lappend ans [list unset __MODULES_LMCONFLICT]
381 lappend ans [list set _LMFILES_ $mp/m1]
382 lappend ans [list set LOADEDMODULES m1]
383 set tserr [list {unload m1} {unload m5} {load m1} \n[msg_top_unload m5 {} {} m1]]
384 testouterr_cmd_re sh {unload --auto m5} $ans [join $tserr \n]
385 # force mode does not change a thing
386 testouterr_cmd_re sh {unload --auto --force m5} $ans [join $tserr \n]
387 # target not reloaded when conflict vanishes if auto_handling disabled
388 set tserr [list {unload m5}]
389 testouterr_cmd_re sh {unload --no-auto m5} $ans [join $tserr \n]
390 testouterr_cmd_re sh {unload --no-auto --force m5} $ans [join $tserr \n]
391
392 # unload test in case 'module unload' target is loaded, user asked, required by another loaded module
393 # as conflict vanishes, target and its dependent are reloaded if auto_handling enabled
394 setenv_loaded_module [list m5 m1 m2] [list $mp/m5 $mp/m1 $mp/m2]
395 setenv_var __MODULES_LMCONFLICT m5&m1
396 setenv_var __MODULES_LMPREREQ m2&m1
397 set ans [list]
398 lappend ans [list unset __MODULES_LMCONFLICT]
399 lappend ans [list set __MODULES_LMPREREQ m2&m1]
400 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
401 lappend ans [list set LOADEDMODULES m1:m2]
402 set tserr [list {unload m2} {unload m1} {unload m5} {load m1} {load m2} \n[msg_top_unload m5 {} {} [list m1 m2]]]
403 testouterr_cmd_re sh {unload --auto m5} $ans [join $tserr \n]
404 # force mode does not change a thing
405 testouterr_cmd_re sh {unload --auto --force m5} $ans [join $tserr \n]
406 # target and dependent not reloaded when conflict vanishes if auto_handling disabled
407 set ans [list]
408 lappend ans [list unset __MODULES_LMCONFLICT]
409 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
410 lappend ans [list set LOADEDMODULES m1:m2]
411 set tserr [list {unload m5}]
412 testouterr_cmd_re sh {unload --no-auto m5} $ans [join $tserr \n]
413 testouterr_cmd_re sh {unload --no-auto --force m5} $ans [join $tserr \n]
414
415 # unload test in case 'module unload' target is loaded, not user asked, required by another loaded module
416 setenv_loaded_module [list m5 m1 m2] [list $mp/m5 $mp/m1 $mp/m2] [list m1]
417 setenv_var __MODULES_LMCONFLICT m5&m1
418 setenv_var __MODULES_LMPREREQ m2&m1
419 set ans [list]
420 lappend ans [list unset __MODULES_LMCONFLICT]
421 lappend ans [list set __MODULES_LMPREREQ m2&m1]
422 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
423 lappend ans [list set LOADEDMODULES m1:m2]
424 lappend ans [list set __MODULES_LMTAG m1&auto-loaded]
425 set tserr [list {unload m2} {unload m1} {unload m5} {load m1} {load m2} \n[msg_top_unload m5 {} {} [list m1 m2]]]
426 testouterr_cmd_re sh {unload --auto m5} $ans [join $tserr \n]
427 # force mode does not change a thing
428 testouterr_cmd_re sh {unload --auto --force m5} $ans [join $tserr \n]
429 # target and dependent not reloaded when conflict vanishes if auto_handling disabled
430 set ans [list]
431 lappend ans [list unset __MODULES_LMCONFLICT]
432 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
433 lappend ans [list set LOADEDMODULES m1:m2]
434 set tserr [list {unload m5}]
435 testouterr_cmd_re sh {unload --no-auto m5} $ans [join $tserr \n]
436 testouterr_cmd_re sh {unload --no-auto --force m5} $ans [join $tserr \n]
437
438 # same situation than above but with __MODULES_LMCONFLICT not set, should not happen but just
439 # check here the behavior
440 unsetenv_var __MODULES_LMCONFLICT
441 set ans [list]
442 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2]
443 lappend ans [list set LOADEDMODULES m1:m2]
444 set tserr [list {unload m5}]
445 # missing conflict information, no m1/m2 unload is attempted
446 testouterr_cmd_re sh {unload --auto m5} $ans [join $tserr \n]
447 testouterr_cmd_re sh {unload --auto --force m5} $ans [join $tserr \n]
448 testouterr_cmd_re sh {unload --no-auto m5} $ans [join $tserr \n]
449 testouterr_cmd_re sh {unload --no-auto --force m5} $ans [join $tserr \n]
450
451 # unload 'module unload' target, starts by DepUn modules when auto_handling is enabled
452 setenv_var __MODULES_LMCONFLICT m5&m1
453 set ans [list]
454 lappend ans [list set __MODULES_LMCONFLICT m5&m1]
455 lappend ans [list unset __MODULES_LMPREREQ]
456 lappend ans [list set _LMFILES_ $mp/m5]
457 lappend ans [list set LOADEDMODULES m5]
458 lappend ans [list unset __MODULES_LMTAG]
459 set tserr [list {unload m2} {unload m5} {unload m1} {load m5} \n[msg_top_unload {m1 <aL>} {m2 m5} {} {{} {m5}}]]
460 testouterr_cmd_re sh {unload --auto m1} $ans [join $tserr \n]
461 # raise an error to keep consistency and no unload if auto_handling is disabled
462 set tserr [list [msg_unload {m1 <aL>} [err_prerequn m2]]]
463 testouterr_cmd_re sh {unload --no-auto m1} ERR [join $tserr \n]
464
465
466 # switch tests
467 setenv_loaded_module [list m1 m2 m3] [list $mp/m1 $mp/m2 $mp/m3] [list m1]
468 unsetenv_var __MODULES_LMCONFLICT
469 setenv_var __MODULES_LMPREREQ m2&m1:m3&m1
470 set ans [list]
471 lappend ans [list set __MODULES_LMCONFLICT m6&m3]
472 lappend ans [list unset __MODULES_LMPREREQ]
473 lappend ans [list set _LMFILES_ $mp/m6]
474 lappend ans [list set LOADEDMODULES m6]
475 lappend ans [list unset __MODULES_LMTAG]
476 set tserr [list {unload m2} {unload m3} {load m6} {unload m1} \n[msg_top_switch m2 m6 {} m1 m3 {} {}]]
477 testouterr_cmd_re sh {switch --auto m2 m6} $ans [join $tserr \n]
478
479 set ans [list]
480 lappend ans [list set __MODULES_LMCONFLICT m6&m3]
481 lappend ans [list unset __MODULES_LMPREREQ]
482 lappend ans [list set _LMFILES_ $mp/m6]
483 lappend ans [list set LOADEDMODULES m6]
484 lappend ans [list unset __MODULES_LMTAG]
485 set tserr [list {unload m2} {unload m1} {unload m3} {load m6} \n[msg_top_switch m2 m6 {} m1 m3 {} {}]]
486 testouterr_cmd_re sh {switch --no-auto m2 m6} $ans [join $tserr \n]
487
488 set ans [list]
489 lappend ans [list set __MODULES_LMCONFLICT m6&m3]
490 lappend ans [list set __MODULES_LMPREREQ m2&m1]
491 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2:$mp/m6]
492 lappend ans [list set LOADEDMODULES m1:m2:m6]
493 set tserr [list {unload m3} {load m6}]
494 testouterr_cmd_re sh {switch --auto m3 m6} $ans [join $tserr \n]
495 testouterr_cmd_re sh {switch --no-auto m3 m6} $ans [join $tserr \n]
496
497 setenv_loaded_module [list m1 m2 m6] [list $mp/m1 $mp/m2 $mp/m6] [list m1]
498 setenv_var __MODULES_LMPREREQ m2&m1
499 setenv_var __MODULES_LMCONFLICT m6&m3
500 set ans [list]
501 lappend ans [list set LOADEDMODULES m6]
502 lappend ans [list set _LMFILES_ $mp/m6]
503 lappend ans [list unset __MODULES_LMPREREQ]
504 lappend ans [list unset __MODULES_LMTAG]
505 lappend ans [list ERR]
506 set tserr [list {unload m1} {unload m2} {load m1} {load m3} \n[msg_load m3 [err_conflict m6]] \n[msg_top_switch m2 m3 {} m1 {} {} {} [err_swon m3]]]
507 testouterr_cmd_re sh {switch --no-auto m2 m3} $ans [join $tserr \n]
508 if {[is_conf_enabled conflictunload]} {
509 set ans [list]
510 lappend ans [list unset __MODULES_LMCONFLICT]
511 lappend ans [list set __MODULES_LMPREREQ m3&m1]
512 lappend ans [list set _LMFILES_ $mp/m1:$mp/m3]
513 lappend ans [list set LOADEDMODULES m1:m3]
514 set tserr [list {unload m2} {unload m6} {load m3} \n[msg_top_switch_conun m2 m3 {} {} m6 {} {}]]
515 } else {
516 # evaluation is attempted prior conflict violation check
517 set tserr [list {unload m2} {load m3} \n[msg_load m3 [err_conflict m6]]\n {unload m1} \n[msg_top_switch m2 m3 {} m1 {} {} {} [err_swon m3]]]
518 }
519 testouterr_cmd_re sh {switch --auto m2 m3} $ans [join $tserr \n]
520
521 set ans [list]
522 lappend ans [list unset __MODULES_LMCONFLICT]
523 lappend ans [list set __MODULES_LMPREREQ m2&m1:m3&m1]
524 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2:$mp/m3]
525 lappend ans [list set LOADEDMODULES m1:m2:m3]
526 set tserr [list {unload m6} {load m3}]
527 testouterr_cmd_re sh {switch --auto m6 m3} $ans [join $tserr \n]
528 testouterr_cmd_re sh {switch --no-auto m6 m3} $ans [join $tserr \n]
529
530
531 # purge and reload tests
532 setenv_loaded_module [list m1 m2 m6] [list $mp/m1 $mp/m2 $mp/m6] [list m1]
533 setenv_var __MODULES_LMCONFLICT m6&m3
534 setenv_var __MODULES_LMPREREQ m2&m1
535 set ans [list]
536 lappend ans [list unset __MODULES_LMCONFLICT]
537 lappend ans [list unset __MODULES_LMPREREQ]
538 lappend ans [list unset _LMFILES_]
539 lappend ans [list unset LOADEDMODULES]
540 lappend ans [list unset __MODULES_LMTAG]
541 set tserr [list {unload m6} {unload m2} {unload m1}]
542 testouterr_cmd_re sh {purge --auto} $ans [join $tserr \n]
543 testouterr_cmd_re sh {purge --no-auto} $ans [join $tserr \n]
544 set ans [list]
545 lappend ans [list set __MODULES_LMCONFLICT m6&m3]
546 lappend ans [list set __MODULES_LMPREREQ m2&m1]
547 lappend ans [list set _LMFILES_ $mp/m1:$mp/m2:$mp/m6]
548 lappend ans [list set LOADEDMODULES m1:m2:m6]
549 lappend ans [list set __MODULES_LMTAG m1&auto-loaded]
550 set tserr [list {unload m6} {unload m2} {unload m1} {load m1} {load m2} {load m6}]
551 testouterr_cmd_re sh {reload --auto} $ans [join $tserr \n]
552 testouterr_cmd_re sh {reload --no-auto} $ans [join $tserr \n]
553
554
555 #
556 # Cleanup
557 #
558
559 reset_test_env