diff mbox series

nm01: fix regex matching internal symbols

Message ID 797dd5eeadd81fae30635dd66d0a715cc213c51e.1588942651.git.jstancek@redhat.com
State Accepted
Headers show
Series nm01: fix regex matching internal symbols | expand

Commit Message

Jan Stancek May 8, 2020, 12:58 p.m. UTC
Current regex matches any word character followed by space
and one of letters "abdft". So it doesn't match only symbol type,
but can match for example value and size:
  $ grep "\w [a,b,d,f,t]" nm.out
  __libc_csu_init T 10000640 b4
                   matches ^ ^

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/commands/nm/nm01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel May 10, 2020, 8:21 a.m. UTC | #1
> Current regex matches any word character followed by space
> and one of letters "abdft". So it doesn't match only symbol type,
> but can match for example value and size:
>   $ grep "\w [a,b,d,f,t]" nm.out
>   __libc_csu_init T 10000640 b4
>                    matches ^ ^

> Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Good catch, Jan.

Kind regards,
Petr
Li Wang May 11, 2020, 6:33 a.m. UTC | #2
On Sun, May 10, 2020 at 4:22 PM Petr Vorel <pvorel@suse.cz> wrote:

> > Current regex matches any word character followed by space
> > and one of letters "abdft". So it doesn't match only symbol type,
> > but can match for example value and size:
> >   $ grep "\w [a,b,d,f,t]" nm.out
> >   __libc_csu_init T 10000640 b4
> >                    matches ^ ^
>
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Good catch, Jan.
>

Tested and pushed.
diff mbox series

Patch

diff --git a/testcases/commands/nm/nm01.sh b/testcases/commands/nm/nm01.sh
index fd9d3d92262f..873126d20945 100755
--- a/testcases/commands/nm/nm01.sh
+++ b/testcases/commands/nm/nm01.sh
@@ -47,7 +47,7 @@  test2()
 {
 	EXPECT_PASS $NM -f posix -g $TST_DATAROOT/f1 \> nm.out
 
-	if grep -q "\w [a,b,d,f,t]" nm.out; then
+	if grep -q "^[^ ]\+ [abdft]" nm.out; then
 		tst_res TFAIL "Got internal symbols with -g"
 		cat nm.out
 	else