Open lenticularis39 opened 1 year ago
@lenticularis39 Does something like this fix it for you?
diff --git a/test/inject-smart.sh b/test/inject-smart.sh
index 046322b..4bca492 100755
--- a/test/inject-smart.sh
+++ b/test/inject-smart.sh
@@ -105,7 +105,14 @@ get_field()
json="$($NDCTL list -b $bus -d $dimm -H)"
val="$(jq -r ".[].dimms[].health.$smart_listing" <<< $json)"
val="$(translate_val $val)"
- printf "%0.0f\n" "$val"
+
+ # val can be e.g. "20.0". Printf complains on this for locales that
+ # use ',' as the decimal separator. For this %0.0f case, it doesn't
+ # matter what the decimal separator is, and bash helpfully does print
+ # "20" even if #$? indicates an error, and there is an error message
+ # on stderr. Ignore the error, and just pick the "20" to avoid such
+ # cases
+ printf "%0.0f\n" "$val" 2 >/dev/null || true
}
verify()
@stellarhopper Yes, that fixes the issue, if applied without typo 2 >/dev/null
-> 2>/dev/null
.
With locale set to
cs_CZ.UTF-8
, inject-smart.sh test fails with the following error (full log of the test here):This is caused by the floating point separator being
,
in Czech locale rather than.
:Running the test with
LC_ALL=C
fixes the issue.