Skip to contentSkip to conversation

multipath-tools: fix unit test breakage

PATCH In review [email protected] 2 participants 9 messages May 3, 2022 – May 5, 2022 Device mapper

lore
Share & tools
lore
#0 lore raw

cover multipath-tools: fix unit test breakage

From: Martin Wilck <[email protected]>

Hi Christophe, hi Ben,

The previous patches

af15832 multipath-tools: make multipath_dir a compiled-in option 1fc7c4d multipath-tools: make config_dir a compiled-in option 21b3d6b multipath-tools: stop supporting getuid_callout

have caused breakage in the unit tests. Not so much because they'd actually break the tests, but because they broke the compilation and the search paths for the configuration files (for the former two commits) and because the hwtable test relied on being able to the retrieve the now removed "getuid_callout" property from config files.

Fix it. As always, comments welcome.

Regards
Martin

Martin Wilck (7):
multipath-tools: enable local configdir and plugindir for unit tests tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE multipath-tools tests: hwtable: adapt after removal of getuid tests/hwtable: fix test_regex_2_strings_hwe_dir
libmultipath: fix valgrind_test
tests/Makefile: make TESTDIR configurable
github workflows: foreign.yaml: fix config dir in run environment

 .github/workflows/foreign.yaml |   7 +-
 libmultipath/Makefile          |  24 ++++--
 libmultipath/config.c          |   3 +
 tests/Makefile                 |  12 ++-
 tests/hwtable.c                | 151 ++++++++++++++++-----------------
 tests/mpathvalid.c             |   2 +-
 tests/test-lib.c               |  89 ++++++++++++++-----
 tests/test-lib.h               |   2 +-
 8 files changed, 180 insertions(+), 110 deletions(-)
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#1 lore raw

PATCH 1/7 multipath-tools: enable local configdir and plugindir for unit tests

From: Martin Wilck <[email protected]>

After the recent patches disabling the config_dir and multipath_dir runtime options, we need to take special care while building the unit tests. Create separate object files to link with the unit tests (e.g. "config-test.o" instead of "config.o"), using overrides for "configdir" and "plugindir".

---
 libmultipath/Makefile | 24 ++++++++++++++++++------
 tests/Makefile        |  9 ++++++---
 tests/hwtable.c       |  7 +++----
 3 files changed, 27 insertions(+), 13 deletions(-)
libmultipath/Makefile +18 -6
index b3a48c4..a56dd1e 100644
@@ -49,17 +49,24 @@ ifneq ($(call check_var,ELS_DTAG_LNK_INTEGRITY,$(LINUX_HEADERS_INCDIR)/scsi/fc/f
 	CFLAGS += -DFPIN_EVENT_HANDLER
 endif
 
+# object files referencing MULTIPATH_DIR or CONFIG_DIR
+# they need to be recompiled for unit tests
+OBJS-U := prio.o checkers.o foreign.o config.o
+OBJS-T := $(patsubst %.o,%-test.o,$(OBJS-U))
 
-OBJS = parser.o vector.o devmapper.o \
-	hwtable.o blacklist.o util.o dmparser.o config.o \
+# other object files
+OBJS-O := parser.o vector.o devmapper.o \
+	hwtable.o blacklist.o util.o dmparser.o \
 	structs.o discovery.o propsel.o dict.o \
 	pgpolicies.o debug.o defaults.o uevent.o time-util.o \
 	switchgroup.o uxsock.o print.o alias.o log_pthread.o \
-	log.o configure.o structs_vec.o sysfs.o prio.o checkers.o \
+	log.o configure.o structs_vec.o sysfs.o \
 	lock.o file.o wwids.o prioritizers/alua_rtpg.o prkey.o \
-	io_err_stat.o dm-generic.o generic.o foreign.o nvme-lib.o \
+	io_err_stat.o dm-generic.o generic.o nvme-lib.o \
 	libsg.o valid.o strbuf.o
 
+OBJS := $(OBJS-O) $(OBJS-U)
+
 all:	$(DEVLIB)
 
 nvme-lib.o: nvme-lib.c nvme-ioctl.c nvme-ioctl.h
@@ -97,11 +104,16 @@ $(LIBS:%.so.$(SONAME)=%-nv.so):	$(OBJS) $(NV_VERSION_SCRIPT)
 
 abi:    $(LIBS:%.so.$(SONAME)=%-nv.abi)
 
-../tests/$(LIBS): $(OBJS) $(VERSION_SCRIPT)
+../tests/$(LIBS): $(OBJS-O) $(OBJS-T) $(VERSION_SCRIPT)
 	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=`basename $@` \
-		-o $@ $(OBJS) $(LIBDEPS)
+		-o $@ $(OBJS-O) $(OBJS-T) $(LIBDEPS)
 	$(LN) $@ ${@:.so.0=.so}
 
+# This rule is invoked from tests/Makefile, overriding configdir and plugindir
+%-test.o: %.c
+	@echo building $@ because of $?
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
 test-lib:	../tests/$(LIBS)
 
 install: all
tests/Makefile +6 -3
index 8cbc4b7..7341b7e 100644
@@ -9,7 +9,7 @@ TEST_MISSING_INITIALIZERS = $(shell \
 W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS)
 
 CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) \
-	-Wno-unused-parameter $(W_MISSING_INITIALIZERS)
+	-Wno-unused-parameter $(W_MISSING_INITIALIZERS) -DTESTCONFDIR=\"$(CURDIR)/conf.d\"
 LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka
 
 TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \
@@ -40,6 +40,9 @@ mpathvalid-test_FLAGS := -I$(mpathvaliddir)
 #    That may be necessary if functions called from the object file are wrapped
 #    (wrapping works only for symbols which are undefined after processing a
 #    linker input file).
+#    Some object files, e.g. "config.o", are compiled separately for the
+#    unit tests. Look for OBJS-U in libmultipath/Makefile. Make sure to use the
+#    unit test file, e.g. "config-test.o", in XYZ-test_OBJDEPS
 # XYZ-test_LIBDEPS: Additional libs to link for this test
 
 dmevents-test_OBJDEPS = ../libmultipath/devmapper.o
@@ -91,7 +94,7 @@ valgrind_clean:
 
 clean: test_clean valgrind_clean dep_clean
 	$(RM) $(TESTS:%=%-test) $(OBJS) *.o.wrap
-	$(RM) -rf lib
+	$(RM) -rf lib conf.d
 
 .SECONDARY: $(OBJS)
 
@@ -105,7 +108,7 @@ dep_clean:
 		sort -u | tr '\n' ' ' >$@
 
 libmultipath.so.0:
-	$(MAKE) -C $(multipathdir) test-lib
+	make -C $(multipathdir) configdir=$(CURDIR)/conf.d plugindir=$(CURDIR)/lib test-lib
 
 # COLON will get expanded during second expansion below
 COLON:=:
tests/hwtable.c +3 -4
index 79bfa5f..400e114 100644
@@ -143,12 +143,11 @@ static int setup(void **state)
 	}
 	hwt->tmpname = strdup(buf);
 
-	snprintf(buf, sizeof(buf), "%s", tmplate);
-	if (mkdtemp(buf) == NULL) {
-		condlog(0, "mkdtemp (2): %s", strerror(errno));
+	hwt->dirname = strdup(TESTCONFDIR);
+	if (mkdir(hwt->dirname, 0744) != 0) {
+		condlog(0, "mkdir %s: %s", hwt->dirname, strerror(errno));
 		goto err;
 	}
-	hwt->dirname = strdup(buf);
 
 	make_config_file_path(buf, sizeof(buf), hwt, -1);
 	hwt->config_file = fopen(buf, "w+");
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#2 lore raw

PATCH 2/7 tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE

In reply to [email protected]

From: Martin Wilck <[email protected]>

---
 tests/mpathvalid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/mpathvalid.c +1 -1
index cfe4bae..0230a88 100644
@@ -104,7 +104,7 @@ int __wrap_init_config(const char *file)
 	int r = mock_type(int);
 	struct config *conf;
 
-	assert_ptr_equal(file, DEFAULT_CONFIGFILE);
+	assert_string_equal(file, DEFAULT_CONFIGFILE);
 	if (r != 0)
 		return r;
 
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#3 lore raw

PATCH 3/7 multipath-tools tests: hwtable: adapt after removal of getuid

In reply to [email protected]

From: Martin Wilck <[email protected]>

The "getuid_callout" runtime option has been removed and can thus not be used in the hwtable test any more. The test was just using it as a sample path property, not for any real WWID determination. We need to use another path property replacement. I decided to use "vpd_vendor". This is only initialized from scsi_ioctl_pathinfo(). Therefore test-lib.c must now support DI_SERIAL, too.

---
 tests/hwtable.c  | 142 +++++++++++++++++++++++------------------------
 tests/test-lib.c |  89 ++++++++++++++++++++++-------
 tests/test-lib.h |   2 +-
 3 files changed, 140 insertions(+), 93 deletions(-)
tests/hwtable.c +71 -71
index 400e114..b8e73a6 100644
@@ -403,7 +403,7 @@ static const char _vendor[] = "vendor";
 static const char _product[] = "product";
 static const char _prio[] = "prio";
 static const char _checker[] = "path_checker";
-static const char _getuid[] = "getuid_callout";
+static const char _vpd_vnd[] = "vpd_vendor";
 static const char _uid_attr[] = "uid_attribute";
 static const char _bl_product[] = "product_blacklist";
 static const char _minio[] = "rr_min_io_rq";
@@ -435,7 +435,7 @@ static const struct key_value prio_emc = { _prio, "emc" };
 static const struct key_value prio_hds = { _prio, "hds" };
 static const struct key_value prio_rdac = { _prio, "rdac" };
 static const struct key_value chk_hp = { _checker, "hp_sw" };
-static const struct key_value gui_foo = { _getuid, "/tmp/foo" };
+static const struct key_value vpd_hp3par = { _vpd_vnd, "hp3par" };
 static const struct key_value uid_baz = { _uid_attr, "BAZ_ATTR" };
 static const struct key_value bl_bar = { _bl_product, "bar" };
 static const struct key_value bl_baz = { _bl_product, "baz" };
@@ -755,31 +755,31 @@ static void test_regex_string_hwe(const struct hwt_state *hwt)
 	/* foo:baz matches kv1 */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* boo:baz matches kv1 */
 	pp = mock_path(vnd_boo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* .oo:ba. matches kv1 */
 	pp = mock_path(vnd__oo.value, prd_ba_.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* .foo:(bar|baz|ba\.) doesn't match */
 	pp = mock_path(vnd__oo.value, prd_ba_s.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches kv2 and kv1 */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
@@ -787,7 +787,7 @@ static int setup_regex_string_hwe(void **state)
 {
 	struct hwt_state *hwt = CHECK_STATE(state);
 	const struct key_value kv1[] = { vnd_t_oo, prd_ba_s, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 
 	WRITE_TWO_DEVICES(hwt, kv1, kv2);
 	SET_TEST_FUNC(hwt, test_regex_string_hwe);
@@ -812,39 +812,39 @@ static void test_regex_string_hwe_dir(const struct hwt_state *hwt)
 	/* foo:baz matches kv1 */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* boo:baz matches kv1 */
 	pp = mock_path(vnd_boo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* .oo:ba. matches kv1 */
 	pp = mock_path(vnd__oo.value, prd_ba_.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* .oo:(bar|baz|ba\.)$ doesn't match */
 	pp = mock_path(vnd__oo.value, prd_ba_s.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches kv2 */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	/* Later match takes prio */
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
 static int setup_regex_string_hwe_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd_t_oo, prd_ba_s, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES_W_DIR(hwt, kv1, kv2);
@@ -867,29 +867,29 @@ static void test_regex_2_strings_hwe_dir(const struct hwt_state *hwt)
 	/* foo:baz matches kv1 */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(pp->uid_attribute, DEFAULT_UID_ATTRIBUTE);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* boo:baz doesn't match */
 	pp = mock_path(vnd_boo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(pp->uid_attribute, DEFAULT_UID_ATTRIBUTE);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches kv2 and kv1 */
 	pp = mock_path(vnd_foo.value, prd_bar.value);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(pp->uid_attribute, uid_baz.value);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* foo:barz matches kv3 and kv2 and kv1 */
-	pp = mock_path_flags(vnd_foo.value, prd_barz.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_barz.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_rdac.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
 	TEST_PROP(pp->uid_attribute, NULL);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
@@ -898,7 +898,7 @@ static int setup_regex_2_strings_hwe_dir(void **state)
 	const struct key_value kv1[] = { vnd_foo, prd_ba_, prio_emc, chk_hp };
 	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, uid_baz };
 	const struct key_value kv3[] = { vnd_foo, prd_barz,
-					 prio_rdac, gui_foo };
+					 prio_rdac, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	begin_config(hwt);
@@ -924,40 +924,40 @@ static void test_string_regex_hwe_dir(const struct hwt_state *hwt)
 	struct path *pp;
 
 	/* foo:bar matches kv2 and kv1 */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* foo:baz matches kv1 */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* boo:baz matches kv1 */
 	pp = mock_path(vnd_boo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* .oo:ba. matches kv1 */
 	pp = mock_path(vnd__oo.value, prd_ba_.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* .oo:(bar|baz|ba\.)$ doesn't match */
 	pp = mock_path(vnd__oo.value, prd_ba_s.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 }
 
 static int setup_string_regex_hwe_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd_t_oo, prd_ba_s, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES_W_DIR(hwt, kv2, kv1);
@@ -980,20 +980,20 @@ static void test_2_ident_strings_hwe(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches both */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
 static int setup_2_ident_strings_hwe(void **state)
 {
 	const struct key_value kv1[] = { vnd_foo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES(hwt, kv1, kv2);
@@ -1015,20 +1015,20 @@ static void test_2_ident_strings_both_dir(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches both */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
 static int setup_2_ident_strings_both_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd_foo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	begin_config(hwt);
@@ -1055,13 +1055,13 @@ static void test_2_ident_strings_both_dir_w_prev(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches both */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
@@ -1071,7 +1071,7 @@ static int setup_2_ident_strings_both_dir_w_prev(void **state)
 
 	const struct key_value kv0[] = { vnd_foo, prd_bar };
 	const struct key_value kv1[] = { vnd_foo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 
 	begin_config(hwt);
 	begin_section_all(hwt, "devices");
@@ -1100,20 +1100,20 @@ static void test_2_ident_strings_hwe_dir(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches both */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
 static int setup_2_ident_strings_hwe_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd_foo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES_W_DIR(hwt, kv1, kv2);
@@ -1134,13 +1134,13 @@ static void test_3_ident_strings_hwe_dir(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches both */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
@@ -1148,7 +1148,7 @@ static int setup_3_ident_strings_hwe_dir(void **state)
 {
 	const struct key_value kv0[] = { vnd_foo, prd_bar };
 	const struct key_value kv1[] = { vnd_foo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	begin_config(hwt);
@@ -1178,20 +1178,20 @@ static void test_2_ident_self_matching_re_hwe_dir(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches both */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
 static int setup_2_ident_self_matching_re_hwe_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd__oo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd__oo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd__oo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES_W_DIR(hwt, kv1, kv2);
@@ -1213,20 +1213,20 @@ static void test_2_ident_self_matching_re_hwe(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
 static int setup_2_ident_self_matching_re_hwe(void **state)
 {
 	const struct key_value kv1[] = { vnd__oo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd__oo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd__oo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES(hwt, kv1, kv2);
@@ -1250,20 +1250,20 @@ test_2_ident_not_self_matching_re_hwe_dir(const struct hwt_state *hwt)
 	/* foo:baz doesn't match */
 	pp = mock_path(vnd_foo.value, prd_baz.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
 	/* foo:bar matches both */
-	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_bar.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
 static int setup_2_ident_not_self_matching_re_hwe_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd_t_oo, prd_bar, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_t_oo, prd_bar, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_t_oo, prd_bar, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES_W_DIR(hwt, kv1, kv2);
@@ -1287,26 +1287,26 @@ static void test_2_matching_res_hwe_dir(const struct hwt_state *hwt)
 	/* foo:bar matches k1 only */
 	pp = mock_path(vnd_foo.value, prd_bar.value);
 	TEST_PROP(prio_name(&pp->prio), prio_emc.value);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* foo:bay matches k1 and k2 */
-	pp = mock_path_flags(vnd_foo.value, "bay", USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, "bay", USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 
 	/* foo:baz matches k2 only. */
-	pp = mock_path_flags(vnd_foo.value, prd_baz.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_baz.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 }
 
 static int setup_2_matching_res_hwe_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd_foo, prd_barx, prio_emc, chk_hp };
-	const struct key_value kv2[] = { vnd_foo, prd_bazy, prio_hds, gui_foo };
+	const struct key_value kv2[] = { vnd_foo, prd_bazy, prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES_W_DIR(hwt, kv1, kv2);
@@ -1328,12 +1328,12 @@ static void test_2_nonmatching_res_hwe_dir(const struct hwt_state *hwt)
 	/* foo:bar doesn't match */
 	pp = mock_path(vnd_foo.value, prd_bar.value);
 	TEST_PROP(prio_name(&pp->prio), DEFAULT_PRIO);
-	TEST_PROP(pp->getuid, NULL);
+	assert_int_equal(pp->vpd_vendor_id, 0);
 	TEST_PROP(checker_name(&pp->checker), DEFAULT_CHECKER);
 
-	pp = mock_path_flags(vnd_foo.value, prd_baz.value, USE_GETUID);
+	pp = mock_path_flags(vnd_foo.value, prd_baz.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_hds.value);
-	TEST_PROP(pp->getuid, gui_foo.value);
+	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
@@ -1341,7 +1341,7 @@ static int setup_2_nonmatching_res_hwe_dir(void **state)
 {
 	const struct key_value kv1[] = { vnd_foo, prd_bazy, prio_emc, chk_hp };
 	const struct key_value kv2[] = { vnd_foo, prd_bazy1,
-					 prio_hds, gui_foo };
+					 prio_hds, vpd_hp3par };
 	struct hwt_state *hwt = CHECK_STATE(state);
 
 	WRITE_TWO_DEVICES_W_DIR(hwt, kv1, kv2);
tests/test-lib.c +68 -21

140 lines not on this page · raw message

tests/test-lib.h +1 -1
index 7643ab6..efd03a7 100644
@@ -14,7 +14,7 @@ enum {
 	BL_MASK = BL_BY_DEVNODE|BL_BY_DEVICE|BL_BY_WWID|BL_BY_PROPERTY,
 	NEED_SELECT_PRIO = (1 << 8),
 	NEED_FD		= (1 << 9),
-	USE_GETUID	= (1 << 10),
+	USE_VPD_VND	= (1 << 10),
 	DEV_HIDDEN	= (1 << 11),
 };
 
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#4 lore raw

PATCH 4/7 tests/hwtable: fix test_regex_2_strings_hwe_dir

In reply to [email protected]

From: Martin Wilck <[email protected]>

Unlike "getuid_callout", "vpd_vendor" doesn't invalidate "uid_attribute".

---
 tests/hwtable.c  | 2 +-
 tests/test-lib.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/hwtable.c +1 -1
index b8e73a6..e60e914 100644
@@ -888,8 +888,8 @@ static void test_regex_2_strings_hwe_dir(const struct hwt_state *hwt)
 	/* foo:barz matches kv3 and kv2 and kv1 */
 	pp = mock_path_flags(vnd_foo.value, prd_barz.value, USE_VPD_VND);
 	TEST_PROP(prio_name(&pp->prio), prio_rdac.value);
-	TEST_PROP(pp->uid_attribute, NULL);
 	assert_int_equal(pp->vpd_vendor_id, VPD_VP_HP3PAR);
+	TEST_PROP(pp->uid_attribute, uid_baz.value);
 	TEST_PROP(checker_name(&pp->checker), chk_hp.value);
 }
 
tests/test-lib.c +1 -1
index 68e0dd8..6dd3ee8 100644
@@ -229,7 +229,7 @@ int __wrap_ioctl(int fd, unsigned long request, void *param)
 		if (hdr->interface_id == 'S' && hdr->cmdp[0] == 0x12
 		    && (hdr->cmdp[1] & 1) == 1 && hdr->cmdp[2] == HP3PAR_VPD) {
 			assert_in_range(hdr->dxfer_len,
-					sizeof(vpd_data + 3), INT_MAX);
+					sizeof(vpd_data) + 3, INT_MAX);
 			memset(buf, 0, hdr->dxfer_len);
 			buf[1] = HP3PAR_VPD;
 			put_unaligned_be16(sizeof(vpd_data), &buf[2]);
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#5 lore raw

PATCH 5/7 libmultipath: fix valgrind_test

In reply to [email protected]

From: Martin Wilck <[email protected]>

"enable_foreign" was not freed. Fix it.

---
 libmultipath/config.c | 3 +++
 1 file changed, 3 insertions(+)
libmultipath/config.c +3 -0
index 6f67285..ab8b26e 100644
@@ -760,6 +760,9 @@ static void _uninit_config(struct config *conf)
 	if (conf->checker_name)
 		free(conf->checker_name);
 
+	if (conf->enable_foreign)
+		free(conf->enable_foreign);
+
 	free_blacklist(conf->blist_devnode);
 	free_blacklist(conf->blist_wwid);
 	free_blacklist(conf->blist_property);
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#6 lore raw

PATCH 6/7 tests/Makefile: make TESTDIR configurable

In reply to [email protected]

From: Martin Wilck <[email protected]>

This is required for the "foreign arch" workflow, where build and test dir aren't necessarily equal.

---
 tests/Makefile | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tests/Makefile +5 -2
index 7341b7e..0b39c30 100644
@@ -1,5 +1,8 @@
 include ../Makefile.inc
 
+# directory where to run the tests
+TESTDIR := $(CURDIR)
+
 # Test special behavior of gcc 4.8 with nested initializers
 # gcc 4.8 compiles blacklist.c only with -Wno-missing-field-initializers
 TEST_MISSING_INITIALIZERS = $(shell \
@@ -9,7 +12,7 @@ TEST_MISSING_INITIALIZERS = $(shell \
 W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS)
 
 CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) \
-	-Wno-unused-parameter $(W_MISSING_INITIALIZERS) -DTESTCONFDIR=\"$(CURDIR)/conf.d\"
+	-Wno-unused-parameter $(W_MISSING_INITIALIZERS) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\"
 LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka
 
 TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \
@@ -108,7 +111,7 @@ dep_clean:
 		sort -u | tr '\n' ' ' >$@
 
 libmultipath.so.0:
-	make -C $(multipathdir) configdir=$(CURDIR)/conf.d plugindir=$(CURDIR)/lib test-lib
+	make -C $(multipathdir) configdir=$(TESTDIR)/conf.d plugindir=$(TESTDIR)/lib test-lib
 
 # COLON will get expanded during second expansion below
 COLON:=:
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#7 lore raw

PATCH 7/7 github workflows: foreign.yaml: fix config dir in run environment

In reply to [email protected]

From: Martin Wilck <[email protected]>

The foreign workflow uses a container for running the tests. The paths for the working directory must match between builder and runner, otherwise the hwtable test fails while trying to create the CONFIG_DIR.

The container uses ${{ github.workspace }} as working directory, whereas the build environment uses the abbreviated __w/multipath-tools/multipath-tools. Adapt the build environment such that the path is correct later.

See https://github.com/mosteo-actions/docker-run/blob/v1/action.yml

---
 .github/workflows/foreign.yaml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
.github/workflows/foreign.yaml +5 -2
index c164cb3..e9ffd3d 100644
@@ -24,7 +24,8 @@ jobs:
         run: make test
       - name: build
         if: ${{ matrix.arch != '' && matrix.arch != '-i386' }}
-        run: make test-progs
+        # The build path is different between builder and runner
+        run: make TESTDIR=${{ github.workspace }}/tests test-progs
       - name: archive
         if: ${{ matrix.arch != '' && matrix.arch != '-i386' }}
         run: >
@@ -61,6 +62,8 @@ jobs:
         uses: mosteo-actions/docker-run@v1
         with:
           image: mwilck/multipath-run-${{ matrix.os }}-${{ matrix.arch }}
-          # The runner is an image that has "make" as entrypoint
+          # The runner is an image that has "make" as entrypoint and uses
+          # github.workspace as both host dir and guest volume by default.
+          # See https://github.com/mosteo-actions/docker-run/blob/v1/action.yml
           # So run "make -C tests" here
           command: -C tests
Signature · 6 lines
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
maintainer Reviewed-by on the v1 series
#8 lore raw
In reply to [email protected]
Quoted 10 lines · On Wed, May 04, 2022 at 12:06:39AM +0200, [email protected] wrote:

From: Martin Wilck <[email protected]>

Hi Christophe, hi Ben,

The previous patches

af15832 multipath-tools: make multipath_dir a compiled-in option 1fc7c4d multipath-tools: make config_dir a compiled-in option 21b3d6b multipath-tools: stop supporting getuid_callout

Quoted 7 lines

have caused breakage in the unit tests. Not so much because they'd actually break the tests, but because they broke the compilation and the search paths for the configuration files (for the former two commits) and because the hwtable test relied on being able to the retrieve the now removed "getuid_callout" property from config files.

Fix it. As always, comments welcome.

For the set,

Quoted 13 lines

Regards
Martin

Martin Wilck (7):
multipath-tools: enable local configdir and plugindir for unit tests tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE multipath-tools tests: hwtable: adapt after removal of getuid tests/hwtable: fix test_regex_2_strings_hwe_dir
libmultipath: fix valgrind_test
tests/Makefile: make TESTDIR configurable
github workflows: foreign.yaml: fix config dir in run environment

Quoted 12 lines
 .github/workflows/foreign.yaml |   7 +-
 libmultipath/Makefile          |  24 ++++--
 libmultipath/config.c          |   3 +
 tests/Makefile                 |  12 ++-
 tests/hwtable.c                | 151 ++++++++++++++++-----------------
 tests/mpathvalid.c             |   2 +-
 tests/test-lib.c               |  89 ++++++++++++++-----
 tests/test-lib.h               |   2 +-
 8 files changed, 180 insertions(+), 110 deletions(-)
Signature · 1 line
2.36.0

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel