Debian Codegraph @

testsuite/modules.00-init/110-quar.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2017/11/02
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # Check runtime quarantine mechanism of environment variables.
18 # }C%
19 #
20 ##############################################################################
21
22 # Test handling of quarantine-related variables, full runtime quarantine
23 # test is made in the install testsuite.
24 if {$install_quarantinesupport eq y} {
25
26 set modfile "$env(TESTSUITEDIR)/modulefiles.2/quar"
27
28 # set to mimic key variable transmitted by module shell function to tell some
29 # quarantine setup has been made
30 setenv_var __MODULES_QUARANTINE_SET 1
31
32 # no quarantine setup, nothing should be set
33 testouterr_cmd "ALL" "source $modfile" "OK" ""
34
35
36 # empty quarantine setup
37 set quar ""
38 if {$verbose} {
39 send_user "\tSetup MODULES_RUN_QUARANTINE = '$quar'\n"
40 }
41 set env(MODULES_RUN_QUARANTINE) $quar
42
43 set ans [list]
44 lappend ans "MODULES_RUN_QUARANTINE=$quar"
45
46 testouterr_cmd "ALL" "source $modfile" "OK" [join $ans "\n"]
47
48 skip_if_quick_mode
49
50 # one quarantine variable, no env value, no runtime value: nop
51 set quar "BAR"
52 if {$verbose} {
53 send_user "\tSetup MODULES_RUN_QUARANTINE = '$quar'\n"
54 send_user "\tUnset BAR\n"
55 }
56 set env(MODULES_RUN_QUARANTINE) $quar
57 if {[info exists env(BAR)]} {
58 unset env(BAR)
59 }
60
61 set ans [list]
62 lappend ans "MODULES_RUN_QUARANTINE=$quar"
63
64 testouterr_cmd "ALL" "source $modfile" "OK" [join $ans "\n"]
65
66
67 # one quarantine variable, no env value, with runtime value: envvar set, quarvar unset
68 set runenv1 "value valpart2 valspe\"ci\"al"
69 if {$verbose} {
70 send_user "\tSetup MODULES_RUNENV_BAR = '$runenv1'\n"
71 send_user "\tSetup BAR = '$runenv1'\n"
72 }
73 set env(MODULES_RUNENV_BAR) $runenv1
74 set env(BAR) $runenv1
75
76 set ans [list]
77 lappend ans "MODULES_RUN_QUARANTINE=$quar"
78 lappend ans "MODULES_RUNENV_BAR=$runenv1"
79
80 # quarantine mechanism also applies to csh/tcsh by modulecmd.tcl but as it is not
81 # implemented in module shell alias, the __MODULES_QUARANTINE_SET is never defined
82 # by this shell so the mechanism is in real life situation never activated
83 foreach shell $supported_shells {
84 testouterr_cmd "$shell" "source $modfile" "OK" [join $ans "\n"]
85 }
86
87
88 # one quarantine variable, with env value, no runtime value: envvar empty, quarvar set
89 set env1 "orig"
90 if {$verbose} {
91 send_user "\tUnset MODULES_RUNENV_BAR\n"
92 }
93 unset env(MODULES_RUNENV_BAR)
94 setenv_var __MODULES_QUAR_BAR $env1
95 setenv_var BAR {}
96
97 set ans [list]
98 lappend ans "MODULES_RUN_QUARANTINE=$quar"
99 lappend ans "BAR=$env1"
100
101 foreach shell $supported_shells {
102 testouterr_cmd "$shell" "source $modfile" "OK" [join $ans "\n"]
103 }
104
105
106 # one quarantine variable, with env value, with runtime value: envar set, quarvar set
107 if {$verbose} {
108 send_user "\tSetup MODULES_RUNENV_BAR = '$runenv1'\n"
109 send_user "\tSetup BAR = '$runenv1'\n"
110 }
111 set env(MODULES_RUNENV_BAR) $runenv1
112 set env(BAR) $runenv1
113
114 set ans [list]
115 lappend ans "MODULES_RUN_QUARANTINE=$quar"
116 lappend ans "BAR=$env1"
117 lappend ans "MODULES_RUNENV_BAR=$runenv1"
118
119 foreach shell $supported_shells {
120 testouterr_cmd "$shell" "source $modfile" "OK" [join $ans "\n"]
121 }
122
123
124 # one good quarantine variable (with env value & runtime value) among bad variable names
125 set quar "BAR F:OO B\\AD 0BAD"
126 if {$verbose} {
127 send_user "\tSetup MODULES_RUN_QUARANTINE = '$quar'\n"
128 }
129 set env(MODULES_RUN_QUARANTINE) $quar
130
131 set ans [list]
132 lappend ans "$warn_msgs: Bad variable name set in MODULES_RUN_QUARANTINE (F:OO)"
133 lappend ans "$warn_msgs: Bad variable name set in MODULES_RUN_QUARANTINE (B\\AD)"
134 lappend ans "$warn_msgs: Bad variable name set in MODULES_RUN_QUARANTINE (0BAD)"
135 lappend ans "MODULES_RUN_QUARANTINE=$quar"
136 lappend ans "BAR=$env1"
137 lappend ans "MODULES_RUNENV_BAR=$runenv1"
138
139 foreach shell $supported_shells {
140 testouterr_cmd "$shell" "source $modfile" "OK" [join $ans "\n"]
141 }
142
143
144 # two quarantine variables, first with env and runtime, second with env no runtime
145 set quar "BAR FOO"
146 set env2 "orig2 part2 spe\"ci\"al"
147 if {$verbose} {
148 send_user "\tSetup MODULES_RUN_QUARANTINE = '$quar'\n"
149 }
150 set env(MODULES_RUN_QUARANTINE) $quar
151 setenv_var __MODULES_QUAR_FOO $env2
152 setenv_var FOO {}
153
154 set ans [list]
155 lappend ans "MODULES_RUN_QUARANTINE=$quar"
156 lappend ans "BAR=$env1"
157 lappend ans "FOO=$env2"
158 lappend ans "MODULES_RUNENV_BAR=$runenv1"
159
160 foreach shell $supported_shells {
161 testouterr_cmd "$shell" "source $modfile" "OK" [join $ans "\n"]
162 }
163
164
165 # mimic if no variable transmitted by module shell function to tell some
166 # quarantine setup has been made
167 unsetenv_var __MODULES_QUARANTINE_SET
168
169 set ans [list]
170 lappend ans "MODULES_RUN_QUARANTINE=$quar"
171 lappend ans "BAR=$runenv1"
172 lappend ans "FOO="
173 lappend ans "MODULES_RUNENV_BAR=$runenv1"
174 lappend ans "__MODULES_QUAR_FOO=$env2"
175 lappend ans "__MODULES_QUAR_BAR=$env1"
176
177 foreach shell $supported_shells {
178 testouterr_cmd "$shell" "source $modfile" "OK" [join $ans "\n"]
179 }
180
181
182 #
183 # Clean up variables used in this test case
184 #
185
186 reset_test_env
187
188 } elseif {$verbose} {
189 send_user "\tSkipping quarantine mechanism checks\n"
190 }