From patchwork Tue Nov 28 04:11:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13470491 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fXY9pqwM" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DFAC1A7 for ; Mon, 27 Nov 2023 20:11:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701144706; x=1732680706; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dJglqphnvdxezvitIujtsqJJ6XB6KC9QjQFLQwt0L0E=; b=fXY9pqwMrd2kd6KBH0GmHregk6xFRFOqPDtzqFs5T19k0ClfdvLVN1Wh 751parMssQ3xnt9LYbZyZFkHtEYVrfetf5IRnu62jyt9dQUsDGM0A+20T uwf35LS2pgpT9JVcrNe1/fGcz4l/U1FzcuS5KdxNzNkHaeR+/sEILDkl4 TiaKa+NbKjjVY670gsOpc83IXaQwUTjBs0i00WMVonNAtxCs67pmzS+Iz hVbw2DtdhfUctjmLLrZ/cBK0k+TwgJ5zNpwCEU2oY2hNf/ZGuwyhow/RR O07NgW74L8mo1qFShskZMW5uKHHtDxH50t1p2Pj29fYdinmv3o4fDK2+t Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="390001064" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="390001064" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 20:11:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="891948434" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="891948434" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.212.170.56]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 20:11:45 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [ndctl PATCH 1/3] cxl/test: add and use cxl_common_[start|stop] helpers Date: Mon, 27 Nov 2023 20:11:40 -0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield CXL unit tests use a mostly common set of commands to setup and tear down their test environments. Standardize on a common set and make all unit tests that run as part of the CXL suite use the helpers. This assures that each test is following the best known practice of set up and tear down, and that each is using the existing common helper - check_dmesg(). It also allows for expansion of the common helpers without the need to touch every unit test. Note that this makes all tests have the same execution prerequisites, so all tests will skip if a prerequisite for any test is not present. At the moment, the extra prereqs are sha256sum and dd, both used by cxl-update-firmware.sh. The broad requirement is a good thing, in that it enforces correct setup and complete runs of the entire CXL suite. cxl-security.sh was excluded from this migration as its setup has more in common with the nfit_test and legacy security test than with the other CXL unit tests. Signed-off-by: Alison Schofield Reviewed-by: Dave Jiang --- test/common | 23 +++++++++++++++++++++++ test/cxl-create-region.sh | 16 ++-------------- test/cxl-events.sh | 18 +++--------------- test/cxl-labels.sh | 16 ++-------------- test/cxl-poison.sh | 17 ++--------------- test/cxl-region-sysfs.sh | 16 ++-------------- test/cxl-topology.sh | 16 ++-------------- test/cxl-update-firmware.sh | 17 ++--------------- test/cxl-xor-region.sh | 15 ++------------- 9 files changed, 40 insertions(+), 114 deletions(-) diff --git a/test/common b/test/common index f1023ef20f7e..7a4711593624 100644 --- a/test/common +++ b/test/common @@ -150,3 +150,26 @@ check_dmesg() grep -q "Call Trace" <<< $log && err $1 true } + +# cxl_common_start +# $1: optional module parameter(s) for cxl-test +cxl_common_start() +{ + rc=77 + set -ex + trap 'err $LINENO' ERR + check_prereq "jq" + check_prereq "dd" + check_prereq "sha256sum" + modprobe -r cxl_test + modprobe cxl_test "$1" + rc=1 +} + +# cxl_common_end +# $1: line number where this is called +cxl_common_stop() +{ + check_dmesg "$1" + modprobe -r cxl_test +} diff --git a/test/cxl-create-region.sh b/test/cxl-create-region.sh index 658b9b8ff58a..aa586b1471f6 100644 --- a/test/cxl-create-region.sh +++ b/test/cxl-create-region.sh @@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start destroy_regions() { @@ -149,6 +139,4 @@ for mem in ${mems[@]}; do create_subregions "$mem" done -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO" diff --git a/test/cxl-events.sh b/test/cxl-events.sh index fe702bf98ad4..b181646d0fcb 100644 --- a/test/cxl-events.sh +++ b/test/cxl-events.sh @@ -4,24 +4,14 @@ . "$(dirname "$0")/common" +cxl_common_start + # Results expected num_overflow_expected=1 num_fatal_expected=2 num_failure_expected=16 num_info_expected=3 -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 - dev_path="/sys/bus/platform/devices" test_cxl_events() @@ -74,6 +64,4 @@ if [ "$num_info" -ne $num_info_expected ]; then err "$LINENO" fi -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO" diff --git a/test/cxl-labels.sh b/test/cxl-labels.sh index 36b0341c8039..c911816696c5 100644 --- a/test/cxl-labels.sh +++ b/test/cxl-labels.sh @@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start test_label_ops() { @@ -66,6 +56,4 @@ for nmem in ${nmems[@]}; do test_label_ops "$nmem" done -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO" diff --git a/test/cxl-poison.sh b/test/cxl-poison.sh index 8747ffe8cff7..2f16dc11884c 100644 --- a/test/cxl-poison.sh +++ b/test/cxl-poison.sh @@ -4,18 +4,7 @@ . "$(dirname "$0")"/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test - -rc=1 +cxl_common_start # THEORY OF OPERATION: Exercise cxl-cli and cxl driver ability to # inject, clear, and get the poison list. Do it by memdev and by region. @@ -153,6 +142,4 @@ echo 1 > /sys/kernel/tracing/events/cxl/cxl_poison/enable test_poison_by_memdev test_poison_by_region -check_dmesg "$LINENO" - -modprobe -r cxl-test +cxl_common_stop "$LINENO" diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh index 863639271afa..2c81d8f0b006 100644 --- a/test/cxl-region-sysfs.sh +++ b/test/cxl-region-sysfs.sh @@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start # THEORY OF OPERATION: Create a x8 interleave across the pmem capacity # of the 8 endpoints defined by cxl_test, commit the decoders (which @@ -163,6 +153,4 @@ readarray -t endpoint < <($CXL free-dpa -t pmem ${mem[*]} | jq -r ".[] | .decoder.decoder") echo "$region released ${#endpoint[@]} targets: ${endpoint[@]}" -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO" diff --git a/test/cxl-topology.sh b/test/cxl-topology.sh index e8b9f56543b5..7822abada7dc 100644 --- a/test/cxl-topology.sh +++ b/test/cxl-topology.sh @@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start # THEORY OF OPERATION: Validate the hard coded assumptions of the # cxl_test.ko module that defines its topology in @@ -187,6 +177,4 @@ done # validate that the bus can be disabled without issue $CXL disable-bus $root -f -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO" diff --git a/test/cxl-update-firmware.sh b/test/cxl-update-firmware.sh index f326868977a9..cf080150ccbc 100755 --- a/test/cxl-update-firmware.sh +++ b/test/cxl-update-firmware.sh @@ -4,19 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" -check_prereq "dd" -check_prereq "sha256sum" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start mk_fw_file() { @@ -192,5 +180,4 @@ test_nonblocking_update test_multiple_memdev test_cancel -check_dmesg "$LINENO" -modprobe -r cxl_test +cxl_common_stop "$LINENO" diff --git a/test/cxl-xor-region.sh b/test/cxl-xor-region.sh index 117e7a4bba61..6d74af8c98cd 100644 --- a/test/cxl-xor-region.sh +++ b/test/cxl-xor-region.sh @@ -4,18 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test interleave_arithmetic=1 -udevadm settle -rc=1 +cxl_common_start "interleave_arithmetic=1" # THEORY OF OPERATION: Create x1,2,3,4 regions to exercise the XOR math # option of the CXL driver. As with other cxl_test tests, changes to the @@ -93,4 +82,4 @@ create_and_destroy_region setup_x4 create_and_destroy_region -modprobe -r cxl_test +cxl_common_stop "$LINENO" From patchwork Tue Nov 28 04:11:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13470490 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HL/whBc9" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812091AA for ; Mon, 27 Nov 2023 20:11:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701144706; x=1732680706; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ip5PyEhyvYbbRH/6U5LIUuhALeMlHi0XxMtqRdbksTc=; b=HL/whBc9IkJnEWVyCrNwnD6jCzGHSzUBwwfNY6wDX75e70QrUis6VLc2 k0yhFKMJ9Eppd5T8SKUS2niiVF/p3aazbm++wRP2M5Fc1b9ajUAEqOZ/w KIjhfqLZpTtipILey3bwrmvEifOmcWZ6uypFiiaeS8MqWTLutkrBwc1mH uWl1J6ZMdTqGFsC8IxlIbEH0KRgzvPB+NaxmHOgOJGmTrIHrwUJKHMvIB ah2/h+r5mBHlTG5lZC2ZyQKObdHxD3wVv+pdzzs2ZPcf30XgKmljNI44n /F8Ul4daojVWeQ05tpDS4oSgNAoieopmGQEQzSLcneUiP8mUYUYTQPny2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="390001066" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="390001066" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 20:11:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="891948439" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="891948439" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.212.170.56]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 20:11:45 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [ndctl PATCH 2/3] cxl/test: add a cxl_ derivative of check_dmesg() Date: Mon, 27 Nov 2023 20:11:41 -0800 Message-Id: <39c11efdefeb12c3c928f36e9c59eeb40a841e72.1701143039.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield check_dmesg() is used by CXL unit tests as well as by a few DAX unit tests. Add a cxl_check_dmesg() version that can be expanded for CXL special checks like this: Add a check for an interleave calculation failure. This is a dev_dbg() message that spews (success or failure) whenever a user creates a region. It is useful as a regression check across the entire CXL suite. Signed-off-by: Alison Schofield Reviewed-by: Dave Jiang --- test/common | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/common b/test/common index 7a4711593624..c20b7e48c2b6 100644 --- a/test/common +++ b/test/common @@ -151,6 +151,19 @@ check_dmesg() true } +# cxl_check_dmesg +# $1: line number where this is called +cxl_check_dmesg() +{ + sleep 1 + log=$(journalctl -r -k --since "-$((SECONDS+1))s") + # validate no WARN or lockdep report during the run + grep -q "Call Trace" <<< "$log" && err "$1" + # validate no failures of the interleave calc dev_dbg() check + grep -q "Test cxl_calc_interleave_pos(): fail" <<< "$log" && err "$1" + true +} + # cxl_common_start # $1: optional module parameter(s) for cxl-test cxl_common_start() @@ -170,6 +183,6 @@ cxl_common_start() # $1: line number where this is called cxl_common_stop() { - check_dmesg "$1" + cxl_check_dmesg "$1" modprobe -r cxl_test } From patchwork Tue Nov 28 04:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13470489 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="idalali7" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 620371AD for ; Mon, 27 Nov 2023 20:11:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701144707; x=1732680707; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s23M8GQJ0QGy6Tw/q4SmIxShJcKb+Z5G+O+sswjlU30=; b=idalali7Re3WYddbPHsLOKZJyyrFktRprtRkojuXP19KEGb9tFBGpNnW MU/Pc2YjJ+mhZhJRayoSBwxTw2V6Rjm1WyfLRFYOVilpFFF1lSntpmbEh /XQyfMuWjQPhCEb0VNfhC/QGnWsf2KCLJDaGYYSpYA7sUTLe06vwJwrxD 11LemJWJAFB61+UQfFrb1liDJadvOCNu7MY27QjsjVaxfJXagQjCCnUMW F4ntYUt3uEaC/8KYpPx7sqpb2Vtrt2v/emyk8jVoiOca9f9nH/AzAEmrh JiUsvGXiyJkEe4v+QbJxq6vh7dOqSYF3iJoz1LHUjsxNk0C546ZNgTE/R w==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="390001069" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="390001069" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 20:11:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="891948442" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="891948442" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.212.170.56]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 20:11:46 -0800 From: alison.schofield@intel.com To: Vishal Verma Cc: Alison Schofield , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Subject: [ndctl PATCH 3/3] cxl/test: use an explicit --since time in journalctl Date: Mon, 27 Nov 2023 20:11:42 -0800 Message-Id: <1802cf15f22fe5c284167a9186eba8f2cd3c31c6.1701143039.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alison Schofield Using the bash variable 'SECONDS' plus 1 for searching the dmesg log sometimes led to one test picking up error messages from the previous test when run as a suite. SECONDS alone may miss some logs, but SECONDS + 1 is just as often too great. Since unit tests in the CXL suite are using common helpers to start and stop work, initialize and use a "starttime" variable with millisecond granularity for journalctl. Signed-off-by: Alison Schofield Reviewed-by: Dave Jiang --- test/common | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/common b/test/common index c20b7e48c2b6..93a280c7c150 100644 --- a/test/common +++ b/test/common @@ -156,7 +156,7 @@ check_dmesg() cxl_check_dmesg() { sleep 1 - log=$(journalctl -r -k --since "-$((SECONDS+1))s") + log=$(journalctl -r -k --since "$starttime") # validate no WARN or lockdep report during the run grep -q "Call Trace" <<< "$log" && err "$1" # validate no failures of the interleave calc dev_dbg() check @@ -175,6 +175,7 @@ cxl_common_start() check_prereq "dd" check_prereq "sha256sum" modprobe -r cxl_test + starttime=$(date +"%T.%3N") modprobe cxl_test "$1" rc=1 }