depmod: export static device node information to modules.devname
[mit.git] / tests / test-modprobe / 28softdep.sh
blob234a214aca38e22e0e6e87fb7167c3f319f46155
1 #! /bin/sh
3 BITNESS=32
5 rm -rf tests/tmp/*
7 MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
9 # Set up modules
10 mkdir -p $MODULE_DIR
11 ln tests/data/$BITNESS/normal/noexport_nodep-$BITNESS.ko $MODULE_DIR/a.ko
12 ln -s a.ko $MODULE_DIR/b.ko
13 ln -s a.ko $MODULE_DIR/c.ko
14 ln -s a.ko $MODULE_DIR/d.ko
15 ln -s a.ko $MODULE_DIR/e.ko
16 ln -s a.ko $MODULE_DIR/f.ko
18 # Set up dependencies
19 cat > $MODULE_DIR/modules.dep << EOF
20 /lib/modules/$MODTEST_UNAME/a.ko:
21 /lib/modules/$MODTEST_UNAME/b.ko:
22 /lib/modules/$MODTEST_UNAME/c.ko:
23 /lib/modules/$MODTEST_UNAME/d.ko:
24 /lib/modules/$MODTEST_UNAME/e.ko:
25 /lib/modules/$MODTEST_UNAME/f.ko:
26 EOF
28 # Test softdeps
30 mkdir -p tests/tmp/etc/modprobe.d
31 cat > tests/tmp/etc/modprobe.d/modprobe.conf << EOF
32 alias a_alias a
33 alias c_alias c
34 softdep c pre: a_alias b post: d e
35 softdep e post: f
36 softdep f pre: a
37 EOF
39 # Insert-test
41 R1=`modprobe -v c_alias 2>&1 | \
42 grep -v INIT_MODULE\: | \
43 sed -e "s/\/lib\/modules\/$MODTEST_UNAME\///g"`
44 R2=`echo $R1` # remove newlines
45 [ "$R2" = "insmod a.ko insmod b.ko insmod c.ko insmod d.ko insmod e.ko insmod a.ko insmod f.ko" ]
47 # Remove-test
49 R1=`modprobe -v -r c_alias 2>&1 | \
50 grep -v DELETE_MODULE\: | \
51 sed -e "s/\/lib\/modules\/$MODTEST_UNAME\///g"`
52 R2=`echo $R1` # remove newlines
53 [ "$R2" = "rmmod f.ko rmmod a.ko rmmod e.ko rmmod d.ko rmmod c.ko rmmod b.ko rmmod a.ko" ]
55 # Test loop detector
57 mkdir -p tests/tmp/etc/modprobe.d
58 cat > tests/tmp/etc/modprobe.d/modprobe.conf << EOF
59 alias a_alias a
60 softdep a pre: b
61 softdep b pre: a
62 EOF
64 R1=`modprobe -v a_alias 2>&1 | cat` # shell won't assign to R1 without no-op cat.
65 # This comparison will fail if MAX_RECURSION is odd. In that case: s/b/a/g
66 [ "$R1" = "FATAL: modprobe: softdep dependency loop encountered inserting b" ]