X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=test%2Fudev-test.pl;h=47cadc5db35768f64f6a3165d90cdf291ba4d414;hp=61e91c48b66e9ec5381ea72b87cee7beb5bfd900;hb=1230d021bd75de9b1503bbaa807d6a59789963db;hpb=bcf44d55762557096fdd627b14415e35f3a4e14d diff --git a/test/udev-test.pl b/test/udev-test.pl index 61e91c48b..47cadc5db 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -21,8 +21,8 @@ use warnings; use strict; my $PWD = $ENV{PWD}; -my $sysfs = "sys/"; -my $udev_bin = "../udev/test-udev"; +my $sysfs = "test/sys/"; +my $udev_bin = "udev/test-udev"; my $valgrind = 0; my $udev_bin_valgrind = "valgrind --tool=memcheck --leak-check=yes --quiet $udev_bin"; my $udev_root = "udev-root/"; @@ -281,15 +281,6 @@ EOF exp_name => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0" , rules => < "test substitution chars (with length limit)", - subsys => "block", - devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "M8-m5-n5-b0:0-xAT" , - rules => < "test-0:0:0:0" , rules => < "program with escaped format char (tricky: callout returns format char!)", - subsys => "block", - devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "escape-5" , - rules => < < "ATTR (empty file)", + subsys => "tty", + devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", + exp_name => "empty" , + rules => < "ATTR (non-existent file)", + subsys => "tty", + devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", + exp_name => "non-existent" , + rules => < "tty", devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", exp_name => "symlink2-ttyACM0", - exp_target => "ttyACM0", + exp_target => "ttyACM-0", rules => < "ttyACM0", rules => < "symlink %Ns{filename} substitution", - subsys => "tty", - devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "166", - exp_target => "ttyACM0", - rules => < "node", exp_add_error => "yes", rules => < "tty", devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", exp_name => "", + not_exp_name => "ttyACM0", + exp_add_error => "yes", + rules => < "test empty NAME (empty override)", + subsys => "tty", + devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", + exp_name => "", not_exp_name => "wrong", exp_add_error => "yes", rules => < "test empty NAME 2", + desc => "test empty NAME (non-empty override)", subsys => "tty", devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", exp_name => "right", @@ -1514,8 +1524,20 @@ KERNEL=="sda1", GOTO="TEST" KERNEL=="sda1", NAME="wrong" KERNEL=="sda1", GOTO="BAD" KERNEL=="sda1", NAME="", LABEL="NO" -KERNEL=="sda1", NAME="right", LABEL="TEST" -KERNEL=="sda1", LABEL="BAD" +KERNEL=="sda1", NAME="right", LABEL="TEST", GOTO="end" +KERNEL=="sda1", NAME="wrong2", LABEL="BAD" +LABEL="end" +EOF + }, + { + desc => "GOTO label does not exist", + subsys => "block", + devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", + exp_name => "right", + rules => < < "TEST invalid NAME= only (skip invalid rule)", - subsys => "block", - devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "yes", - rules => < "TEST PROGRAM feeds MODE", + desc => "TEST PROGRAM feeds OWNER, GROUP, MODE", subsys => "block", devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", exp_name => "sda", - exp_perms => "0:0:0400", + exp_perms => "5000:100:0400", rules => <{subsys}, $rules->{devpath}, \$rules->{rules}); + 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 ((-e "$PWD/$udev_root$rules->{exp_name}") || (-l "$PWD/$udev_root$rules->{exp_name}")) { my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$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); }