From patchwork Fri Oct 18 01:30:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13840967 Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ADC455897 for ; Fri, 18 Oct 2024 01:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.139.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729214993; cv=none; b=qClK1tfsDPYtXMrQn1UDeaAYck3JVeOz+fpkebt4MbKWc+XVsBx2z7PvkYv+7JGmkfXV02DA4NQM/xxjwOJfJMThsk912TiLzkN4P+/Ts65XqqV/ME83L/PEPWUrH/xyY2DkTTGPqPlUCZ9/a6uQNJfnz+AcaLS8PD2uoDBtyWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729214993; c=relaxed/simple; bh=+bBjc/9A+Ua5H7HXqJ8S16MXO9zhPZKhjHJsC2Pwv6k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MCTRZn8ibfiITU2kI43E5k8wR++SH0xiV4Tg/v7Ngrxafn6Or/ProAcefEQiLSXvDIXH06F3NCQKAi6zDsYJTB9FFvQOoqYKAVSdj1VehQg9YPrptD6wU7Ww90++oQoNyaZcHWxE/jVVl9FFHU8DS5KXb6UPh+GhJPQuX9484dQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=Cv9wjU2I; arc=none smtp.client-ip=68.232.139.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="Cv9wjU2I" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1729214991; x=1760750991; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+bBjc/9A+Ua5H7HXqJ8S16MXO9zhPZKhjHJsC2Pwv6k=; b=Cv9wjU2I6dle09FlB/Ze/R2vDGxfhzIjgrS9SCIKo43/uvkGocJWiRpy KMlCloHHLAQmcR0bROYJL0yFQdwUSuvFITA2rFuWqDr3X05lTJnbq7hJK 9x/ut509YvDUll2VF094s3wwXhBz84rU59J8JXvpZD3b25gsN3HpIcglL KXwcJpHNd/enDZvYmJ7rQoibB+HlMP/wL1pzeMBp6w/NAWLuEeXjq3mKW cgn4DrprhxyWAxh/bvrsTR12zYxQKeUoWyCqA9mQiw2KCd+EP8bNzFOaZ grG9JveSpIbOB5LLlj1qfkUbDQNwRQAIVZvb7K4DMwyXrzHPYFPB7NOYT w==; X-CSE-ConnectionGUID: ECIWZSoCQOmSyfQP1/FCqA== X-CSE-MsgGUID: NMJEbWPhSXCFeH7hVhzQWA== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="179323625" X-IronPort-AV: E=Sophos;i="6.11,212,1725289200"; d="scan'208";a="179323625" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 10:29:42 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 35748D4258 for ; Fri, 18 Oct 2024 10:29:40 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 79700BF3DD for ; Fri, 18 Oct 2024 10:29:39 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 0D144E51B8 for ; Fri, 18 Oct 2024 10:29:39 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 811741A000B; Fri, 18 Oct 2024 09:29:38 +0800 (CST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian Subject: [ndctl PATCH v3 1/2] test/monitor.sh convert float to integer before increment Date: Fri, 18 Oct 2024 09:30:19 +0800 Message-ID: <20241018013020.2523845-1-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28738.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28738.003 X-TMASE-Result: 10--2.069100-10.000000 X-TMASE-MatchedRID: 3VvmmxedNeKHYSb76u64f1hRyidsElYkGEGBUNvh8GASkNsdBvOYg2Uo D5JLGXzAnC7F+qVaTtq9Q4CDyJILGS7SL1WWCs3qEXjPIvKd74BMkOX0UoduueyufIOcfWGpo8W MkQWv6iUoTQl7wNH8Pg1fA1QHegDv3QfwsVk0UbvqwGfCk7KUswyi9UGnfc1kmVyPCbGrMTNYtm ygm+pbSYfEC2MAyNF/GZ/CA/4y894kJ8AODzlrRdx2pRgSEDDgM0G0VS1whvBTK7SumpFvNiHJp 2UYVccqxOB8J0pRLhyJxKSZiwBX6QtRTXOqKmFVftwZ3X11IV0= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 The test log reported: test/monitor.sh: line 149: 40.0: syntax error: invalid arithmetic operator (error token is ".0") It does stop the test prematurely. We never run the temperature inject test case of test_filter_dimmevent() because of the inability to increment the float. Signed-off-by: Li Zhijian --- V3: split as a separate patch --- test/monitor.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/monitor.sh b/test/monitor.sh index c5beb2c..7049b36 100755 --- a/test/monitor.sh +++ b/test/monitor.sh @@ -146,6 +146,7 @@ test_filter_dimmevent() stop_monitor inject_value=$($NDCTL list -H -d $monitor_dimms | jq -r .[]."health"."temperature_threshold") + inject_value=${inject_value%.*} inject_value=$((inject_value + 1)) start_monitor "-d $monitor_dimms -D dimm-media-temperature" inject_smart "-m $inject_value" From patchwork Fri Oct 18 01:30:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13840968 Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 763D420E319 for ; Fri, 18 Oct 2024 01:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729215056; cv=none; b=OXBfktWQjyyQipOGo5WzR4aQS3zjRhTeK7a5lj81+TgOqLU9/OJPi8QHVLo9YvMBJALC5+SoNUlcKdbvQ0SSSaFvINLZ/3jFwrVFtcyhuMSjzFsET8R9mAKnu1tzQuniqWO2vvr5LyUI9bEDcncM4ft1ig7HTsX/CXEAnOZf/Ho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729215056; c=relaxed/simple; bh=ARm9CdF/CqkuZrcM7QwN+wl9hZM+rn5ag6V2mqobYvg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZYuHj0Ea6CJ3TzqQkYan+GFwkATlw8CSghr01qvWt7BqKD8ziROxTcNHIKjcPR5bLHggjMjnn5PPyIj0apiaczSY0rIYFpTwHI8ZFh8jjOAKbIF7KPl5ar5umhH83UIc+TMgcLU1QEvoFe6IfgmyqIefIdnbyP/GeyXzIb5rGtQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=ESo6VFb8; arc=none smtp.client-ip=207.54.90.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="ESo6VFb8" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1729215055; x=1760751055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ARm9CdF/CqkuZrcM7QwN+wl9hZM+rn5ag6V2mqobYvg=; b=ESo6VFb86//KNygQj2rJtRDG3WErSvLLm11qYLYtNRWyj0hzNY1xWByI 23tSqAumNMlaaaVEZMaL8+PSk7yqOnNBdF99Rx4gl3TgxKpHcA/MtsV2d V7DvN1bkqZfKOOIGK+/8YD+OfamN1Wua17ryvAHEsqyjoSpiZA7p+nzjr TASGBL9ZgtSRQ9Q5Z+VgEAv2kOoFbsTPGP6a09zWlxCoEhBcMcsc2PDGo tdmYyscAt/l5Y4HxnYp6fwud5/M8EIxugNnSEIp0cUB0RZFqt+3AwHOKd 0YoXX8EWr8xDjHoXpRXwr8Q3Kwu1LiYBSSEgHo3h+vjmc5vbJqQ8rzy/b Q==; X-CSE-ConnectionGUID: aVsk9WdTQQqeFrlGRO870w== X-CSE-MsgGUID: dYfMc3MKTO2wjBewGy+o1A== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="177111195" X-IronPort-AV: E=Sophos;i="6.11,212,1725289200"; d="scan'208";a="177111195" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2024 10:29:43 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 8B1F9CA1E3 for ; Fri, 18 Oct 2024 10:29:40 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id BAEC9BF3E1 for ; Fri, 18 Oct 2024 10:29:39 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 57F4D20079540 for ; Fri, 18 Oct 2024 10:29:39 +0900 (JST) Received: from iaas-rdma.. (unknown [10.167.135.44]) by edo.cn.fujitsu.com (Postfix) with ESMTP id E486F1A01ED; Fri, 18 Oct 2024 09:29:38 +0800 (CST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian Subject: [ndctl PATCH v3 2/2] test/monitor.sh: Fix shellcheck SC2086 issues as more as possible Date: Fri, 18 Oct 2024 09:30:20 +0800 Message-ID: <20241018013020.2523845-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241018013020.2523845-1-lizhijian@fujitsu.com> References: <20241018013020.2523845-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28738.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28738.003 X-TMASE-Result: 10--10.532800-10.000000 X-TMASE-MatchedRID: GJWipKZ49enCS1NeCvs3qIdlc1JaOB1TqMXw4YFVmwhf/JRqlbLSV7Sn Jfu7KIKtEi5XEH00QubCsyZB1bKGqCqQO0zIUpyn8IK7yRWPRNEk2ugFoZn4tZE8TgOkbzEohEz I3+mkzifvPrWB/m7DX0y+rse8BOXw0hQoRxePIEGfrLSY2RbRpE3yuY9BGW8r9Iz2KSWO8hx7j+ VBlZHsEjjiJ+c203Ms8vc3EUpCmrVzE1fI6N2sO0hwlOfYeSqxIm2Js0m7E8KhuT/MQ6uAV/qAD eqinEVf2cknzgMeAbs51K+dagOOz/XhWE12qWg+GYJhRh6sses4Ddbs3t0GCZ6fSoF3Lt+M5aE0 pi4zt43jfe52KJUqfc/7jrKpSJx3HxPMjOKY7A8LbigRnpKlKSPzRlrdFGDwZbSJQ9f2HSlhgIr YE2VKa7ZEfCsCXb1sr/ygZ6K2Kn21GQ3EnYnJTA== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 SC2086 [1], aka. Double quote to prevent globbing and word splitting. Previously, SC2086 will cause error in [[]] or [], for example $ grep -w line build/meson-logs/testlog.txt test/monitor.sh: line 99: [: too many arguments test/monitor.sh: line 99: [: nmem0: binary operator expected Firstly, generated diff by shellcheck tool: $ shellcheck -i SC2086 -f diff test/monitor.sh In addition, we have remove the double quote around $1 like below changes. That's because when an empty "$1" passed to a command will open to '' it would cause an error, for example $ ndctl/build/test/list-smart-dimm -b nfit_test.0 '' Error: unknown parameter "" - $NDCTL monitor -c "$monitor_conf" -l "$logfile" "$1" & + $NDCTL monitor -c "$monitor_conf" -l "$logfile" $1 & - jlist=$("$TEST_PATH"/list-smart-dimm -b "$smart_supported_bus" "$1") + jlist=$("$TEST_PATH"/list-smart-dimm -b "$smart_supported_bus" $1) - $NDCTL inject-smart "$monitor_dimms" "$1" + $NDCTL inject-smart "$monitor_dimms" $1 - [[ $1 == $notify_dimms ]] + [[ "$1" == "$notify_dimms" ]] - [ ! -z "$monitor_dimms" ] && break + [[ "$monitor_dimms" ]] && break [1] https://www.shellcheck.net/wiki/SC2086 Signed-off-by: Li Zhijian --- `shellcheck -i SC2086 -f diff test/*.sh | patch -p1` can auto correct some remaining SC2086 issues, however we can find it still miss some patterns and some changes will break the origial test. V3: - Fix SC2086 issues as more as possible # Alison - covert [ ! -z $foo ] to [[ "foo" ]] as Vishal's suggestion. V1: V1 has a mistake which overts to integer too late. Move the conversion forward before the operation Signed-off-by: Li Zhijian --- test/monitor.sh | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/monitor.sh b/test/monitor.sh index 7049b36..be8e24d 100755 --- a/test/monitor.sh +++ b/test/monitor.sh @@ -11,7 +11,7 @@ monitor_regions="" monitor_namespace="" smart_supported_bus="" -. $(dirname $0)/common +. $(dirname "$0")/common monitor_conf="$TEST_PATH/../ndctl" @@ -24,51 +24,51 @@ check_min_kver "4.15" || do_skip "kernel $KVER may not support monitor service" start_monitor() { logfile=$(mktemp) - $NDCTL monitor -c "$monitor_conf" -l $logfile $1 & + $NDCTL monitor -c "$monitor_conf" -l "$logfile" $1 & monitor_pid=$! sync; sleep 3 - truncate --size 0 $logfile #remove startup log + truncate --size 0 "$logfile" #remove startup log } set_smart_supported_bus() { smart_supported_bus=$NFIT_TEST_BUS0 - monitor_dimms=$($TEST_PATH/list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev) - if [ -z $monitor_dimms ]; then + 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 } get_monitor_dimm() { - jlist=$($TEST_PATH/list-smart-dimm -b $smart_supported_bus $1) - monitor_dimms=$(jq '.[]."dev"?, ."dev"?' <<<$jlist | sort | uniq | xargs) - echo $monitor_dimms + 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() { - $TEST_PATH/smart-notify $smart_supported_bus + "$TEST_PATH"/smart-notify "$smart_supported_bus" sync; sleep 3 } inject_smart() { - $NDCTL inject-smart $monitor_dimms $1 + $NDCTL inject-smart "$monitor_dimms" $1 sync; sleep 3 } check_result() { - jlog=$(cat $logfile) - notify_dimms=$(jq ."dimm"."dev" <<<$jlog | sort | uniq | xargs) - [[ $1 == $notify_dimms ]] + jlog=$(cat "$logfile") + notify_dimms=$(jq ."dimm"."dev" <<<"$jlog" | sort | uniq | xargs) + [[ "$1" == "$notify_dimms" ]] } stop_monitor() { kill $monitor_pid - rm $logfile + rm "$logfile" } test_filter_dimm() @@ -91,12 +91,12 @@ test_filter_bus() test_filter_region() { - count=$($NDCTL list -R -b $smart_supported_bus | jq -r .[].dev | wc -l) + count=$($NDCTL list -R -b "$smart_supported_bus" | jq -r .[].dev | wc -l) i=0 - while [ $i -lt $count ]; do - monitor_region=$($NDCTL list -R -b $smart_supported_bus | jq -r .[$i].dev) + while [ $i -lt "$count" ]; do + monitor_region=$($NDCTL list -R -b "$smart_supported_bus" | jq -r .[$i].dev) monitor_dimms=$(get_monitor_dimm "-r $monitor_region") - [ ! -z $monitor_dimms ] && break + [[ "$monitor_dimms" ]] && break i=$((i + 1)) done start_monitor "-r $monitor_region" @@ -108,25 +108,25 @@ test_filter_region() test_filter_namespace() { reset - monitor_namespace=$($NDCTL create-namespace -b $smart_supported_bus | jq -r .dev) + monitor_namespace=$($NDCTL create-namespace -b "$smart_supported_bus" | jq -r .dev) monitor_dimms=$(get_monitor_dimm "-n $monitor_namespace") start_monitor "-n $monitor_namespace" call_notify check_result "$monitor_dimms" stop_monitor - $NDCTL destroy-namespace $monitor_namespace -f + $NDCTL destroy-namespace "$monitor_namespace" -f } test_conf_file() { monitor_dimms=$(get_monitor_dimm) conf_file=$(mktemp) - echo -e "[monitor]\ndimm = $monitor_dimms" > $conf_file + echo -e "[monitor]\ndimm = $monitor_dimms" > "$conf_file" start_monitor "-c $conf_file" call_notify check_result "$monitor_dimms" stop_monitor - rm $conf_file + rm "$conf_file" } test_filter_dimmevent() @@ -138,14 +138,14 @@ test_filter_dimmevent() check_result "$monitor_dimms" stop_monitor - inject_value=$($NDCTL list -H -d $monitor_dimms | jq -r .[]."health"."spares_threshold") + inject_value=$($NDCTL list -H -d "$monitor_dimms" | jq -r .[]."health"."spares_threshold") inject_value=$((inject_value - 1)) start_monitor "-d $monitor_dimms -D dimm-spares-remaining" inject_smart "-s $inject_value" check_result "$monitor_dimms" stop_monitor - inject_value=$($NDCTL list -H -d $monitor_dimms | jq -r .[]."health"."temperature_threshold") + inject_value=$($NDCTL list -H -d "$monitor_dimms" | jq -r .[]."health"."temperature_threshold") inject_value=${inject_value%.*} inject_value=$((inject_value + 1)) start_monitor "-d $monitor_dimms -D dimm-media-temperature"