diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-02-10 18:26:09 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:31:07 -0700 |
commit | f22e9686fd4f8e602e8dc11a4b06765206f26edf (patch) | |
tree | 3d99beeb2bd964051aff5b6f6c6fe7d938b3a479 /test | |
parent | 27753a3cf74f9d665728e0e2c483435b1d72721f (diff) |
[PATCH] udevstart: simplify "dev" file searching
Just stat() the "dev" file in the device directory instead of
opening the directory and iterating over all entries.
Make udevstart work with the settings in with udev.conf so we can
run a test program.
Add a test for udevstart.
Remove changelog stuff from code. We should never start with this
silly thing.
Diffstat (limited to 'test')
-rw-r--r-- | test/udev-test.pl | 8 | ||||
-rw-r--r-- | test/udevstart-test.pl | 58 |
2 files changed, 59 insertions, 7 deletions
diff --git a/test/udev-test.pl b/test/udev-test.pl index 5a519ef13b..992fc0019a 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -14,14 +14,8 @@ # After creation and removal the result is checked against the # expected value and the result is printed. # -# happy testing, # Kay Sievers <kay.sievers@vrfy.org>, 2003 -# -# Modified April 9, 2004 by Leann Ogasawara <ogasawara@osdl.org> -# - expanded @tests array to add more symlinks and permissions tests -# - some of the symlinks tests also test lack of node creation -# - added symlink_test() function -# - moved permissions and major_minor tests into their own functions +# Leann Ogasawara <ogasawara@osdl.org>, 2004 use warnings; use strict; diff --git a/test/udevstart-test.pl b/test/udevstart-test.pl new file mode 100644 index 0000000000..b6f85bb38c --- /dev/null +++ b/test/udevstart-test.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +# udevstart-test +# +# runs udevstart in a temporary directory with our test sysfs-tree +# and counts the created nodes to compare it with the expected numbers. +# +# Kay Sievers <kay.sievers@vrfy.org>, 2005 +# + +use warnings; +use strict; + +my $PWD = $ENV{PWD}; +my $sysfs = "sys/"; +my $udev_bin = "../udev"; +my $udev_root = "udev-root/"; # !!! directory will be removed !!! +my $udev_db = ".udevdb"; +my $main_conf = "udev-test.conf"; +my $conf_tmp = "udev-test.rules"; + +# set env +$ENV{UDEV_TEST} = "yes"; +$ENV{SYSFS_PATH} = $sysfs; +$ENV{UDEV_CONFIG_FILE} = $main_conf; +$ENV{UDEV_NO_DEVD} = "yes"; +$ENV{UDEV_NO_HOTPLUGD} = "yes"; + +# due to mknod restrictions +if (!($<==0)) { + print "Must have root permissions to run properly.\n"; + exit; +} + +# prepare +system("rm -rf $udev_root"); +mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; + +# create initial config file +open CONF, ">$main_conf" || die "unable to create config file: $main_conf"; +print CONF "udev_root=\"$udev_root\"\n"; +print CONF "udev_db=\"$udev_db\"\n"; +print CONF "udev_rules=\"$conf_tmp\"\n"; +close CONF; + +system("$udev_bin udevstart"); +my $block = int( `find $udev_root -type b -print | wc -l`); +my $char = int( `find $udev_root -type c -print | wc -l`); + +print "block devices: $block/10\n"; +print "char devices: $char/91\n"; + +# cleanup +system("rm -rf $udev_db"); +system("rm -rf $udev_root"); +unlink($conf_tmp); +unlink($main_conf); + |