From b0b08b548af08b2ceb85acbce581ee34f342fdc5 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Feb 01 2021 09:27:42 +0000 Subject: test/udev-test: gracefully exit when imports fail In Fedora rawhide various perl modules are now available as separate packages that are not pulled in by dependencies. If we don't have some package, skip the tests. This ugly code is apparently the way to do conditional imports: https://www.cs.ait.ac.th/~on/O/oreilly/perl/cookbook/ch12_03.htm. (cherry picked from commit d40763838278246e2073d15ca927ee700e583afc) Related: #1642728 patch_name: 0543-test-udev-test-gracefully-exit-when-imports-fail.patch present_in_specfile: true location_in_specfile: 543 squash_commits: true --- diff --git a/test/udev-test.pl b/test/udev-test.pl index cf6ca6b..5b1e335 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -18,11 +18,19 @@ use warnings; use strict; -use POSIX qw(WIFEXITED WEXITSTATUS); -use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT); -use IPC::Semaphore; -use Time::HiRes qw(usleep); -use Cwd qw(getcwd abs_path); + +BEGIN { + my $EXIT_TEST_SKIP = 77; + + unless (eval "use POSIX qw(WIFEXITED WEXITSTATUS); + use Cwd qw(getcwd abs_path); + use IPC::Semaphore; + use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT); + use Time::HiRes qw(usleep); 1") { + warn "Failed to import dependencies, skipping the test: $@"; + exit($EXIT_TEST_SKIP); + } +} my $udev_bin = "./test-udev"; my $valgrind = 0;