chiark / gitweb /
[PATCH] The following patch fixes some warnings when compiling volume_id
[elogind.git] / test / udevstart-test.pl
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/";
16 my $udev_bin  = "../udev";
17 my $udev_root = "udev-root/"; # !!! directory will be removed !!!
18 my $udev_db   = ".udevdb";
19 my $main_conf = "udev-test.conf";
20 my $conf_tmp  = "udev-test.rules";
21
22 # set env
23 $ENV{UDEV_TEST} = "yes";
24 $ENV{SYSFS_PATH} = $sysfs;
25 $ENV{UDEV_CONFIG_FILE} = $main_conf;
26 $ENV{UDEV_NO_DEVD} = "yes";
27 $ENV{UDEV_NO_HOTPLUGD} = "yes";
28
29 # due to mknod restrictions
30 if (!($<==0)) {
31         print "Must have root permissions to run properly.\n";
32         exit;
33 }
34
35 # prepare
36 system("rm -rf $udev_root");
37 mkdir($udev_root) || die "unable to create udev_root: $udev_root\n";
38
39 # create initial config file
40 open CONF, ">$main_conf" || die "unable to create config file: $main_conf";
41 print CONF "udev_root=\"$udev_root\"\n";
42 print CONF "udev_db=\"$udev_db\"\n";
43 print CONF "udev_rules=\"$conf_tmp\"\n";
44 close CONF;
45
46 system("$udev_bin udevstart");
47 my $block = int( `find $udev_root -type b -print | wc -l`);
48 my $char  = int( `find $udev_root -type c -print | wc -l`);
49
50 print "block devices: $block/10\n";
51 print "char devices: $char/91\n";
52
53 # cleanup
54 system("rm -rf $udev_db");
55 system("rm -rf $udev_root");
56 unlink($conf_tmp);
57 unlink($main_conf);
58