From patchwork Tue May 3 22:06:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12836512 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B8A1C433EF for ; Tue, 3 May 2022 22:58:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-7eu8j0DfONiwCjzc2nIDSw-1; Tue, 03 May 2022 18:58:35 -0400 X-MC-Unique: 7eu8j0DfONiwCjzc2nIDSw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4923818E5389; Tue, 3 May 2022 22:58:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36E9F2166B4E; Tue, 3 May 2022 22:58:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C518D1947040; Tue, 3 May 2022 22:58:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9E02319466DF for ; Tue, 3 May 2022 22:58:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8B405463E15; Tue, 3 May 2022 22:58:31 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8774D40ED53 for ; Tue, 3 May 2022 22:58:31 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F66E3C025B6 for ; Tue, 3 May 2022 22:58:31 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-zmXe5ffHNRKtgrVcSFR_gg-1; Tue, 03 May 2022 18:07:27 -0400 X-MC-Unique: zmXe5ffHNRKtgrVcSFR_gg-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 41DA7210EB; Tue, 3 May 2022 22:07:16 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 12A7313ABE; Tue, 3 May 2022 22:07:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KE3nApSncWLfFgAAMHmgww (envelope-from ); Tue, 03 May 2022 22:07:16 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 May 2022 00:06:40 +0200 Message-Id: <20220503220646.16925-2-mwilck@suse.com> In-Reply-To: <20220503220646.16925-1-mwilck@suse.com> References: <20220503220646.16925-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Subject: [dm-devel] [PATCH 1/7] multipath-tools: enable local configdir and plugindir for unit tests X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck 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 --- 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+"); From patchwork Tue May 3 22:06:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12836513 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78CF3C433F5 for ; Tue, 3 May 2022 22:58:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-TEcxCo3GOyCbUdi_z0NTbw-1; Tue, 03 May 2022 18:58:40 -0400 X-MC-Unique: TEcxCo3GOyCbUdi_z0NTbw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C76C138C5C41; Tue, 3 May 2022 22:58:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B29102026D2D; Tue, 3 May 2022 22:58:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 71FD71947040; Tue, 3 May 2022 22:58:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B6F7B19466DF for ; Tue, 3 May 2022 22:58:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9DEDE40D282C; Tue, 3 May 2022 22:58:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99D3940D282B for ; Tue, 3 May 2022 22:58:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82DEF811E80 for ; Tue, 3 May 2022 22:58:37 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-8p8aoFYwOuCuWP0A8CvRaQ-1; Tue, 03 May 2022 18:07:27 -0400 X-MC-Unique: 8p8aoFYwOuCuWP0A8CvRaQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 82A671F747; Tue, 3 May 2022 22:07:16 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4A8C213ABE; Tue, 3 May 2022 22:07:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qN6aEJSncWLfFgAAMHmgww (envelope-from ); Tue, 03 May 2022 22:07:16 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 May 2022 00:06:41 +0200 Message-Id: <20220503220646.16925-3-mwilck@suse.com> In-Reply-To: <20220503220646.16925-1-mwilck@suse.com> References: <20220503220646.16925-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Subject: [dm-devel] [PATCH 2/7] tests/mpathvalid: fix check for DEFAULT_CONFIG_FILE X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Signed-off-by: Martin Wilck --- 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; From patchwork Tue May 3 22:06:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12836424 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 292A6C433F5 for ; Tue, 3 May 2022 22:10:29 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-163-18m0ShnxP0aH25JvD4IE-A-1; Tue, 03 May 2022 18:10:26 -0400 X-MC-Unique: 18m0ShnxP0aH25JvD4IE-A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 25F9A8E4847; Tue, 3 May 2022 22:10:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D931111E3FD; Tue, 3 May 2022 22:10:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA4FA1947040; Tue, 3 May 2022 22:10:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 02B5819466DF for ; Tue, 3 May 2022 22:10:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CC377554314; Tue, 3 May 2022 22:10:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7BF755430C for ; Tue, 3 May 2022 22:10:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7529D8E4843 for ; Tue, 3 May 2022 22:10:22 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-412-ERGyiqLPOwC4evxDIsHOsw-1; Tue, 03 May 2022 18:07:23 -0400 X-MC-Unique: ERGyiqLPOwC4evxDIsHOsw-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C352C210EC; Tue, 3 May 2022 22:07:16 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8ED1513ABE; Tue, 3 May 2022 22:07:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2HxDIZSncWLfFgAAMHmgww (envelope-from ); Tue, 03 May 2022 22:07:16 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 May 2022 00:06:42 +0200 Message-Id: <20220503220646.16925-4-mwilck@suse.com> In-Reply-To: <20220503220646.16925-1-mwilck@suse.com> References: <20220503220646.16925-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH 3/7] multipath-tools tests: hwtable: adapt after removal of getuid X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck 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 --- 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 #include #include +#include +#include #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), }; From patchwork Tue May 3 22:06:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12836549 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 412EFC433EF for ; Tue, 3 May 2022 23:15:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-194--irc6z4wPQGNIbxk7CCv1g-1; Tue, 03 May 2022 19:15:44 -0400 X-MC-Unique: -irc6z4wPQGNIbxk7CCv1g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22325185A7B2; Tue, 3 May 2022 23:15:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B38EC414A7E7; Tue, 3 May 2022 23:15:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 702FF1947040; Tue, 3 May 2022 23:15:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8A9D619466DF for ; Tue, 3 May 2022 23:15:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4FF245553A2; Tue, 3 May 2022 23:15:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C2AD5553A0 for ; Tue, 3 May 2022 23:15:39 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DE4E2891F58 for ; Tue, 3 May 2022 23:15:31 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-GflJoyBvM6iVOHHR1zjq3w-1; Tue, 03 May 2022 18:07:18 -0400 X-MC-Unique: GflJoyBvM6iVOHHR1zjq3w-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 05CFB210ED; Tue, 3 May 2022 22:07:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CC2B913ABE; Tue, 3 May 2022 22:07:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id INJBMJSncWLfFgAAMHmgww (envelope-from ); Tue, 03 May 2022 22:07:16 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 May 2022 00:06:43 +0200 Message-Id: <20220503220646.16925-5-mwilck@suse.com> In-Reply-To: <20220503220646.16925-1-mwilck@suse.com> References: <20220503220646.16925-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH 4/7] tests/hwtable: fix test_regex_2_strings_hwe_dir X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Unlike "getuid_callout", "vpd_vendor" doesn't invalidate "uid_attribute". Signed-off-by: Martin Wilck --- 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]); From patchwork Tue May 3 22:06:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12836425 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C54BC433FE for ; Tue, 3 May 2022 22:10:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-3RFwCTtEO3u2A3Idw5z1aQ-1; Tue, 03 May 2022 18:10:44 -0400 X-MC-Unique: 3RFwCTtEO3u2A3Idw5z1aQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9259B94A28D; Tue, 3 May 2022 22:10:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E795400DFA0; Tue, 3 May 2022 22:10:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0F39A1947040; Tue, 3 May 2022 22:10:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8FEC119466DF for ; Tue, 3 May 2022 22:10:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 756AAC28109; Tue, 3 May 2022 22:10:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71236C080BC for ; Tue, 3 May 2022 22:10:26 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5705494A291 for ; Tue, 3 May 2022 22:10:26 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-0gteqaimP3KueXnbCU458Q-1; Tue, 03 May 2022 18:07:28 -0400 X-MC-Unique: 0gteqaimP3KueXnbCU458Q-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 462A3210EE; Tue, 3 May 2022 22:07:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0FCEF13ABE; Tue, 3 May 2022 22:07:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wFozApWncWLfFgAAMHmgww (envelope-from ); Tue, 03 May 2022 22:07:17 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 May 2022 00:06:44 +0200 Message-Id: <20220503220646.16925-6-mwilck@suse.com> In-Reply-To: <20220503220646.16925-1-mwilck@suse.com> References: <20220503220646.16925-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Subject: [dm-devel] [PATCH 5/7] libmultipath: fix valgrind_test X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck "enable_foreign" was not freed. Fix it. Signed-off-by: Martin Wilck --- 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); From patchwork Tue May 3 22:06:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12836423 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 356F6C433EF for ; Tue, 3 May 2022 22:09:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-216-w0mHmEtWMgSRguu8ma68Dg-1; Tue, 03 May 2022 18:09:44 -0400 X-MC-Unique: w0mHmEtWMgSRguu8ma68Dg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC85894A2AA; Tue, 3 May 2022 22:07:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AACB2C27EA6; Tue, 3 May 2022 22:07:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 40B821947040; Tue, 3 May 2022 22:07:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1137819466DF for ; Tue, 3 May 2022 22:07:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D135F9E89; Tue, 3 May 2022 22:07:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCC389E84 for ; Tue, 3 May 2022 22:07:34 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68EC794A29C for ; Tue, 3 May 2022 22:07:34 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-489-ZBnqoL-AM_21O0Zawc1NTQ-1; Tue, 03 May 2022 18:07:25 -0400 X-MC-Unique: ZBnqoL-AM_21O0Zawc1NTQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 80915210F4; Tue, 3 May 2022 22:07:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 50E9C13ABE; Tue, 3 May 2022 22:07:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UGQMEpWncWLfFgAAMHmgww (envelope-from ); Tue, 03 May 2022 22:07:17 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 May 2022 00:06:45 +0200 Message-Id: <20220503220646.16925-7-mwilck@suse.com> In-Reply-To: <20220503220646.16925-1-mwilck@suse.com> References: <20220503220646.16925-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Subject: [dm-devel] [PATCH 6/7] tests/Makefile: make TESTDIR configurable X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck This is required for the "foreign arch" workflow, where build and test dir aren't necessarily equal. Signed-off-by: Martin Wilck --- 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:=: From patchwork Tue May 3 22:06:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12836426 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FCD9C433F5 for ; Tue, 3 May 2022 22:10:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-90-sS8jbCgHMjiS2TAAqbMpkw-1; Tue, 03 May 2022 18:09:43 -0400 X-MC-Unique: sS8jbCgHMjiS2TAAqbMpkw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1EAC210187E4; Tue, 3 May 2022 22:07:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5829E553FF0; Tue, 3 May 2022 22:07:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 093CC1947040; Tue, 3 May 2022 22:07:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9C67119466DF for ; Tue, 3 May 2022 22:07:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8C395111D78B; Tue, 3 May 2022 22:07:32 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 872C7111D78A for ; Tue, 3 May 2022 22:07:27 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18B0C29AA2FC for ; Tue, 3 May 2022 22:07:27 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-qP7JIWajN0WXfpI1iVzfBg-1; Tue, 03 May 2022 18:07:25 -0400 X-MC-Unique: qP7JIWajN0WXfpI1iVzfBg-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B73842186F; Tue, 3 May 2022 22:07:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8A11313ABE; Tue, 3 May 2022 22:07:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WIgTIJWncWLfFgAAMHmgww (envelope-from ); Tue, 03 May 2022 22:07:17 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 May 2022 00:06:46 +0200 Message-Id: <20220503220646.16925-8-mwilck@suse.com> In-Reply-To: <20220503220646.16925-1-mwilck@suse.com> References: <20220503220646.16925-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH 7/7] github workflows: foreign.yaml: fix config dir in run environment X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck 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 --- .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