richardphibel / rpms / systemd

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