gprof: Update PR gprof/32764 test

Message ID CAMe9rOpfu1PZpWfTODWwAOjW7g=H=m4DauxxbJ5cv7CfJkWbgA@mail.gmail.com
State New
Headers
Series gprof: Update PR gprof/32764 test |

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 7, 2025, 6:04 a.m. UTC
  On Fri, Mar 7, 2025 at 9:10 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Mar 7, 2025 at 7:58 AM Alan Modra <amodra@gmail.com> wrote:
> >
> > On Fri, Mar 07, 2025 at 07:00:41AM +0800, H.J. Lu wrote:
> > > Copy a simple gprof test from glibc to test the basic gprof functionality.
> >
> > Good idea.  OK if you have tested this natively and for a cross target
> > with and without cross-compiler installed.
>
> Here is the v2 patch I am checking in:
>
> 1. Tested natively on Linux/x86-64 and Linux/i686.
> 2. Tested for the x86_64-solaris cross target without cross-compiler.
> 3. Tested for the aarch64-linux-gnu cross target with cross-compiler.
>
> --
> H.J.

1. Remove gmon.out first before generating it in the configure check.
2. Make tst-gmon-gprof.out depend on the gprof binary.
3. Check that gmon.out is non-empty.
4. Don't include <sys/cdefs.h> in tst-gmon.c.

PR gprof/32764
* configure.ac: Remove gmon.out first.
* configure: Regenerated.
* testsuite/Makefile.am (tst-gmon-gprof.out): Depend on
$(GPROF).
* testsuite/Makefile.in: Regenerated.
* testsuite/tst-gmon-gprof.sh: Check that gmon.out is non-empty.
* testsuite/tst-gmon.c: Don't include <sys/cdefs.h>.
  

Comments

H.J. Lu March 7, 2025, 7:05 a.m. UTC | #1
On Fri, Mar 7, 2025 at 2:04 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Mar 7, 2025 at 9:10 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Fri, Mar 7, 2025 at 7:58 AM Alan Modra <amodra@gmail.com> wrote:
> > >
> > > On Fri, Mar 07, 2025 at 07:00:41AM +0800, H.J. Lu wrote:
> > > > Copy a simple gprof test from glibc to test the basic gprof functionality.
> > >
> > > Good idea.  OK if you have tested this natively and for a cross target
> > > with and without cross-compiler installed.
> >
> > Here is the v2 patch I am checking in:
> >
> > 1. Tested natively on Linux/x86-64 and Linux/i686.
> > 2. Tested for the x86_64-solaris cross target without cross-compiler.
> > 3. Tested for the aarch64-linux-gnu cross target with cross-compiler.
> >
> > --
> > H.J.
>
> 1. Remove gmon.out first before generating it in the configure check.
> 2. Make tst-gmon-gprof.out depend on the gprof binary.
> 3. Check that gmon.out is non-empty.
> 4. Don't include <sys/cdefs.h> in tst-gmon.c.
>
> PR gprof/32764
> * configure.ac: Remove gmon.out first.
> * configure: Regenerated.
> * testsuite/Makefile.am (tst-gmon-gprof.out): Depend on
> $(GPROF).
> * testsuite/Makefile.in: Regenerated.
> * testsuite/tst-gmon-gprof.sh: Check that gmon.out is non-empty.
> * testsuite/tst-gmon.c: Don't include <sys/cdefs.h>.
>
> --
> H.J.

I am checking in this.
  

Patch

From 25933befc307cc985f49ae84e14f09bb191d0513 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 7 Mar 2025 13:55:06 +0800
Subject: [PATCH] gprof: Update PR gprof/32764 test

1. Remove gmon.out first before generating it in the configure check.
2. Make tst-gmon-gprof.out depend on the gprof binary.
3. Check that gmon.out is non-empty.
4. Don't include <sys/cdefs.h> in tst-gmon.c.

	PR gprof/32764
	* configure.ac: Remove gmon.out first.
	* configure: Regenerated.
	* testsuite/Makefile.am (tst-gmon-gprof.out): Depend on
	$(GPROF).
	* testsuite/Makefile.in: Regenerated.
	* testsuite/tst-gmon-gprof.sh: Check that gmon.out is non-empty.
	* testsuite/tst-gmon.c: Don't include <sys/cdefs.h>.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 gprof/configure                   | 1 +
 gprof/configure.ac                | 1 +
 gprof/testsuite/Makefile.am       | 2 +-
 gprof/testsuite/Makefile.in       | 2 +-
 gprof/testsuite/tst-gmon-gprof.sh | 2 +-
 gprof/testsuite/tst-gmon.c        | 2 --
 6 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gprof/configure b/gprof/configure
index ad2033c802a..b830da03289 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -13973,6 +13973,7 @@  else
     gprof_cv_sys_native=no
   if test x"${host}" = x"${target}" \
      && ${CC-cc} -O2 -pg -o tst-gmon $srcdir/testsuite/tst-gmon.c; then
+    rm -f gmon.out
     ./tst-gmon
     if test -s gmon.out; then
       gprof_cv_sys_native=yes
diff --git a/gprof/configure.ac b/gprof/configure.ac
index 37eff97b2c2..f74da7d309a 100644
--- a/gprof/configure.ac
+++ b/gprof/configure.ac
@@ -78,6 +78,7 @@  AC_CACHE_CHECK([whether gprof tests can run],
   gprof_cv_sys_native=no
   if test x"${host}" = x"${target}" \
      && ${CC-cc} -O2 -pg -o tst-gmon $srcdir/testsuite/tst-gmon.c; then
+    rm -f gmon.out
     ./tst-gmon
     if test -s gmon.out; then
       gprof_cv_sys_native=yes
diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am
index 17ee148df5b..7cc95e33f1b 100644
--- a/gprof/testsuite/Makefile.am
+++ b/gprof/testsuite/Makefile.am
@@ -32,7 +32,7 @@  tst-gmon.$(OBJEXT): tst-gmon.c
 	$(COMPILE) -c -o $@ $<
 tst-gmon: tst-gmon.$(OBJEXT)
 	$(LINK) tst-gmon.$(OBJEXT)
-tst-gmon-gprof.out: tst-gmon$(EXEEXT)
+tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
 	$(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
 
 endif NATIVE
diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in
index 87ce1dcf886..91d2854c438 100644
--- a/gprof/testsuite/Makefile.in
+++ b/gprof/testsuite/Makefile.in
@@ -875,7 +875,7 @@  uninstall-am:
 @NATIVE_TRUE@	$(COMPILE) -c -o $@ $<
 @NATIVE_TRUE@tst-gmon: tst-gmon.$(OBJEXT)
 @NATIVE_TRUE@	$(LINK) tst-gmon.$(OBJEXT)
-@NATIVE_TRUE@tst-gmon-gprof.out: tst-gmon$(EXEEXT)
+@NATIVE_TRUE@tst-gmon-gprof.out: tst-gmon$(EXEEXT) $(GPROF)
 @NATIVE_TRUE@	$(srcdir)/tst-gmon-gprof.sh $(GPROF) tst-gmon$(EXEEXT)
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/gprof/testsuite/tst-gmon-gprof.sh b/gprof/testsuite/tst-gmon-gprof.sh
index 562d4806e96..deaa8028374 100755
--- a/gprof/testsuite/tst-gmon-gprof.sh
+++ b/gprof/testsuite/tst-gmon-gprof.sh
@@ -28,7 +28,7 @@  program="$2"
 data=gmon.out
 rm -f $data
 ./$program
-if test ! -f $data; then
+if test ! -s $data; then
     echo "FAIL"
     exit 1
 fi
diff --git a/gprof/testsuite/tst-gmon.c b/gprof/testsuite/tst-gmon.c
index add2d9253c2..917f5e64af4 100644
--- a/gprof/testsuite/tst-gmon.c
+++ b/gprof/testsuite/tst-gmon.c
@@ -16,8 +16,6 @@ 
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sys/cdefs.h>
-
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-- 
2.48.1