Debian Codegraph @

testsuite/modules.20-locate/060-rc.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.20-locate/%M%
6 # Revision: %I%
7 # First Edition: 1995/12/06
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Jens Hamisch, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: load, display, whatis, paths
14 # Modulefiles: loc_rc1/1.0
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Tests the evaluation of the MODULERCFILE environment
19 # variable
20 # }C%
21 #
22 ##############################################################################
23
24 #
25 # Variables. This test forces a module load command. It will result in the
26 # environment variables "_LMFILES_", "LOADEDMODULES" and "testsuite" to
27 # be set up
28 #
29
30 set module_1 "loc_rc1/1.0"
31 set modulefile_1 "$modpath/$module_1"
32 set modulefilere_1 "$modpathre/$module_1"
33 set module_2 "loc_rc2/1.0"
34 set modulefile_2 "$modpath/$module_2"
35 set modulefilere_2 "$modpathre/$module_2"
36 set module_3 "virt_bar"
37 set modulefile_3 "$modpath/loc_rcv1/.common"
38 set modulefilere_3 "$modpathre/loc_rcv1/.common"
39
40 #
41 # Only checked for the csh
42 #
43
44 set disp_csh "setenv\t\ttestsuite yes"
45 set whatis_csh_1 "module-whatis\t$module_1"
46 set disp_1 "$modlin\n$modulefilere_1:\n\n$whatis_csh_1\n$disp_csh\n$modlin"
47 set avail_1_al "$modlin global/user modulerc $modlin\nsym_foo\\(special:@\\)\n\nKey:\n\\(@\\)=module-alias \\(symbolic-version\\)"
48 set avail_1 "$modlin $modpathre $modlin\n$module_1\\(foo:special\\)\n\nKey:\n\\(symbolic-version\\)"
49 set what_1 "$modlin $modpathre $modlin\n $module_1: $module_1"
50 set whatis_csh_2 "module-whatis\t$module_2"
51 set disp_2 "$modlin\n$modulefilere_2:\n\n$whatis_csh_2\n$disp_csh\n$modlin"
52 set what_2 "$modlin $modpathre $modlin\n $module_2: $module_2"
53 set whatis_csh_3 "module-whatis\t$module_3"
54 set disp_3 "$modlin\n$modulefilere_3:\n\n$whatis_csh_3\n$modlin"
55 set what_3 "$modlin $modpathre $modlin\n $module_3: $module_3"
56
57 set locate_msg "$err_path'sym_foo'"
58
59 #
60 # The tests
61 #
62
63 set env(MODULERCFILE) "$env(TESTSUITEDIR)/etc/modulerc"
64
65 lappend ans [list set __MODULES_LMALTNAME $module_1&loc_rc1/foo&sym_foo/special&loc_rc1/special&al|sym_foo]
66 lappend ans [list set _LMFILES_ $modulefile_1]
67 lappend ans [list set LOADEDMODULES $module_1]
68 lappend ans [list set testsuite yes]
69 lappend anspa [list text $modulefile_1]
70 test_cmd "csh" "load sym_foo" $ans
71 testouterr_cmd_re "sh" "display sym_foo" "OK" "$disp_1"
72 testouterr_cmd_re "sh" "whatis sym_foo" "OK" "$what_1"
73 test_cmd "sh" "paths sym_foo" $anspa
74 test_cmd "csh" "load sym_foo/special" $ans
75 testouterr_cmd_re "sh" "display sym_foo/special" "OK" "$disp_1"
76 testouterr_cmd_re "sh" "avail sym_foo/special" "OK" "$avail_1_al"
77 testouterr_cmd_re "sh" "whatis sym_foo/special" "OK" "$what_1"
78 test_cmd "sh" "paths sym_foo/special" $anspa
79
80 skip_if_quick_mode
81
82 set env(MODULERCFILE) "$env(TESTSUITEDIR)/etc/"
83 test_cmd "csh" "load sym_foo" $ans
84 testouterr_cmd_re "sh" "display sym_foo" "OK" "$disp_1"
85 testouterr_cmd_re "sh" "whatis sym_foo" "OK" "$what_1"
86 test_cmd "sh" "paths sym_foo" $anspa
87
88 # test symbol set in global RC gets correct transitivity
89 test_cmd "csh" "load loc_rc1/special" $ans
90 testouterr_cmd_re "sh" "display loc_rc1/special" "OK" "$disp_1"
91 testouterr_cmd_re "sh" "avail loc_rc1/special" "OK" "$avail_1"
92 testouterr_cmd_re "sh" "whatis loc_rc1/special" "OK" "$what_1"
93 test_cmd "sh" "paths loc_rc1/special" $anspa
94
95 unset env(MODULERCFILE)
96 testouterr_cmd "csh" "load sym_foo" "ERR" "$locate_msg"
97 testouterr_cmd "sh" "display sym_foo" "ERR" "$locate_msg"
98 testouterr_cmd "sh" "whatis sym_foo" "ERR" "$locate_msg"
99 set anspa [list]
100 lappend anspa [list text ""]
101 testouterr_cmd "sh" "paths sym_foo" $anspa ""
102
103 set env(MODULERCFILE) "$env(TESTSUITEDIR)/etc/rc"
104 set ans [list]
105 lappend ans [list set __MODULES_LMALTNAME $module_2&loc_rc2/foo&sym_foo/special2&loc_rc2/special2&loc_rc2/bar&loc_rc2/blah&al|sym_foo]
106 lappend ans [list set _LMFILES_ $modulefile_2]
107 lappend ans [list set LOADEDMODULES $module_2]
108 lappend ans [list set testsuite yes]
109 set anspa [list]
110 lappend anspa [list text $modulefile_2]
111 test_cmd "csh" "load sym_foo" $ans
112 testouterr_cmd_re "sh" "display sym_foo" "OK" "$disp_2"
113 testouterr_cmd_re "sh" "whatis sym_foo" "OK" "$what_2"
114 test_cmd "sh" "paths sym_foo" $anspa
115 test_cmd "csh" "load sym_foo/special2" $ans
116 testouterr_cmd_re "sh" "display sym_foo/special2" "OK" "$disp_2"
117 testouterr_cmd_re "sh" "whatis sym_foo/special2" "OK" "$what_2"
118 test_cmd "sh" "paths sym_foo/special2" $anspa
119
120 # test global RCs cascading is now achieved with 'make install-testetcrc'
121 # that setup a @etcdir@/rc file for the whole 'make test' duration
122
123 # test with virtual modules
124 set ans [list]
125 lappend ans [list set __MODULES_LMALTNAME $module_3&sym_bar/special3&virt_bar/special3&al|sym_bar&al|sym_bar_load&al|sym_bar_0]
126 lappend ans [list set _LMFILES_ $modulefile_3]
127 lappend ans [list set LOADEDMODULES $module_3]
128 set anspa [list]
129 lappend anspa [list text $modulefile_3]
130 test_cmd "csh" "load sym_bar" $ans
131 testouterr_cmd_re "sh" "display sym_bar" "OK" "$disp_3"
132 testouterr_cmd_re "sh" "whatis sym_bar" "OK" "$what_3"
133 test_cmd "sh" "paths sym_bar" $anspa
134 test_cmd "csh" "load sym_bar/special3" $ans
135 testouterr_cmd_re "sh" "display sym_bar/special3" "OK" "$disp_3"
136 testouterr_cmd_re "sh" "whatis sym_bar/special3" "OK" "$what_3"
137 test_cmd "sh" "paths sym_bar/special3" $anspa
138 # check resolution of [module-info command] in a global rc
139 test_cmd "csh" "load sym_bar_load" $ans
140
141 # check resolution of [is-loaded mod] in a global rc
142 test_cmd "csh" "load sym_bar_0" $ans
143 setenv_loaded_module [list $module_2] [list $modulefile_2]
144 set ans [list]
145 lappend ans [list set __MODULES_LMALTNAME $module_3&sym_bar/special3&virt_bar/special3&al|sym_bar&al|sym_bar_load&al|sym_bar_1]
146 lappend ans [list set _LMFILES_ $modulefile_2:$modulefile_3]
147 lappend ans [list set LOADEDMODULES $module_2:$module_3]
148 test_cmd_re "csh" "load sym_bar_1" $ans
149 unsetenv_loaded_module
150
151
152 #
153 # Test erroneous MODULERCFILE file
154 #
155
156 set mp $modpath.3
157 setenv_path_var MODULEPATH $mp
158
159 # user rc file without magic cookie
160 set modrcfile $env(TESTSUITEDIR)/home.3/.modulerc
161 setenv_var MODULERCFILE $modrcfile
162
163 set tserr $err_magic'$modrcfile'\n$err_contact
164 set ans [list]
165 lappend ans [list set _LMFILES_ $mp/bar/1.0]
166 lappend ans [list set LOADEDMODULES bar/1.0]
167 lappend ans [list ERR]
168 testouterr_cmd sh {load bar/1.0} $ans $tserr
169
170 set tserr [escre $tserr]\n$modlin\n[escre $mp]/bar/1.0:\n\nmodule-whatis\tbar/1.0\n$modlin
171 testouterr_cmd_re sh {display bar/1.0} ERR $tserr
172
173 # user rc file with magic cookie specifying an higher module version
174 set modrcfile $env(TESTSUITEDIR)/home.4/.modulerc
175 setenv_var MODULERCFILE $modrcfile
176
177 set tserr [moderr_minverreq $modrcfile 99]
178 set ans [list]
179 lappend ans [list set _LMFILES_ $mp/bar/1.0]
180 lappend ans [list set LOADEDMODULES bar/1.0]
181 lappend ans [list ERR]
182 testouterr_cmd sh {load bar/1.0} $ans $tserr
183
184 set tserr [escre $tserr]\n$modlin\n[escre $mp]/bar/1.0:\n\nmodule-whatis\tbar/1.0\n$modlin
185 testouterr_cmd_re sh {display bar/1.0} ERR $tserr
186
187
188 #
189 # Test multiple files defined in MODULERCFILE
190 #
191
192 setenv_path_var MODULEPATH $modpath.4
193 setenv_var MODULERCFILE $env(TESTSUITEDIR)/etc/modulerc.multi1:$env(TESTSUITEDIR)/etc/modulerc.multi2
194
195 set tserr "foo/1.0 <mytag>
196 foo/2.0
197 foo/9.0
198 foo/alias"
199 testouterr_cmd_re sh {avail -t --starts-with --indepth -o alias:tag foo} OK $tserr
200 testouterr_cmd_re sh {load foo/alias} ERR $err_path'foo/4.0'
201
202 setenv_var MODULERCFILE $env(TESTSUITEDIR)/etc/modulerc.multi2:$env(TESTSUITEDIR)/etc/modulerc.multi1
203 testouterr_cmd_re sh {load foo/alias} ERR $err_path'foo/3.0'
204
205
206 #
207 # Cleanup
208 #
209
210 reset_test_env