daandemeyer / rpms / systemd

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