teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0543-test-udev-test-gracefully-exit-when-imports-fail.patch

6136c1
From 2e50a00f6930f1c65ca804b78f4a853e2ae2d2c0 Mon Sep 17 00:00:00 2001
6136c1
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
6136c1
Date: Tue, 17 Nov 2020 17:13:31 +0100
6136c1
Subject: [PATCH] test/udev-test: gracefully exit when imports fail
6136c1
6136c1
In Fedora rawhide various perl modules are now available as separate
6136c1
packages that are not pulled in by dependencies. If we don't have some
6136c1
package, skip the tests.
6136c1
6136c1
This ugly code is apparently the way to do conditional imports:
6136c1
https://www.cs.ait.ac.th/~on/O/oreilly/perl/cookbook/ch12_03.htm.
6136c1
6136c1
(cherry picked from commit d40763838278246e2073d15ca927ee700e583afc)
6136c1
6136c1
Related: #1642728
6136c1
---
6136c1
 test/udev-test.pl | 18 +++++++++++++-----
6136c1
 1 file changed, 13 insertions(+), 5 deletions(-)
6136c1
6136c1
diff --git a/test/udev-test.pl b/test/udev-test.pl
6136c1
index cf6ca6b80c..5b1e33504e 100755
6136c1
--- a/test/udev-test.pl
6136c1
+++ b/test/udev-test.pl
6136c1
@@ -18,11 +18,19 @@
6136c1
 
6136c1
 use warnings;
6136c1
 use strict;
6136c1
-use POSIX qw(WIFEXITED WEXITSTATUS);
6136c1
-use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
6136c1
-use IPC::Semaphore;
6136c1
-use Time::HiRes qw(usleep);
6136c1
-use Cwd qw(getcwd abs_path);
6136c1
+
6136c1
+BEGIN {
6136c1
+    my $EXIT_TEST_SKIP = 77;
6136c1
+
6136c1
+    unless (eval "use POSIX qw(WIFEXITED WEXITSTATUS);
6136c1
+                  use Cwd qw(getcwd abs_path);
6136c1
+                  use IPC::Semaphore;
6136c1
+                  use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
6136c1
+                  use Time::HiRes qw(usleep); 1") {
6136c1
+        warn "Failed to import dependencies, skipping the test: $@";
6136c1
+        exit($EXIT_TEST_SKIP);
6136c1
+    }
6136c1
+}
6136c1
 
6136c1
 my $udev_bin            = "./test-udev";
6136c1
 my $valgrind            = 0;