All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage
@ 2022-05-03 22:06 mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 1/7] multipath-tools: enable local configdir and plugindir for unit tests mwilck
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

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(-)

-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dm-devel] [PATCH 1/7] multipath-tools: enable local configdir and plugindir for unit tests
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
@ 2022-05-03 22:06 ` mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 2/7] tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE mwilck
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

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".

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/Makefile | 24 ++++++++++++++++++------
 tests/Makefile        |  9 ++++++---
 tests/hwtable.c       |  7 +++----
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index b3a48c4..a56dd1e 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -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
diff --git a/tests/Makefile b/tests/Makefile
index 8cbc4b7..7341b7e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -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:=:
diff --git a/tests/hwtable.c b/tests/hwtable.c
index 79bfa5f..400e114 100644
--- a/tests/hwtable.c
+++ b/tests/hwtable.c
@@ -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+");
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [dm-devel] [PATCH 2/7] tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 1/7] multipath-tools: enable local configdir and plugindir for unit tests mwilck
@ 2022-05-03 22:06 ` mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 3/7] multipath-tools tests: hwtable: adapt after removal of getuid mwilck
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/mpathvalid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/mpathvalid.c b/tests/mpathvalid.c
index cfe4bae..0230a88 100644
--- a/tests/mpathvalid.c
+++ b/tests/mpathvalid.c
@@ -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;
 
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [dm-devel] [PATCH 3/7] multipath-tools tests: hwtable: adapt after removal of getuid
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 1/7] multipath-tools: enable local configdir and plugindir for unit tests mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 2/7] tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE mwilck
@ 2022-05-03 22:06 ` mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 4/7] tests/hwtable: fix test_regex_2_strings_hwe_dir mwilck
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

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.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/hwtable.c  | 142 +++++++++++++++++++++++------------------------
 tests/test-lib.c |  89 ++++++++++++++++++++++-------
 tests/test-lib.h |   2 +-
 3 files changed, 140 insertions(+), 93 deletions(-)

diff --git a/tests/hwtable.c b/tests/hwtable.c
index 400e114..b8e73a6 100644
--- a/tests/hwtable.c
+++ b/tests/hwtable.c
@@ -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);
diff --git a/tests/test-lib.c b/tests/test-lib.c
index f5542ed..68e0dd8 100644
--- a/tests/test-lib.c
+++ b/tests/test-lib.c
@@ -4,6 +4,8 @@
 #include <cmocka.h>
 #include <libudev.h>
 #include <sys/sysmacros.h>
+#include <linux/hdreg.h>
+#include <scsi/sg.h>
 #include "debug.h"
 #include "util.h"
 #include "vector.h"
@@ -12,9 +14,10 @@
 #include "config.h"
 #include "discovery.h"
 #include "propsel.h"
+#include "unaligned.h"
 #include "test-lib.h"
 
-const int default_mask = (DI_SYSFS|DI_BLACKLIST|DI_WWID|DI_CHECKER|DI_PRIO);
+const int default_mask = (DI_SYSFS|DI_BLACKLIST|DI_WWID|DI_CHECKER|DI_PRIO|DI_SERIAL);
 const char default_devnode[] = "sdxTEST";
 const char default_wwid[] = "TEST-WWID";
 /* default_wwid should be a substring of default_wwid_1! */
@@ -47,15 +50,6 @@ int __wrap_open(const char *path, int flags, int mode)
 	return __real_open(path, flags, mode);
 }
 
-int __wrap_execute_program(char *path, char *value, int len)
-{
-	char *val = mock_ptr_type(char *);
-
-	condlog(5, "%s: %s", __func__, val);
-	strlcpy(value, val, len);
-	return 0;
-}
-
 int __wrap_libmp_get_version(int which, unsigned int version[3])
 {
 	unsigned int *vers = mock_ptr_type(unsigned int *);
@@ -181,6 +175,23 @@ ssize_t __wrap_sysfs_attr_get_value(struct udev_device *dev,
 	return strlen(value);
 }
 
+/* mock vpd_pg80 */
+ssize_t __wrap_sysfs_bin_attr_get_value(struct udev_device *dev,
+					const char *attr_name,
+					char *buf, size_t sz)
+{
+	static const char serial[] = "mptest_serial";
+
+	assert_string_equal(attr_name, "vpd_pg80");
+	assert_in_range(sz, sizeof(serial) + 3, INT_MAX);
+	memset(buf, 0, sizeof(serial) + 3);
+	buf[1] = 0x80;
+	put_unaligned_be16(sizeof(serial) - 1, &buf[2]);
+	memcpy(&buf[4], serial, sizeof(serial) - 1);
+
+	return sizeof(serial) + 3;
+}
+
 int __wrap_checker_check(struct checker *c, int st)
 {
 	condlog(5, "%s: %d", __func__, st);
@@ -195,6 +206,41 @@ int __wrap_prio_getprio(struct prio *p, struct path *pp, unsigned int tmo)
 	return pr;
 }
 
+int __real_ioctl(int fd, unsigned long request, void *param);
+
+int __wrap_ioctl(int fd, unsigned long request, void *param)
+{
+	condlog(5, "%s: %lu", __func__, request);
+
+	if (request == HDIO_GETGEO) {
+		static const struct hd_geometry geom = {
+			.heads = 4, .sectors = 31, .cylinders = 64, .start = 0
+		};
+		memcpy(param, &geom, sizeof(geom));
+		return 0;
+	} else if (request == SG_IO) {
+		/* mock hp3par special VPD */
+		struct sg_io_hdr *hdr = param;
+		static const char vpd_data[] = "VPD DATA";
+		unsigned char *buf = hdr->dxferp;
+		/* see vpd_vendor_pages in discovery.c */
+		const int HP3PAR_VPD = 0xc0;
+
+		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);
+			memset(buf, 0, hdr->dxfer_len);
+			buf[1] = HP3PAR_VPD;
+			put_unaligned_be16(sizeof(vpd_data), &buf[2]);
+			memcpy(&buf[4], vpd_data, sizeof(vpd_data));
+			hdr->status = 0;
+			return 0;
+		}
+	}
+	return __real_ioctl(fd, request, param);
+}
+
 struct mocked_path *fill_mocked_path(struct mocked_path *mp,
 				     const char *vendor, const char *product,
 				     const char *rev, const char *wwid,
@@ -219,14 +265,13 @@ struct mocked_path *mocked_path_from_path(struct mocked_path *mp,
 	mp->devnode = pp->dev;
 	mp->flags = (prio_selected(&pp->prio) ? 0 : NEED_SELECT_PRIO) |
 		(pp->fd < 0 ? NEED_FD : 0) |
-		(pp->getuid ? USE_GETUID : 0);
+		(pp->vpd_vendor_id != 0 ? USE_VPD_VND : 0);
 	return mp;
 }
 
+static const char hbtl[] = "4:0:3:1";
 static void mock_sysfs_pathinfo(const struct mocked_path *mp)
 {
-	static const char hbtl[] = "4:0:3:1";
-
 	will_return(__wrap_udev_device_get_subsystem, "scsi");
 	will_return(__wrap_udev_device_get_sysname, hbtl);
 	will_return(__wrap_udev_device_get_sysname, hbtl);
@@ -284,16 +329,18 @@ void mock_pathinfo(int mask, const struct mocked_path *mp)
 	/* fake open() in pathinfo() */
 	if (mp->flags & NEED_FD)
 		will_return(__wrap_udev_device_get_devnode, _mocked_filename);
-	/* DI_SERIAL is unsupported */
-	assert_false(mask & DI_SERIAL);
+
+	/* scsi_ioctl_pathinfo() */
+	if (mask & DI_SERIAL) {
+		will_return(__wrap_udev_device_get_subsystem, "scsi");
+		will_return(__wrap_udev_device_get_sysname, hbtl);
+		will_return(__wrap_udev_device_get_sysname, hbtl);
+	}
 
 	if (mask & DI_WWID) {
-		if (mp->flags & USE_GETUID)
-			will_return(__wrap_execute_program, mp->wwid);
-		else
-			/* get_udev_uid() */
-			will_return(__wrap_udev_device_get_property_value,
-				    mp->wwid);
+		/* get_udev_uid() */
+		will_return(__wrap_udev_device_get_property_value,
+			    mp->wwid);
 	}
 
 	if (mask & DI_CHECKER) {
diff --git a/tests/test-lib.h b/tests/test-lib.h
index 7643ab6..efd03a7 100644
--- a/tests/test-lib.h
+++ b/tests/test-lib.h
@@ -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),
 };
 
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [dm-devel] [PATCH 4/7] tests/hwtable: fix test_regex_2_strings_hwe_dir
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
                   ` (2 preceding siblings ...)
  2022-05-03 22:06 ` [dm-devel] [PATCH 3/7] multipath-tools tests: hwtable: adapt after removal of getuid mwilck
@ 2022-05-03 22:06 ` mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 5/7] libmultipath: fix valgrind_test mwilck
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

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

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/hwtable.c  | 2 +-
 tests/test-lib.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/hwtable.c b/tests/hwtable.c
index b8e73a6..e60e914 100644
--- a/tests/hwtable.c
+++ b/tests/hwtable.c
@@ -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);
 }
 
diff --git a/tests/test-lib.c b/tests/test-lib.c
index 68e0dd8..6dd3ee8 100644
--- a/tests/test-lib.c
+++ b/tests/test-lib.c
@@ -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]);
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [dm-devel] [PATCH 5/7] libmultipath: fix valgrind_test
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
                   ` (3 preceding siblings ...)
  2022-05-03 22:06 ` [dm-devel] [PATCH 4/7] tests/hwtable: fix test_regex_2_strings_hwe_dir mwilck
@ 2022-05-03 22:06 ` mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 6/7] tests/Makefile: make TESTDIR configurable mwilck
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

"enable_foreign" was not freed. Fix it.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/config.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 6f67285..ab8b26e 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -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);
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [dm-devel] [PATCH 6/7] tests/Makefile: make TESTDIR configurable
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
                   ` (4 preceding siblings ...)
  2022-05-03 22:06 ` [dm-devel] [PATCH 5/7] libmultipath: fix valgrind_test mwilck
@ 2022-05-03 22:06 ` mwilck
  2022-05-03 22:06 ` [dm-devel] [PATCH 7/7] github workflows: foreign.yaml: fix config dir in run environment mwilck
  2022-05-05 21:36 ` [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage Benjamin Marzinski
  7 siblings, 0 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

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

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/Makefile | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 7341b7e..0b39c30 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -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:=:
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [dm-devel] [PATCH 7/7] github workflows: foreign.yaml: fix config dir in run environment
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
                   ` (5 preceding siblings ...)
  2022-05-03 22:06 ` [dm-devel] [PATCH 6/7] tests/Makefile: make TESTDIR configurable mwilck
@ 2022-05-03 22:06 ` mwilck
  2022-05-05 21:36 ` [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage Benjamin Marzinski
  7 siblings, 0 replies; 9+ messages in thread
From: mwilck @ 2022-05-03 22:06 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

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

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 .github/workflows/foreign.yaml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/foreign.yaml b/.github/workflows/foreign.yaml
index c164cb3..e9ffd3d 100644
--- a/.github/workflows/foreign.yaml
+++ b/.github/workflows/foreign.yaml
@@ -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
-- 
2.36.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage
  2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
                   ` (6 preceding siblings ...)
  2022-05-03 22:06 ` [dm-devel] [PATCH 7/7] github workflows: foreign.yaml: fix config dir in run environment mwilck
@ 2022-05-05 21:36 ` Benjamin Marzinski
  7 siblings, 0 replies; 9+ messages in thread
From: Benjamin Marzinski @ 2022-05-05 21:36 UTC (permalink / raw)
  To: mwilck; +Cc: Christophe Varoqui, dm-devel

On Wed, May 04, 2022 at 12:06:39AM +0200, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> 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.

For the set,
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>

> 
> 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(-)
> 
> -- 
> 2.36.0
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-05 21:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-03 22:06 [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage mwilck
2022-05-03 22:06 ` [dm-devel] [PATCH 1/7] multipath-tools: enable local configdir and plugindir for unit tests mwilck
2022-05-03 22:06 ` [dm-devel] [PATCH 2/7] tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE mwilck
2022-05-03 22:06 ` [dm-devel] [PATCH 3/7] multipath-tools tests: hwtable: adapt after removal of getuid mwilck
2022-05-03 22:06 ` [dm-devel] [PATCH 4/7] tests/hwtable: fix test_regex_2_strings_hwe_dir mwilck
2022-05-03 22:06 ` [dm-devel] [PATCH 5/7] libmultipath: fix valgrind_test mwilck
2022-05-03 22:06 ` [dm-devel] [PATCH 6/7] tests/Makefile: make TESTDIR configurable mwilck
2022-05-03 22:06 ` [dm-devel] [PATCH 7/7] github workflows: foreign.yaml: fix config dir in run environment mwilck
2022-05-05 21:36 ` [dm-devel] [PATCH 0/7] multipath-tools: fix unit test breakage Benjamin Marzinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.