From patchwork Thu Sep 2 20:43:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12472465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00197C433EF for ; Thu, 2 Sep 2021 20:43:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D20E661054 for ; Thu, 2 Sep 2021 20:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344848AbhIBUoR (ORCPT ); Thu, 2 Sep 2021 16:44:17 -0400 Received: from mga02.intel.com ([134.134.136.20]:20361 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344846AbhIBUoK (ORCPT ); Thu, 2 Sep 2021 16:44:10 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="206462219" X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="206462219" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:11 -0700 X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="602548264" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:10 -0700 Subject: [ndctl PATCH v2 2/6] Documentation: Drop attrs.adoc include From: Dan Williams To: nvdimm@lists.linux.dev Cc: vishal.l.verma@intel.com, linux-cxl@vger.kernel.org Date: Thu, 02 Sep 2021 13:43:10 -0700 Message-ID: <163061539059.1943957.3717594871893118896.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> References: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org In preparation for switching build systems, drop the attrs.adoc include for communicating variables to asciidoc. Simply add the necessary variable values to the invocation of the command using the --attribute argument. Signed-off-by: Dan Williams --- Documentation/ndctl/Makefile.am | 14 ++++---------- Documentation/ndctl/intel-nvdimm-security.txt | 2 -- Documentation/ndctl/ndctl-load-keys.txt | 2 -- Documentation/ndctl/ndctl-monitor.txt | 5 +---- Documentation/ndctl/ndctl-sanitize-dimm.txt | 2 -- Documentation/ndctl/ndctl-setup-passphrase.txt | 2 -- Documentation/ndctl/ndctl-update-passphrase.txt | 2 -- 7 files changed, 5 insertions(+), 24 deletions(-) diff --git a/Documentation/ndctl/Makefile.am b/Documentation/ndctl/Makefile.am index f0d5b213057c..9ec5458c2268 100644 --- a/Documentation/ndctl/Makefile.am +++ b/Documentation/ndctl/Makefile.am @@ -56,14 +56,6 @@ EXTRA_DIST = $(man1_MANS) CLEANFILES = $(man1_MANS) -.ONESHELL: -attrs.adoc: $(srcdir)/Makefile.am - $(AM_V_GEN) cat <<- EOF >$@ - :ndctl_monitorconfdir: $(ndctl_monitorconfdir) - :ndctl_monitorconf: $(ndctl_monitorconf) - :ndctl_keysdir: $(ndctl_keysdir) - EOF - XML_DEPS = \ ../../version.m4 \ Makefile \ @@ -76,8 +68,7 @@ XML_DEPS = \ xable-namespace-options.txt \ ars-description.txt \ labels-description.txt \ - labels-options.txt \ - attrs.adoc + labels-options.txt RM ?= rm -f @@ -88,6 +79,9 @@ if USE_ASCIIDOCTOR $(ASCIIDOC) -b manpage -d manpage -acompat-mode \ -I. -rasciidoctor-extensions \ -amansource=ndctl -amanmanual="ndctl Manual" \ + -andctl_monitorconf=$(ndctl_monitorconfdir)/$(ndctl_monitorconf) \ + -andctl_monitorconfdir=$(ndctl_monitorconfdir) \ + -andctl_keysdir=$(ndctl_keysdir) \ -andctl_version=$(VERSION) -o $@+ $< && \ mv $@+ $@ diff --git a/Documentation/ndctl/intel-nvdimm-security.txt b/Documentation/ndctl/intel-nvdimm-security.txt index 142b4603db69..88b305b81978 100644 --- a/Documentation/ndctl/intel-nvdimm-security.txt +++ b/Documentation/ndctl/intel-nvdimm-security.txt @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -include::attrs.adoc[] - THEORY OF OPERATION ------------------- The Intel Device Specific Methods (DSM) specification v1.7 and v1.8 [1] diff --git a/Documentation/ndctl/ndctl-load-keys.txt b/Documentation/ndctl/ndctl-load-keys.txt index a064f97fd069..70db57441820 100644 --- a/Documentation/ndctl/ndctl-load-keys.txt +++ b/Documentation/ndctl/ndctl-load-keys.txt @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -include::attrs.adoc[] - ndctl-load-keys(1) ================== diff --git a/Documentation/ndctl/ndctl-monitor.txt b/Documentation/ndctl/ndctl-monitor.txt index dbc9070c6331..14e0026c657e 100644 --- a/Documentation/ndctl/ndctl-monitor.txt +++ b/Documentation/ndctl/ndctl-monitor.txt @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -include::attrs.adoc[] - ndctl-monitor(1) ================ @@ -21,8 +19,7 @@ objects and dumping the json format notifications to syslog, standard output or a logfile. The objects to monitor and smart events to notify can be selected by -setting options and/or the configuration file at -{ndctl_monitorconfdir}/{ndctl_monitorconf} +setting options and/or the configuration file at {ndctl_monitorconf} Both, the values in configuration file and in options will work. If there is a conflict, the values in options will override the values in diff --git a/Documentation/ndctl/ndctl-sanitize-dimm.txt b/Documentation/ndctl/ndctl-sanitize-dimm.txt index b2e5fde9ecb3..e04467856ca4 100644 --- a/Documentation/ndctl/ndctl-sanitize-dimm.txt +++ b/Documentation/ndctl/ndctl-sanitize-dimm.txt @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -include::attrs.adoc[] - ndctl-sanitize-dimm(1) ====================== diff --git a/Documentation/ndctl/ndctl-setup-passphrase.txt b/Documentation/ndctl/ndctl-setup-passphrase.txt index 1219279b4c66..96f709b468fc 100644 --- a/Documentation/ndctl/ndctl-setup-passphrase.txt +++ b/Documentation/ndctl/ndctl-setup-passphrase.txt @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -include::attrs.adoc[] - ndctl-setup-passphrase(1) ========================= diff --git a/Documentation/ndctl/ndctl-update-passphrase.txt b/Documentation/ndctl/ndctl-update-passphrase.txt index c7c1bfc8ab0b..591ce44ebc3e 100644 --- a/Documentation/ndctl/ndctl-update-passphrase.txt +++ b/Documentation/ndctl/ndctl-update-passphrase.txt @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -include::attrs.adoc[] - ndctl-update-passphrase(1) ========================== From patchwork Thu Sep 2 20:43:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12472475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAF52C433F5 for ; Thu, 2 Sep 2021 20:43:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B900E61054 for ; Thu, 2 Sep 2021 20:43:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344241AbhIBUok (ORCPT ); Thu, 2 Sep 2021 16:44:40 -0400 Received: from mga11.intel.com ([192.55.52.93]:18162 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344623AbhIBUoh (ORCPT ); Thu, 2 Sep 2021 16:44:37 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="216102182" X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="216102182" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:16 -0700 X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="691676385" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:16 -0700 Subject: [ndctl PATCH v2 3/6] build: Drop unnecessary $tool/config.h includes From: Dan Williams To: nvdimm@lists.linux.dev Cc: vishal.l.verma@intel.com, linux-cxl@vger.kernel.org Date: Thu, 02 Sep 2021 13:43:16 -0700 Message-ID: <163061539621.1943957.15148388017989435698.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> References: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org In preparation for support for meson as the build infrastructure remove some explicit config.h includes that will be replaced by a unified config.h at the top of the project. Signed-off-by: Dan Williams --- daxctl/migrate.c | 1 - ndctl/keys.c | 1 - ndctl/monitor.c | 1 - 3 files changed, 3 deletions(-) diff --git a/daxctl/migrate.c b/daxctl/migrate.c index 5fbe970fdaff..c51106625849 100644 --- a/daxctl/migrate.c +++ b/daxctl/migrate.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/ndctl/keys.c b/ndctl/keys.c index 876b34714b7e..2f33b8fb488c 100644 --- a/ndctl/keys.c +++ b/ndctl/keys.c @@ -13,7 +13,6 @@ #include #include -#include #include #include diff --git a/ndctl/monitor.c b/ndctl/monitor.c index 85890c5367d3..fde5b1209565 100644 --- a/ndctl/monitor.c +++ b/ndctl/monitor.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include From patchwork Thu Sep 2 20:43:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12472473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB0FDC433FE for ; Thu, 2 Sep 2021 20:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2531610CC for ; Thu, 2 Sep 2021 20:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344891AbhIBUob (ORCPT ); Thu, 2 Sep 2021 16:44:31 -0400 Received: from mga18.intel.com ([134.134.136.126]:59174 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344631AbhIBUoa (ORCPT ); Thu, 2 Sep 2021 16:44:30 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="206364690" X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="206364690" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:22 -0700 X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="533471479" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:22 -0700 Subject: [ndctl PATCH v2 4/6] test: Prepare out of line builds From: Dan Williams To: nvdimm@lists.linux.dev Cc: vishal.l.verma@intel.com, linux-cxl@vger.kernel.org Date: Thu, 02 Sep 2021 13:43:21 -0700 Message-ID: <163061540176.1943957.10710406605059844145.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> References: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org In preparation for converting to meson prepare the unit tests to run out of a build directory rather than out of the source directory. Introduce TEST_PATH for the location of the test executables. Signed-off-by: Dan Williams --- test/btt-errors.sh | 4 +--- test/common | 37 +++++++++++++++++++++---------------- test/dax-pmd.c | 7 +++++-- test/dax.sh | 6 +++--- test/daxdev-errors.sh | 4 ++-- test/device-dax-fio.sh | 2 +- test/dm.sh | 4 ++-- test/inject-smart.sh | 2 +- test/mmap.sh | 6 +++--- test/monitor.sh | 6 +++--- test/pmem-errors.sh | 8 +++----- test/sub-section.sh | 4 ++-- test/track-uuid.sh | 2 +- 13 files changed, 48 insertions(+), 44 deletions(-) diff --git a/test/btt-errors.sh b/test/btt-errors.sh index 4e59f57aea7c..599d160d1922 100755 --- a/test/btt-errors.sh +++ b/test/btt-errors.sh @@ -11,14 +11,12 @@ rc=77 cleanup() { - rm -f $FILE - rm -f $MNT/$FILE if grep -q "$MNT" /proc/mounts; then umount $MNT else rc=77 fi - rmdir $MNT + rm -rf $MNT } force_raw() diff --git a/test/common b/test/common index 6bcefcad9bf9..251a129b1771 100644 --- a/test/common +++ b/test/common @@ -4,27 +4,32 @@ # Global variables # NDCTL -# -if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then - export NDCTL=../ndctl/ndctl -elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then - export NDCTL=./ndctl/ndctl -else - echo "Couldn't find an ndctl binary" - exit 1 +if [ -z $NDCTL ]; then + if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then + export NDCTL=../ndctl/ndctl + elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then + export NDCTL=./ndctl/ndctl + else + echo "Couldn't find an ndctl binary" + exit 1 + fi fi # DAXCTL -# -if [ -f "../daxctl/daxctl" ] && [ -x "../daxctl/daxctl" ]; then - export DAXCTL=../daxctl/daxctl -elif [ -f "./daxctl/daxctl" ] && [ -x "./daxctl/daxctl" ]; then - export DAXCTL=./daxctl/daxctl -else - echo "Couldn't find an daxctl binary" - exit 1 +if [ -z $DAXCTL ]; then + if [ -f "../daxctl/daxctl" ] && [ -x "../daxctl/daxctl" ]; then + export DAXCTL=../daxctl/daxctl + elif [ -f "./daxctl/daxctl" ] && [ -x "./daxctl/daxctl" ]; then + export DAXCTL=./daxctl/daxctl + else + echo "Couldn't find an daxctl binary" + exit 1 + fi fi +if [ -z $TEST_PATH ]; then + export TEST_PATH=. +fi # NFIT_TEST_BUS[01] # diff --git a/test/dax-pmd.c b/test/dax-pmd.c index 7648e348b0a6..1a61abf10c11 100644 --- a/test/dax-pmd.c +++ b/test/dax-pmd.c @@ -24,7 +24,7 @@ __func__, __LINE__, strerror(errno)) #define faili(i) fprintf(stderr, "%s: failed at: %d: %d (%s)\n", \ __func__, __LINE__, i, strerror(errno)) -#define TEST_FILE "test_dax_data" +#define TEST_FILE "test_dax_mnt/test_dax_data" #define REGION_MEM_SIZE 4096*4 #define REGION_PM_SIZE 4096*512 @@ -172,8 +172,11 @@ int test_dax_directio(int dax_fd, unsigned long align, void *dax_addr, off_t off rc = -ENXIO; fd2 = open(TEST_FILE, O_CREAT|O_TRUNC|O_DIRECT|O_RDWR, - DEFFILEMODE); + 0600); if (fd2 < 0) { + /* skip on tmpfs */ + if (errno == EINVAL) + rc = 77; faili(i); munmap(addr, 2*align); break; diff --git a/test/dax.sh b/test/dax.sh index bcdd4e9bda27..bb9848b10ecc 100755 --- a/test/dax.sh +++ b/test/dax.sh @@ -15,13 +15,13 @@ cleanup() { else rc=77 fi - rmdir $MNT + rm -rf $MNT exit $rc } run_test() { rc=0 - if ! trace-cmd record -e fs_dax:dax_pmd_fault_done ./dax-pmd $MNT/$FILE; then + if ! trace-cmd record -e fs_dax:dax_pmd_fault_done $TEST_PATH/dax-pmd $MNT/$FILE; then rc=$? if [ "$rc" -ne 77 ] && [ "$rc" -ne 0 ]; then cleanup "$1" @@ -104,7 +104,7 @@ set -e mkdir -p $MNT trap 'err $LINENO cleanup' ERR -dev=$(./dax-dev) +dev=$($TEST_PATH/dax-dev) json=$($NDCTL list -N -n $dev) eval $(json2var <<< "$json") rc=1 diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh index 9547d781162b..3718e32a3052 100755 --- a/test/daxdev-errors.sh +++ b/test/daxdev-errors.sh @@ -64,8 +64,8 @@ read sector len < /sys/bus/nd/devices/$region/badblocks echo "sector: $sector len: $len" # run the daxdev-errors test -test -x ./daxdev-errors -./daxdev-errors $busdev $region +test -x $TEST_PATH/daxdev-errors +$TEST_PATH/daxdev-errors $busdev $region # check badblocks, should be empty if read sector len < /sys/bus/platform/devices/nfit_test.0/$busdev/$region/badblocks; then diff --git a/test/device-dax-fio.sh b/test/device-dax-fio.sh index f57a9d266afc..c43ac058d2b0 100755 --- a/test/device-dax-fio.sh +++ b/test/device-dax-fio.sh @@ -18,7 +18,7 @@ if ! fio --enghelp | grep -q "dev-dax"; then exit 77 fi -dev=$(./dax-dev) +dev=$($TEST_PATH/dax-dev) for align in 4k 2m 1g do json=$($NDCTL create-namespace -m devdax -a $align -f -e $dev) diff --git a/test/dm.sh b/test/dm.sh index 4656e5bfbebe..b780a65c27d2 100755 --- a/test/dm.sh +++ b/test/dm.sh @@ -8,7 +8,7 @@ SKIP=77 FAIL=1 SUCCESS=0 -. ./common +. $(dirname $0)/common MNT=test_dax_mnt TEST_DM_PMEM=/dev/mapper/test_pmem @@ -30,7 +30,7 @@ cleanup() { if [ -L $TEST_DM_PMEM ]; then dmsetup remove $TEST_DM_PMEM fi - rmdir $MNT + rm -rf $MNT # opportunistic cleanup, not fatal if these fail namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev") for i in $namespaces diff --git a/test/inject-smart.sh b/test/inject-smart.sh index 4ca83b8b2263..8b913601bdd2 100755 --- a/test/inject-smart.sh +++ b/test/inject-smart.sh @@ -170,7 +170,7 @@ check_prereq "jq" modprobe nfit_test rc=1 -jlist=$(./list-smart-dimm -b $bus) +jlist=$($TEST_PATH/list-smart-dimm -b $bus) dimm="$(jq '.[]."dev"?, ."dev"?' <<< $jlist | sort | head -1 | xargs)" test -n "$dimm" diff --git a/test/mmap.sh b/test/mmap.sh index 50a1d34d0b75..760257dc7f93 100755 --- a/test/mmap.sh +++ b/test/mmap.sh @@ -7,7 +7,7 @@ MNT=test_mmap_mnt FILE=image DEV="" -TEST=./mmap +TEST=$TEST_PATH/mmap rc=77 cleanup() { @@ -17,7 +17,7 @@ cleanup() { else rc=77 fi - rmdir $MNT + rm -rf $MNT exit $rc } @@ -49,7 +49,7 @@ set -e mkdir -p $MNT trap 'err $LINENO cleanup' ERR -dev=$(./dax-dev) +dev=$($TEST_PATH/dax-dev) json=$($NDCTL list -N -n $dev) eval $(json2var <<< "$json") DEV="/dev/${blockdev}" diff --git a/test/monitor.sh b/test/monitor.sh index 28c55415c819..7b0031c650f3 100755 --- a/test/monitor.sh +++ b/test/monitor.sh @@ -38,7 +38,7 @@ start_monitor() set_smart_supported_bus() { smart_supported_bus=$NFIT_TEST_BUS0 - monitor_dimms=$(./list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev) + monitor_dimms=$($TEST_PATH/list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev) if [ -z $monitor_dimms ]; then smart_supported_bus=$NFIT_TEST_BUS1 fi @@ -46,14 +46,14 @@ set_smart_supported_bus() get_monitor_dimm() { - jlist=$(./list-smart-dimm -b $smart_supported_bus $1) + jlist=$($TEST_PATH/list-smart-dimm -b $smart_supported_bus $1) monitor_dimms=$(jq '.[]."dev"?, ."dev"?' <<<$jlist | sort | uniq | xargs) echo $monitor_dimms } call_notify() { - ./smart-notify $smart_supported_bus + $TEST_PATH/smart-notify $smart_supported_bus sync; sleep 3 } diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh index 4225c3bce0c7..4083fc389bdf 100755 --- a/test/pmem-errors.sh +++ b/test/pmem-errors.sh @@ -10,14 +10,12 @@ rc=77 cleanup() { - rm -f $FILE - rm -f $MNT/$FILE if [ -n "$blockdev" ]; then umount /dev/$blockdev else rc=77 fi - rmdir $MNT + rm -rf $MNT } check_min_kver "4.7" || do_skip "may lack dax error handling" @@ -84,8 +82,8 @@ echo $start_sect 8 > /sys/block/$blockdev/badblocks dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || true # run the dax-errors test -test -x ./dax-errors -./dax-errors $MNT/$FILE +test -x $TEST_PATH/dax-errors +$TEST_PATH/dax-errors $MNT/$FILE # TODO: disable this check till we have clear-on-write in the kernel #if read sector len < /sys/block/$blockdev/badblocks; then diff --git a/test/sub-section.sh b/test/sub-section.sh index 92ae816c448c..77b963355c8f 100755 --- a/test/sub-section.sh +++ b/test/sub-section.sh @@ -8,7 +8,7 @@ SKIP=77 FAIL=1 SUCCESS=0 -. ./common +. $(dirname $0)/common check_min_kver "5.3" || do_skip "may lack align sub-section hotplug support" @@ -30,7 +30,7 @@ cleanup() { if mountpoint -q $MNT; then umount $MNT fi - rmdir $MNT + rm -rf $MNT # opportunistic cleanup, not fatal if these fail namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev") for i in $namespaces diff --git a/test/track-uuid.sh b/test/track-uuid.sh index be3cf9c07a0a..516d073ac109 100755 --- a/test/track-uuid.sh +++ b/test/track-uuid.sh @@ -5,7 +5,7 @@ blockdev="" rc=77 -. ./common +. $(dirname $0)/common set -e trap 'err $LINENO' ERR From patchwork Thu Sep 2 20:43:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12472469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76D45C433EF for ; Thu, 2 Sep 2021 20:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 542BD60FDA for ; Thu, 2 Sep 2021 20:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232045AbhIBUo1 (ORCPT ); Thu, 2 Sep 2021 16:44:27 -0400 Received: from mga02.intel.com ([134.134.136.20]:20387 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344623AbhIBUo1 (ORCPT ); Thu, 2 Sep 2021 16:44:27 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="206462266" X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="206462266" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:28 -0700 X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="691676454" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:27 -0700 Subject: [ndctl PATCH v2 5/6] build: Add meson build infrastructure From: Dan Williams To: nvdimm@lists.linux.dev Cc: Vaibhav Jain , vishal.l.verma@intel.com, linux-cxl@vger.kernel.org Date: Thu, 02 Sep 2021 13:43:27 -0700 Message-ID: <163061540739.1943957.16160705686052773753.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> References: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Build times improve from 10s of seconds to sub-second builds especially when ccache gets involved and the only change is a git version bump. Recall that every time the version changes with autotools it does a reconfigure. With meson only the objects that depend on the version string are rebuilt. So the primary motivation is to make the ndctl project more enjoyable to develop. Tools, libraries, documentation, and tests all seem to be working. The remaining work is to redo the rpm build infrastructure, and validate that installation is working as expected. Given the long standing momentum on the old build system it is still kept functional for now. The only compatibility hack when moving from an autotools build to a meson build is to delete the config.h files generated by the old system in favor of the unified configuration header build from the config.h.meson template. Tested-by: Vaibhav Jain Signed-off-by: Dan Williams --- .gitignore | 5 + Documentation/cxl/lib/meson.build | 79 +++++++++++ Documentation/cxl/meson.build | 84 ++++++++++++ Documentation/daxctl/meson.build | 88 ++++++++++++ Documentation/ndctl/meson.build | 124 +++++++++++++++++ clean_config.sh | 2 config.h.meson | 149 ++++++++++++++++++++ contrib/meson.build | 16 ++ cxl/lib/meson.build | 35 +++++ cxl/meson.build | 25 +++ daxctl/lib/meson.build | 44 ++++++ daxctl/meson.build | 27 ++++ meson.build | 269 +++++++++++++++++++++++++++++++++++++ meson_options.txt | 23 +++ ndctl/lib/meson.build | 48 +++++++ ndctl/meson.build | 85 ++++++++++++ test/meson.build | 262 ++++++++++++++++++++++++++++++++++++ tools/meson-vcs-tag.sh | 18 ++ util/meson.build | 15 ++ version.h.in | 2 20 files changed, 1399 insertions(+), 1 deletion(-) create mode 100644 Documentation/cxl/lib/meson.build create mode 100644 Documentation/cxl/meson.build create mode 100644 Documentation/daxctl/meson.build create mode 100644 Documentation/ndctl/meson.build create mode 100755 clean_config.sh create mode 100644 config.h.meson create mode 100644 contrib/meson.build create mode 100644 cxl/lib/meson.build create mode 100644 cxl/meson.build create mode 100644 daxctl/lib/meson.build create mode 100644 daxctl/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 ndctl/lib/meson.build create mode 100644 ndctl/meson.build create mode 100644 test/meson.build create mode 100755 tools/meson-vcs-tag.sh create mode 100644 util/meson.build create mode 100644 version.h.in diff --git a/.gitignore b/.gitignore index 6468c7a91f06..4cb232519e72 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,9 @@ Makefile.in /aclocal.m4 /autom4te.cache /build-aux -/config.* +/config.h +/config.log +/config.status /configure /libtool /stamp-h1 @@ -25,6 +27,7 @@ Documentation/cxl/asciidoctor-extensions.rb Documentation/cxl/lib/asciidoctor-extensions.rb Documentation/ndctl/attrs.adoc .dirstamp +build/ daxctl/config.h daxctl/daxctl daxctl/lib/libdaxctl.la diff --git a/Documentation/cxl/lib/meson.build b/Documentation/cxl/lib/meson.build new file mode 100644 index 000000000000..fbfd776b4dcb --- /dev/null +++ b/Documentation/cxl/lib/meson.build @@ -0,0 +1,79 @@ +if get_option('asciidoctor').enabled() + asciidoc_conf = custom_target('asciidoctor-extensions.rb', + command : [ + 'sed', '-e', 's,@Utility@,libcxl,g', '-e', 's,@utility@,cxl,g', '@INPUT@' + ], + input : '../../asciidoctor-extensions.rb.in', + output : 'asciidoctor-extensions.rb', + capture : true, + ) +else + asciidoc_conf = custom_target('asciidoc.conf', + command : [ + 'sed', '-e', 's,UTILITY,libcxl,g', + ], + input : '../../asciidoc.conf.in', + output : 'asciidoc.conf', + capture : true, + ) +endif + +filedeps = [ + '../../copyright.txt', +] + +libcxl_manpages = [ + 'libcxl.txt', + 'cxl_new.txt', +] + +foreach man : libcxl_manpages + name = man.split('.')[0] + output = name + '.3' + output_xml = name + '.xml' + if get_option('asciidoctor').enabled() + custom_target(name, + command : [ + asciidoc, + '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@', + '-rasciidoctor-extensions', '-amansource=libcxl', + '-amanmanual=libcxl Manual', + '-andctl_version=@0@'.format(meson.project_version()), + '-o', '@OUTPUT@', '@INPUT@' + ], + input : man, + output : output, + depend_files : filedeps, + depends : asciidoc_conf, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man3'), + ) + else + xml = custom_target(output_xml, + command : [ + asciidoc, + '-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe', + '-andctl_version=@0@'.format(meson.project_version()), + '-o', '@OUTPUT@', '@INPUT@', + ], + input : man, + output : output_xml, + depend_files : filedeps, + depends : asciidoc_conf, + ) + + xsl = files('../../manpage-normal.xsl') + + custom_target(name, + command : [ + xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@' + ], + depends : xml, + depend_files : xsl, + input : xml, + output : output, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man3'), + ) + endif +endforeach diff --git a/Documentation/cxl/meson.build b/Documentation/cxl/meson.build new file mode 100644 index 000000000000..da4e44edafe5 --- /dev/null +++ b/Documentation/cxl/meson.build @@ -0,0 +1,84 @@ +if get_option('asciidoctor').enabled() + asciidoc_conf = custom_target('asciidoctor-extensions.rb', + command : [ + 'sed', '-e', 's,@Utility@,cxl,g', '-e', 's,@utility@,cxl,g', '@INPUT@' + ], + input : '../asciidoctor-extensions.rb.in', + output : 'asciidoctor-extensions.rb', + capture : true, + ) +else + asciidoc_conf = custom_target('asciidoc.conf', + command : [ + 'sed', '-e', 's,UTILITY,cxl,g', + ], + input : '../asciidoc.conf.in', + output : 'asciidoc.conf', + capture : true, + ) +endif + +filedeps = [ + '../copyright.txt', +] + +cxl_manpages = [ + 'cxl.txt', + 'cxl-list.txt', + 'cxl-read-labels.txt', + 'cxl-write-labels.txt', + 'cxl-zero-labels.txt', +] + +foreach man : cxl_manpages + name = man.split('.')[0] + output = name + '.1' + output_xml = name + '.xml' + if get_option('asciidoctor').enabled() + custom_target(name, + command : [ + asciidoc, + '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@', + '-rasciidoctor-extensions', '-amansource=cxl', + '-amanmanual=cxl Manual', + '-andctl_version=@0@'.format(meson.project_version()), + '-o', '@OUTPUT@', '@INPUT@' + ], + input : man, + output : output, + depend_files : filedeps, + depends : asciidoc_conf, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man1'), + ) + else + xml = custom_target(output_xml, + command : [ + asciidoc, + '-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe', + '-andctl_version=@0@'.format(meson.project_version()), + '-o', '@OUTPUT@', '@INPUT@', + ], + input : man, + output : output_xml, + depend_files : filedeps, + depends : asciidoc_conf, + ) + + xsl = files('../manpage-normal.xsl') + + custom_target(name, + command : [ + xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@' + ], + depends : xml, + depend_files : xsl, + input : xml, + output : output, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man1'), + ) + endif +endforeach + +subdir('lib') diff --git a/Documentation/daxctl/meson.build b/Documentation/daxctl/meson.build new file mode 100644 index 000000000000..4a80ecb98a9f --- /dev/null +++ b/Documentation/daxctl/meson.build @@ -0,0 +1,88 @@ +if get_option('asciidoctor').enabled() + asciidoc_conf = custom_target('asciidoctor-extensions.rb', + command : [ + 'sed', '-e', 's,@Utility@,Daxctl,g', '-e', 's,@utility@,daxctl,g', '@INPUT@' + ], + input : '../asciidoctor-extensions.rb.in', + output : 'asciidoctor-extensions.rb', + capture : true, + ) +else + asciidoc_conf = custom_target('asciidoc.conf', + command : [ + 'sed', '-e', 's,UTILITY,daxctl,g', + ], + input : '../asciidoc.conf.in', + output : 'asciidoc.conf', + capture : true, + ) +endif + +filedeps = [ + 'human-option.txt', + '../copyright.txt', +] + +daxctl_manpages = [ + 'daxctl.txt', + 'daxctl-list.txt', + 'daxctl-migrate-device-model.txt', + 'daxctl-reconfigure-device.txt', + 'daxctl-online-memory.txt', + 'daxctl-offline-memory.txt', + 'daxctl-disable-device.txt', + 'daxctl-enable-device.txt', + 'daxctl-create-device.txt', + 'daxctl-destroy-device.txt', +] + +foreach man : daxctl_manpages + name = man.split('.')[0] + output = name + '.1' + output_xml = name + '.xml' + if get_option('asciidoctor').enabled() + custom_target(name, + command : [ + asciidoc, + '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@', + '-rasciidoctor-extensions', '-amansource=daxctl', + '-amanmanual=daxctl Manual', + '-andctl_version=@0@'.format(meson.project_version()), + '-o', '@OUTPUT@', '@INPUT@' + ], + input : man, + output : output, + depend_files : filedeps, + depends : asciidoc_conf, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man1'), + ) + else + xml = custom_target(output_xml, + command : [ + asciidoc, + '-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe', + '-andctl_version=@0@'.format(meson.project_version()), + '-o', '@OUTPUT@', '@INPUT@', + ], + input : man, + output : output_xml, + depend_files : filedeps, + depends : asciidoc_conf, + ) + + xsl = files('../manpage-normal.xsl') + + custom_target(name, + command : [ + xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@' + ], + depends : xml, + depend_files : xsl, + input : xml, + output : output, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man1'), + ) + endif +endforeach diff --git a/Documentation/ndctl/meson.build b/Documentation/ndctl/meson.build new file mode 100644 index 000000000000..9e16eb399fa3 --- /dev/null +++ b/Documentation/ndctl/meson.build @@ -0,0 +1,124 @@ +if get_option('asciidoctor').enabled() + asciidoc_conf = custom_target('asciidoctor-extensions.rb', + command : [ + 'sed', '-e', 's,@Utility@,Ndctl,g', '-e', 's,@utility@,ndctl,g', '@INPUT@' + ], + input : '../asciidoctor-extensions.rb.in', + output : 'asciidoctor-extensions.rb', + capture : true, + ) +else + asciidoc_conf = custom_target('asciidoc.conf', + command : [ + 'sed', '-e', 's,UTILITY,ndctl,g', + ], + input : '../asciidoc.conf.in', + output : 'asciidoc.conf', + capture : true, + ) +endif + +filedeps = [ + '../copyright.txt', + 'region-description.txt', + 'xable-region-options.txt', + 'dimm-description.txt', + 'xable-dimm-options.txt', + 'xable-namespace-options.txt', + 'ars-description.txt', + 'labels-description.txt', + 'labels-options.txt', +] + +ndctl_manpages = [ + 'ndctl.txt', + 'ndctl-wait-scrub.txt', + 'ndctl-start-scrub.txt', + 'ndctl-zero-labels.txt', + 'ndctl-read-labels.txt', + 'ndctl-write-labels.txt', + 'ndctl-init-labels.txt', + 'ndctl-check-labels.txt', + 'ndctl-enable-region.txt', + 'ndctl-disable-region.txt', + 'ndctl-enable-dimm.txt', + 'ndctl-disable-dimm.txt', + 'ndctl-enable-namespace.txt', + 'ndctl-disable-namespace.txt', + 'ndctl-create-namespace.txt', + 'ndctl-destroy-namespace.txt', + 'ndctl-check-namespace.txt', + 'ndctl-clear-errors.txt', + 'ndctl-inject-error.txt', + 'ndctl-inject-smart.txt', + 'ndctl-update-firmware.txt', + 'ndctl-list.txt', + 'ndctl-monitor.txt', + 'ndctl-setup-passphrase.txt', + 'ndctl-update-passphrase.txt', + 'ndctl-remove-passphrase.txt', + 'ndctl-freeze-security.txt', + 'ndctl-sanitize-dimm.txt', + 'ndctl-load-keys.txt', + 'ndctl-wait-overwrite.txt', + 'ndctl-read-infoblock.txt', + 'ndctl-write-infoblock.txt', + 'ndctl-activate-firmware.txt', +] + +foreach man : ndctl_manpages + name = man.split('.')[0] + output = name + '.1' + output_xml = name + '.xml' + if get_option('asciidoctor').enabled() + custom_target(name, + command : [ + asciidoc, + '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@', + '-rasciidoctor-extensions', '-amansource=ndctl', + '-amanmanual=ndctl Manual', + '-andctl_monitorconfdir=@0@'.format(ndctlconf_dir), + '-andctl_monitorconf=@0@'.format(ndctlconf), + '-andctl_keysdir=@0@'.format(ndctlkeys_dir), + '-andctl_version=@0@'.format(meson.project_version()), + '-o', '@OUTPUT@', '@INPUT@' + ], + input : man, + output : output, + depend_files : filedeps, + depends : asciidoc_conf, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man1'), + ) + else + xml = custom_target(output_xml, + command : [ + asciidoc, + '-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe', + '-andctl_version=@0@'.format(meson.project_version()), + '-andctl_monitorconfdir=@0@'.format(ndctlconf_dir), + '-andctl_monitorconf=@0@'.format(ndctlconf), + '-andctl_keysdir=@0@'.format(ndctlkeys_dir), + '-o', '@OUTPUT@', '@INPUT@', + ], + input : man, + output : output_xml, + depend_files : filedeps, + depends : asciidoc_conf, + ) + + xsl = files('../manpage-normal.xsl') + + custom_target(name, + command : [ + xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@' + ], + depends : xml, + depend_files : xsl, + input : xml, + output : output, + install : get_option('docs').enabled(), + install_dir : join_paths(get_option('mandir'), 'man1'), + ) + endif +endforeach diff --git a/clean_config.sh b/clean_config.sh new file mode 100755 index 000000000000..03ec04c5554b --- /dev/null +++ b/clean_config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git ls-files -o --exclude build | grep config.h\$ | xargs rm diff --git a/config.h.meson b/config.h.meson new file mode 100644 index 000000000000..4796ea67b0db --- /dev/null +++ b/config.h.meson @@ -0,0 +1,149 @@ +/* Debug messages. */ +#mesondefine ENABLE_DEBUG + +/* destructive functional tests support */ +#mesondefine ENABLE_DESTRUCTIVE + +/* Documentation / man pages. */ +#mesondefine ENABLE_DOCS + +/* Enable keyutils support */ +#mesondefine ENABLE_KEYUTILS + +/* System logging. */ +#mesondefine ENABLE_LOGGING + +/* ndctl test poison support */ +#mesondefine ENABLE_POISON + +/* ndctl test support */ +#mesondefine ENABLE_TEST + +/* Define to 1 if big-endian-arch */ +#mesondefine HAVE_BIG_ENDIAN + +/* Define to 1 if you have the declaration of `BUS_MCEERR_AR', and to 0 if you + don't. */ +#mesondefine HAVE_DECL_BUS_MCEERR_AR + +/* Define to 1 if you have the declaration of `MAP_SHARED_VALIDATE', and to 0 + if you don't. */ +#mesondefine HAVE_DECL_MAP_SHARED_VALIDATE + +/* Define to 1 if you have the declaration of `MAP_SYNC', and to 0 if you + don't. */ +#mesondefine HAVE_DECL_MAP_SYNC + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_KEYUTILS_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_LINUX_VERSION_H + +/* Define to 1 if little-endian-arch */ +#mesondefine HAVE_LITTLE_ENDIAN + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_MEMORY_H + +/* Define to 1 if you have the `secure_getenv' function. */ +#mesondefine HAVE_SECURE_GETENV + +/* Define to 1 if you have statement expressions. */ +#mesondefine HAVE_STATEMENT_EXPR + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_SYS_TYPES_H + +/* Define to 1 if typeof works with your compiler. */ +#mesondefine HAVE_TYPEOF + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_UNISTD_H + +/* Define to 1 if using libuuid */ +#mesondefine HAVE_UUID + +/* Define to 1 if you have the `__secure_getenv' function. */ +#mesondefine HAVE___SECURE_GETENV + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#mesondefine LT_OBJDIR + +/* Name of package */ +#mesondefine PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#mesondefine PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#mesondefine PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#mesondefine PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#mesondefine PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#mesondefine PACKAGE_URL + +/* Define to the version of this package. */ +#mesondefine PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#mesondefine STDC_HEADERS + +/* Version number of package */ +#mesondefine VERSION + +/* Number of bits in a file offset, on hosts where this is settable. */ +#mesondefine _FILE_OFFSET_BITS + +/* Define for large files, on AIX-style hosts. */ +#mesondefine _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#mesondefine _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#mesondefine _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#mesondefine _POSIX_SOURCE + +/* Define to __typeof__ if your compiler spells it that way. */ +#mesondefine typeof + +/* Define to enable GNU Source Extensions */ +#mesondefine _GNU_SOURCE + +/* Locations to install configuration files, key config, man pages, etc.. */ +#mesondefine NDCTL_CONF_FILE +#mesondefine NDCTL_KEYS_DIR +#mesondefine NDCTL_MAN_PATH +#mesondefine DAXCTL_MODPROBE_DATA +#mesondefine DAXCTL_MODPROBE_INSTALL +#mesondefine PREFIX diff --git a/contrib/meson.build b/contrib/meson.build new file mode 100644 index 000000000000..a6505d58cea4 --- /dev/null +++ b/contrib/meson.build @@ -0,0 +1,16 @@ +bashcompletiondir = get_option('bashcompletiondir') +if bashcompletiondir == '' + bash_completion = dependency('bash-completion', required : false) + if bash_completion.found() + bashcompletiondir = bash_completion.get_pkgconfig_variable('completionsdir') + else + bashcompletiondir = datadir / 'bash-completion/completions' + endif +endif + +if bashcompletiondir != 'no' + install_data('ndctl', install_dir : bashcompletiondir) +endif + +modprobedatadir = get_option('sysconfdir') + '/modprobe.d/' +install_data('nvdimm-security.conf', install_dir : modprobedatadir) diff --git a/cxl/lib/meson.build b/cxl/lib/meson.build new file mode 100644 index 000000000000..eba0ce7278e7 --- /dev/null +++ b/cxl/lib/meson.build @@ -0,0 +1,35 @@ +libcxl_version = '@0@.@1@.@2@'.format( + LIBCXL_CURRENT - LIBCXL_AGE, + LIBCXL_REVISION, + LIBCXL_AGE) + +mapfile = files('libcxl.sym') +vflag = '-Wl,--version-script,@0@/@1@'.format(project_source_root, mapfile[0]) + +cxl = library('cxl', + '../../util/sysfs.c', + '../../util/log.c', + '../../util/log.h', + 'libcxl.c', + include_directories : root_inc, + dependencies : [ + uuid, + kmod, + ], + version : libcxl_version, + install : true, + install_dir : rootlibdir, + link_args : vflag, + link_depends : mapfile, +) +cxl_dep = declare_dependency(link_with : cxl) + +custom_target( + 'libcxl.pc', + command : pkgconfig_script + [ '@INPUT@' ], + input : 'libcxl.pc.in', + output : 'libcxl.pc', + capture : true, + install : true, + install_dir : pkgconfiglibdir, +) diff --git a/cxl/meson.build b/cxl/meson.build new file mode 100644 index 000000000000..146c8493330e --- /dev/null +++ b/cxl/meson.build @@ -0,0 +1,25 @@ +cxl_src = [ + 'cxl.c', + 'list.c', + 'memdev.c', + '../util/json.c', + 'json.c', + 'filter.c', +] + +cxl_tool = executable('cxl', + cxl_src, + include_directories : root_inc, + dependencies : [ + versiondep, + cxl_dep, + util_dep, + uuid, + kmod, + json, + ], + install : true, + install_dir : rootbindir, +) + +install_headers('libcxl.h', subdir : 'cxl') diff --git a/daxctl/lib/meson.build b/daxctl/lib/meson.build new file mode 100644 index 000000000000..b79c6e591945 --- /dev/null +++ b/daxctl/lib/meson.build @@ -0,0 +1,44 @@ +libdaxctl_version = '@0@.@1@.@2@'.format( + LIBDAXCTL_CURRENT - LIBDAXCTL_AGE, + LIBDAXCTL_REVISION, + LIBDAXCTL_AGE, +) + +mapfile = files('libdaxctl.sym') +vflag = '-Wl,--version-script,@0@/@1@'.format(project_source_root, mapfile[0]) + +libdaxctl_src = [ + '../../util/iomem.c', + '../../util/sysfs.c', + '../../util/log.c', + 'libdaxctl.c', +] + +daxctl = library( + 'daxctl', + libdaxctl_src, + version : libdaxctl_version, + include_directories : root_inc, + dependencies : [ + uuid, + kmod, + ], + install : true, + install_dir : rootlibdir, + link_args : vflag, + link_depends : mapfile, +) + +daxctl_dep = declare_dependency(link_with : daxctl) + +custom_target( + 'libdaxctl.pc', + command : pkgconfig_script + [ '@INPUT@' ], + input : 'libdaxctl.pc.in', + output : 'libdaxctl.pc', + capture : true, + install : true, + install_dir : pkgconfiglibdir, +) + +install_data('daxctl.conf', install_dir : datadir / 'daxctl') diff --git a/daxctl/meson.build b/daxctl/meson.build new file mode 100644 index 000000000000..c6738743b5d1 --- /dev/null +++ b/daxctl/meson.build @@ -0,0 +1,27 @@ +daxctl_src = [ + 'daxctl.c', + 'acpi.c', + 'list.c', + 'migrate.c', + 'device.c', + '../util/json.c', + 'json.c', + 'filter.c', +] + +daxctl_tool = executable('daxctl', + daxctl_src, + include_directories : root_inc, + dependencies : [ + versiondep, + daxctl_dep, + util_dep, + uuid, + kmod, + json, + ], + install : true, + install_dir : rootbindir, +) + +install_headers('libdaxctl.h', subdir : 'daxctl') diff --git a/meson.build b/meson.build new file mode 100644 index 000000000000..746408948e4d --- /dev/null +++ b/meson.build @@ -0,0 +1,269 @@ +project('ndctl', 'c', + version : '71', + license : [ + 'GPL-2.0', + 'LGPL-2.1', + 'CC0-1.0', + 'MIT', + ], + default_options : [ + 'c_std=gnu99', + 'prefix=/usr', + 'sysconfdir=/etc', + 'localstatedir=/var', + ], +) + +# rootprefixdir and rootlibdir setup copied from systemd: +rootprefixdir = get_option('rootprefix') +rootprefix_default = '/usr' +if rootprefixdir == '' + rootprefixdir = rootprefix_default +endif +rootbindir = join_paths(rootprefixdir, 'bin') + +# join_paths ignores the preceding arguments if an absolute component is +# encountered, so this should canonicalize various paths when they are +# absolute or relative. +prefixdir = get_option('prefix') +if not prefixdir.startswith('/') + error('Prefix is not absolute: "@0@"'.format(prefixdir)) +endif +if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/') + error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format( + rootprefixdir, prefixdir)) +endif + +libdir = join_paths(prefixdir, get_option('libdir')) +rootlibdir = get_option('rootlibdir') +if rootlibdir == '' + rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1]) +endif +datadir = prefixdir / get_option('datadir') +includedir = prefixdir / get_option('includedir') + +pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig' + +datadir = prefixdir / get_option('datadir') +includedir = prefixdir / get_option('includedir') +sysconfdir = get_option('sysconfdir') + +pkgconfig_script = ''' +sed -e s,@VERSION@,@0@,g + -e s,@prefix@,@1@,g + -e s,@exec_prefix@,@1@,g + -e s,@libdir@,@2@,g + -e s,@includedir@,@3@,g +'''.format(meson.project_version(), prefixdir, libdir, includedir).split() + +cc_flags = [ + '-Wall', + '-Wchar-subscripts', + '-Wformat-security', + '-Wmissing-declarations', + '-Wmissing-prototypes', + '-Wnested-externs ', + '-Wshadow', + '-Wsign-compare', + '-Wstrict-prototypes', + '-Wtype-limits', + '-Wmaybe-uninitialized', + '-Wdeclaration-after-statement', + '-Wunused-result', + '-D_FORTIFY_SOURCE=2', + '-O2', +] +cc = meson.get_compiler('c') +add_project_arguments(cc.get_supported_arguments(cc_flags), language : 'c') + +project_source_root = meson.current_source_dir() + +# Remove this after the conversion to meson has been completed +# Cleanup the leftover config.h files to avoid conflicts with the meson +# generated config.h +git = find_program('git', required : false) +if git.found() + run_command('clean_config.sh', + env : 'GIT_DIR=@0@/.git'.format(project_source_root), + ) +endif + +version_tag = get_option('version-tag') +if version_tag != '' + vcs_data = configuration_data() + vcs_data.set('VCS_TAG', version_tag) + version_h = configure_file( + configuration : vcs_data, + input : 'version.h.in', + output : 'version.h' + ) +else + vcs_tagger = [ + project_source_root + '/tools/meson-vcs-tag.sh', + project_source_root, + meson.project_version() + ] + + version_h = vcs_tag( + input : 'version.h.in', + output : 'version.h', + command: vcs_tagger + ) +endif +add_project_arguments('-include', 'version.h', language : 'c') + +versiondep = declare_dependency(sources: version_h) + +kmod = dependency('libkmod') +udev = dependency('libudev') +uuid = dependency('uuid') +json = dependency('json-c') +if get_option('docs').enabled() + if get_option('asciidoctor').enabled() + asciidoc = find_program('asciidoctor', required : true) + else + asciidoc = find_program('asciidoc', required : true) + xmlto = find_program('xmlto', required : true) + endif +endif + +if get_option('systemd').enabled() + systemd = dependency('systemd', required : true) + systemdunitdir = systemd.get_pkgconfig_variable('systemd_system_unit_dir') +endif + +cc = meson.get_compiler('c') + +# keyutils lacks pkgconfig +keyutils = cc.find_library('keyutils', required : get_option('keyutils')) + +conf = configuration_data() +check_headers = [ + ['HAVE_DLFCN_H', 'dlfcn.h'], + ['HAVE_INTTYPES_H', 'inttypes.h'], + ['HAVE_KEYUTILS_H', 'keyutils.h'], + ['HAVE_LINUX_VERSION_H', 'linux/version.h'], + ['HAVE_MEMORY_H', 'memory.h'], + ['HAVE_STDINT_H', 'stdint.h'], + ['HAVE_STDLIB_H', 'stdlib.h'], + ['HAVE_STRINGS_H', 'strings.h'], + ['HAVE_STRING_H', 'string.h'], + ['HAVE_SYS_STAT_H', 'sys/stat.h'], + ['HAVE_SYS_TYPES_H', 'sys/types.h'], + ['HAVE_UNISTD_H', 'unistd.h'], +] + +foreach h : check_headers + if cc.has_header(h.get(1)) + conf.set(h.get(0), 1) + endif +endforeach + +map_sync_symbols = [ + [ 'signal.h', 'BUS_MCEERR_AR' ], + [ 'linux/mman.h', 'MAP_SHARED_VALIDATE' ], + [ 'linux/mman.h', 'MAP_SYNC' ], +] + +count = 0 +foreach symbol : map_sync_symbols + if cc.has_header_symbol(symbol[0], symbol[1]) + conf.set('HAVE_DECL_@0@'.format(symbol[1].to_upper()), 1) + count = count + 1 + endif +endforeach + +poison_enabled = false +if get_option('poison').enabled() and count == 3 + poison_enabled = true +endif + +conf.set('ENABLE_POISON', poison_enabled) +conf.set('ENABLE_KEYUTILS', get_option('keyutils').enabled()) +conf.set('ENABLE_TEST', get_option('test').enabled()) +conf.set('ENABLE_DESTRUCTIVE', get_option('destructive').enabled()) +conf.set('ENABLE_LOGGING', get_option('logging').enabled()) + +typeof = cc.run(''' + int main() { + struct { + char a[16]; + } x; + typeof(x) y; + + return sizeof(x) == sizeof(y); + } + ''' +) + +if typeof.compiled() and typeof.returncode() == 1 + conf.set('HAVE_TYPEOF', 1) + conf.set('HAVE_STATEMENT_EXPR', 1) +endif + +if target_machine.endian() == 'big' + conf.set('HAVE_BIG_ENDIAN', 1) +else + conf.set('HAVE_LITTLE_ENDIAN', 1) +endif + +conf.set('_GNU_SOURCE', true) +conf.set_quoted('PREFIX', get_option('prefix')) +conf.set_quoted('NDCTL_MAN_PATH', get_option('mandir')) + +foreach ident : ['secure_getenv', '__secure_getenv'] + conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident)) +endforeach + + +ndctlconf_dir = sysconfdir / 'ndctl' +ndctlconf = ndctlconf_dir / 'monitor.conf' +conf.set_quoted('NDCTL_CONF_FILE', ndctlconf) + +ndctlkeys_dir = sysconfdir / 'ndctl' +ndctlkeys = ndctlkeys_dir / 'keys' +conf.set_quoted('NDCTL_KEYS_DIR', ndctlkeys) + +conf.set_quoted('DAXCTL_MODPROBE_DATA', datadir / 'daxctl/daxctl.conf') +conf.set_quoted('DAXCTL_MODPROBE_INSTALL', sysconfdir / 'modprobe.d/daxctl.conf') + +config_h = configure_file( + input : 'config.h.meson', + output : 'config.h', + configuration : conf +) +add_project_arguments('-include', 'config.h', language : 'c') + +LIBNDCTL_CURRENT=25 +LIBNDCTL_REVISION=1 +LIBNDCTL_AGE=19 + +LIBDAXCTL_CURRENT=6 +LIBDAXCTL_REVISION=0 +LIBDAXCTL_AGE=5 + +LIBCXL_CURRENT=1 +LIBCXL_REVISION=0 +LIBCXL_AGE=0 + +root_inc = include_directories(['.', 'ndctl', ]) + +ccan = static_library('ccan', + [ 'ccan/str/str.c', 'ccan/list/list.c' ], +) +ccan_dep = declare_dependency(link_with : ccan) + +subdir('daxctl/lib') +subdir('ndctl/lib') +subdir('cxl/lib') +subdir('util') +subdir('ndctl') +subdir('daxctl') +subdir('cxl') +if get_option('docs').enabled() + subdir('Documentation/ndctl') + subdir('Documentation/daxctl') + subdir('Documentation/cxl') +endif +subdir('test') +subdir('contrib') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000000..5ccbf1230b55 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,23 @@ +option('version-tag', type : 'string', + description : 'override the git version string') +option('docs', type : 'feature', value : 'enabled') +option('asciidoctor', type : 'feature', value : 'disabled') +option('systemd', type : 'feature', value : 'enabled') +option('keyutils', type : 'feature', value : 'enabled', + description : 'enable nvdimm device passphrase management') +option('test', type : 'feature', value : 'disabled', + description : 'enable shipping tests in ndctl') +option('destructive', type : 'feature', value : 'disabled', + description : 'enable tests that may clobber live system resources') +option('poison', type : 'feature', value : 'enabled', + description : 'enable tests that inject poison / memory-failure') +option('logging', type : 'feature', value : 'enabled', + description : 'enable log infrastructure') +option('rootprefix', type : 'string', + description : '''override the root prefix [default '/' if split-usr and '/usr' otherwise]''') +option('rootlibdir', type : 'string', + description : '''[/usr]/lib/x86_64-linux-gnu or such''') +option('pkgconfiglibdir', type : 'string', value : '', + description : 'directory for standard pkg-config files') +option('bashcompletiondir', type : 'string', + description : '''${datadir}/bash-completion/completions''') diff --git a/ndctl/lib/meson.build b/ndctl/lib/meson.build new file mode 100644 index 000000000000..fa46ea381cd4 --- /dev/null +++ b/ndctl/lib/meson.build @@ -0,0 +1,48 @@ +libndctl_version = '@0@.@1@.@2@'.format( + LIBNDCTL_CURRENT - LIBNDCTL_AGE, + LIBNDCTL_REVISION, + LIBNDCTL_AGE) + +mapfile = files('libndctl.sym') +vflag = '-Wl,--version-script,@0@/@1@'.format(project_source_root, mapfile[0]) + +ndctl = library( + 'ndctl', + '../../util/log.c', + '../../util/sysfs.c', + 'dimm.c', + 'inject.c', + 'nfit.c', + 'smart.c', + 'intel.c', + 'hpe1.c', + 'msft.c', + 'hyperv.c', + 'papr.c', + 'ars.c', + 'firmware.c', + 'libndctl.c', + dependencies : [ + daxctl_dep, + udev, + uuid, + kmod, + ], + include_directories : root_inc, + version : libndctl_version, + install : true, + install_dir : rootlibdir, + link_args : vflag, + link_depends : mapfile, +) +ndctl_dep = declare_dependency(link_with : ndctl) + +custom_target( + 'libndctl.pc', + command : pkgconfig_script + [ '@INPUT@' ], + input : 'libndctl.pc.in', + output : 'libndctl.pc', + capture : true, + install : true, + install_dir : pkgconfiglibdir, +) diff --git a/ndctl/meson.build b/ndctl/meson.build new file mode 100644 index 000000000000..86b8c8f7abf3 --- /dev/null +++ b/ndctl/meson.build @@ -0,0 +1,85 @@ +ndctl_src = [ + 'ndctl.c', + 'bus.c', + 'create-nfit.c', + 'namespace.c', + 'check.c', + 'region.c', + 'dimm.c', + '../util/log.c', + '../daxctl/filter.c', + 'filter.c', + 'list.c', + '../util/json.c', + '../daxctl/json.c', + 'json.c', + 'json-smart.c', + 'inject-error.c', + 'inject-smart.c', + 'monitor.c', +] + +deps = [ + versiondep, + util_dep, + ndctl_dep, + daxctl_dep, + cxl_dep, + uuid, + kmod, + json, +] + +if get_option('keyutils').enabled() + ndctl_src += [ + 'keys.c', + 'load-keys.c', + ] + deps += keyutils +endif + +if get_option('test').enabled() + ndctl_src += [ + '../test/libndctl.c', + '../test/dsm-fail.c', + '../util/sysfs.c', + '../test/dpa-alloc.c', + '../test/parent-uuid.c', + '../test/multi-pmem.c', + '../test/core.c', + 'test.c', +] +endif + +if get_option('destructive').enabled() + if get_option('test').disabled() + error('destrive option requires -Dtest=enabled') + endif + ndctl_src += [ + '../test/blk_namespaces.c', + '../test/pmem_namespaces.c', + 'bat.c', + ] +endif + +if get_option('systemd').enabled() + install_data('ndctl-monitor.service', install_dir : systemdunitdir) +endif +install_data('monitor.conf', install_dir : ndctlconf_dir) +ndctlconfkeys_dir = ndctlconf_dir / 'keys/' +install_data('keys.readme', install_dir : ndctlconfkeys_dir) + +ndctl_tool = executable('ndctl', ndctl_src, + dependencies : deps, + install : true, + install_dir : rootbindir, + include_directories : root_inc, +) + +install_headers( + [ + 'libndctl.h', + 'ndctl.h' + ], + subdir : 'ndctl' +) diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 000000000000..2c9d5b954331 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,262 @@ +testcore = [ + 'core.c', + '../util/log.c', + '../util/sysfs.c', + '../util/hexdump.c', +] + +libndctl_deps = [ + ndctl_dep, + daxctl_dep, + uuid, + kmod, +] + +ndctl_deps = libndctl_deps + [ + json, + util_dep, +] + +libndctl = executable('libndctl', testcore + [ 'libndctl.c'], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +namespace_core = [ + '../ndctl/namespace.c', + '../ndctl/filter.c', + '../ndctl/check.c', + '../util/json.c', + '../ndctl/json.c', + '../daxctl/filter.c', + '../daxctl/json.c', +] + +dsm_fail = executable('dsm-fail', testcore + namespace_core + [ 'dsm-fail.c' ], + dependencies : ndctl_deps, + include_directories : root_inc, +) + +dpa_alloc = executable('dpa-alloc', testcore + [ 'dpa-alloc.c' ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +parent_uuid = executable('parent-uuid', testcore + [ 'parent-uuid.c' ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +multi_pmem = executable('multi-pmem', testcore + namespace_core + + [ 'multi-pmem.c' ], + dependencies : ndctl_deps, + include_directories : root_inc, +) + +hugetlb_src = testcore + [ 'hugetlb.c', 'dax-pmd.c' ] +if poison_enabled + hugetlb_src += [ 'dax-poison.c' ] +endif +hugetlb = executable('hugetlb', hugetlb_src, + dependencies : libndctl_deps, + include_directories : root_inc, +) + +ack_shutdown_count = executable('ack-shutdown-count-set', + testcore + [ 'ack-shutdown-count-set.c' ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +dax_errors = executable('dax-errors', 'dax-errors.c') + +smart_notify = executable('smart-notify', 'smart-notify.c', + dependencies : libndctl_deps, + include_directories : root_inc, +) + +smart_listen = executable('smart-listen', 'smart-listen.c', + dependencies : libndctl_deps, + include_directories : root_inc, +) + +daxdev_errors = executable('daxdev-errors', [ + 'daxdev-errors.c', + '../util/log.c', + '../util/sysfs.c', + ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +list_smart_dimm = executable('list-smart-dimm', [ + 'list-smart-dimm.c', + '../ndctl/filter.c', + '../util/json.c', + '../ndctl/json.c', + '../daxctl/json.c', + '../daxctl/filter.c', + ], + dependencies : ndctl_deps, + include_directories : root_inc, +) + +blk_ns = executable('blk-ns', testcore + [ 'blk_namespaces.c' ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +pmem_ns = executable('pmem-ns', testcore + [ 'pmem_namespaces.c' ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +dax_dev = executable('dax-dev', testcore + [ 'dax-dev.c' ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +dax_pmd_src = testcore + [ 'dax-pmd.c' ] +if poison_enabled + dax_pmd_src += [ 'dax-poison.c' ] +endif + +dax_pmd = executable('dax-pmd', dax_pmd_src, + dependencies : libndctl_deps, + include_directories : root_inc, +) + +device_dax_src = testcore + namespace_core + [ + 'device-dax.c', + 'dax-dev.c', + 'dax-pmd.c', +] + +if poison_enabled + device_dax_src += 'dax-poison.c' +endif + +device_dax = executable('device-dax', device_dax_src, + dependencies : ndctl_deps, + include_directories : root_inc, +) + +revoke_devmem = executable('revoke_devmem', testcore + [ + 'revoke-devmem.c', + 'dax-dev.c', + ], + dependencies : libndctl_deps, + include_directories : root_inc, +) + +mmap = executable('mmap', 'mmap.c') + +create = find_program('create.sh') +clear = find_program('clear.sh') +pmem_errors = find_program('pmem-errors.sh') +daxdev_errors_sh = find_program('daxdev-errors.sh') +multi_dax = find_program('multi-dax.sh') +btt_check = find_program('btt-check.sh') +label_compat = find_program('label-compat.sh') +blk_exhaust = find_program('blk-exhaust.sh') +sector_mode = find_program('sector-mode.sh') +inject_error = find_program('inject-error.sh') +btt_errors = find_program('btt-errors.sh') +btt_pad_compat = find_program('btt-pad-compat.sh') +firmware_update = find_program('firmware-update.sh') +rescan_partitions = find_program('rescan-partitions.sh') +inject_smart = find_program('inject-smart.sh') +monitor = find_program('monitor.sh') +max_extent = find_program('max_available_extent_ns.sh') +pfn_meta_errors = find_program('pfn-meta-errors.sh') +track_uuid = find_program('track-uuid.sh') + +tests = [ + [ 'libndctl', libndctl ], + [ 'dsm-fail', dsm_fail ], + [ 'dpa-alloc', dpa_alloc ], + [ 'parent-uuid', parent_uuid ], + [ 'multi-pmem', multi_pmem ], + [ 'create.sh', create ], + [ 'clear.sh', clear ], + [ 'pmem-errors.sh', pmem_errors ], + [ 'daxdev-errors.sh', daxdev_errors_sh ], + [ 'multi-dax.sh', multi_dax ], + [ 'btt-check.sh', btt_check ], + [ 'label-compat.sh', label_compat ], + [ 'blk-exhaust.sh', blk_exhaust ], + [ 'sector-mode.sh', sector_mode ], + [ 'inject-error.sh', inject_error ], + [ 'btt-errors.sh', btt_errors ], + [ 'hugetlb', hugetlb ], + [ 'btt-pad-compat.sh', btt_pad_compat ], + [ 'firmware-update.sh', firmware_update ], + [ 'ack-shutdown-count-set', ack_shutdown_count ], + [ 'rescan-partitions.sh', rescan_partitions ], + [ 'inject-smart.sh', inject_smart ], + [ 'monitor.sh', monitor ], + [ 'max_extent_ns', max_extent ], + [ 'pfn-meta-errors.sh', pfn_meta_errors ], + [ 'track-uuid.sh', track_uuid ], +] + +if get_option('destructive').enabled() + sub_section = find_program('sub-section.sh') + dax_ext4 = find_program('dax-ext4.sh') + dax_xfs = find_program('dax-xfs.sh') + align = find_program('align.sh') + device_dax_fio = find_program('device-dax-fio.sh') + daxctl_devices = find_program('daxctl-devices.sh') + daxctl_create = find_program('daxctl-create.sh') + dm = find_program('dm.sh') + mmap_test = find_program('mmap.sh') + + tests += [ + [ 'blk-ns', blk_ns ], + [ 'pmem-ns', pmem_ns ], + [ 'sub-section.sh', sub_section ], + [ 'dax-dev', dax_dev ], + [ 'dax-ext4.sh', dax_ext4 ], + [ 'dax-xfs.sh', dax_xfs ], + [ 'align.sh', align ], + [ 'device-dax', device_dax ], + [ 'revoke-devmem', revoke_devmem ], + [ 'device-dax-fio.sh', device_dax_fio ], + [ 'daxctl-devices.sh', daxctl_devices ], + [ 'daxctl-create.sh', daxctl_create ], + [ 'dm.sh', dm ], + [ 'mmap.sh', mmap_test ], + ] +endif + +if get_option('keyutils').enabled() + security = find_program('security.sh') + tests += [ + [ 'security.sh', security ] + ] +endif + +foreach t : tests + test(t[0], t[1], + is_parallel : false, + depends : [ + ndctl_tool, + daxctl_tool, + cxl_tool, + smart_notify, + list_smart_dimm, + dax_pmd, + dax_errors, + daxdev_errors, + dax_dev, + mmap, + ], + timeout : 0, + env : [ + 'NDCTL=@0@'.format(ndctl_tool.full_path()), + 'DAXCTL=@0@'.format(daxctl_tool.full_path()), + 'TEST_PATH=@0@'.format(meson.current_build_dir()), + 'DATA_PATH=@0@'.format(meson.current_source_dir()), + ], + ) +endforeach diff --git a/tools/meson-vcs-tag.sh b/tools/meson-vcs-tag.sh new file mode 100755 index 000000000000..9f21c37b7d26 --- /dev/null +++ b/tools/meson-vcs-tag.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later + +set -eu +set -o pipefail + +dir="${1:?}" +fallback="${2:?}" + +# Apparently git describe has a bug where it always considers the work-tree +# dirty when invoked with --git-dir (even though 'git status' is happy). Work +# around this issue by cd-ing to the source directory. +cd "$dir" +# Check that we have either .git/ (a normal clone) or a .git file (a work-tree) +# and that we don't get confused if a tarball is extracted in a higher-level +# git repository. +[ -e .git ] && git describe --abbrev=7 --dirty=+ 2>/dev/null | \ + sed -e 's/^v//' -e 's/-/./g' || echo "$fallback" diff --git a/util/meson.build b/util/meson.build new file mode 100644 index 000000000000..15726bb1e6f5 --- /dev/null +++ b/util/meson.build @@ -0,0 +1,15 @@ +util = static_library('util', [ + 'parse-options.c', + 'usage.c', + 'size.c', + 'main.c', + 'help.c', + 'strbuf.c', + 'wrapper.c', + 'bitmap.c', + 'abspath.c', + 'iomem.c', + ], + include_directories : root_inc, +) +util_dep = declare_dependency(link_with : util) diff --git a/version.h.in b/version.h.in new file mode 100644 index 000000000000..dedbaf95caf7 --- /dev/null +++ b/version.h.in @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ +#define VERSION "@VCS_TAG@" From patchwork Thu Sep 2 20:43:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12472471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FE74C433F5 for ; Thu, 2 Sep 2021 20:43:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B30A610A0 for ; Thu, 2 Sep 2021 20:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345018AbhIBUoe (ORCPT ); Thu, 2 Sep 2021 16:44:34 -0400 Received: from mga05.intel.com ([192.55.52.43]:36785 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344623AbhIBUoc (ORCPT ); Thu, 2 Sep 2021 16:44:32 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="304807392" X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="304807392" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:33 -0700 X-IronPort-AV: E=Sophos;i="5.85,263,1624345200"; d="scan'208";a="689297058" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 13:43:33 -0700 Subject: [ndctl PATCH v2 6/6] build: Add meson rpmbuild support From: Dan Williams To: nvdimm@lists.linux.dev Cc: vishal.l.verma@intel.com, linux-cxl@vger.kernel.org Date: Thu, 02 Sep 2021 13:43:33 -0700 Message-ID: <163061541299.1943957.16202191465635771045.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> References: <163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Beyond being a prerequisite for removing autotools support, this capability served as validation that the meson conversion generated all the same files as autotools and installed them to the same expected locations. The procedure to use the rpmbuild.sh script is: meson setup build meson compile -C build rhel/ndctl.spec ./rpmbuild.sh build/rhel/ndctl.spec Signed-off-by: Dan Williams --- .gitignore | 2 +- Makefile.am | 2 ++ meson.build | 6 ++++++ ndctl.spec.in | 22 ++++++++++++++++++++++ rhel/meson.build | 23 +++++++++++++++++++++++ rpmbuild.sh | 5 ++++- sles/meson.build | 36 ++++++++++++++++++++++++++++++++++++ 7 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 rhel/meson.build create mode 100644 sles/meson.build diff --git a/.gitignore b/.gitignore index 4cb232519e72..68c55c1af80e 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,7 @@ daxctl/lib/libdaxctl.pc ndctl/config.h ndctl/lib/libndctl.pc ndctl/ndctl -rhel/ +rhel/ndctl.spec sles/ndctl.spec version.m4 *.swp diff --git a/Makefile.am b/Makefile.am index 75d80fc24095..909c2699af47 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,6 +22,7 @@ noinst_SCRIPTS = rhel/ndctl.spec sles/ndctl.spec CLEANFILES += $(noinst_SCRIPTS) do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \ + -e 's,MESON,0,g' \ -e 's,DAX_DNAME,daxctl-devel,g' \ -e 's,CXL_DNAME,cxl-devel,g' \ -e 's,DNAME,ndctl-devel,g' \ @@ -31,6 +32,7 @@ do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \ -e 's,LNAME,ndctl-libs,g' do_sles_subst = sed -e 's,VERSION,$(VERSION),g' \ + -e 's,MESON,0,g' \ -e 's,DAX_DNAME,libdaxctl-devel,g' \ -e 's,CXL_DNAME,libcxl-devel,g' \ -e 's,DNAME,libndctl-devel,g' \ diff --git a/meson.build b/meson.build index 746408948e4d..a94bbd740ef0 100644 --- a/meson.build +++ b/meson.build @@ -267,3 +267,9 @@ if get_option('docs').enabled() endif subdir('test') subdir('contrib') + +# only support spec file generation from git builds +if version_tag == '' + subdir('rhel') + subdir('sles') +endif diff --git a/ndctl.spec.in b/ndctl.spec.in index 4b08c05719c9..fd517317b943 100644 --- a/ndctl.spec.in +++ b/ndctl.spec.in @@ -6,14 +6,20 @@ License: GPLv2 Url: https://github.com/pmem/ndctl Source0: https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +%define with_meson MESON Requires: LNAME%{?_isa} = %{version}-%{release} Requires: DAX_LNAME%{?_isa} = %{version}-%{release} Requires: CXL_LNAME%{?_isa} = %{version}-%{release} BuildRequires: autoconf %if 0%{?rhel} < 9 BuildRequires: asciidoc +%if !%{with_meson} %define asciidoc --disable-asciidoctor +%endif %else +%if %{with_meson} +%define asciidoctor -Dasciidoctor=enabled +%endif BuildRequires: rubygem-asciidoctor %endif BuildRequires: xmlto @@ -27,6 +33,9 @@ BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(bash-completion) BuildRequires: pkgconfig(systemd) BuildRequires: keyutils-libs-devel +%if %{with_meson} +BuildRequires: meson +%endif %description Utility library for managing the "libnvdimm" subsystem. The "libnvdimm" @@ -115,17 +124,30 @@ libcxl is a library for enumerating and communicating with CXL devices. %setup -q ndctl-%{version} %build +%if %{with_meson} +%meson %{?asciidoctor} -Dversion-tag=%{version} +%meson_build +%else echo %{version} > version ./autogen.sh %configure --disable-static --disable-silent-rules %{?asciidoc} make %{?_smp_mflags} +%endif %install +%if %{with_meson} +%meson_install +%else %make_install find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' +%endif %check +%if %{with_meson} +%meson_test +%else make check +%endif %ldconfig_scriptlets -n LNAME diff --git a/rhel/meson.build b/rhel/meson.build new file mode 100644 index 000000000000..8672098d84e1 --- /dev/null +++ b/rhel/meson.build @@ -0,0 +1,23 @@ +rhel_spec1 = vcs_tag( + input : '../ndctl.spec.in', + output : 'ndctl.spec.in', + command: vcs_tagger, + replace_string : 'VERSION', +) + +rhel_spec2 = custom_target('ndctl.spec', + command : [ + 'sed', '-e', 's,MESON,1,g', + '-e', 's,DAX_DNAME,daxctl-devel,g', + '-e', 's,CXL_DNAME,cxl-devel,g', + '-e', 's,DNAME,ndctl-devel,g', + '-e', '/^%defattr.*/d', + '-e', 's,DAX_LNAME,daxctl-libs,g', + '-e', 's,CXL_LNAME,cxl-libs,g', + '-e', 's,LNAME,ndctl-libs,g', + '@INPUT@' + ], + input : rhel_spec1, + output : 'ndctl.spec', + capture : true, +) diff --git a/rpmbuild.sh b/rpmbuild.sh index fe4154b6be9f..b1f4d9e5c0f3 100755 --- a/rpmbuild.sh +++ b/rpmbuild.sh @@ -1,6 +1,9 @@ #!/bin/bash + +spec=${1:-$(dirname $0)/rhel/ndctl.spec)} + pushd $(dirname $0) >/dev/null [ ! -d ~/rpmbuild/SOURCES ] && echo "rpmdev tree not found" && exit 1 ./make-git-snapshot.sh popd > /dev/null -rpmbuild -ba $(dirname $0)/rhel/ndctl.spec +rpmbuild --nocheck -ba $spec diff --git a/sles/meson.build b/sles/meson.build new file mode 100644 index 000000000000..21c72cb4f5ec --- /dev/null +++ b/sles/meson.build @@ -0,0 +1,36 @@ +sles_spec1 = vcs_tag( + input : '../ndctl.spec.in', + output : 'ndctl.spec.sles.in', + command: vcs_tagger, + replace_string : 'VERSION', +) + +header = files('header') + +sles_spec2 = custom_target('ndctl.spec.in', + command : [ + 'cat', header, '@INPUT@', + ], + input : sles_spec1, + output : 'ndctl.spec.in', + capture : true, +) + +sles_spec3 = custom_target('ndctl.spec', + command : [ + 'sed', '-e', 's,MESON,1,g', + '-e', 's,DAX_DNAME,libdaxctl-devel,g', + '-e', 's,CXL_DNAME,libcxl-devel,g', + '-e', 's,DNAME,libndctl-devel,g', + '-e', 's,%license,%doc,g', + '-e', 's,\(^License:.*GPL\)v2,\1-2.0,g', + '-e', 's,DAX_LNAME,libdaxctl@0@,g'.format(LIBDAXCTL_CURRENT - LIBDAXCTL_AGE), + '-e', 's,CXL_LNAME,libcxl@0@,g'.format(LIBCXL_CURRENT - LIBCXL_AGE), + '-e', 's,LNAME,libndctl@0@,g'.format(LIBNDCTL_CURRENT - LIBNDCTL_AGE), + '@INPUT@' + ], + + input : sles_spec2, + output : 'ndctl.spec', + capture : true, +)