summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Wilck <mwilck@suse.com>2018-04-24 22:04:55 +0200
committerMichal Sekletár <msekleta@redhat.com>2020-11-02 11:43:15 +0100
commit4a0ec82daf32446519e1d86329bb802325b82104 (patch)
tree962342189ae74699625f47874ab2f8dd9e2d0f19
parenttest/udev-test.pl: count "good" results (diff)
downloadsystemd-4a0ec82daf32446519e1d86329bb802325b82104.tar.xz
systemd-4a0ec82daf32446519e1d86329bb802325b82104.zip
tests/udev-test.pl: add multiple device test
Add 4 new tests using multiple devices. Number 2-4 use many devices claiming the same symlink, where only one device has a higher priority thatn the others. They fail sporadically with the current code, if a race condition causes the symlink to point to the wrong device. Test 4 is like test 2 with sleeps in between, it's much less likely to fail.
-rwxr-xr-xtest/udev-test.pl169
1 files changed, 169 insertions, 0 deletions
diff --git a/test/udev-test.pl b/test/udev-test.pl
index a084343f3dd..36028ba6174 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -2087,6 +2087,175 @@ TAGS=="foo", SYMLINK+="found"
TAGS=="aaa", SYMLINK+="bad"
EOF
},
+ {
+ desc => "multiple devices",
+ devices => [
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
+ exp_links => ["part-1"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
+ exp_links => ["part-5"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
+ exp_links => ["part-6"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
+ exp_links => ["part-7"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
+ exp_links => ["part-8"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
+ exp_links => ["part-9"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
+ exp_links => ["part-10"],
+ },
+ ],
+ rules => <<EOF
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
+EOF
+ },
+ {
+ desc => "multiple devices, same link name, positive prio",
+ devices => [
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
+ exp_links => ["part-1"],
+ not_exp_links => ["partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
+ exp_links => ["part-5"],
+ not_exp_links => ["partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
+ not_exp_links => ["partition"],
+ exp_links => ["part-6"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
+ exp_links => ["part-7", "partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
+ not_exp_links => ["partition"],
+ exp_links => ["part-8"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
+ not_exp_links => ["partition"],
+ exp_links => ["part-9"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
+ not_exp_links => ["partition"],
+ exp_links => ["part-10"],
+ },
+ ],
+ rules => <<EOF
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
+KERNEL=="*7", OPTIONS+="link_priority=10"
+EOF
+ },
+ {
+ desc => "multiple devices, same link name, negative prio",
+ devices => [
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
+ exp_links => ["part-1"],
+ not_exp_links => ["partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
+ exp_links => ["part-5"],
+ not_exp_links => ["partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
+ not_exp_links => ["partition"],
+ exp_links => ["part-6"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
+ exp_links => ["part-7", "partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
+ not_exp_links => ["partition"],
+ exp_links => ["part-8"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
+ not_exp_links => ["partition"],
+ exp_links => ["part-9"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
+ not_exp_links => ["partition"],
+ exp_links => ["part-10"],
+ },
+ ],
+ rules => <<EOF
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
+KERNEL!="*7", OPTIONS+="link_priority=-10"
+EOF
+ },
+ {
+ desc => "multiple devices, same link name, positive prio, sleep",
+ devices => [
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
+ exp_links => ["part-1"],
+ not_exp_links => ["partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
+ exp_links => ["part-5"],
+ not_exp_links => ["partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
+ not_exp_links => ["partition"],
+ exp_links => ["part-6"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
+ exp_links => ["part-7", "partition"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
+ not_exp_links => ["partition"],
+ exp_links => ["part-8"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
+ not_exp_links => ["partition"],
+ exp_links => ["part-9"],
+ },
+ {
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
+ not_exp_links => ["partition"],
+ exp_links => ["part-10"],
+ },
+ ],
+ sleep_us => 10000,
+ rules => <<EOF
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
+KERNEL=="*7", OPTIONS+="link_priority=10"
+EOF
+ },
);
sub create_rules {