2 # Test configuration file handling.
8 # Simple dump out test.
10 [ "`modprobe -C /empty -c 2>&1`" = "" ]
11 [ "`modprobe --config /empty --showconfig 2>&1`" = "" ]
13 # Explicitly mentioned config files must exist.
14 [ "`modprobe -C FILE-WHICH-DOESNT-EXIST foo 2>&1`" = "FATAL: Failed to open config file FILE-WHICH-DOESNT-EXIST: No such file or directory" ]
16 MODULE_DIR
=tests
/tmp
/lib
/modules
/$MODTEST_UNAME
18 touch $MODULE_DIR/modules.dep
20 [ "`modprobe foo 2>&1`" = "FATAL: Module foo not found." ]
22 # Create a simple config file.
23 mkdir
-p tests
/tmp
/etc
/modprobe.d
24 cat > tests
/tmp
/etc
/modprobe.d
/modprobe.conf
<<EOF
26 alias alias_to_foo foo
27 alias alias_to_bar bar
28 alias alias_to_export_dep-$BITNESS export_dep-$BITNESS
29 alias alias_to_noexport_dep-$BITNESS noexport_dep-$BITNESS
30 alias alias_to_noexport_nodep-$BITNESS noexport_nodep-$BITNESS
31 alias alias_to_noexport_doubledep-$BITNESS noexport_doubledep-$BITNESS
32 alias alias_to_noexport_nodep-$BITNESS_with_tabbed_options noexport_nodep-$BITNESS
34 # Various options, including options to aliases.
35 options alias_to_export_dep-$BITNESS I am alias to export_dep
36 options export_dep-$BITNESS I am export_dep
37 options alias_to_noexport_dep-$BITNESS I am alias to noexport_dep
38 options noexport_dep-$BITNESS I am noexport_dep
39 options alias_to_noexport_nodep-$BITNESS I am alias to noexport_nodep
40 options noexport_nodep-$BITNESS I am noexport_nodep
41 options alias_to_noexport_doubledep-$BITNESS I am alias to noexport_doubledep
42 options noexport_doubledep-$BITNESS I am noexport_doubledep
43 options alias_to_noexport_nodep-$BITNESS_with_tabbed_options index=0 id="Thinkpad" isapnp=0 \\
44 port=0x530 cport=0x538 fm_port=0x388 \\
45 mpu_port=-1 mpu_irq=-1 \\
46 irq=9 dma1=1 dma2=3 \\
50 install bar echo Installing bar
51 install foo echo Installing foo
52 install export_nodep-$BITNESS echo Installing export_nodep
55 remove bar echo Removing bar
56 remove foo echo Removing foo
57 remove export_nodep-$BITNESS echo Removing export_nodep
60 # Now create a second file
61 cat > tests
/tmp
/etc
/modprobe.d
/modprobe-include.conf
<<EOF
62 install baz echo Installing baz
63 remove baz echo Removing baz
65 alias alias_to_baz baz
69 ln tests
/data
/$BITNESS/normal
/export_dep-
$BITNESS.ko \
70 tests
/data
/$BITNESS/normal
/noexport_dep-
$BITNESS.ko \
71 tests
/data
/$BITNESS/normal
/export_nodep-
$BITNESS.ko \
72 tests
/data
/$BITNESS/normal
/noexport_nodep-
$BITNESS.ko \
73 tests
/data
/$BITNESS/normal
/noexport_doubledep-
$BITNESS.ko \
76 # Now create modules.dep
77 cat > $MODULE_DIR/modules.dep
<<EOF
78 noexport_nodep-$BITNESS.ko:
79 noexport_doubledep-$BITNESS.ko: export_dep-$BITNESS.ko export_nodep-$BITNESS.ko
80 noexport_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
81 export_nodep-$BITNESS.ko:
82 export_dep-$BITNESS.ko: export_nodep-$BITNESS.ko
85 SIZE_NOEXPORT_NODEP
=`wc -c < tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko`
86 SIZE_EXPORT_NODEP
=`wc -c < tests/data/$BITNESS/normal/export_nodep-$BITNESS.ko`
87 SIZE_NOEXPORT_DEP
=`wc -c < tests/data/$BITNESS/normal/noexport_dep-$BITNESS.ko`
88 SIZE_EXPORT_DEP
=`wc -c < tests/data/$BITNESS/normal/export_dep-$BITNESS.ko`
89 SIZE_NOEXPORT_DOUBLEDEP
=`wc -c < tests/data/$BITNESS/normal/noexport_doubledep-$BITNESS.ko`
91 # Empty /sys/module/ for install commands
92 mkdir
-p tests
/tmp
/sys
/module
94 # Test ignoring install commands
95 [ "`modprobe --ignore-install export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
96 [ "`modprobe -i export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
97 [ "`modprobe -i foo 2>&1`" = "FATAL: Module foo not found." ]
99 # Test install commands (fake modules)
100 [ "`modprobe foo 2>&1`" = "SYSTEM: echo Installing foo" ]
101 [ "`modprobe bar 2>&1`" = "SYSTEM: echo Installing bar" ]
102 [ "`modprobe baz 2>&1`" = "SYSTEM: echo Installing baz" ]
104 # Test install of a what is also a real module.
105 [ "`modprobe export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep" ]
107 # Test install of what is also a real module via dependency.
108 [ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
109 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
111 # Test ignoring install commands: only effects commandline.
112 [ "`modprobe -i noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
113 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
116 [ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep" ]
117 [ "`modprobe noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep OPTIONS" ]
119 [ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
120 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
121 [ "`modprobe noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
122 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep OPTIONS" ]
124 [ "`modprobe export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
125 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep" ]
126 [ "`modprobe export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
127 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep OPTIONS" ]
129 [ "`modprobe noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
130 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
131 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep" ]
132 [ "`modprobe noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
133 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
134 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep OPTIONS" ]
136 # Test aliases doing insertion.
137 [ "`modprobe alias_to_noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep" ]
138 [ "`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" ]
140 [ "`modprobe alias_to_noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
141 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep" ]
142 [ "`modprobe alias_to_noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
143 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep OPTIONS" ]
145 [ "`modprobe alias_to_export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
146 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep" ]
147 [ "`modprobe alias_to_export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
148 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep OPTIONS" ]
150 [ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
151 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
152 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
153 [ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
154 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
155 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
156 [ "`modprobe alias_to_noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
157 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
158 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep OPTIONS" ]
160 [ "`modprobe alias_to_foo 2>&1`" = "SYSTEM: echo Installing foo" ]
161 [ "`modprobe alias_to_bar 2>&1`" = "SYSTEM: echo Installing bar" ]
162 [ "`modprobe alias_to_baz 2>&1`" = "SYSTEM: echo Installing baz" ]
164 # Test tab-to-spaces conversion, and \ wrapping.
165 [ "`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" ]
167 # Populate /sys/module/ for remove commands
168 mkdir
-p tests
/tmp
/sys
/module
/noexport_nodep_
$BITNESS
169 mkdir
-p tests
/tmp
/sys
/module
/noexport_dep_
$BITNESS
170 mkdir
-p tests
/tmp
/sys
/module
/noexport_doubledep_
$BITNESS
171 mkdir
-p tests
/tmp
/sys
/module
/export_nodep_
$BITNESS
172 mkdir
-p tests
/tmp
/sys
/module
/export_dep_
$BITNESS
173 echo live
> tests
/tmp
/sys
/module
/noexport_nodep_
$BITNESS/initstate
174 echo live
> tests
/tmp
/sys
/module
/noexport_dep_
$BITNESS/initstate
175 echo live
> tests
/tmp
/sys
/module
/noexport_doubledep_
$BITNESS/initstate
176 echo live
> tests
/tmp
/sys
/module
/export_nodep_
$BITNESS/initstate
177 echo live
> tests
/tmp
/sys
/module
/export_dep_
$BITNESS/initstate
179 # Test ignoring remove commands.
180 [ "`modprobe -r --ignore-remove export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
181 [ "`modprobe -r -i export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
182 [ "`modprobe -i -r foo 2>&1`" = "FATAL: Module foo not found." ]
184 # Test remove commands (fake modules)
185 [ "`modprobe -r foo 2>&1`" = "SYSTEM: echo Removing foo" ]
186 [ "`modprobe -r bar 2>&1`" = "SYSTEM: echo Removing bar" ]
187 [ "`modprobe -r baz 2>&1`" = "SYSTEM: echo Removing baz" ]
189 # Test remove of a what is also a real module.
190 [ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Removing export_nodep" ]
192 # Test remove of what is also a real module via dependency.
193 [ "`modprobe -r noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
194 SYSTEM: echo Removing export_nodep" ]
196 # Test ignoring remove commands: only effects commandline.
197 [ "`modprobe -r -i noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
198 SYSTEM: echo Removing export_nodep" ]
200 # Test aliases doing removal.
201 [ "`modprobe -r alias_to_noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
202 [ "`modprobe -r alias_to_noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
203 SYSTEM: echo Removing export_nodep" ]
204 [ "`modprobe -r alias_to_export_dep-$BITNESS 2>&1`" = "DELETE_MODULE: export_dep_$BITNESS EXCL
205 SYSTEM: echo Removing export_nodep" ]
206 [ "`modprobe -r alias_to_noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_doubledep_$BITNESS EXCL
207 DELETE_MODULE: export_dep_$BITNESS EXCL
208 SYSTEM: echo Removing export_nodep" ]
210 [ "`modprobe -r alias_to_foo 2>&1`" = "SYSTEM: echo Removing foo" ]
211 [ "`modprobe -r alias_to_bar 2>&1`" = "SYSTEM: echo Removing bar" ]
212 [ "`modprobe -r alias_to_baz 2>&1`" = "SYSTEM: echo Removing baz" ]
214 # Now test install precaution in the absence of /sys/modules
215 rm -r tests
/tmp
/sys
/module
217 # Test install and remove commands (fake modules)
218 # No caution necessary here
219 [ "`modprobe foo 2>&1`" = "SYSTEM: echo Installing foo" ]
220 [ "`modprobe -r foo 2>&1`" = "SYSTEM: echo Removing foo" ]
222 # Test install and remove of a what is also a real module.
223 [ "`modprobe export_nodep-$BITNESS 2>&1`" = "WARNING: /sys/module/ not present or too old, and /proc/modules does not exist.
224 WARNING: Ignoring install commands for export_nodep_$BITNESS in case it is already loaded.
225 INIT_MODULE: $SIZE_EXPORT_NODEP " ]
226 [ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "WARNING: /sys/module/ not present or too old, and /proc/modules does not exist.
227 WARNING: Ignoring remove commands for export_nodep_$BITNESS in case it is not loaded.
228 DELETE_MODULE: export_nodep_32 EXCL " ]