1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7[ -e /proc/modules ] || { echo "Skipping test because modules are not supported"; exit 1; }
8
9# modinfo does not need to output fields in a specified order.
10# Instead, there are labelled fields.  We can use sort to make up for this.
11# Other issues to beware of are the volatile nature of srcversion and vermagic,
12# which change from kernel to kernel and can be disabled.
13# We grep to remove these.
14
15#We expect they have ne2k-pci as a module.
16
17testing "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" "" ""
18testing "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" "" ""
19
20# Output of -F filename should be an absolute path to the module.
21# Otherwise, initrd generating scripts will break.
22
23testing "modinfo -F filename gets absolute path" "[ -e `modinfo -F filename ne2k-pci` ] && echo ne2k-pci " "ne2k-pci\n" "" ""
24
25testing "modinfo supports multiple modules" "modinfo -F filename ne2k-pci 8390 | wc -l" "2\n" "" ""
26
27testing "modinfo does not output filename for bad module" "modinfo -F filename zxcvbnm__9753" "" "" ""
28
29
30
31