From fb8d10456d7d5a085e1adb5bfd45f1cda813ac22 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Tue, 24 Apr 2018 17:15:58 +0200 Subject: [PATCH] test/udev-test.pl: allow checking multiple symlinks Instead of testing the existence or non-exisitence of just a single symlink, allow testing of several links per device. Change the test definitions accordingly. (cherry picked from commit e62acc3159935781f05fa59c48e5a74e85c61ce2) Related: #1642728 --- test/udev-test.pl | 495 +++++++++++++++++++++++++++------------------- 1 file changed, 296 insertions(+), 199 deletions(-) diff --git a/test/udev-test.pl b/test/udev-test.pl index 2e3089c5e0..f5edecefd0 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -71,7 +71,7 @@ EOF devices => [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "boot_disk" , + exp_links => ["boot_disk"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "boot_disk" , + exp_links => ["boot_disk"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "boot_disk" , + exp_links => ["boot_disk"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "boot_disk1" , + exp_links => ["boot_disk1"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "boot_disk1" , + exp_links => ["boot_disk1", "boot_disk1-4", "boot_disk1-5"], + not_exp_links => ["boot_disk1-1", "boot_disk1-2", "boot_disk1-3"] }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "boot_disk1" , + exp_links => ["boot_disk1"], + not_exp_links => ["boot_diskX1"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "boot_disk1" , + exp_links => ["boot_disk1", "boot_diskXY1"], + not_exp_links => ["boot_diskXX1"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem/0" , + exp_links => ["modem/0", "catch-all"], }], rules => < "catch device by * - take 2", devices => [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem/0" , + exp_links => ["modem/0"], + not_exp_links => ["bad"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem/0" , + exp_links => ["modem/0"], + not_exp_links => ["modem/0-1", "modem/0-2"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem/0" , + exp_links => ["modem/0"], + not_exp_links => ["modem/0-1", "modem/0-2"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem" , + exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem" , + exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem" , + exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "whitespace" , + exp_links => ["whitespace"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem" , + exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem" , + exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "aaa", + exp_links => ["aaa"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem" , + exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "sub/direct/ory/modem" , + exp_links => ["sub/direct/ory/modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "first_disk5" , + exp_links => ["first_disk5"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0" , + exp_links => ["Major:8:minor:5:kernelnumber:5:id:0:0:0:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node12345678", + exp_links => ["node12345678"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "disk-ATA-sda" , + exp_links => ["disk-ATA-sda"], + not_exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "special-device-5" , - not_exp_name => "not" , + exp_links => ["special-device-5"], + not_exp_links => ["not"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "newline_removed" , + exp_links => ["newline_removed"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "test-0:0:0:0" , + exp_links => ["test-0:0:0:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "foo9" , + exp_links => ["foo9"], + not_exp_links => ["foo3", "foo4", "foo5", "foo6", "foo7", "foo8"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "bar9" , + exp_links => ["bar9"], + not_exp_links => ["foo3", "foo4", "foo5", "foo6", "foo7", "foo8"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "foo7" , + exp_links => ["foo7"], + not_exp_links => ["foo3", "foo4", "foo5", "foo6", "foo8"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "foo2" , + exp_links => ["foo2"], + not_exp_links => ["foo1"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "foo2" , + exp_links => ["foo2"], + not_exp_links => ["foo1"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "foo2" , + exp_links => ["foo2"], + not_exp_links => ["foo1", "foo3"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "my-foo9" , + exp_links => ["my-foo9"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "my-foo8" , + exp_links => ["my-foo8"], + not_exp_links => ["my-foo3", "my-foo4", "my-foo5", "my-foo6", "my-foo7", "my-foo9"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0", + exp_links => ["Major:8-minor:5-kernelnumber:5-id:0:0:0:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0", + exp_links => ["Major:8-minor:5-kernelnumber:5-id:0:0:0:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "850:0:0:05" , + exp_links => ["850:0:0:05"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "855" , + exp_links => ["855"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "8550:0:0:0" , + exp_links => ["8550:0:0:0"], }], rules => < [ { devpath => "/devices/virtual/tty/console", - exp_name => "TTY", + exp_links => ["TTY"], + not_exp_links => ["foo"], }], rules => < [ { devpath => "/devices/virtual/tty/console", - exp_name => "TTY" , + exp_links => ["TTY"], + not_exp_links => ["foo"], }], rules => < [ { devpath => "/devices/virtual/tty/console", - exp_name => "foo" , + exp_links => ["foo", "TTY"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "empty" , + exp_links => ["empty", "not-something"], + not_exp_links => ["something", "not-empty"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "non-existent" , + exp_links => ["non-existent", "wrong"], + not_exp_links => ["something", "empty", "not-empty", + "not-something", "something"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "scsi-0:0:0:0" , + exp_links => ["scsi-0:0:0:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem" , + exp_links => ["modem"], }], rules => < "/devices/virtual/block/fake!blockdev0", devnode => "fake/blockdev0", - exp_name => "is/a/fake/blockdev0" , + exp_links => ["is/a/fake/blockdev0"], + not_exp_links => ["is/not/a/fake/blockdev0", "modem"], }], rules => < "/devices/virtual/block/fake!blockdev0", devnode => "fake/blockdev0", - exp_rem_error => "yes", + not_exp_links => ["modem"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "scsi-0:0:0:0", + exp_links => ["scsi-0:0:0:0"], + not_exp_links => ["no-match", "short-id", "not-scsi"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "scsi-0:0:0:0", + exp_links => ["scsi-0:0:0:0"], + not_exp_links => ["no-match", "before"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "scsi-0:0:0:0", + exp_links => ["scsi-0:0:0:0", "before"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "scsi-0:0:0:0", + exp_links => ["scsi-0:0:0:0", "before"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "driver-is-sd", + exp_links => ["driver-is-sd"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "driver-is-ahci", + exp_links => ["driver-is-ahci"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "ignored", + exp_links => ["ignored"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "matched-with-space", + exp_links => ["matched-with-space"], + not_exp_links => ["wrong-to-ignore"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_perms => "1::0600", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_perms => ":1:0660", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_perms => "daemon::0600", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_perms => ":daemon:0660", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_perms => "root:audio:0660", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_perms => "::0777", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_perms => "1:1:0777", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], exp_majorminor => "8:0", }], rules => < [ { devpath => "/devices/virtual/misc/misc-fake1", - exp_name => "node", + exp_links => ["node"], exp_majorminor => "4095:1", }], rules => < [ { devpath => "/devices/virtual/misc/misc-fake89999", - exp_name => "node", + exp_links => ["node"], exp_majorminor => "4095:89999", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "symlink2-ttyACM0", + exp_links => ["symlink1-0", "symlink2-ttyACM0", "symlink3-"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "one", - not_exp_name => " ", + exp_links => ["one", "two"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "name-one_two_three-end", - not_exp_name => " ", + exp_links => ["name-one_two_three-end"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "name-one_two_three-end", - not_exp_name => " ", + exp_links => ["name-one_two_three-end"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "name-one_two_three-end", - not_exp_name => " ", + exp_links => ["name-one_two_three-end"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "name-one_two_three-end", - not_exp_name => " ", + exp_links => ["name-one_two_three-end"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "name-one_two_three-end", - not_exp_name => " ", + exp_links => ["name-one_two_three-end"], + not_exp_links => [" "], }], rules => < "symlink with space and var with space, part 1", + desc => "symlink with space and var with space", devices => [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "first", - not_exp_name => " ", + exp_links => ["first"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "name-one_two_three-end", - not_exp_name => " ", + exp_links => ["name-one_two_three-end"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "another_symlink", - not_exp_name => " ", + exp_links => ["another_symlink"], + not_exp_links => [" "], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "modem0", + exp_links => ["modem0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "second-0" , + exp_links => ["first-0", "second-0", "third-0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => ".", + exp_links => ["."], exp_add_error => "yes", exp_rem_error => "yes", }], @@ -1148,7 +1176,7 @@ EOF devices => [ { devpath => "/devices/virtual/tty/tty0", - exp_name => "link", + exp_links => ["link"], exp_add_error => "yes", exp_rem_error => "yes", }], @@ -1162,7 +1190,7 @@ EOF devices => [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "symlink0", + exp_links => ["symlink0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "symlink-ttyACM0", + exp_links => ["symlink-ttyACM0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "major-166:0", + exp_links => ["major-166:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "symlink-0:0:0:0", + exp_links => ["symlink-0:0:0:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "test", + exp_links => ["test"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "test", + exp_links => ["test"], + not_exp_links => ["symlink", "this"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "this", + exp_links => ["test", "this"], + not_exp_links => ["symlink"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "test", + exp_links => ["test", "this"], + not_exp_links => ["symlink"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "166:0", + exp_links => ["166:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "link1", + exp_links => ["link1", "link2"], + not_exp_links => ["node"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", - exp_name => "link4", + exp_links => ["link1", "link2", "link3", "link4"], + not_exp_links => ["node"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], + not_exp_links => ["should_not_match", "should_not_match2"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], + not_exp_links => ["should_not_match"] }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", + exp_links => ["node"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "sda-part-1", + exp_links => ["sda-part-1"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "start-/dev-end", + exp_links => ["start-/dev-end"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "last", + exp_links => ["last"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "match", + exp_links => ["match", "before"], + not_exp_links => ["matches-but-is-negated"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "not-anything", + exp_links => ["before", "not-anything"], + not_exp_links => ["matches-but-is-negated"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "nonzero-program", + exp_links => ["before", "nonzero-program"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "true", + exp_links => ["true"], + not_exp_links => ["bad", "wrong"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "true", + exp_links => ["true"], + not_exp_links => ["bad", "wrong", "no"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "true", + exp_links => ["true", "before"], + not_exp_links => ["no"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "true", + exp_links => ["true", "before"], + not_exp_links => ["no", "bad"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "part", - }], + exp_links => ["part"], + not_exp_links => ["disk"], + }, + ], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "sane", + exp_links => ["sane"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "uber", + exp_links => ["uber"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "replaced", + exp_links => ["replaced"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "serial-354172020305000", + exp_links => ["serial-354172020305000"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "ok", + exp_links => ["ok"], + not_exp_links => ["not-1-ok", "not-2-ok", "not-3-ok"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "ok", + exp_links => ["ok"], + not_exp_links => ["unknown-not-ok"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "ok", + exp_links => ["ok"], exp_perms => "root:tty:0640", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "ok", + exp_links => ["ok"], exp_perms => "root:tty:0640", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node-add-me", + exp_links => ["node-add-me"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "three", - not_exp_name => "two", + exp_links => ["three"], + not_exp_links => ["two", "one"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "right", - not_exp_name => "wrong", + exp_links => ["right"], + not_exp_links => ["wrong"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "right", + exp_links => ["right", "before"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "right", + exp_links => ["right", "before"], + not_exp_links => ["nomatch"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "right", + exp_links => ["right"], + not_exp_links => ["nomatch", "wrong1", "wrong2"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", - exp_name => "right", + exp_links => ["right"], + not_exp_links => ["nomatch", "wrong1", "wrong2", "wrong3"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "parent", + exp_links => ["parent"], }], option => "keep", rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "parentenv-parent_right", + exp_links => ["parentenv-parent_right"], }], option => "clean", rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "right", + exp_links => ["right"], + not_exp_test => ["wrong", "wrong2"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "right", + exp_links => ["right"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "right", - not_exp_name => "wrong", + exp_links => ["right", "link"], + not_exp_links => ["wrong"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "yes", + exp_links => ["yes"], + not_exp_links => ["no"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "yes", + exp_links => ["yes"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", - exp_name => "yes", + exp_links => ["yes"], + not_exp_links => ["no"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "00:16:41:e2:8d:ff", + exp_links => ["00:16:41:e2:8d:ff"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "there", + exp_links => ["there"], + not_exp_links => ["notthere"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "yes", + exp_links => ["yes"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "relative", + exp_links => ["relative"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found-subdir", + exp_links => ["found-subdir"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "sda-8741C4G-end", + exp_links => ["sda-8741C4G-end"], exp_perms => "0:0:0600", }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0", + exp_links => ["disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", - not_exp_name => "bad" , + exp_links => ["found"], + not_exp_links => ["bad"], }], rules => < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], }], rules => $rules_10k_tags . < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => $rules_10k_tags_continuation . < [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], @@ -2046,7 +2098,7 @@ TAGS=="aaa", SYMLINK+="bad" devices => [ { devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "found", + exp_links => ["found"], not_exp_name => "bad", }], rules => <{not_exp_name})) { - if ((-e "$udev_dev/$device->{not_exp_name}") || - (-l "$udev_dev/$device->{not_exp_name}")) { - print "nonexistent: error \'$device->{not_exp_name}\' not expected to be there\n"; - $error++; - sleep(1); - } - } +sub get_link_target { + my ($link) = @_; - my $devnode = check_devnode($device); + my $cwd = getcwd(); + my $dir = "$udev_dev/$link"; + my $tgt = readlink("$udev_dev/$link"); + $dir =~ s!/[^/]*$!!; + $tgt = abs_path("$dir/$tgt"); + $tgt =~ s!^$cwd/!!; + return $tgt; +} - return if (!defined($device->{exp_name})); +sub check_link_add { + my ($link, $devnode, $err_expected) = @_; - my @st = lstat("$udev_dev/$device->{exp_name}"); + my @st = lstat("$udev_dev/$link"); if (-l _) { - my $cwd = getcwd(); - my $dir = "$udev_dev/$device->{exp_name}"; - $dir =~ s!/[^/]*$!!; - my $tgt = readlink("$udev_dev/$device->{exp_name}"); - $tgt = abs_path("$dir/$tgt"); - $tgt =~ s!^$cwd/!!; + my $tgt = get_link_target($link); if ($tgt ne $devnode) { - print "symlink $device->{exp_name}: error, found -> $tgt\n"; + print "symlink $link: error, found -> $tgt\n"; $error++; system("tree", "$udev_dev"); } else { - print "symlink $device->{exp_name}: ok\n"; + print "symlink $link: ok\n"; } } else { - print "symlink $device->{exp_name}: error"; - if ($device->{exp_add_error}) { + print "symlink $link: error"; + if ($err_expected) { print " as expected\n"; } else { print "\n"; @@ -2276,6 +2322,49 @@ sub check_add { } } +sub check_link_nonexistent { + my ($link, $devnode, $err_expected) = @_; + + if ((-e "$udev_dev/$link") || (-l "$udev_dev/$link")) { + my $tgt = get_link_target($link); + + if ($tgt ne $devnode) { + print "nonexistent: '$link' points to other device (ok)\n"; + } else { + print "nonexistent: error \'$link\' should not be there"; + if ($err_expected) { + print " (as expected)\n"; + } else { + print "\n"; + system("tree", "$udev_dev"); + print "\n"; + $error++; + sleep(1); + } + } + } else { + print "nonexistent $link: ok\n"; + } +} + +sub check_add { + my ($device) = @_; + my $devnode = check_devnode($device); + + if (defined($device->{exp_links})) { + foreach my $link (@{$device->{exp_links}}) { + check_link_add($link, $devnode, + $device->{exp_add_error}); + } + } + if (defined $device->{not_exp_links}) { + foreach my $link (@{$device->{not_exp_links}}) { + check_link_nonexistent($link, $devnode, + $device->{exp_nodev_error}); + } + } +} + sub check_remove_devnode { my ($device) = @_; my $devnode = get_devnode($device); @@ -2292,17 +2381,13 @@ sub check_remove_devnode { } } -sub check_remove { - my ($device) = @_; +sub check_link_remove { + my ($link, $err_expected) = @_; - check_remove_devnode($device); - - return if (!defined($device->{exp_name})); - - if ((-e "$udev_dev/$device->{exp_name}") || - (-l "$udev_dev/$device->{exp_name}")) { - print "remove $device->{exp_name}: error"; - if ($device->{exp_rem_error}) { + if ((-e "$udev_dev/$link") || + (-l "$udev_dev/$link")) { + print "remove $link: error"; + if ($err_expected) { print " as expected\n"; } else { print "\n"; @@ -2312,7 +2397,19 @@ sub check_remove { sleep(1); } } else { - print "remove $device->{exp_name}: ok\n"; + print "remove $link: ok\n"; + } +} + +sub check_remove { + my ($device) = @_; + + check_remove_devnode($device); + + return if (!defined($device->{exp_links})); + + foreach my $link (@{$device->{exp_links}}) { + check_link_remove($link, $device->{exp_rem_error}); } }