device-mapper-multipath/0132-multipath-tools-devt-test-avoid-failure-when-run-in-.patch
Benjamin Marzinski b05147c356 device-mapper-multipath-0.8.5-6
Change patch format to remove Git version
  * Patches 0001-0122 only have the patch format modified
Update to the head of the upstream staging branch plus redhat patches
  * Patches 0123-0134 & 1036-0142 are from the upstream staging branch
  * Patches 0143-1046 have been submitted upstream
  * Patch 0156 is a Red Hat only patch. Red Hat udev rules set ID_SERIAL
    from 60-persistent-storage.rules instead of 55-scsi-sg3_id.rules.
    Multipath's parse_vpd_pg83() function needs to match the ID_SERIAL
    value from udev.
Rename files
  * Previous patches 0123-0132 are now patches 1035 & 0147-0155
2021-03-26 13:33:56 -05:00

64 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Thu, 11 Feb 2021 22:54:58 +0100
Subject: [PATCH] multipath-tools: devt test: avoid failure when run in
containers
/sys/dev/block is usually unavailable containers, causing libudev
calls to fail. Skip the respective tests.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
tests/devt.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/devt.c b/tests/devt.c
index 2b728516..02f2e8f3 100644
--- a/tests/devt.c
+++ b/tests/devt.c
@@ -11,11 +11,25 @@
#include <cmocka.h>
#include <libudev.h>
#include <sys/sysmacros.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "util.h"
#include "debug.h"
#include "globals.c"
+static bool sys_dev_block_exists(void)
+{
+ int fd;
+ bool rc;
+
+ fd = open("/sys/dev/block", O_RDONLY|O_DIRECTORY);
+ rc = (fd != -1);
+ close(fd);
+ return rc;
+}
+
static int get_one_devt(char *devt, size_t len)
{
struct udev_enumerate *enm;
@@ -71,6 +85,8 @@ static void test_devt2devname_devt_good(void **state)
{
char dummy[BLK_DEV_SIZE];
+ if (!sys_dev_block_exists())
+ skip();
assert_int_equal(devt2devname(dummy, sizeof(dummy), *state), 0);
}
@@ -137,6 +153,8 @@ static void test_devt2devname_real(void **state)
struct udev_list_entry *first, *item;
unsigned int i = 0;
+ if (!sys_dev_block_exists())
+ skip();
enm = udev_enumerate_new(udev);
assert_non_null(enm);
r = udev_enumerate_add_match_subsystem(enm, "block");