X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=test%2Fudev-test.pl;h=79ed247d46c86f8fe1f6b1e68f52bd951fe944fb;hp=f630b74a9d859247ed96ab3ed38e282e15d0577d;hb=11a421dab5ab4bf9b40464a64b81c9d5c282f414;hpb=91a75e4ad4071d9d0ce1adb5c8d8272aac379d0a diff --git a/test/udev-test.pl b/test/udev-test.pl index f630b74a9..79ed247d4 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/"; @@ -30,13 +30,21 @@ my $udev_conf = "udev-test.conf"; my $udev_rules = "udev-test.rules"; my @tests = ( + { + desc => "no rules", + subsys => "block", + devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", + exp_name => "sda" , + rules => < "label test of scsi disc (old key names)", subsys => "block", devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", exp_name => "boot_disk" , rules => < "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 => < "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", @@ -1508,6 +1526,17 @@ KERNEL=="sda1", GOTO="BAD" KERNEL=="sda1", NAME="", LABEL="NO" KERNEL=="sda1", NAME="right", LABEL="TEST" KERNEL=="sda1", LABEL="BAD" +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 => < "magic [subsys/sysname] attribute substitution", + subsys => "block", + devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", + exp_name => "sda-8741C4G-end", + exp_perms => "0:0:0660", + 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); }