1 Star 0 Fork 48

疯言疯语/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0538-tests-udev-test.pl-add-multiple-device-test.patch 10.72 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:46 . update to systemd-239-45.el8.src.rpm
From 8ab9d11b925e7f39b350ce69a1e28752de411b35 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 24 Apr 2018 22:04:55 +0200
Subject: [PATCH] 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.
(cherry picked from commit 4a0ec82daf32446519e1d86329bb802325b82104)
Related: #1642728
---
test/udev-test.pl | 169 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 169 insertions(+)
diff --git a/test/udev-test.pl b/test/udev-test.pl
index 813be70739..d964c664b6 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -2085,6 +2085,175 @@ KERNEL=="sda", TAG+="aaa" \\
KERNEL=="sdb", TAG+="bbb"
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
},
);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/devttl/systemd.git
git@gitee.com:devttl/systemd.git
devttl
systemd
systemd
a8

搜索帮助