aboutsummaryrefslogtreecommitdiff
path: root/scripts/test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-06-16 02:23:59 -0500
committerRob Landley <rob@landley.net>2013-06-16 02:23:59 -0500
commit5b2510562c26fbb41dd0f93326e4eb3f4f349b50 (patch)
tree37b40c14039ba3bdb6c4446980610c4041dac225 /scripts/test
parentbc9cfe08cfa2c47b2d106eda7b5d0ecc73f47238 (diff)
downloadtoybox-5b2510562c26fbb41dd0f93326e4eb3f4f349b50.tar.gz
Upgrade modinfo to support multiple modules, and add tests, from Isaac Dunham.
Diffstat (limited to 'scripts/test')
-rwxr-xr-xscripts/test/modinfo.test30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/test/modinfo.test b/scripts/test/modinfo.test
new file mode 100755
index 00000000..ac94ce0f
--- /dev/null
+++ b/scripts/test/modinfo.test
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+[ -e /proc/modules ] || { echo "Skipping test because modules are not supported"; exit 1; }
+
+# modinfo does not need to output fields in a specified order.
+# Instead, there are labelled fields. We can use sort to make up for this.
+# Other issues to beware of are the volatile nature of srcversion and vermagic,
+# which change from kernel to kernel and can be disabled.
+# We grep to remove these.
+
+#We expect they have ne2k-pci as a module.
+
+testing "modinfo gets right number of fields" "modinfo ne2k-pci |cut -d: -f1 |grep -v ver|sort" "alias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nauthor\ndepends\ndescription\nfilename\nlicense\nparm\nparm\nparm\n" "" ""
+testing "modinfo treats - and _ as equivalent" "modinfo ne2k_pci |cut -d: -f1 |grep -v ver|sort" "alias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nauthor\ndepends\ndescription\nfilename\nlicense\nparm\nparm\nparm\n" "" ""
+
+# Output of -F filename should be an absolute path to the module.
+# Otherwise, initrd generating scripts will break.
+
+testing "modinfo -F filename gets absolute path" "[ -e `modinfo -F filename ne2k-pci` ] && echo ne2k-pci " "ne2k-pci\n" "" ""
+
+testing "modinfo supports multiple modules" "modinfo -F filename ne2k-pci 8390 | wc -l" "2\n" "" ""
+
+testing "modinfo does not output filename for bad module" "modinfo -F filename zxcvbnm__9753" "" "" ""
+
+
+