From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 044305A026E for ; Tue, 1 Nov 2022 01:59:37 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4N1WrK5kpJz4xN4; Tue, 1 Nov 2022 11:59:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1667264369; bh=UH7pcBFfqKHBGJOD8fW30uzL/MtSxCfJ3E9A+PbyHfE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wf0QJj1p12ZwO+41z4FqTOW54NmXFnDza3G+Utte0jVhOwOlgWW4/75JmRnSllrfr /6bsH9D6jBqKrHArEmJKVcIT3ss/PiGGgX1+x1HevbxuTmzcXsivTPXy7clxwkiHBE MCWDvzD4azJyy8uwJm4N5hUgCu285LN5ODBsrsQo= Date: Tue, 1 Nov 2022 11:42:09 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 4/5] test/lib: Add "td" directive, handled by table_value() Message-ID: References: <20221031112059.170269-1-sbrivio@redhat.com> <20221031112059.170269-5-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UPpxaspkv+SqlTvR" Content-Disposition: inline In-Reply-To: <20221031112059.170269-5-sbrivio@redhat.com> Message-ID-Hash: ZHSMHPKUTMLMBKL4GHZLXLIAUN7NX33Z X-Message-ID-Hash: ZHSMHPKUTMLMBKL4GHZLXLIAUN7NX33Z X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --UPpxaspkv+SqlTvR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > test/lib/term | 28 ++++++++++++++++++++++++++++ > test/lib/test | 3 +++ > 2 files changed, 31 insertions(+) >=20 > 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" > } > =20 > +# 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}" =3D "-" ] && table_cell 1 "-" && perf_td 0 "" && return 0 > + if [ "${2}" !=3D "0" ]; then > + __v=3D"$(echo "scale=3D1; x=3D( ${1} + 10^$((${2} - 1)) / 2 ) / 10^${2= }; if ( x < 1 && x > 0 ) print 0; x" | bc -l)" > + else > + __v=3D"${1}" > + fi > + perf_td 0 "${__v}" > + > + __red=3D"${3}" > + __yellow=3D"${4}" > + if [ "$(echo "${__v} < ${__red}" | bc -l)" =3D "1" ]; then > + table_cell ${#__v} "${PR_RED}${__v}${PR_NC}" > + return 1 > + elif [ "$(echo "${__v} < ${__yellow}" | bc -l)" =3D "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}" =3D "-" ] && table_cell 1 "-" && perf_td 0 "" && return 0 > __v=3D"$(echo "scale=3D1; x=3D( ${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=3D1 > + ;; > "bw") > table_value_throughput ${__arg} || TEST_ONE_perf_nok=3D1 > ;; --=20 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 --UPpxaspkv+SqlTvR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmNga1oACgkQgypY4gEw YSLUGg/+LcGnMLXJz0WCJ/gleogJfZwFlDoJqvpCBLbjbKi7L5Z656zPCWXg/Zlk lvTOQJhTRaJ4z33VfRSwhTbmdCGKQcoqM4xEIxTcNZpsGTxlnsJiS7GIo2sQZHyd /c0u6LM78BHWUdHlWSWKytbZ1WSg0IhG4ywgCTRDucR1vpjubJ43Zvjrt7Gxh8dt p96kMtfFd9jb3PnTIxHM/odu6qhvpB3GoONEvsHRhLzUN2xXuGEFfPK7tjrTQg8q /2Jh2U1liRN+5C5ET0WhsY/rHNs+GAPkl4kPgOO4H5xWSzj9CMPghVNquNKg2YUK 832MyqQo8NgJ6W15IzElXHCQXeKmm3mR058+ZO0OVzeG1QS+eUHhK6DUmKIDMZUq xWL4d3Wi6YET7jd1opkOS+usAqYfFf7tytz5dLfysRtBSzo1xdcx7/ecJhTeXEd5 pyJag+8m+V38OnKkSE/0TJsFtr/hvFREjbiQr6Mbm7UpsAiE9fpz1J+QQT4URx9c /2GGFCjyZb6HEe/iRD0J0o5ZYtP8IvgpBmR1FLie/qcrJRoH3LNXlHjCF5nsc8G8 rYOtIn/TJUQuGaKejc3LlN16mQjae4z/QjvcARVEBzLrjpomeTXDiV6sbbDxUOLD YDB7/Bdk/lFg9OsrKLtZsj4d2UQW+dKXG9CKCk+FxH1Q9A3h+ZE= =XZwq -----END PGP SIGNATURE----- --UPpxaspkv+SqlTvR--