[v2] nm01: Remove prefix zeros of the addresses output by nm before comparing
diff mbox series

Message ID 1577775768-134223-1-git-send-email-zhe.he@windriver.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series
  • [v2] nm01: Remove prefix zeros of the addresses output by nm before comparing
Related show

Commit Message

He Zhe Dec. 31, 2019, 7:02 a.m. UTC
From: He Zhe <zhe.he@windriver.com>

The latest nm v2.33.1.20191208 outputs symbols addresses without prefix zeros
for "nm -f posix", which causes the following error.
nm01 5 TFAIL: Got wrong format with -f bsd

Let's remove the prefix zeros before comparing.

Signed-off-by: He Zhe <zhe.he@windriver.com>
---
v2:
Add boundary mark to RE pattern to exactly cover the prefix zeros
Add one more temp file to contain trimmed output

 testcases/commands/nm/nm01.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Li Wang Dec. 31, 2019, 9:05 a.m. UTC | #1
On Tue, Dec 31, 2019 at 3:03 PM <zhe.he@windriver.com> wrote:

> From: He Zhe <zhe.he@windriver.com>
>
> The latest nm v2.33.1.20191208 outputs symbols addresses without prefix
> zeros
> for "nm -f posix", which causes the following error.
> nm01 5 TFAIL: Got wrong format with -f bsd
>
> Let's remove the prefix zeros before comparing.
>
> Signed-off-by: He Zhe <zhe.he@windriver.com>
>
Reviewed-by: Li Wang <liwang@redhat.com>


> ---
> v2:
> Add boundary mark to RE pattern to exactly cover the prefix zeros
> Add one more temp file to contain trimmed output
>
>  testcases/commands/nm/nm01.sh | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/commands/nm/nm01.sh b/testcases/commands/nm/nm01.sh
> index 30c41bd..fd9d3d9 100755
> --- a/testcases/commands/nm/nm01.sh
> +++ b/testcases/commands/nm/nm01.sh
> @@ -84,8 +84,11 @@ test5()
>         EXPECT_PASS $NM -f bsd $TST_DATAROOT/f1 \> nm_bsd.out
>         EXPECT_PASS $NM -f posix $TST_DATAROOT/f1 \> nm_posix.out
>
> -       ROD awk '{print $3 $2 $1}' nm_bsd.out \> nm1.out
> -       ROD awk '{print $1 $2 $3}' nm_posix.out \> nm2.out
> +       ROD awk '{print gensub(/\y(0+)([0-9a-fA-F]+)\y/, "\\2", "g")}'
> nm_bsd.out \> trimmed_nm_bsd.out
> +       ROD awk '{print gensub(/\y(0+)([0-9a-fA-F]+)\y/, "\\2", "g")}'
> nm_posix.out \> trimmed_nm_posix.out
> +
> +       ROD awk '{print $3 $2 $1}' trimmed_nm_bsd.out \> nm1.out
> +       ROD awk '{print $1 $2 $3}' trimmed_nm_posix.out \> nm2.out
>
>         if diff nm1.out nm2.out > /dev/null; then
>                 tst_res TPASS "Got BSD format with -f bsd"
> --
> 2.7.4
>
>
Petr Vorel Jan. 3, 2020, 2:14 p.m. UTC | #2
Hi He,

thanks for your patch, merged.

Kind regards,
Petr

Patch
diff mbox series

diff --git a/testcases/commands/nm/nm01.sh b/testcases/commands/nm/nm01.sh
index 30c41bd..fd9d3d9 100755
--- a/testcases/commands/nm/nm01.sh
+++ b/testcases/commands/nm/nm01.sh
@@ -84,8 +84,11 @@  test5()
 	EXPECT_PASS $NM -f bsd $TST_DATAROOT/f1 \> nm_bsd.out
 	EXPECT_PASS $NM -f posix $TST_DATAROOT/f1 \> nm_posix.out
 
-	ROD awk '{print $3 $2 $1}' nm_bsd.out \> nm1.out
-	ROD awk '{print $1 $2 $3}' nm_posix.out \> nm2.out
+	ROD awk '{print gensub(/\y(0+)([0-9a-fA-F]+)\y/, "\\2", "g")}' nm_bsd.out \> trimmed_nm_bsd.out
+	ROD awk '{print gensub(/\y(0+)([0-9a-fA-F]+)\y/, "\\2", "g")}' nm_posix.out \> trimmed_nm_posix.out
+
+	ROD awk '{print $3 $2 $1}' trimmed_nm_bsd.out \> nm1.out
+	ROD awk '{print $1 $2 $3}' trimmed_nm_posix.out \> nm2.out
 
 	if diff nm1.out nm2.out > /dev/null; then
 		tst_res TPASS "Got BSD format with -f bsd"