From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202508 header.b=D4H1fAsw; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 02CB05A026F for ; Tue, 30 Sep 2025 04:10:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1759198243; bh=LJ4tXbHkVhrWRB8dNMMKFioW3i7gL+u+j3P1c6NA1TY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D4H1fAsw1FgQlq/RbSldQBbjVVyJEO7GvibBiPAItAMUr0qMt9NiYKbu1h/QPR2JD HkW+YDUF2/5MulRsnw5TbJfQz/R/5uDu7wWrfYFVRoJ4h8HJNLnkFS4CVbo4mZle5+ iX8G5w4DhFKYiwM5+LraGyDoke0AnkiaP1nyqSIRaIFEhGd7GKZlYLI1wIOYgu7EGW 2VxRX+9i9i6A172h1c2BYInG0wBOVN/OibdIjmEW0MEC4T4Cf0mCqPix2DOeFuBx6C knOu92F7qgrO3Z392saV5epSIkvSs7XlXz4ergGPajx6aD/UTNjhcSPHixE12OkjGN jMFsWw0772IXg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cbM3R2qdTz4wC3; Tue, 30 Sep 2025 12:10:43 +1000 (AEST) Date: Tue, 30 Sep 2025 12:10:33 +1000 From: David Gibson To: Yumei Huang Subject: Re: [PATCH v2] test: Fix printf error when debug is enabled Message-ID: References: <20250930014158.6949-1-yuhuang@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="52Bndo2BC9Et7cjJ" Content-Disposition: inline In-Reply-To: <20250930014158.6949-1-yuhuang@redhat.com> Message-ID-Hash: FO6BSP4C7WBUWQ34L7X3QGMUOSFZV67C X-Message-ID-Hash: FO6BSP4C7WBUWQ34L7X3QGMUOSFZV67C 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, sbrivio@redhat.com X-Mailman-Version: 3.3.8 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: --52Bndo2BC9Et7cjJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 30, 2025 at 09:41:58AM +0800, Yumei Huang wrote: > Running test pasta/tcp with debug enabled would get stuck with > below error: >=20 > + printf 'DEBUG: ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[__GW6_= _%__IFNAME__]:10003\n' > lib/term: line 38: printf: `_': invalid format character >=20 > The error occurs because printf interprets the % character as the > start of a format specifier, and the following '_' isn't one of > them. >=20 > Fix it by replacing 'printf "${*}"' with 'printf "%b" "${*}"'. > Also update the docstring. >=20 > Link: https://bugs.passt.top/show_bug.cgi?id=3D154 > Fixes: de28c20d8051 ("test: Update lib/term for clearer output when DEBUG= is enabled") > Signed-off-by: Yumei Huang Reviewed-by: David Gibson > --- > test/lib/term | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) >=20 > diff --git a/test/lib/term b/test/lib/term > index 6400746..79aa2b7 100755 > --- a/test/lib/term > +++ b/test/lib/term > @@ -29,32 +29,32 @@ PR_NC=3D'\033[0m' > PR_DELAY_INIT=3D100 # ms > =20 > # info() - Highlight test log pane, print message to it and to log file > -# $@: Message to print > +# $*: Message to print > info() { > tmux select-pane -t ${PANE_INFO} > - printf "${*}\n" >> $STATEBASE/log_pipe > - printf "${*}\n" >> "${LOGFILE}" > + printf "%b\n" "${*}" >> $STATEBASE/log_pipe > + printf "%b\n" "${*}" >> "${LOGFILE}" > } > =20 > # info_n() - Highlight, print message to pane and to log file without ne= wline > -# $@: Message to print > +# $*: Message to print > info_n() { > tmux select-pane -t ${PANE_INFO} > - printf "${*}" >> $STATEBASE/log_pipe > - printf "${*}" >> "${LOGFILE}" > + printf "%b" "${*}" >> $STATEBASE/log_pipe > + printf "%b" "${*}" >> "${LOGFILE}" > } > =20 > # info_nolog() - Highlight test log pane, print message to it > -# $@: Message to print > +# $*: Message to print > info_nolog() { > tmux select-pane -t ${PANE_INFO} > - printf "${*}\n" >> $STATEBASE/log_pipe > + printf "%b\n" "${*}" >> $STATEBASE/log_pipe > } > =20 > # info_nolog() - Print message to log file > -# $@: Message to print > +# $*: Message to print > log() { > - printf "${*}\n" >> "${LOGFILE}" > + printf "%b\n" "${*}" >> "${LOGFILE}" > } > =20 > # info_nolog_n() - Send message to pane without highlighting it, without= newline > @@ -363,8 +363,8 @@ status_test_start() { > info_check() { > switch_pane ${PANE_INFO} > =20 > - printf "${PR_YELLOW}?${PR_NC} ${*}" >> $STATEBASE/log_pipe > - printf "? ${*}" >> "${LOGFILE}" > + printf "%b" "${PR_YELLOW}?${PR_NC} ${*}" >> $STATEBASE/log_pipe > + printf "? %b" "${*}" >> "${LOGFILE}" > } > =20 > # info_check_passed() - Display and log a new line when a check passes > --=20 > 2.47.0 >=20 --=20 David Gibson (he or they) | 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 --52Bndo2BC9Et7cjJ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmjbPBgACgkQzQJF27ox 2GcgNQ/+KNc4NtZZs/RvaGN0xrA1+ff+kbeWrAUjYQfOfZhmZxpBhc312W0lGWF8 CP4mAJ5m0pt8s96W1S+eS1bKtl4CauHAm43La0+0cSvdNv/KjCWvLAdRPoscNnFA h2NW6h0Aj++GijOBkBVkczykUPrLiC2ehesp2fCfihxhpsRcbc6/JHB+sqM5A7b4 K0Q6E3xlby5NsZcOZjGBiiywncy8fr2g/J9wQQ3+sHvKmJDNaChonj7U/YAjJtnA tHjMbx5akFkjjOiGvInLZjZowXLW6eW470ppHeoy7rYnXENUndz/LnARFcuEmDls 1WKrOW9oz8m1zHbzll5oJ6aUc1lyAh//oWT1l7UhdwoOig+ggZNljn/7xeeg8Zj2 QuWXvfd7EXYWB6N8op2xrs9C+yyIYbVcPWdKTwVQvJxOgDzGfjWp/35t+s9mwS1j nMtXmaQQkBYxj86oN8F+Bi1E7gimPby+nJ8tuG9+S+lNNBa1JUgJeWXtEQYd2Xqx yotJID3ARmiwdC2xtLZHXL9vNSCbeSmM7l/kcB7IKntik5RdqGL0fAZKqcjJ+GII Y8wBbLCmctSssNFR+G8nrxLNJ3ScFbF7xusZsjzD7hE93gR8eVDBa9X3u/9Z01JG TmtUvSgXVcU13vlmq9+tu9FucdpuX+uZXkEv32/uR9TUd7Qq5W4= =8nGs -----END PGP SIGNATURE----- --52Bndo2BC9Et7cjJ--