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=u2krM1uO; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 8DFDD5A026F for ; Mon, 29 Sep 2025 08:41:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1759128080; bh=g9SMVicQkUILglsOzm4cJPpnCtkdAJjqTPN2xpqQ+K8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u2krM1uONg+EFY4i9F54AWcjd9dZRYYaSkTQX52tupj7YAomoadT3n7E3KNtqbtbi FXClVrUhb/T1cJRfNcopmacdJYWIjx9mAyZDsoghw6VbgFm4JHGWMrdBhRul7qgI0u dOgXvwuq9scW+z+mkPwHGmHV4E2HV+SwMtkjgH6z16n88j2UlXzesN4sHXKaVO12WP XFwipK8EKK+H2C4ivnydbe1L7bt10UQPQ9jY5FPV9ex+Yk81K8t80uC5OjOwMW5hUV WmZGzClC2GEsCCMh8DoB4oI6SGBUOsegvWWXRuQF9fWSa1/onI5G7FqJsiKNMwM4VB eTBIsauaCVcmQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cZs683y70z4wBj; Mon, 29 Sep 2025 16:41:20 +1000 (AEST) Date: Mon, 29 Sep 2025 16:41:15 +1000 From: David Gibson To: Yumei Huang Subject: Re: [PATCH] test: Fix printf error when debug is enabled Message-ID: References: <20250929063014.17293-1-yuhuang@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cVBAXJP/fUcMp2bH" Content-Disposition: inline In-Reply-To: <20250929063014.17293-1-yuhuang@redhat.com> Message-ID-Hash: UJIC62WKA6HVYSOZSZVLFXNRDA35CSJG X-Message-ID-Hash: UJIC62WKA6HVYSOZSZVLFXNRDA35CSJG 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: --cVBAXJP/fUcMp2bH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 29, 2025 at 02:30:14PM +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 "${*}\n"' with 'printf "%s\n" "$*"'. > 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 I'm a little embarrassed I didn't spot this gotcha when I suggested the initial change. > --- > test/lib/term | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) >=20 > diff --git a/test/lib/term b/test/lib/term > index 6400746..2293474 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 "%s\n" "$*" >> $STATEBASE/log_pipe > + printf "%s\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 "%s\n" "$*" >> $STATEBASE/log_pipe > + printf "%s\n" "$*" >> "${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 "%s\n" "$*" >> $STATEBASE/log_pipe > } > =20 > # info_nolog() - Print message to log file > -# $@: Message to print > +# $*: Message to print > log() { > - printf "${*}\n" >> "${LOGFILE}" > + printf "%s\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 "%s" "${PR_YELLOW}?${PR_NC} ${*}" >> $STATEBASE/log_pipe > + printf "? %s" "${*}" >> "${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 --cVBAXJP/fUcMp2bH Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmjaKgoACgkQzQJF27ox 2GeS+w//UM4q7AxldiQaFVmuPLggBGybwiArLMbZM9Qff9PNcuairZFXeKnIRGmY kA4emKEy0uAjvhlwX+RpfXA/EDHjUqJUYojsgee7Ktoep6CerNfGMNmUJN88TQuf I0XdR/X3pnNVByrPPYgb8MdwsC9YMr66loF0T/awHu3btzgjuxgphDkjcPRIFd7R CL3V/8mhp4DkyHfVuwsPjxV7VBSdQnERIuaZH3nvNMkXrOaO4Y84UwZ6WQrgtNxi 2K3b/XMQXwXCekGILdL2dhDoTFHK8L+mcKsVmync2T/6mkDLWdwL2nLi7g8tuwzo y6It0QZK15GA8HYkSy7AOPfZAJpDaGLf8XDXSCOABnvWvET4+HmTOA9V/SbSLN4K Yt6/zNrnXcHrpCTtd2yDSCmwS32TH3L+4mWkGODM7QYeOAH9LLJTvMjVULRv2E5L arcgJskwJJgImDUNoHOfog9tv9ZB17qfQ8TBysqmVaaOrOuZ6cW3zPf7+XG7eRBN FVPDhuB+09ZPcjy+rXiBYOojrIIIREpVszlUXg5+2TutrJj7EmT5h7ZPzzGC1xNk CDGIMiVDFLS5iCk51MMS8PEj6lEiscfs+jeqgVOZweupX85w/8tMaOfjXqxIMysN CnvZL31JluBGMWJrB6w85ANxdAeqNn29nPoieZqsQZle0Yrs2JM= =y7Dg -----END PGP SIGNATURE----- --cVBAXJP/fUcMp2bH--