X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=test%2Fudev-test.pl;h=63715ac093d77f742c4a01593ccd7195ecf87a6f;hp=ed94629dd1a5437d9b6c413d5f145c215eb32ca6;hb=d4ae9925eecf6df33ca5bc4d285bdc71f9274952;hpb=98bbc835f584ed6792e895519326cc637f64f411 diff --git a/test/udev-test.pl b/test/udev-test.pl old mode 100644 new mode 100755 index ed94629dd..63715ac09 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -24,7 +24,6 @@ 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 $udev_conf = "udev-test.conf"; my $udev_rules = "udev-test.rules"; @@ -232,7 +231,7 @@ KERNEL=="ttyUSB0", NAME="sub/direct/ory/visor" EOF }, { - desc => "place on bus of scsi partition", + desc => "parent device name match of scsi partition", subsys => "block", devpath => "/block/sda/sda3", exp_name => "first_disk3" , @@ -241,21 +240,41 @@ BUS=="scsi", ID=="0:0:0:0", NAME="first_disk%n" EOF }, { - desc => "test NAME substitution chars", + desc => "test substitution chars", subsys => "block", devpath => "/block/sda/sda3", - exp_name => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" , + exp_name => "Major:8:minor:3:kernelnumber:3:id:0:0:0:0" , rules => < "test NAME substitution chars (with length limit)", + desc => "test substitution chars (with length limit)", subsys => "block", devpath => "/block/sda/sda3", exp_name => "M8-m3-n3-b0:0-sIBM" , rules => < "import of shell-value file", + subsys => "block", + devpath => "/block/sda", + exp_name => "subdir/info/node" , + rules => < "import of shell-value returned from program", + subsys => "block", + devpath => "/block/sda", + exp_name => "node12345678", + rules => < "program result substitution (no argument should be subsystem)", - subsys => "block", - devpath => "/block/sda/sda3", - exp_name => "subsys_block" , - rules => < "invalid program for device with no bus", - subsys => "tty", - devpath => "/class/tty/console", - exp_name => "TTY" , + desc => "test substitution by variable name", + subsys => "block", + devpath => "/block/sda/sda3", + exp_name => "Major:8-minor:3-kernelnumber:3-id:0:0:0:0", rules => < "valid program for device with no bus", + desc => "test substitution by variable name 2", + subsys => "block", + devpath => "/block/sda/sda3", + exp_name => "Major:8-minor:3-kernelnumber:3-id:0:0:0:0", + rules => < "test substitution by variable name 3", + subsys => "block", + devpath => "/block/sda/sda3", + exp_name => "830:0:0:03" , + rules => < "test substitution by variable name 4", + subsys => "block", + devpath => "/block/sda/sda3", + exp_name => "833" , + rules => < "test substitution by variable name 5", + subsys => "block", + devpath => "/block/sda/sda3", + exp_name => "8330:0:0:0" , + rules => < "non matching BUS for device with no parent", subsys => "tty", devpath => "/class/tty/console", - exp_name => "foo" , + exp_name => "TTY", rules => < "invalid label for device with no bus", + desc => "non matching BUS", subsys => "tty", devpath => "/class/tty/console", exp_name => "TTY" , @@ -393,7 +438,7 @@ KERNEL=="console", NAME="TTY" EOF }, { - desc => "valid label for device with no bus", + desc => "SYSFS match", subsys => "tty", devpath => "/class/tty/console", exp_name => "foo" , @@ -418,6 +463,7 @@ EOF subsys => "block", devpath => "/block/sda", exp_name => "boot_disk15" , + exp_majorminor => "8:15", rules => < "ttyUSB0", rules => < "multiple symlinks with a lot of s p a c e s", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "one", + not_exp_name => " ", + exp_target => "ttyUSB0", + rules => < "symlink-only2", exp_target => "link", rules => < "yes", exp_rem_error => "yes", rules => < "/class/tty/tty0", exp_name => "link", exp_target => "link", + exp_add_error => "yes", exp_rem_error => "yes", - option => "clear", + option => "clean", rules => < "symlink0", exp_target => "ttyUSB0", rules => < "symlink-ttyUSB0", exp_target => "ttyUSB0", rules => < "major-188:0", exp_target => "ttyUSB0", rules => < "symlink-0:0:0:0", exp_target => "node", rules => < "test", exp_target => "ttyUSB0", rules => < "test", exp_target => "ttyUSB0", rules => < "this", exp_target => "ttyUSB0", rules => < "test", exp_target => "link", rules => < "188:0", exp_target => "ttyUSB0", rules => < "188", exp_target => "ttyUSB0", rules => < "percent%sign", exp_target => "ttyUSB0", rules => < "%ttyUSB0_name", exp_target => "ttyUSB0", rules => < "link1", exp_target => "node", rules => < "link4", exp_target => "node", rules => < "enumeration char test (single test)", - subsys => "block", - devpath => "/block/sda", - exp_name => "cdrom", - rules => < "enumeration char test sequence 1/5 (keep)", - subsys => "block", - devpath => "/block/sda", - exp_name => "cdrom", - option => "keep", - rules => < "enumeration char test sequence 2/5 (keep)", - subsys => "block", - devpath => "/block/sda/sda1", - exp_name => "enum", - option => "keep", - rules => < "enumeration char test sequence 3/5 (keep)", - subsys => "block", - devpath => "/block/sda/sda2", - exp_name => "cdrom1", - option => "keep", - rules => < "enumeration char test sequence 4/5 (keep)", - subsys => "block", - devpath => "/block/sda/sda3", - exp_name => "enum1", - option => "keep", - rules => < "enumeration char test sequence 5/5 (clean)", - subsys => "block", - devpath => "/block/sda/sda4", - exp_name => "cdrom2", - option => "clear", - rules => < "enumeration char test after cleanup (single test)", - subsys => "block", - devpath => "/block/sda", - exp_name => "cdrom", - rules => < "ignore rule test", subsys => "block", devpath => "/block/sda", - exp_name => "node", + exp_name => "nothing", + not_exp_name => "node", exp_add_error => "yes", rules => < "/block/sda", exp_name => "node14", exp_rem_error => "yes", - option => "clear", + option => "clean", rules => < "/block/sda/sda1", exp_name => "last", rules => < "ENV{} test (assign)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "true", + rules => < "ENV{} test (assign2)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "part", + rules => < "/block/sda/sda1", exp_name => "sane", rules => < "untrusted string sanitize (don't replace utf8)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "uber", + rules => < "untrusted string sanitize (replace invalid utf8)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "replaced", + rules => < "serial-0000:00:09.0", rules => < "match against empty key string", + subsys => "block", + devpath => "/block/sda", + exp_name => "ok", + rules => < "check ACTION value", + subsys => "block", + devpath => "/block/sda", + exp_name => "ok", + rules => < "apply NAME only once", + subsys => "block", + devpath => "/block/sda", + exp_name => "link", + exp_target => "ok", + rules => < "test RUN key", + subsys => "block", + devpath => "/block/sda", + exp_name => "testsymlink", + exp_target => "ok", + exp_rem_error => "yes", + option => "clean", + rules => < "test RUN key and DEVNAME", + subsys => "block", + devpath => "/block/sda", + exp_name => "testsymlink", + exp_target => "ok", + exp_rem_error => "yes", + option => "clean", + rules => < "test RUN key remove", + subsys => "block", + devpath => "/block/sda", + exp_name => "testsymlink2", + exp_target => "ok2", + rules => < "final assignment", + subsys => "block", + devpath => "/block/sda", + exp_name => "ok", + exp_perms => "root:nobody:0640", + rules => < "final assignment", + subsys => "block", + devpath => "/block/sda", + exp_name => "ok", + exp_perms => "root:nobody:0640", + rules => < "env substitution", + subsys => "block", + devpath => "/block/sda", + exp_name => "node-add-me", + rules => < "reset list to current value", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "three", + not_exp_name => "two", + exp_target => "node", + rules => < "test empty NAME", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "node", + not_exp_name => "wrong", + exp_add_error => "yes", + rules => < "test empty NAME 2", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "right", + rules => < "test multi matches", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "right", + rules => < "test multi matches 2", + subsys => "tty", + devpath => "/class/tty/ttyUSB0", + exp_name => "right", + rules => < "IMPORT parent test sequence 1/2 (keep)", + subsys => "block", + devpath => "/block/sda", + exp_name => "parent", + option => "keep", + rules => < "IMPORT parent test sequence 2/2 (keep)", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "parentenv-parent_right", + option => "clean", + rules => < "GOTO test", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "right", + rules => < "NAME compare test", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "link", + exp_target => "node", + not_exp_name => "wronglink", + rules => < "NAME compare test 2", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "link2", + exp_target => "sda1", + not_exp_name => "link", + rules => < "invalid key operation", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "yes", + rules => < "overlong comment line", + subsys => "block", + devpath => "/block/sda/sda1", + exp_name => "yes", + rules => <{exp_name}"); + if (defined($rules->{not_exp_name})) { + if ((-e "$PWD/$udev_root$rules->{not_exp_name}") || + (-l "$PWD/$udev_root$rules->{not_exp_name}")) { + print "nonexistent: error \'$rules->{not_exp_name}\' not expected to be there\n"; + $error++ + } + } if (defined($rules->{exp_perms})) { permissions_test($rules, $uid, $gid, $mode); } @@ -1415,8 +1701,7 @@ sub run_test { print "\n"; - if (defined($rules->{option}) && $rules->{option} eq "clear") { - system("rm -rf $udev_db"); + if (defined($rules->{option}) && $rules->{option} eq "clean") { system("rm -rf $udev_root"); mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; } @@ -1437,8 +1722,8 @@ mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; # create config file open CONF, ">$udev_conf" || die "unable to create config file: $udev_conf"; print CONF "udev_root=\"$udev_root\"\n"; -print CONF "udev_db=\"$udev_db\"\n"; print CONF "udev_rules=\"$udev_rules\"\n"; +print CONF "udev_log=\"info\"\n"; close CONF; my $test_num = 1; @@ -1466,7 +1751,6 @@ if ($ARGV[0]) { print "$error errors occured\n\n"; # cleanup -system("rm -rf $udev_db"); system("rm -rf $udev_root"); unlink($udev_rules); unlink($udev_conf);