[Toybox] modinfo test

idunham at lavabit.com idunham at lavabit.com
Thu Jun 13 22:38:22 PDT 2013


Here's a test for modinfo; it expects ne2k-pci and 8390 to be modules.
I chose those as lower-churn modules that are likely for VMs...
If /proc/modules is absent, the test is skipped.

(In the process of writing the tests, I discovered that busybox has some
incompatabilities, like the 1-module limit, not giving a full pathname 
for filename, mis-handling the -/_ mess, and outputting "filename:
<arg>.ko if a module isn't found.)

Additionally, I have a patch for modinfo, which will add support for
multiple modules at virtually no cost.

HTH,
Isaac Dunham
-------------- next part --------------
A non-text attachment was scrubbed...
Name: modinfo.diff
Type: text/x-diff
Size: 848 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20130613/74c15d66/attachment-0006.diff>
-------------- next part --------------
#!/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" "" "" ""





More information about the Toybox mailing list