]> git.pld-linux.org Git - projects/geninitrd.git/blob - tests/find-module-by-pciclass.sh
Timeout here is not a good idea. rootfs cannot be mounted and kernel oopses due to...
[projects/geninitrd.git] / tests / find-module-by-pciclass.sh
1 #!/bin/sh
2 # for is_yes
3 . /etc/rc.d/init.d/functions
4
5 . ./setup-test.sh
6 flags=$-
7
8 sysfs=${sysfs:-/sys}
9 have_lspci=yes
10
11 lowercase() {
12         echo "$1" | LC_ALL=C tr '[A-Z]' '[a-z]'
13 }
14
15 find_modules_by_class() {
16         set -$flags
17
18         # XXX: not sure, which to prefer, /sys or lspci
19         if is_yes "$have_lspci"; then
20                 pcimap='modules.pcimap-2.6.33.4-1'
21                 lspci='cat lspci-mod-sata.txt'
22                 local module vendordev
23                 vendordev=$($lspci | awk '/0106/{ gsub(/:/," "); print "0x0000"$4 " " "0x0000"$5}')
24                 module=$(grep "$vendordev" "$pcimap" | awk '{print $1}')
25                 echo $module
26         fi
27
28         local path module class="$1"
29         for path in $(grep -l $class $sysfs/bus/pci/devices/*/class); do
30                 module=$(readlink ${path%/class}/driver)
31                 module=${module##*/}
32                 # 2.6.16 (at least) has this uppercased, workaround
33                 lowercase $module
34         done
35 }
36
37
38 find_modules_sata() {
39         set -$flags
40
41         find_modules_by_class 0x0101
42 }
43
44 find_modules_xata() {
45         set -$flags
46
47         find_modules_by_class 0x0106
48 }
49
50 runtest_run() {
51         have_lspci=no sysfs=sysfs find_modules_sata
52 }
53 runtest <<'EOF'
54 ata_piix
55 ata_piix
56 EOF
57
58 runtest_run() {
59         have_lspci=yes find_modules_xata
60 }
61 runtest <<'EOF'
62 ahci
63 EOF
64
65 echo "OK: $ok; FAIL: $fail"
This page took 0.12751 seconds and 3 git commands to generate.