modindex: getopt_long returns int not char (fix ppc64 bug)
[mit.git] / tests / test-modprobe / 04config.sh
blobcb85422b3db85dc75c64e1695e5f5f1e55c3e327
1 #! /bin/sh
2 # Test configuration file handling.
4 BITNESS=32
6 rm -rf tests/tmp/*
8 # Simple dump out test.
9 touch tests/tmp/empty
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
17 mkdir -p $MODULE_DIR
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
25 # Various aliases
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 \\
47 enable=1 isapnp=0
49 # Install commands
50 install bar echo Installing bar
51 install foo echo Installing foo
52 install export_nodep-$BITNESS echo Installing export_nodep
54 # Remove commands
55 remove bar echo Removing bar
56 remove foo echo Removing foo
57 remove export_nodep-$BITNESS echo Removing export_nodep
58 EOF
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
66 EOF
68 # Create inputs
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 \
74 $MODULE_DIR
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
83 EOF
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 # Test ignoring install & remove.
93 [ "`modprobe --ignore-install export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
94 [ "`modprobe -i export_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_EXPORT_NODEP " ]
95 [ "`modprobe -i foo 2>&1`" = "FATAL: Module foo not found." ]
96 [ "`modprobe -r --ignore-remove export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
97 [ "`modprobe -r -i export_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: export_nodep_$BITNESS EXCL " ]
98 [ "`modprobe -i -r foo 2>&1`" = "FATAL: Module foo not found." ]
100 # Test install & remove (fake modules)
101 [ "`modprobe foo 2>&1`" = "SYSTEM: echo Installing foo" ]
102 [ "`modprobe bar 2>&1`" = "SYSTEM: echo Installing bar" ]
103 [ "`modprobe baz 2>&1`" = "SYSTEM: echo Installing baz" ]
104 [ "`modprobe -r foo 2>&1`" = "SYSTEM: echo Removing foo" ]
105 [ "`modprobe -r bar 2>&1`" = "SYSTEM: echo Removing bar" ]
106 [ "`modprobe -r baz 2>&1`" = "SYSTEM: echo Removing baz" ]
108 # Test install & remove of a what is also a real module.
109 [ "`modprobe export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep" ]
110 [ "`modprobe -r export_nodep-$BITNESS 2>&1`" = "SYSTEM: echo Removing export_nodep" ]
112 # Test install & remove of what is also a real module via dependency.
113 [ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
114 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
115 [ "`modprobe -r noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
116 SYSTEM: echo Removing export_nodep" ]
118 # Test ignoring install & remove: only effects commandline.
119 [ "`modprobe -i noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
120 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
121 [ "`modprobe -r -i noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
122 SYSTEM: echo Removing export_nodep" ]
124 # Test options
125 [ "`modprobe noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep" ]
126 [ "`modprobe noexport_nodep-$BITNESS OPTIONS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep OPTIONS" ]
128 [ "`modprobe noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
129 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep" ]
130 [ "`modprobe noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
131 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep OPTIONS" ]
133 [ "`modprobe export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
134 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep" ]
135 [ "`modprobe export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
136 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep OPTIONS" ]
138 [ "`modprobe noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
139 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
140 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep" ]
141 [ "`modprobe noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
142 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
143 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep OPTIONS" ]
145 # Test aliases doing insertion.
146 [ "`modprobe alias_to_noexport_nodep-$BITNESS 2>&1`" = "INIT_MODULE: $SIZE_NOEXPORT_NODEP I am noexport_nodep I am alias to noexport_nodep" ]
147 [ "`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" ]
149 [ "`modprobe alias_to_noexport_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
150 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep" ]
151 [ "`modprobe alias_to_noexport_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
152 INIT_MODULE: $SIZE_NOEXPORT_DEP I am noexport_dep I am alias to noexport_dep OPTIONS" ]
154 [ "`modprobe alias_to_export_dep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
155 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep" ]
156 [ "`modprobe alias_to_export_dep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
157 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep I am alias to export_dep OPTIONS" ]
159 [ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
160 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
161 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
162 [ "`modprobe alias_to_noexport_doubledep-$BITNESS 2>&1`" = "SYSTEM: echo Installing export_nodep
163 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
164 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep" ]
165 [ "`modprobe alias_to_noexport_doubledep-$BITNESS OPTIONS 2>&1`" = "SYSTEM: echo Installing export_nodep
166 INIT_MODULE: $SIZE_EXPORT_DEP I am export_dep
167 INIT_MODULE: $SIZE_NOEXPORT_DOUBLEDEP I am noexport_doubledep I am alias to noexport_doubledep OPTIONS" ]
169 [ "`modprobe alias_to_foo 2>&1`" = "SYSTEM: echo Installing foo" ]
170 [ "`modprobe alias_to_bar 2>&1`" = "SYSTEM: echo Installing bar" ]
171 [ "`modprobe alias_to_baz 2>&1`" = "SYSTEM: echo Installing baz" ]
173 # Test tab-to-spaces conversion, and \ wrapping.
174 [ "`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" ]
176 # Test aliases doing removal.
177 [ "`modprobe -r alias_to_noexport_nodep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_nodep_$BITNESS EXCL " ]
178 [ "`modprobe -r alias_to_noexport_dep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_dep_$BITNESS EXCL
179 SYSTEM: echo Removing export_nodep" ]
180 [ "`modprobe -r alias_to_export_dep-$BITNESS 2>&1`" = "DELETE_MODULE: export_dep_$BITNESS EXCL
181 SYSTEM: echo Removing export_nodep" ]
182 [ "`modprobe -r alias_to_noexport_doubledep-$BITNESS 2>&1`" = "DELETE_MODULE: noexport_doubledep_$BITNESS EXCL
183 DELETE_MODULE: export_dep_$BITNESS EXCL
184 SYSTEM: echo Removing export_nodep" ]
186 [ "`modprobe -r alias_to_foo 2>&1`" = "SYSTEM: echo Removing foo" ]
187 [ "`modprobe -r alias_to_bar 2>&1`" = "SYSTEM: echo Removing bar" ]
188 [ "`modprobe -r alias_to_baz 2>&1`" = "SYSTEM: echo Removing baz" ]