From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v2 4/5] test/lib: Add "td" directive, handled by table_value()
Date: Tue, 1 Nov 2022 11:42:09 +1100 [thread overview]
Message-ID: <Y2BrYcDuoeojqpz7@yekko> (raw)
In-Reply-To: <20221031112059.170269-5-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2331 bytes --]
On Mon, Oct 31, 2022 at 12:20:58PM +0100, Stefano Brivio wrote:
> 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>
> ---
> test/lib/term | 28 ++++++++++++++++++++++++++++
> test/lib/test | 3 +++
> 2 files changed, 31 insertions(+)
>
> diff --git a/test/lib/term b/test/lib/term
> index 1b42df8..8515c50 100755
> --- a/test/lib/term
> +++ b/test/lib/term
> @@ -552,6 +552,34 @@ table_end() {
> 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() {
> [ "${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)"
> diff --git a/test/lib/test b/test/lib/test
> index 4c271a5..df32178 100755
> --- a/test/lib/test
> +++ b/test/lib/test
> @@ -278,6 +278,9 @@ test_one_line() {
> "te")
> table_end
> ;;
> + "td")
> + table_value ${__arg} || TEST_ONE_perf_nok=1
> + ;;
> "bw")
> table_value_throughput ${__arg} || TEST_ONE_perf_nok=1
> ;;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-11-01 0:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 11:20 [PATCH v2 0/5] Test cases to display memory usage in kernel and userspace Stefano Brivio
2022-10-31 11:20 ` [PATCH v2 1/5] test/lib: Move screen-scraping setup and layout functions to _ugly files Stefano Brivio
2022-11-01 0:39 ` David Gibson
2022-10-31 11:20 ` [PATCH v2 2/5] tap: Support for detection of existing sockets on ramfs Stefano Brivio
2022-11-01 0:41 ` David Gibson
2022-10-31 11:20 ` [PATCH v2 3/5] test/lib/perf_report: Use own flag to track initialisation Stefano Brivio
2022-11-01 0:41 ` David Gibson
2022-10-31 11:20 ` [PATCH v2 4/5] test/lib: Add "td" directive, handled by table_value() Stefano Brivio
2022-11-01 0:42 ` David Gibson [this message]
2022-10-31 11:20 ` [PATCH v2 5/5] test: Add memory/passt test cases Stefano Brivio
2022-11-01 0:58 ` David Gibson
2022-11-01 7:59 ` Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y2BrYcDuoeojqpz7@yekko \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).