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

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