anitazha / rpms / ndctl

Forked from rpms/ndctl a year ago
Clone

Blame SOURCES/0124-ndctl-test-make-inject-smart.sh-more-tolerant-of-dec.patch

e0018b
From 4921c0c2040ffbe10facd320f6a718a3d42ad815 Mon Sep 17 00:00:00 2001
e0018b
From: Vishal Verma <vishal.l.verma@intel.com>
e0018b
Date: Thu, 17 Feb 2022 22:42:29 -0700
e0018b
Subject: [PATCH 124/217] ndctl/test: make inject-smart.sh more tolerant of
e0018b
 decimal fields
e0018b
e0018b
Some combinations of json-c/jq/other libraries seem to produce differing
e0018b
outputs for the final jq-filtered smart fields, in that some have a
e0018b
decimal "42.0" numeric field, where as in other combinations it is a
e0018b
simple "42" (still a numeric field, not string).
e0018b
e0018b
This shouldn't matter in practice, but for this contrived test case, we
e0018b
need to make sure that "42" is treated the same as "42.0"
e0018b
e0018b
Normalize all fields before comparing them to "%0.0f" so that the
e0018b
comparison doesn't result in superfluous failures.
e0018b
e0018b
Reported-by: Dan Williams <dan.j.williams@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 test/inject-smart.sh | 4 ++--
e0018b
 1 file changed, 2 insertions(+), 2 deletions(-)
e0018b
e0018b
diff --git a/test/inject-smart.sh b/test/inject-smart.sh
e0018b
index 8b91360..046322b 100755
e0018b
--- a/test/inject-smart.sh
e0018b
+++ b/test/inject-smart.sh
e0018b
@@ -105,13 +105,13 @@ get_field()
e0018b
 	json="$($NDCTL list -b $bus -d $dimm -H)"
e0018b
 	val="$(jq -r ".[].dimms[].health.$smart_listing" <<< $json)"
e0018b
 	val="$(translate_val $val)"
e0018b
-	echo $val
e0018b
+	printf "%0.0f\n" "$val"
e0018b
 }
e0018b
 
e0018b
 verify()
e0018b
 {
e0018b
 	local field="$1"
e0018b
-	local val="$2"
e0018b
+	local val="$(printf "%0.0f\n" "$2")"
e0018b
 
e0018b
 	[[ "$val" == "$(get_field $field)" ]]
e0018b
 }
e0018b
-- 
e0018b
2.27.0
e0018b