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