X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=test%2Fudev-test.pl;h=d584579584ba2b7bb7606ba2ebaed0d32ba26d93;hb=b1e95455d2683f43f47ea94a7b79af64f0738d36;hp=9feb28a7ba1afc40650b88926bccdb7bd7bd5690;hpb=3db7fa27027110fde92a1b6061fab434fe708e9f;p=elogind.git diff --git a/test/udev-test.pl b/test/udev-test.pl index 9feb28a7b..d58457958 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -30,7 +30,7 @@ my $PWD = $ENV{PWD}; my $sysfs = "sys/"; my $udev_bin = "../udev"; my $udev_root = "udev-root/"; # !!! directory will be removed !!! -my $udev_db = ".udev.tdb"; +my $udev_db = ".udevdb"; my $perm = "udev.permissions"; my $main_conf = "udev-test.conf"; my $conf_tmp = "udev-test.rules"; @@ -253,6 +253,15 @@ BUS="scsi", PROGRAM="/bin/echo -n special-device", RESULT="special--*", NAME="%c BUS="scsi", PROGRAM="/bin/echo -n special-device", RESULT="special-device-", NAME="%c-3-%n" BUS="scsi", PROGRAM="/bin/echo -n special-device", RESULT="special-devic", NAME="%c-4-%n" BUS="scsi", PROGRAM="/bin/echo -n special-device", RESULT="special-*", NAME="%c-%n" +EOF + }, + { + desc => "program result substitution (no argument should be subsystem)", + subsys => "block", + devpath => "/block/sda/sda3", + exp_name => "subsys_block" , + conf => < "permissions tty3:::", + desc => "permissions tty3::: (default mode applied)", subsys => "tty", devpath => "/class/tty/tty3", exp_name => "tty3", - exp_perms => "0:0:0", + exp_perms => "0:0:600", conf => < "4094:89999", conf => < "multiple symlinks with format char", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "symlink2-ttyUSB0", + exp_target => "ttyUSB0", + conf => < "node", conf => < "enumeration char test (single test)", + subsys => "block", + devpath => "/block/sda", + exp_name => "cdrom", + conf => < "enumeration char test sequence (1/5 keep)", + subsys => "block", + devpath => "/block/sda", + exp_name => "cdrom", + option => "keep", + conf => < "enumeration char test sequence 2/5 (keep)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "enum", + option => "keep", + conf => < "enumeration char test sequence 3/5 (keep)", + subsys => "block", + devpath => "/block/sda/sda2", + exp_name => "cdrom1", + option => "keep", + conf => < "enumeration char test sequence 4/5 (keep)", + subsys => "block", + devpath => "/block/sda/sda3", + exp_name => "enum1", + option => "keep", + conf => < "enumeration char test sequence 5/5 (clean)", + subsys => "block", + devpath => "/block/sda/sda4", + exp_name => "cdrom2", + option => "clear", + conf => < "enumeration char test after cleanup (single test)", + subsys => "block", + devpath => "/block/sda", + exp_name => "cdrom", + conf => < "ignore remove event test", + subsys => "block", + devpath => "/block/sda", + exp_name => "node", + exp_error => "yes", + conf => < "ignore remove event test (with all partitions)", + subsys => "block", + devpath => "/block/sda", + exp_name => "node14", + exp_error => "yes", + option => "clear", + conf => < "SUBSYSTEM match test", + subsys => "block", + devpath => "/block/sda", + exp_name => "node", + conf => < "DRIVER match test", + subsys => "block", + devpath => "/block/sda", + exp_name => "node", + conf => <{option}) && $config->{option} eq "keep") { + print "\n\n"; + return; + } + udev("remove", $config->{subsys}, $config->{devpath}, \$config->{conf}); if ((-e "$PWD/$udev_root$config->{exp_name}") || (-l "$PWD/$udev_root$config->{exp_name}")) { @@ -1175,6 +1308,20 @@ sub run_test { } else { print "remove: ok\n\n"; } + + if (defined($config->{option}) && $config->{option} eq "clear") { + system("rm -rf $udev_db"); + system("rm -rf $udev_root"); + mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; + } + +} + +# only run if we have root permissions +# due to mknod restrictions +if (!($<==0)) { + print "Must have root permissions to run properly.\n"; + exit; } # prepare @@ -1194,9 +1341,13 @@ my $test_num = 1; if ($ARGV[0]) { # only run one test $test_num = $ARGV[0]; - print "udev-test will run test number $test_num only\n"; - run_test($tests[$test_num-1], $test_num); + if (defined($tests[$test_num-1]->{desc})) { + print "udev-test will run test number $test_num only:\n\n"; + run_test($tests[$test_num-1], $test_num); + } else { + print "test does not exist.\n"; + } } else { # test all print "\nudev-test will run ".($#tests + 1)." tests:\n\n"; @@ -1204,14 +1355,13 @@ if ($ARGV[0]) { foreach my $config (@tests) { run_test($config, $test_num); $test_num++; - } } print "$error errors occured\n\n"; # cleanup -unlink($udev_db); +system("rm -rf $udev_db"); system("rm -rf $udev_root"); unlink($conf_tmp); unlink($main_conf);