richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
bd1529
From 8ab9d11b925e7f39b350ce69a1e28752de411b35 Mon Sep 17 00:00:00 2001
bd1529
From: Martin Wilck <mwilck@suse.com>
bd1529
Date: Tue, 24 Apr 2018 22:04:55 +0200
bd1529
Subject: [PATCH] tests/udev-test.pl: add multiple device test
bd1529
bd1529
Add 4 new tests using multiple devices. Number 2-4 use many
bd1529
devices claiming the same symlink, where only one device has
bd1529
a higher priority thatn the others. They fail sporadically with
bd1529
the current code, if a race condition causes the symlink to point
bd1529
to the wrong device. Test 4 is like test 2 with sleeps in between,
bd1529
it's much less likely to fail.
bd1529
bd1529
(cherry picked from commit 4a0ec82daf32446519e1d86329bb802325b82104)
bd1529
bd1529
Related: #1642728
bd1529
---
bd1529
 test/udev-test.pl | 169 ++++++++++++++++++++++++++++++++++++++++++++++
bd1529
 1 file changed, 169 insertions(+)
bd1529
bd1529
diff --git a/test/udev-test.pl b/test/udev-test.pl
bd1529
index 813be70739..d964c664b6 100755
bd1529
--- a/test/udev-test.pl
bd1529
+++ b/test/udev-test.pl
bd1529
@@ -2085,6 +2085,175 @@ KERNEL=="sda", TAG+="aaa" \\
bd1529
 KERNEL=="sdb", TAG+="bbb"
bd1529
 TAGS=="foo", SYMLINK+="found"
bd1529
 TAGS=="aaa", SYMLINK+="bad"
bd1529
+EOF
bd1529
+        },
bd1529
+        {
bd1529
+                desc            => "multiple devices",
bd1529
+                devices => [
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
bd1529
+                                exp_links       => ["part-1"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
bd1529
+                                exp_links       => ["part-5"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
bd1529
+                                exp_links       => ["part-6"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
bd1529
+                                exp_links       => ["part-7"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
bd1529
+                                exp_links       => ["part-8"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
bd1529
+                                exp_links       => ["part-9"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
bd1529
+                                exp_links       => ["part-10"],
bd1529
+                        },
bd1529
+                    ],
bd1529
+                rules          => <
bd1529
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
bd1529
+EOF
bd1529
+        },
bd1529
+        {
bd1529
+                desc            => "multiple devices, same link name, positive prio",
bd1529
+                devices => [
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
bd1529
+                                exp_links       => ["part-1"],
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
bd1529
+                                exp_links       => ["part-5"],
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-6"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
bd1529
+                                exp_links       => ["part-7", "partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-8"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-9"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-10"],
bd1529
+                        },
bd1529
+                    ],
bd1529
+                rules          => <
bd1529
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
bd1529
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
bd1529
+KERNEL=="*7", OPTIONS+="link_priority=10"
bd1529
+EOF
bd1529
+        },
bd1529
+        {
bd1529
+                desc            => "multiple devices, same link name, negative prio",
bd1529
+                devices => [
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
bd1529
+                                exp_links       => ["part-1"],
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
bd1529
+                                exp_links       => ["part-5"],
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-6"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
bd1529
+                                exp_links       => ["part-7", "partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-8"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-9"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-10"],
bd1529
+                        },
bd1529
+                    ],
bd1529
+                rules          => <
bd1529
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
bd1529
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
bd1529
+KERNEL!="*7", OPTIONS+="link_priority=-10"
bd1529
+EOF
bd1529
+        },
bd1529
+        {
bd1529
+                desc            => "multiple devices, same link name, positive prio, sleep",
bd1529
+                devices => [
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
bd1529
+                                exp_links       => ["part-1"],
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
bd1529
+                                exp_links       => ["part-5"],
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-6"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
bd1529
+                                exp_links       => ["part-7", "partition"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-8"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-9"],
bd1529
+                        },
bd1529
+                        {
bd1529
+                                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
bd1529
+                                not_exp_links   => ["partition"],
bd1529
+                                exp_links       => ["part-10"],
bd1529
+                        },
bd1529
+                    ],
bd1529
+                sleep_us       => 10000,
bd1529
+                rules          => <
bd1529
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
bd1529
+SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
bd1529
+KERNEL=="*7", OPTIONS+="link_priority=10"
bd1529
 EOF
bd1529
         },
bd1529
 );