test/lib: Add "td" directive, handled by table_value()
This can be used for generic cell values with an arbitrary scale. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
bfd311aec7
commit
ce2a0a5bb4
2 changed files with 31 additions and 0 deletions
|
@ -552,6 +552,34 @@ table_end() {
|
||||||
info_n "\n${__buf}'\n"
|
info_n "\n${__buf}'\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# table_value() - Print generic table value in its own cell
|
||||||
|
# $1: Value, can be '-' to indicate a filler
|
||||||
|
# $2: Scale, exponent of 10
|
||||||
|
# $3: Error value, scaled: if value is less than this, print in red
|
||||||
|
# $4: Warning value, scaled: if value is less than this, print in yellow
|
||||||
|
table_value() {
|
||||||
|
[ "${1}" = "-" ] && table_cell 1 "-" && perf_td 0 "" && return 0
|
||||||
|
if [ "${2}" != "0" ]; then
|
||||||
|
__v="$(echo "scale=1; x=( ${1} + 10^$((${2} - 1)) / 2 ) / 10^${2}; if ( x < 1 && x > 0 ) print 0; x" | bc -l)"
|
||||||
|
else
|
||||||
|
__v="${1}"
|
||||||
|
fi
|
||||||
|
perf_td 0 "${__v}"
|
||||||
|
|
||||||
|
__red="${3}"
|
||||||
|
__yellow="${4}"
|
||||||
|
if [ "$(echo "${__v} < ${__red}" | bc -l)" = "1" ]; then
|
||||||
|
table_cell ${#__v} "${PR_RED}${__v}${PR_NC}"
|
||||||
|
return 1
|
||||||
|
elif [ "$(echo "${__v} < ${__yellow}" | bc -l)" = "1" ]; then
|
||||||
|
table_cell ${#__v} "${PR_YELLOW}${__v}${PR_NC}"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
table_cell ${#__v} "${PR_GREEN}${__v}${PR_NC}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
table_value_throughput() {
|
table_value_throughput() {
|
||||||
[ "${1}" = "-" ] && table_cell 1 "-" && perf_td 0 "" && return 0
|
[ "${1}" = "-" ] && table_cell 1 "-" && perf_td 0 "" && return 0
|
||||||
__v="$(echo "scale=1; x=( ${1} + 10^8 / 2 ) / 10^9; if ( x < 1 && x > 0 ) print 0; x" | bc -l)"
|
__v="$(echo "scale=1; x=( ${1} + 10^8 / 2 ) / 10^9; if ( x < 1 && x > 0 ) print 0; x" | bc -l)"
|
||||||
|
|
|
@ -278,6 +278,9 @@ test_one_line() {
|
||||||
"te")
|
"te")
|
||||||
table_end
|
table_end
|
||||||
;;
|
;;
|
||||||
|
"td")
|
||||||
|
table_value ${__arg} || TEST_ONE_perf_nok=1
|
||||||
|
;;
|
||||||
"bw")
|
"bw")
|
||||||
table_value_throughput ${__arg} || TEST_ONE_perf_nok=1
|
table_value_throughput ${__arg} || TEST_ONE_perf_nok=1
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue