[PATCH 11/14] tests: test depmod 'alternatives' feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Keegan McAllister <keegan@xxxxxxxxxxx>
---
 tests/test-depmod/17alternatives.sh        |   70 +++++++++++++++++++++++++++
 tests/test-depmod/18alternatives-syntax.sh |   72 ++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+), 0 deletions(-)
 create mode 100755 tests/test-depmod/17alternatives.sh
 create mode 100755 tests/test-depmod/18alternatives-syntax.sh

diff --git a/tests/test-depmod/17alternatives.sh b/tests/test-depmod/17alternatives.sh
new file mode 100755
index 0000000..6cf99f4
--- /dev/null
+++ b/tests/test-depmod/17alternatives.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Test that we read alternatives and their config files
+
+for ENDIAN in $TEST_ENDIAN; do
+for BITNESS in $TEST_BITS; do
+
+rm -rf tests/tmp/*
+
+# Create inputs
+# foo.ko depends on bar.ko
+# subdir/foo.ko does not
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+MODULE_DATA=tests/data/$BITNESS$ENDIAN/normal
+mkdir -p $MODULE_DIR/subdir
+cp $MODULE_DATA/export_dep-$BITNESS.ko     $MODULE_DIR/foo.ko
+cp $MODULE_DATA/export_nodep-$BITNESS.ko   $MODULE_DIR/bar.ko
+cp $MODULE_DATA/noexport_nodep-$BITNESS.ko $MODULE_DIR/subdir/foo.ko
+
+# Set up an identical alternate directory tree.
+ALT_MODULE_DIR=tests/tmp/other_lib/modules/$MODTEST_UNAME
+mkdir -p $ALT_MODULE_DIR
+cp -r $MODULE_DIR/* $ALT_MODULE_DIR/
+
+# Make the directory where alternatives are configured.
+ALTS_DIR=tests/tmp/etc/depmod.alternatives
+mkdir -p $ALTS_DIR
+
+# We did not set up the alternative yet, so
+# we should have only one modules.dep file.
+[ "`depmod 2>&1 || echo $?`" = "" ]
+[ -f $MODULE_DIR/modules.dep ]
+[ ! -f $ALT_MODULE_DIR/modules.dep ]
+rm $MODULE_DIR/modules.dep
+
+# Set up the alternative.
+cat > $ALTS_DIR/01alt.conf <<EOF
+moduledir /other_lib/modules
+EOF
+
+# Create a config file but don't use it yet.
+mkdir -p tests/tmp/etc/depmod.d.my-alt
+cat > tests/tmp/etc/depmod.d.my-alt/01test.conf <<EOF
+override foo * subdir
+EOF
+
+# Re-run and check for two identical files.
+[ "`depmod 2>&1 || echo $?`" = "" ]
+[ -f $MODULE_DIR/modules.dep ]
+[ -f $ALT_MODULE_DIR/modules.dep ]
+diff -u $MODULE_DIR/modules.dep $ALT_MODULE_DIR/modules.dep >/dev/null
+
+# Now use the alternate config file.
+cat > $ALTS_DIR/01alt.conf <<EOF
+moduledir /other_lib/modules
+config /etc/depmod.d.my-alt
+EOF
+
+# Re-run with the new config.
+[ "`depmod 2>&1 || echo $?`" = "" ]
+[ -f $MODULE_DIR/modules.dep ]
+[ -f $ALT_MODULE_DIR/modules.dep ]
+
+# Check the files.
+[ "`sort $MODULE_DIR/modules.dep`" = "bar.ko:
+foo.ko: bar.ko" ]
+[ "`sort $ALT_MODULE_DIR/modules.dep`" = "bar.ko:
+subdir/foo.ko:" ]
+
+done
+done
diff --git a/tests/test-depmod/18alternatives-syntax.sh b/tests/test-depmod/18alternatives-syntax.sh
new file mode 100755
index 0000000..7dededb
--- /dev/null
+++ b/tests/test-depmod/18alternatives-syntax.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Test syntax of alternatives files
+
+rm -rf tests/tmp/*
+
+MODULE_DIR=tests/tmp/lib/modules/$MODTEST_UNAME
+mkdir -p $MODULE_DIR
+ALT_MODULE_DIR=tests/tmp/other_lib/modules/$MODTEST_UNAME
+mkdir -p $ALT_MODULE_DIR
+
+# No alternatives dir
+[ "`depmod 2>&1 || echo $?`" = "" ]
+
+# Empty alternatives dir
+ALTS_DIR=tests/tmp/etc/depmod.alternatives
+mkdir -p $ALTS_DIR
+[ "`depmod 2>&1 || echo $?`" = "" ]
+
+ALT_CONF=$ALTS_DIR/01alt.conf
+
+# Well-formed alternative
+cat > $ALT_CONF <<EOF
+moduledir /other_lib/modules
+EOF
+[ "`depmod 2>&1 || echo $?`" = "" ]
+
+# Empty file
+rm $ALT_CONF
+touch $ALT_CONF
+[ "`depmod 2>&1 ||echo $?`" = "WARNING: /etc/depmod.alternatives/01alt.conf line 0: malformed alternatives file" ]
+
+# No moduledir
+cat > $ALT_CONF <<EOF
+config /foo
+EOF
+[ "`depmod 2>&1 || echo $?`" = "WARNING: /etc/depmod.alternatives/01alt.conf line 1: malformed alternatives file" ]
+
+# Bogus command
+cat > $ALT_CONF <<EOF
+moduledir /other_lib/modules
+bogus command
+EOF
+[ "`depmod 2>&1 || echo $?`" = "WARNING: /etc/depmod.alternatives/01alt.conf line 2: malformed alternatives file" ]
+
+# Repeated moduledir
+cat > $ALT_CONF <<EOF
+moduledir /other_lib/modules
+moduledir /other_lib/modules
+EOF
+[ "`depmod 2>&1 || echo $?`" = "WARNING: /etc/depmod.alternatives/01alt.conf line 2: malformed alternatives file" ]
+
+# Repeated config
+cat > $ALT_CONF <<EOF
+config /foo
+moduledir /other_lib/modules
+config /foo
+EOF
+[ "`depmod 2>&1 || echo $?`" = "WARNING: /etc/depmod.alternatives/01alt.conf line 3: malformed alternatives file" ]
+
+# Unreadable file
+echo > $ALT_CONF
+chmod 000 $ALT_CONF
+[ "`depmod 2>&1 || echo $?`" = "FATAL: could not open '/etc/depmod.alternatives/01alt.conf', reason: Permission denied
+1" ]
+rm -f $ALT_CONF
+
+# Broken symlink, no verbose
+ln -s this_file_does_not_exist $ALT_CONF
+[ "`depmod 2>&1 || echo $?`" = "" ]
+
+# Broken symlink, verbose
+[ "`depmod -v 2>&1 || echo $?`" = "WARNING: config file does not actually exist (broken symlink?): /etc/depmod.alternatives/01alt.conf" ]
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux