1 Star 0 Fork 50

苏峰/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0512-udev-test-skip-the-test-only-if-it-can-t-setup-its-e.patch 3.09 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:46 . update to systemd-239-45.el8.src.rpm
From 8c82f3a4aa2d029dcc303cbf95a71194aa5ac9c3 Mon Sep 17 00:00:00 2001
From: Evgeny Vereshchagin <evvers@ya.ru>
Date: Fri, 9 Nov 2018 04:01:15 +0100
Subject: [PATCH] udev-test: skip the test only if it can't setup its
environment
This is basically a replacement for 0eb3cc88504b5d8f74.
(cherry picked from commit 110a13202eab6d92678abcde08372d4afac1cc45)
Related: #1642728
---
src/test/test-udev.c | 8 ++++++++
test/udev-test.pl | 24 +++++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index bed51c1270..f098fab721 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -65,6 +65,11 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
+ if (!IN_SET(argc, 2, 3)) {
+ log_error("This program needs one or two arguments, %d given", argc - 1);
+ return EXIT_FAILURE;
+ }
+
err = fake_filesystems();
if (err < 0)
return EXIT_FAILURE;
@@ -73,6 +78,9 @@ int main(int argc, char *argv[]) {
if (udev == NULL)
return EXIT_FAILURE;
+ if (argc == 2)
+ return EXIT_SUCCESS;
+
log_debug("version %s", PACKAGE_VERSION);
mac_selinux_init();
diff --git a/test/udev-test.pl b/test/udev-test.pl
index 05b3e17188..aa38bae0b1 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -1537,18 +1537,28 @@ sub udev_setup {
system("umount", $udev_tmpfs);
rmdir($udev_tmpfs);
mkdir($udev_tmpfs) || die "unable to create udev_tmpfs: $udev_tmpfs\n";
- system("mount", "-o", "rw,mode=755,nosuid,noexec", "-t", "tmpfs", "tmpfs", $udev_tmpfs) && die "unable to mount tmpfs";
+
+ if (system("mount", "-o", "rw,mode=755,nosuid,noexec", "-t", "tmpfs", "tmpfs", $udev_tmpfs)) {
+ warn "unable to mount tmpfs";
+ return 0;
+ }
mkdir($udev_dev) || die "unable to create udev_dev: $udev_dev\n";
# setting group and mode of udev_dev ensures the tests work
# even if the parent directory has setgid bit enabled.
chown (0, 0, $udev_dev) || die "unable to chown $udev_dev\n";
chmod (0755, $udev_dev) || die "unable to chmod $udev_dev\n";
- system("mknod", $udev_dev . "/null", "c", "1", "3") && die "unable to create $udev_dev/null";
+
+ if (system("mknod", $udev_dev . "/null", "c", "1", "3")) {
+ warn "unable to create $udev_dev/null";
+ return 0;
+ }
system("cp", "-r", "test/sys/", $udev_sys) && die "unable to copy test/sys";
system("rm", "-rf", "$udev_run");
+
+ return 1;
}
sub run_test {
@@ -1646,7 +1656,15 @@ if ($? >> 8 == 0) {
exit($EXIT_TEST_SKIP);
}
-udev_setup();
+if (!udev_setup()) {
+ warn "Failed to set up the environment, skipping the test";
+ exit($EXIT_TEST_SKIP);
+}
+
+if (!system($udev_bin, "check")) {
+ warn "$udev_bin failed to set up the environment, skipping the test";
+ exit($EXIT_TEST_SKIP);
+}
my $test_num = 1;
my @list;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/su-feng-nmg/systemd.git
git@gitee.com:su-feng-nmg/systemd.git
su-feng-nmg
systemd
systemd
a8

搜索帮助