]>
Commit | Line | Data |
---|---|---|
f22e9686 KS |
1 | #!/usr/bin/perl |
2 | ||
3 | # udevstart-test | |
4 | # | |
5 | # runs udevstart in a temporary directory with our test sysfs-tree | |
6 | # and counts the created nodes to compare it with the expected numbers. | |
7 | # | |
8 | # Kay Sievers <kay.sievers@vrfy.org>, 2005 | |
9 | # | |
10 | ||
11 | use warnings; | |
12 | use strict; | |
13 | ||
14 | my $PWD = $ENV{PWD}; | |
15 | my $sysfs = "sys/"; | |
65005a7f | 16 | my $udevstart_bin = "../udevstart"; |
f22e9686 KS |
17 | my $udev_root = "udev-root/"; # !!! directory will be removed !!! |
18 | my $udev_db = ".udevdb"; | |
65005a7f KS |
19 | my $udev_conf = "udev-test.conf"; |
20 | my $udev_rules = "udev-test.rules"; | |
f22e9686 KS |
21 | |
22 | # set env | |
f22e9686 | 23 | $ENV{SYSFS_PATH} = $sysfs; |
65005a7f | 24 | $ENV{UDEV_CONFIG_FILE} = $udev_conf; |
f22e9686 KS |
25 | |
26 | # due to mknod restrictions | |
27 | if (!($<==0)) { | |
28 | print "Must have root permissions to run properly.\n"; | |
29 | exit; | |
30 | } | |
31 | ||
32 | # prepare | |
33 | system("rm -rf $udev_root"); | |
34 | mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; | |
35 | ||
65005a7f KS |
36 | # create config file |
37 | open CONF, ">$udev_conf" || die "unable to create config file: $udev_conf"; | |
f22e9686 KS |
38 | print CONF "udev_root=\"$udev_root\"\n"; |
39 | print CONF "udev_db=\"$udev_db\"\n"; | |
65005a7f | 40 | print CONF "udev_rules=\"$udev_rules\"\n"; |
f22e9686 KS |
41 | close CONF; |
42 | ||
65005a7f KS |
43 | # create rules file |
44 | open RULES, ">$udev_rules" || die "unable to create rules file: $udev_rules"; | |
45 | print RULES "\n"; | |
46 | close RULES; | |
47 | ||
48 | system("$udevstart_bin"); | |
49 | my $block = int(`find $udev_root -type b -print | wc -l`); | |
50 | my $char = int(`find $udev_root -type c -print | wc -l`); | |
f22e9686 KS |
51 | |
52 | print "block devices: $block/10\n"; | |
53 | print "char devices: $char/91\n"; | |
65005a7f | 54 | print "\n"; |
f22e9686 KS |
55 | |
56 | # cleanup | |
57 | system("rm -rf $udev_db"); | |
58 | system("rm -rf $udev_root"); | |
65005a7f KS |
59 | unlink($udev_rules); |
60 | unlink($udev_conf); | |
f22e9686 | 61 |