X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=test%2Fudev-test.pl;h=258d5c9596f6f1c183ce11b95a11c6f2c12a86f6;hp=ab27c74c6a5d5d103d4c6c76efe6c909972d11e2;hb=50e5de03d16be3e35e65cdf65f552807ad24e996;hpb=ac28b86d631f23b5df74dbeb33e76a2b3f5d88bb diff --git a/test/udev-test.pl b/test/udev-test.pl index ab27c74c6..258d5c959 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -90,6 +90,16 @@ EOF expected => "visor/0" , conf => < "catch device by * - take 2", + subsys => "tty", + devpath => "class/tty/ttyUSB0", + expected => "visor/0" , + conf => < "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" , conf => < "select sysfs attribute by SYSFS{vendor}", + subsys => "block", + devpath => "block/sda", + expected => "disk-IBM-ESXS-sda" , + conf => < "sustitution of sysfs value (%s{file})", + subsys => "block", + devpath => "block/sda", + expected => "disk-IBM-ESXS-sda" , + conf => < "test-0:0:0:0" , conf => < "program with escaped format char (tricky: callout returns format char!)", + subsys => "block", + devpath => "block/sda/sda3", + expected => "escape-3" , + conf => < < "devfs disk naming substitution", - subsys => "block", - devpath => "block/sda", - expected => "lun0/disc" , - conf => < "devfs disk naming substitution", - subsys => "block", - devpath => "block/sda/sda2", - expected => "lun0/part2" , - conf => < "second-0" , conf => < "create all possible partitions", + subsys => "block", + devpath => "block/sda", + expected => "boot_disk15" , + conf => < "sysfs parent hierarchy", + subsys => "tty", + devpath => "class/tty/ttyUSB0", + expected => "visor" , + conf => < "name test with ! in the name", + subsys => "block", + devpath => "block/rd!c0d0", + expected => "rd/c0d0" , + conf => < "name test with ! in the name, but no matching rule", + subsys => "block", + devpath => "block/rd!c0d0", + expected => "rd/c0d0" , + 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"; -print CONF "udev_permissions=\"$perm\"\n"; -close CONF; -foreach my $config (@tests) { - print "TEST: $config->{desc}\n"; +sub run_test { + my ($config, $number) = @_; + + print "TEST $number: $config->{desc}\n"; print "device \'$config->{devpath}\' expecting node \'$config->{expected}\'\n"; udev("add", $config->{subsys}, $config->{devpath}, \$config->{conf}); @@ -392,6 +437,37 @@ foreach my $config (@tests) { } } +# 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"; +print CONF "udev_permissions=\"$perm\"\n"; +close CONF; + +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); +} else { + # test all + print "\nudev-test will run ".($#tests + 1)." tests:\n\n"; + + foreach my $config (@tests) { + run_test($config, $test_num); + $test_num++; + + } +} + print "$error errors occured\n\n"; # cleanup