gprof: Add a simple test for gprof -l

Message ID 20250309153452.1326128-1-hjl.tools@gmail.com
State New
Headers
Series gprof: Add a simple test for gprof -l |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

H.J. Lu March 9, 2025, 3:34 p.m. UTC
  Verify that "gprof -l" works properly.

	* testsuite/Makefile.am (check_SCRIPTS): Add tst-gmon-gprof-l.sh.
	* testsuite/Makefile.in: Regenerated.
	* testsuite/tst-gmon-gprof-l.sh: New.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 gprof/testsuite/Makefile.am         |  5 ++
 gprof/testsuite/Makefile.in         | 13 ++++-
 gprof/testsuite/tst-gmon-gprof-l.sh | 74 +++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 2 deletions(-)
 create mode 100755 gprof/testsuite/tst-gmon-gprof-l.sh
  

Comments

Sam James March 10, 2025, 12:08 a.m. UTC | #1
"H.J. Lu" <hjl.tools@gmail.com> writes:

> Verify that "gprof -l" works properly.
>
> 	* testsuite/Makefile.am (check_SCRIPTS): Add tst-gmon-gprof-l.sh.
> 	* testsuite/Makefile.in: Regenerated.
> 	* testsuite/tst-gmon-gprof-l.sh: New.
>

It looks good.

> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  gprof/testsuite/Makefile.am         |  5 ++
>  gprof/testsuite/Makefile.in         | 13 ++++-
>  gprof/testsuite/tst-gmon-gprof-l.sh | 74 +++++++++++++++++++++++++++++
>  3 files changed, 90 insertions(+), 2 deletions(-)
>  create mode 100755 gprof/testsuite/tst-gmon-gprof-l.sh
>
> diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am
> index 6a3eb726294..c4d6c41fcf4 100644
> --- a/gprof/testsuite/Makefile.am
> +++ b/gprof/testsuite/Makefile.am
> @@ -35,4 +35,9 @@ tst-gmon: tst-gmon.$(OBJEXT)
>  tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
>  	$(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
>  
> +check_SCRIPTS += tst-gmon-gprof-l.sh
> +check_DATA += tst-gmon-gprof-l.out
> +tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
> +	$(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
> +
>  endif NATIVE
> diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in
> index 3e26c2c952c..008f6be879e 100644
> --- a/gprof/testsuite/Makefile.in
> +++ b/gprof/testsuite/Makefile.in
> @@ -90,8 +90,8 @@ POST_UNINSTALL = :
>  build_triplet = @build@
>  host_triplet = @host@
>  target_triplet = @target@
> -@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh
> -@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out
> +@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh tst-gmon-gprof-l.sh
> +@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out tst-gmon-gprof-l.out
>  @NATIVE_TRUE@am__append_3 = tst-gmon.$(OBJEXT) tst-gmon$(EXEEXT) gmon.out
>  subdir = testsuite
>  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
> @@ -705,6 +705,13 @@ tst-gmon-gprof.sh.log: tst-gmon-gprof.sh
>  	--log-file $$b.log --trs-file $$b.trs \
>  	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
>  	"$$tst" $(AM_TESTS_FD_REDIRECT)
> +tst-gmon-gprof-l.sh.log: tst-gmon-gprof-l.sh
> +	@p='tst-gmon-gprof-l.sh'; \
> +	b='tst-gmon-gprof-l.sh'; \
> +	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
> +	--log-file $$b.log --trs-file $$b.trs \
> +	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
> +	"$$tst" $(AM_TESTS_FD_REDIRECT)
>  .test.log:
>  	@p='$<'; \
>  	$(am__set_b); \
> @@ -879,6 +886,8 @@ uninstall-am:
>  @NATIVE_TRUE@	$(LINK) tst-gmon.$(OBJEXT)
>  @NATIVE_TRUE@tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
>  @NATIVE_TRUE@	$(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
> +@NATIVE_TRUE@tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
> +@NATIVE_TRUE@	$(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
>  
>  # Tell versions [3.59,3.63) of GNU make to not export all variables.
>  # Otherwise a system limit (for SysV at least) may be exceeded.
> diff --git a/gprof/testsuite/tst-gmon-gprof-l.sh b/gprof/testsuite/tst-gmon-gprof-l.sh
> new file mode 100755
> index 00000000000..3e54da6b4f7
> --- /dev/null
> +++ b/gprof/testsuite/tst-gmon-gprof-l.sh
> @@ -0,0 +1,74 @@
> +#!/bin/sh
> +# Check the output of gprof against a carfully crafted binary.
> +# Copyright (C) 2017-2025 Free Software Foundation, Inc.
> +# This file is part of the GNU C Library.
> +
> +# The GNU C Library is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU Lesser General Public
> +# License as published by the Free Software Foundation; either
> +# version 2.1 of the License, or (at your option) any later version.
> +
> +# The GNU C Library is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +# Lesser General Public License for more details.
> +
> +# You should have received a copy of the GNU Lesser General Public
> +# License along with the GNU C Library; if not, see
> +# <https://www.gnu.org/licenses/>.
> +
> +GPROF="$1"
> +if test -z "$GPROF"; then
> +  # Exit 0 for automake test script run.
> +  exit 0

I think we may want 'exit 77' here to SKIP.

> +fi
> +
> +program="$2"
> +# Generate gmon.out
> +data=gmon.out
> +rm -f $data
> +./$program
> +if test ! -s $data; then
> +    echo "FAIL"
> +    exit 1
> +fi
> +
> +LC_ALL=C
> +export LC_ALL
> +set -e
> +exec 2>&1
> +
> +actual=${program}.actual
> +expected=${program}.expected
> +expected_dot=${program}.expected_dot
> +cleanup () {
> +    rm -f "$actual"
> +    rm -f "$expected"
> +    rm -f "$expected_dot"
> +}
> +trap cleanup 0
> +
> +cat > "$expected" <<EOF
> +25 f1 2000
> +31 f2 1000
> +40 f3 1
> +EOF
> +
> +# Special version for powerpc with function descriptors.
> +cat > "$expected_dot" <<EOF
> +25 .f1 2000
> +31 .f2 1000
> +40 .f3 1
> +EOF
> +
> +"$GPROF" -l -C "$program" "$data" \
> +    | awk -F  '[(): ]' '/executions/{print $2, $5, $8}' \
> +    | sort > "$actual"
> +
> +if cmp -s "$actual" "$expected_dot" \
> +   || diff -u --label expected "$expected" --label actual "$actual" ; then
> +    echo "PASS"
> +else
> +    echo "FAIL"
> +    exit 1
> +fi
  
H.J. Lu March 10, 2025, 4:01 a.m. UTC | #2
On Sun, Mar 9, 2025 at 5:08 PM Sam James <sam@gentoo.org> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > Verify that "gprof -l" works properly.
> >
> >       * testsuite/Makefile.am (check_SCRIPTS): Add tst-gmon-gprof-l.sh.
> >       * testsuite/Makefile.in: Regenerated.
> >       * testsuite/tst-gmon-gprof-l.sh: New.
> >
>
> It looks good.
>
> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > ---
> >  gprof/testsuite/Makefile.am         |  5 ++
> >  gprof/testsuite/Makefile.in         | 13 ++++-
> >  gprof/testsuite/tst-gmon-gprof-l.sh | 74 +++++++++++++++++++++++++++++
> >  3 files changed, 90 insertions(+), 2 deletions(-)
> >  create mode 100755 gprof/testsuite/tst-gmon-gprof-l.sh
> >
> > diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am
> > index 6a3eb726294..c4d6c41fcf4 100644
> > --- a/gprof/testsuite/Makefile.am
> > +++ b/gprof/testsuite/Makefile.am
> > @@ -35,4 +35,9 @@ tst-gmon: tst-gmon.$(OBJEXT)
> >  tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
> >       $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
> >
> > +check_SCRIPTS += tst-gmon-gprof-l.sh
> > +check_DATA += tst-gmon-gprof-l.out
> > +tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
> > +     $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
> > +
> >  endif NATIVE
> > diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in
> > index 3e26c2c952c..008f6be879e 100644
> > --- a/gprof/testsuite/Makefile.in
> > +++ b/gprof/testsuite/Makefile.in
> > @@ -90,8 +90,8 @@ POST_UNINSTALL = :
> >  build_triplet = @build@
> >  host_triplet = @host@
> >  target_triplet = @target@
> > -@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh
> > -@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out
> > +@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh tst-gmon-gprof-l.sh
> > +@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out tst-gmon-gprof-l.out
> >  @NATIVE_TRUE@am__append_3 = tst-gmon.$(OBJEXT) tst-gmon$(EXEEXT) gmon.out
> >  subdir = testsuite
> >  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
> > @@ -705,6 +705,13 @@ tst-gmon-gprof.sh.log: tst-gmon-gprof.sh
> >       --log-file $$b.log --trs-file $$b.trs \
> >       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
> >       "$$tst" $(AM_TESTS_FD_REDIRECT)
> > +tst-gmon-gprof-l.sh.log: tst-gmon-gprof-l.sh
> > +     @p='tst-gmon-gprof-l.sh'; \
> > +     b='tst-gmon-gprof-l.sh'; \
> > +     $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
> > +     --log-file $$b.log --trs-file $$b.trs \
> > +     $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
> > +     "$$tst" $(AM_TESTS_FD_REDIRECT)
> >  .test.log:
> >       @p='$<'; \
> >       $(am__set_b); \
> > @@ -879,6 +886,8 @@ uninstall-am:
> >  @NATIVE_TRUE@        $(LINK) tst-gmon.$(OBJEXT)
> >  @NATIVE_TRUE@tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
> >  @NATIVE_TRUE@        $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
> > +@NATIVE_TRUE@tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
> > +@NATIVE_TRUE@        $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
> >
> >  # Tell versions [3.59,3.63) of GNU make to not export all variables.
> >  # Otherwise a system limit (for SysV at least) may be exceeded.
> > diff --git a/gprof/testsuite/tst-gmon-gprof-l.sh b/gprof/testsuite/tst-gmon-gprof-l.sh
> > new file mode 100755
> > index 00000000000..3e54da6b4f7
> > --- /dev/null
> > +++ b/gprof/testsuite/tst-gmon-gprof-l.sh
> > @@ -0,0 +1,74 @@
> > +#!/bin/sh
> > +# Check the output of gprof against a carfully crafted binary.
> > +# Copyright (C) 2017-2025 Free Software Foundation, Inc.
> > +# This file is part of the GNU C Library.
> > +
> > +# The GNU C Library is free software; you can redistribute it and/or
> > +# modify it under the terms of the GNU Lesser General Public
> > +# License as published by the Free Software Foundation; either
> > +# version 2.1 of the License, or (at your option) any later version.
> > +
> > +# The GNU C Library is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +# Lesser General Public License for more details.
> > +
> > +# You should have received a copy of the GNU Lesser General Public
> > +# License along with the GNU C Library; if not, see
> > +# <https://www.gnu.org/licenses/>.
> > +
> > +GPROF="$1"
> > +if test -z "$GPROF"; then
> > +  # Exit 0 for automake test script run.
> > +  exit 0
>
> I think we may want 'exit 77' here to SKIP.

Since automake always runs tst-gmon-gprof-l.sh without
any arguments, I used "exit 0" to avoid any confusion.

> > +fi
> > +
> > +program="$2"
> > +# Generate gmon.out
> > +data=gmon.out
> > +rm -f $data
> > +./$program
> > +if test ! -s $data; then
> > +    echo "FAIL"
> > +    exit 1
> > +fi
> > +
> > +LC_ALL=C
> > +export LC_ALL
> > +set -e
> > +exec 2>&1
> > +
> > +actual=${program}.actual
> > +expected=${program}.expected
> > +expected_dot=${program}.expected_dot
> > +cleanup () {
> > +    rm -f "$actual"
> > +    rm -f "$expected"
> > +    rm -f "$expected_dot"
> > +}
> > +trap cleanup 0
> > +
> > +cat > "$expected" <<EOF
> > +25 f1 2000
> > +31 f2 1000
> > +40 f3 1
> > +EOF
> > +
> > +# Special version for powerpc with function descriptors.
> > +cat > "$expected_dot" <<EOF
> > +25 .f1 2000
> > +31 .f2 1000
> > +40 .f3 1
> > +EOF
> > +
> > +"$GPROF" -l -C "$program" "$data" \
> > +    | awk -F  '[(): ]' '/executions/{print $2, $5, $8}' \
> > +    | sort > "$actual"
> > +
> > +if cmp -s "$actual" "$expected_dot" \
> > +   || diff -u --label expected "$expected" --label actual "$actual" ; then
> > +    echo "PASS"
> > +else
> > +    echo "FAIL"
> > +    exit 1
> > +fi
  
Sam James March 10, 2025, 4:16 a.m. UTC | #3
"H.J. Lu" <hjl.tools@gmail.com> writes:

> On Sun, Mar 9, 2025 at 5:08 PM Sam James <sam@gentoo.org> wrote:
>>
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>> > Verify that "gprof -l" works properly.
>> >
>> >       * testsuite/Makefile.am (check_SCRIPTS): Add tst-gmon-gprof-l.sh.
>> >       * testsuite/Makefile.in: Regenerated.
>> >       * testsuite/tst-gmon-gprof-l.sh: New.
>> >
>>
>> It looks good.
>>
>> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
>> > ---
>> >  gprof/testsuite/Makefile.am         |  5 ++
>> >  gprof/testsuite/Makefile.in         | 13 ++++-
>> >  gprof/testsuite/tst-gmon-gprof-l.sh | 74 +++++++++++++++++++++++++++++
>> >  3 files changed, 90 insertions(+), 2 deletions(-)
>> >  create mode 100755 gprof/testsuite/tst-gmon-gprof-l.sh
>> >
>> > diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am
>> > index 6a3eb726294..c4d6c41fcf4 100644
>> > --- a/gprof/testsuite/Makefile.am
>> > +++ b/gprof/testsuite/Makefile.am
>> > @@ -35,4 +35,9 @@ tst-gmon: tst-gmon.$(OBJEXT)
>> >  tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
>> >       $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
>> >
>> > +check_SCRIPTS += tst-gmon-gprof-l.sh
>> > +check_DATA += tst-gmon-gprof-l.out
>> > +tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
>> > +     $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
>> > +
>> >  endif NATIVE
>> > diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in
>> > index 3e26c2c952c..008f6be879e 100644
>> > --- a/gprof/testsuite/Makefile.in
>> > +++ b/gprof/testsuite/Makefile.in
>> > @@ -90,8 +90,8 @@ POST_UNINSTALL = :
>> >  build_triplet = @build@
>> >  host_triplet = @host@
>> >  target_triplet = @target@
>> > -@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh
>> > -@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out
>> > +@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh tst-gmon-gprof-l.sh
>> > +@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out tst-gmon-gprof-l.out
>> >  @NATIVE_TRUE@am__append_3 = tst-gmon.$(OBJEXT) tst-gmon$(EXEEXT) gmon.out
>> >  subdir = testsuite
>> >  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
>> > @@ -705,6 +705,13 @@ tst-gmon-gprof.sh.log: tst-gmon-gprof.sh
>> >       --log-file $$b.log --trs-file $$b.trs \
>> >       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
>> >       "$$tst" $(AM_TESTS_FD_REDIRECT)
>> > +tst-gmon-gprof-l.sh.log: tst-gmon-gprof-l.sh
>> > +     @p='tst-gmon-gprof-l.sh'; \
>> > +     b='tst-gmon-gprof-l.sh'; \
>> > +     $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
>> > +     --log-file $$b.log --trs-file $$b.trs \
>> > +     $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
>> > +     "$$tst" $(AM_TESTS_FD_REDIRECT)
>> >  .test.log:
>> >       @p='$<'; \
>> >       $(am__set_b); \
>> > @@ -879,6 +886,8 @@ uninstall-am:
>> >  @NATIVE_TRUE@        $(LINK) tst-gmon.$(OBJEXT)
>> >  @NATIVE_TRUE@tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
>> >  @NATIVE_TRUE@        $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
>> > +@NATIVE_TRUE@tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
>> > +@NATIVE_TRUE@        $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
>> >
>> >  # Tell versions [3.59,3.63) of GNU make to not export all variables.
>> >  # Otherwise a system limit (for SysV at least) may be exceeded.
>> > diff --git a/gprof/testsuite/tst-gmon-gprof-l.sh b/gprof/testsuite/tst-gmon-gprof-l.sh
>> > new file mode 100755
>> > index 00000000000..3e54da6b4f7
>> > --- /dev/null
>> > +++ b/gprof/testsuite/tst-gmon-gprof-l.sh
>> > @@ -0,0 +1,74 @@
>> > +#!/bin/sh
>> > +# Check the output of gprof against a carfully crafted binary.
>> > +# Copyright (C) 2017-2025 Free Software Foundation, Inc.
>> > +# This file is part of the GNU C Library.
>> > +
>> > +# The GNU C Library is free software; you can redistribute it and/or
>> > +# modify it under the terms of the GNU Lesser General Public
>> > +# License as published by the Free Software Foundation; either
>> > +# version 2.1 of the License, or (at your option) any later version.
>> > +
>> > +# The GNU C Library is distributed in the hope that it will be useful,
>> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> > +# Lesser General Public License for more details.
>> > +
>> > +# You should have received a copy of the GNU Lesser General Public
>> > +# License along with the GNU C Library; if not, see
>> > +# <https://www.gnu.org/licenses/>.
>> > +
>> > +GPROF="$1"
>> > +if test -z "$GPROF"; then
>> > +  # Exit 0 for automake test script run.
>> > +  exit 0
>>
>> I think we may want 'exit 77' here to SKIP.
>
> Since automake always runs tst-gmon-gprof-l.sh without
> any arguments, I used "exit 0" to avoid any confusion.

Oh, I see. Thanks.
  
H.J. Lu March 10, 2025, 1:40 p.m. UTC | #4
On Sun, Mar 9, 2025 at 9:16 PM Sam James <sam@gentoo.org> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > On Sun, Mar 9, 2025 at 5:08 PM Sam James <sam@gentoo.org> wrote:
> >>
> >> "H.J. Lu" <hjl.tools@gmail.com> writes:
> >>
> >> > Verify that "gprof -l" works properly.
> >> >
> >> >       * testsuite/Makefile.am (check_SCRIPTS): Add tst-gmon-gprof-l.sh.
> >> >       * testsuite/Makefile.in: Regenerated.
> >> >       * testsuite/tst-gmon-gprof-l.sh: New.
> >> >
> >>
> >> It looks good.
> >>
> >> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> >> > ---
> >> >  gprof/testsuite/Makefile.am         |  5 ++
> >> >  gprof/testsuite/Makefile.in         | 13 ++++-
> >> >  gprof/testsuite/tst-gmon-gprof-l.sh | 74 +++++++++++++++++++++++++++++
> >> >  3 files changed, 90 insertions(+), 2 deletions(-)
> >> >  create mode 100755 gprof/testsuite/tst-gmon-gprof-l.sh
> >> >
> >> > diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am
> >> > index 6a3eb726294..c4d6c41fcf4 100644
> >> > --- a/gprof/testsuite/Makefile.am
> >> > +++ b/gprof/testsuite/Makefile.am
> >> > @@ -35,4 +35,9 @@ tst-gmon: tst-gmon.$(OBJEXT)
> >> >  tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
> >> >       $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
> >> >
> >> > +check_SCRIPTS += tst-gmon-gprof-l.sh
> >> > +check_DATA += tst-gmon-gprof-l.out
> >> > +tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
> >> > +     $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
> >> > +
> >> >  endif NATIVE
> >> > diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in
> >> > index 3e26c2c952c..008f6be879e 100644
> >> > --- a/gprof/testsuite/Makefile.in
> >> > +++ b/gprof/testsuite/Makefile.in
> >> > @@ -90,8 +90,8 @@ POST_UNINSTALL = :
> >> >  build_triplet = @build@
> >> >  host_triplet = @host@
> >> >  target_triplet = @target@
> >> > -@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh
> >> > -@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out
> >> > +@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh tst-gmon-gprof-l.sh
> >> > +@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out tst-gmon-gprof-l.out
> >> >  @NATIVE_TRUE@am__append_3 = tst-gmon.$(OBJEXT) tst-gmon$(EXEEXT) gmon.out
> >> >  subdir = testsuite
> >> >  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
> >> > @@ -705,6 +705,13 @@ tst-gmon-gprof.sh.log: tst-gmon-gprof.sh
> >> >       --log-file $$b.log --trs-file $$b.trs \
> >> >       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
> >> >       "$$tst" $(AM_TESTS_FD_REDIRECT)
> >> > +tst-gmon-gprof-l.sh.log: tst-gmon-gprof-l.sh
> >> > +     @p='tst-gmon-gprof-l.sh'; \
> >> > +     b='tst-gmon-gprof-l.sh'; \
> >> > +     $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
> >> > +     --log-file $$b.log --trs-file $$b.trs \
> >> > +     $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
> >> > +     "$$tst" $(AM_TESTS_FD_REDIRECT)
> >> >  .test.log:
> >> >       @p='$<'; \
> >> >       $(am__set_b); \
> >> > @@ -879,6 +886,8 @@ uninstall-am:
> >> >  @NATIVE_TRUE@        $(LINK) tst-gmon.$(OBJEXT)
> >> >  @NATIVE_TRUE@tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
> >> >  @NATIVE_TRUE@        $(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
> >> > +@NATIVE_TRUE@tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
> >> > +@NATIVE_TRUE@        $(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
> >> >
> >> >  # Tell versions [3.59,3.63) of GNU make to not export all variables.
> >> >  # Otherwise a system limit (for SysV at least) may be exceeded.
> >> > diff --git a/gprof/testsuite/tst-gmon-gprof-l.sh b/gprof/testsuite/tst-gmon-gprof-l.sh
> >> > new file mode 100755
> >> > index 00000000000..3e54da6b4f7
> >> > --- /dev/null
> >> > +++ b/gprof/testsuite/tst-gmon-gprof-l.sh
> >> > @@ -0,0 +1,74 @@
> >> > +#!/bin/sh
> >> > +# Check the output of gprof against a carfully crafted binary.
> >> > +# Copyright (C) 2017-2025 Free Software Foundation, Inc.
> >> > +# This file is part of the GNU C Library.
> >> > +
> >> > +# The GNU C Library is free software; you can redistribute it and/or
> >> > +# modify it under the terms of the GNU Lesser General Public
> >> > +# License as published by the Free Software Foundation; either
> >> > +# version 2.1 of the License, or (at your option) any later version.
> >> > +
> >> > +# The GNU C Library is distributed in the hope that it will be useful,
> >> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >> > +# Lesser General Public License for more details.
> >> > +
> >> > +# You should have received a copy of the GNU Lesser General Public
> >> > +# License along with the GNU C Library; if not, see
> >> > +# <https://www.gnu.org/licenses/>.
> >> > +
> >> > +GPROF="$1"
> >> > +if test -z "$GPROF"; then
> >> > +  # Exit 0 for automake test script run.
> >> > +  exit 0
> >>
> >> I think we may want 'exit 77' here to SKIP.
> >
> > Since automake always runs tst-gmon-gprof-l.sh without
> > any arguments, I used "exit 0" to avoid any confusion.
>
> Oh, I see. Thanks.

I am checking it in.
  

Patch

diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am
index 6a3eb726294..c4d6c41fcf4 100644
--- a/gprof/testsuite/Makefile.am
+++ b/gprof/testsuite/Makefile.am
@@ -35,4 +35,9 @@  tst-gmon: tst-gmon.$(OBJEXT)
 tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
 	$(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
 
+check_SCRIPTS += tst-gmon-gprof-l.sh
+check_DATA += tst-gmon-gprof-l.out
+tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
+	$(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
+
 endif NATIVE
diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in
index 3e26c2c952c..008f6be879e 100644
--- a/gprof/testsuite/Makefile.in
+++ b/gprof/testsuite/Makefile.in
@@ -90,8 +90,8 @@  POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh
-@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out
+@NATIVE_TRUE@am__append_1 = tst-gmon-gprof.sh tst-gmon-gprof-l.sh
+@NATIVE_TRUE@am__append_2 = tst-gmon-gprof.out tst-gmon-gprof-l.out
 @NATIVE_TRUE@am__append_3 = tst-gmon.$(OBJEXT) tst-gmon$(EXEEXT) gmon.out
 subdir = testsuite
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -705,6 +705,13 @@  tst-gmon-gprof.sh.log: tst-gmon-gprof.sh
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+tst-gmon-gprof-l.sh.log: tst-gmon-gprof-l.sh
+	@p='tst-gmon-gprof-l.sh'; \
+	b='tst-gmon-gprof-l.sh'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 .test.log:
 	@p='$<'; \
 	$(am__set_b); \
@@ -879,6 +886,8 @@  uninstall-am:
 @NATIVE_TRUE@	$(LINK) tst-gmon.$(OBJEXT)
 @NATIVE_TRUE@tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
 @NATIVE_TRUE@	$(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
+@NATIVE_TRUE@tst-gmon-gprof-l.out: tst-gmon$(EXEEXT) $(GPROF)
+@NATIVE_TRUE@	$(srcdir)/tst-gmon-gprof-l.sh $(GPROF) tst-gmon$(EXEEXT)
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/gprof/testsuite/tst-gmon-gprof-l.sh b/gprof/testsuite/tst-gmon-gprof-l.sh
new file mode 100755
index 00000000000..3e54da6b4f7
--- /dev/null
+++ b/gprof/testsuite/tst-gmon-gprof-l.sh
@@ -0,0 +1,74 @@ 
+#!/bin/sh
+# Check the output of gprof against a carfully crafted binary.
+# Copyright (C) 2017-2025 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+GPROF="$1"
+if test -z "$GPROF"; then
+  # Exit 0 for automake test script run.
+  exit 0
+fi
+
+program="$2"
+# Generate gmon.out
+data=gmon.out
+rm -f $data
+./$program
+if test ! -s $data; then
+    echo "FAIL"
+    exit 1
+fi
+
+LC_ALL=C
+export LC_ALL
+set -e
+exec 2>&1
+
+actual=${program}.actual
+expected=${program}.expected
+expected_dot=${program}.expected_dot
+cleanup () {
+    rm -f "$actual"
+    rm -f "$expected"
+    rm -f "$expected_dot"
+}
+trap cleanup 0
+
+cat > "$expected" <<EOF
+25 f1 2000
+31 f2 1000
+40 f3 1
+EOF
+
+# Special version for powerpc with function descriptors.
+cat > "$expected_dot" <<EOF
+25 .f1 2000
+31 .f2 1000
+40 .f3 1
+EOF
+
+"$GPROF" -l -C "$program" "$data" \
+    | awk -F  '[(): ]' '/executions/{print $2, $5, $8}' \
+    | sort > "$actual"
+
+if cmp -s "$actual" "$expected_dot" \
+   || diff -u --label expected "$expected" --label actual "$actual" ; then
+    echo "PASS"
+else
+    echo "FAIL"
+    exit 1
+fi