testsuite: update for order change to option parsing
[mit.git] / tests / test-modprobe / 04config.sh
blob0433a96e8afd469b523152717d92359bae94d69c
1 #! /bin/sh
2 # Test configuration file handling.
4 for BITNESS in 32 64; do
6 # Simple dump out test.
7 [ "`./modprobe -C /dev/null -c 2>&1`" = "" ]
8 [ "`./modprobe --config /dev/null --showconfig 2>&1`" = "" ]
10 # Explicitly mentioned config files must exist.
11 [ "`./modprobe -C FILE-WHICH-DOESNT-EXIST foo 2>&1`" = "FATAL: Failed to open config file FILE-WHICH-DOESNT-EXIST: No such file or directory" ]
13 # Default one doesn't have to.
14 MODTEST_OVERRIDE1=/lib/modules/$MODTEST_UNAME/modules.dep
15 MODTEST_OVERRIDE_WITH1=/dev/null
16 export MODTEST_OVERRIDE1 MODTEST_OVERRIDE_WITH1
18 MODTEST_OVERRIDE2=/etc/modprobe.conf
19 MODTEST_OVERRIDE_WITH2=FILE-WHICH-DOESNT-EXIST:
20 export MODTEST_OVERRIDE2 MODTEST_OVERRIDE_WITH2
22 MODTEST_OVERRIDE3=/lib/modules/$MODTEST_UNAME/modules.dep.bin
23 MODTEST_OVERRIDE_WITH3=FILE-WHICH-DOESNT-EXIST
24 export MODTEST_OVERRIDE3 MODTEST_OVERRIDE_WITH3
25 [ "`./modprobe foo 2>&1`" = "FATAL: Module foo not found." ]
27 # Create a simple config file.
28 cat > tests/tmp/modprobe.conf <<EOF
29 # Various aliases
30 alias alias_to_foo foo
31 alias alias_to_bar bar
32 alias alias_to_export_dep-$BITNESS export_dep-$BITNESS
33 alias alias_to_noexport_dep-$BITNESS noexport_dep-$BITNESS
34 alias alias_to_noexport_nodep-$BITNESS noexport_nodep-$BITNESS
35 alias alias_to_noexport_doubledep-$BITNESS noexport_doubledep-$BITNESS
36 alias alias_to_noexport_nodep-$BITNESS_with_tabbed_options noexport_nodep-$BITNESS
38 # Various options, including options to aliases.
39 options alias_to_export_dep-$BITNESS I am alias to export_dep
40 options export_dep-$BITNESS I am export_dep
41 options alias_to_noexport_dep-$BITNESS I am alias to noexport_dep
42 options noexport_dep-$BITNESS I am noexport_dep
43 options alias_to_noexport_nodep-$BITNESS I am alias to noexport_nodep
44 options noexport_nodep-$BITNESS I am noexport_nodep
45 options alias_to_noexport_doubledep-$BITNESS I am alias to noexport_doubledep
46 options noexport_doubledep-$BITNESS I am noexport_doubledep
47 options alias_to_noexport_nodep-$BITNESS_with_tabbed_options index=0 id="Thinkpad" isapnp=0 \\
48 port=0x530 cport=0x538 fm_port=0x388 \\
49 mpu_port=-1 mpu_irq=-1 \\
50 irq=9 dma1=1 dma2=3 \\
51 enable=1 isapnp=0
53 # Install commands
54 install bar echo Installing bar
55 install foo echo Installing foo
56 install export_nodep-$BITNESS echo Installing export_nodep
58 # Remove commands
59 remove bar echo Removing bar
60 remove foo echo Removing foo
61 remove export_nodep-$BITNESS echo Removing export_nodep
63 # Finally, an include
64 include tests/tmp/modprobe.conf.included
65 EOF
67 # Now create this included file
68 cat > tests/tmp/modprobe.conf.included <<EOF
69 install baz echo Installing baz
70 remove baz echo Removing baz
72 alias alias_to_baz baz
73 EOF
75 # Inputs
76 MODTEST_OVERRIDE1=/lib/modules/$MODTEST_UNAME
77 MODTEST_OVERRIDE_WITH1=tests/data/$BITNESS/normal
78 export MODTEST_OVERRIDE1 MODTEST_OVERRIDE_WITH1
80 MODTEST_OVERRIDE2=/lib/modules/$MODTEST_UNAME/export_dep-$BITNESS.ko
81 MODTEST_OVERRIDE_WITH2=tests/data/$BITNESS/normal/export_dep-$BITNESS.ko
82 export MODTEST_OVERRIDE2 MODTEST_OVERRIDE_WITH2
84 MODTEST_OVERRIDE3=/lib/modules/$MODTEST_UNAME/noexport_dep-$BITNESS.ko
85 MODTEST_OVERRIDE_WITH3=tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko
86 export MODTEST_OVERRIDE3 MODTEST_OVERRIDE_WITH3
88 MODTEST_OVERRIDE4=/lib/modules/$MODTEST_UNAME/noexport_nodep-$BITNESS.ko
89 MODTEST_OVERRIDE_WITH4=tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko
90 export MODTEST_OVERRIDE4 MODTEST_OVERRIDE_WITH4
92 MODTEST_OVERRIDE5=/lib/modules/$MODTEST_UNAME/export_nodep-$BITNESS.ko
93 MODTEST_OVERRIDE_WITH5=tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko
94 export MODTEST_OVERRIDE5 MODTEST_OVERRIDE_WITH5
96 MODTEST_OVERRIDE6=/lib/modules/$MODTEST_UNAME/noexport_doubledep-$BITNESS.ko
97 MODTEST_OVERRIDE_WITH6=tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko
98 export MODTEST_OVERRIDE6 MODTEST_OVERRIDE_WITH6
100 MODTEST_OVERRIDE7=/lib/modules/$MODTEST_UNAME/modules.dep
101 MODTEST_OVERRIDE_WITH7=tests/tmp/modules.dep
102 export MODTEST_OVERRIDE7 MODTEST_OVERRIDE_WITH7
104 MODTEST_OVERRIDE8=/etc/modprobe.conf
105 MODTEST_OVERRIDE_WITH8=tests/tmp/modprobe.conf
106 export MODTEST_OVERRIDE8 MODTEST_OVERRIDE_WITH8
108 MODTEST_OVERRIDE9=/etc/modprobe.conf.included
109 MODTEST_OVERRIDE_WITH9=tests/tmp/modprobe.conf.included
110 export MODTEST_OVERRIDE9 MODTEST_OVERRIDE_WITH9
112 MODTEST_OVERRIDE10=/lib/modules/$MODTEST_UNAME/modules.dep.bin
113 MODTEST_OVERRIDE_WITH10=FILE-WHICH-DOESNT-EXIST
114 export MODTEST_OVERRIDE10 MODTEST_OVERRIDE_WITH10
116 MODTEST_OVERRIDE11=/sys/module/noexport_nodep_$BITNESS
117 MODTEST_OVERRIDE_WITH11=tests/tmp/sys/module/noexport_nodep_$BITNESS
118 export MODTEST_OVERRIDE11 MODTEST_OVERRIDE_WITH11
120 MODTEST_OVERRIDE12=/sys/module/noexport_nodep_$BITNESS/initstate
121 MODTEST_OVERRIDE_WITH12=tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
122 export MODTEST_OVERRIDE12 MODTEST_OVERRIDE_WITH12
124 MODTEST_OVERRIDE13=/sys/module/noexport_dep_$BITNESS
125 MODTEST_OVERRIDE_WITH13=tests/tmp/sys/module/noexport_dep_$BITNESS
126 export MODTEST_OVERRIDE13 MODTEST_OVERRIDE_WITH13
128 MODTEST_OVERRIDE14=/sys/module/noexport_dep_$BITNESS/initstate
129 MODTEST_OVERRIDE_WITH14=tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
130 export MODTEST_OVERRIDE14 MODTEST_OVERRIDE_WITH14
132 MODTEST_OVERRIDE15=/sys/module/export_nodep_$BITNESS
133 MODTEST_OVERRIDE_WITH15=tests/tmp/sys/module/export_nodep_$BITNESS
134 export MODTEST_OVERRIDE15 MODTEST_OVERRIDE_WITH15
136 MODTEST_OVERRIDE16=/sys/module/export_nodep_$BITNESS/initstate
137 MODTEST_OVERRIDE_WITH16=tests/tmp/sys/module/export_nodep_$BITNESS/initstate
138 export MODTEST_OVERRIDE16 MODTEST_OVERRIDE_WITH16
140 MODTEST_OVERRIDE17=/sys/module/export_dep_$BITNESS
141 MODTEST_OVERRIDE_WITH17=tests/tmp/sys/module/export_dep_$BITNESS
142 export MODTEST_OVERRIDE17 MODTEST_OVERRIDE_WITH17
144 MODTEST_OVERRIDE18=/sys/module/export_dep_$BITNESS/initstate
145 MODTEST_OVERRIDE_WITH18=tests/tmp/sys/module/export_dep_$BITNESS/initstate
146 export MODTEST_OVERRIDE18 MODTEST_OVERRIDE_WITH18
148 MODTEST_OVERRIDE19=/sys/module/noexport_doubledep_$BITNESS
149 MODTEST_OVERRIDE_WITH19=tests/tmp/sys/module/noexport_doubledep_$BITNESS
150 export MODTEST_OVERRIDE19 MODTEST_OVERRIDE_WITH19
152 MODTEST_OVERRIDE20=/sys/module/noexport_doubledep_$BITNESS/initstate
153 MODTEST_OVERRIDE_WITH20=tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
154 export MODTEST_OVERRIDE20 MODTEST_OVERRIDE_WITH20
156 # Now create modules.dep
157 cat > tests/tmp/modules.dep <<EOF
158 noexport_nodep-$BITNESS.ko:
159 noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
160 noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
161 export_nodep-$BITNESS.ko:
162 export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
165 # Now make a fake /sys/module structure for the test
166 mkdir -p tests/tmp/sys/module
167 mkdir -p tests/tmp/sys/module/noexport_nodep_$BITNESS
168 mkdir -p tests/tmp/sys/module/noexport_dep_$BITNESS
169 mkdir -p tests/tmp/sys/module/export_nodep_$BITNESS
170 mkdir -p tests/tmp/sys/module/export_dep_$BITNESS
171 mkdir -p tests/tmp/sys/module/noexport_doubledep_$BITNESS
172 touch tests/tmp/sys/module/noexport_nodep_$BITNESS/initstate
173 touch tests/tmp/sys/module/noexport_dep_$BITNESS/initstate
174 touch tests/tmp/sys/module/export_nodep_$BITNESS/initstate
175 touch tests/tmp/sys/module/export_dep_$BITNESS/initstate
176 touch tests/tmp/sys/module/noexport_doubledep_$BITNESS/initstate
178 SIZE_NOEXPORT_NODEP=$(echo `wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`)
179 SIZE_EXPORT_NODEP=$(echo `wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`)
180 SIZE_NOEXPORT_DEP=$(echo `wc -c < tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko`)
181 SIZE_EXPORT_DEP=$(echo `wc -c < tests/data/$BITNESS/normal/export_dep-$BITNESS.ko`)
182 SIZE_NOEXPORT_DOUBLEDEP=$(echo `wc -c < tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko`)
184 # Test ignoring install & remove.
186 [ "`./modprobe --ignore-install export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
187 [ "`./modprobe -i export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
188 [ "`./modprobe -i foo 2>&1`" = "FATAL: Module foo not found." ]
189 [ "`./modprobe -r --ignore-remove export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
190 [ "`./modprobe -r -i export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
191 [ "`./modprobe -i -r foo 2>&1`" = "FATAL: Module foo not found." ]
193 # Test install & remove (fake modules)
194 [ "`./modprobe foo 2>&1`" = "SYSTEM: echo Installing foo" ]
195 [ "`./modprobe bar 2>&1`" = "SYSTEM: echo Installing bar" ]
196 [ "`./modprobe baz 2>&1`" = "SYSTEM: echo Installing baz" ]
197 [ "`./modprobe -r foo 2>&1`" = "SYSTEM: echo Removing foo" ]
198 [ "`./modprobe -r bar 2>&1`" = "SYSTEM: echo Removing bar" ]
199 [ "`./modprobe -r baz 2>&1`" = "SYSTEM: echo Removing baz" ]
201 # Test install & remove of a what is also a real module.
202 [ "`./modprobe export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep" ]
203 [ "`./modprobe -r export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Removing export_nodep" ]
205 # Test install & remove of what is also a real module via dependency.
206 [ "`./modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
207 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
208 [ "`./modprobe -r noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
209 SYSTEM: echo Removing export_nodep" ]
211 # Test ignoring install & remove: only effects commandline.
212 [ "`./modprobe -i noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
213 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
214 [ "`./modprobe -r -i noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
215 SYSTEM: echo Removing export_nodep" ]
217 # Test options
218 [ "`./modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep" ]
219 [ "`./modprobe noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep OPTIONS" ]
221 [ "`./modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
222 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
223 [ "`./modprobe noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
224 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep OPTIONS" ]
226 [ "`./modprobe export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
227 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep" ]
228 [ "`./modprobe export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
229 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep OPTIONS" ]
231 [ "`./modprobe noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
232 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
233 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep" ]
234 [ "`./modprobe noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
235 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
236 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep OPTIONS" ]
238 # Test aliases doing insertion.
239 [ "`./modprobe alias_to_noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep" ]
240 [ "`./modprobe alias_to_noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep OPTIONS" ]
242 [ "`./modprobe alias_to_noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
243 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep" ]
244 [ "`./modprobe alias_to_noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
245 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep OPTIONS" ]
247 [ "`./modprobe alias_to_export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
248 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep" ]
249 [ "`./modprobe alias_to_export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
250 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep OPTIONS" ]
252 [ "`./modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
253 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
254 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
255 [ "`./modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
256 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
257 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
258 [ "`./modprobe alias_to_noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
259 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
260 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep OPTIONS" ]
262 [ "`./modprobe alias_to_foo 2>&1`" = "SYSTEM: echo Installing foo" ]
263 [ "`./modprobe alias_to_bar 2>&1`" = "SYSTEM: echo Installing bar" ]
264 [ "`./modprobe alias_to_baz 2>&1`" = "SYSTEM: echo Installing baz" ]
266 # Test tab-to-spaces conversion, and \ wrapping.
267 [ "`./modprobe alias_to_noexport_nodep-$BITNESS_with_tabbed_options 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep index=0 id=\"Thinkpad\" isapnp=0 port=0x530 cport=0x538 fm_port=0x388 mpu_port=-1 mpu_irq=-1 irq=9 dma1=1 dma2=3 enable=1 isapnp=0" ]
269 # Test aliases doing removal.
270 [ "`./modprobe -r alias_to_noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
271 [ "`./modprobe -r alias_to_noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
272 SYSTEM: echo Removing export_nodep" ]
273 [ "`./modprobe -r alias_to_export_dep-$BITNESS 2>&1`" = "DELETE_MODULE: export_dep_$BITNESS EXCL
274 SYSTEM: echo Removing export_nodep" ]
275 [ "`./modprobe -r alias_to_noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_doubledep_$BITNESS EXCL
276 DELETE_MODULE: export_dep_$BITNESS EXCL
277 SYSTEM: echo Removing export_nodep" ]
279 [ "`./modprobe -r alias_to_foo 2>&1`" = "SYSTEM: echo Removing foo" ]
280 [ "`./modprobe -r alias_to_bar 2>&1`" = "SYSTEM: echo Removing bar" ]
281 [ "`./modprobe -r alias_to_baz 2>&1`" = "SYSTEM: echo Removing baz" ]
283 done