From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2103) id B702B3858D1E; Sat, 8 Apr 2023 15:49:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B702B3858D1E Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Alcock To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] libctf, tests: do not assume host and target have identical field offsets X-Act-Checkin: binutils-gdb X-Git-Author: Nick Alcock X-Git-Refname: refs/heads/master X-Git-Oldrev: 2dd5ec24c8560a7aca27475b1698aa3f133c3eae X-Git-Newrev: 30a794e9f1db2de9099ed4c494d917d4e86de0fd Message-Id: <20230408154937.B702B3858D1E@sourceware.org> Date: Sat, 8 Apr 2023 15:49:37 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Apr 2023 15:49:37 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D30a794e9f1db= 2de9099ed4c494d917d4e86de0fd commit 30a794e9f1db2de9099ed4c494d917d4e86de0fd Author: Nick Alcock Date: Wed Apr 5 16:36:45 2023 +0100 libctf, tests: do not assume host and target have identical field offse= ts =20 The newly-introduced libctf-lookup unnamed-field-info test checks C compiler-observed field offsets against libctf-computed ones by #including the testcase in the lookup runner as well as generating CTF for it. This only works if the host, on which the lookup runner is compiled and executed, is the same architecture as the target, for which the CTF is generated: when crossing, the trick may fail. =20 So pass down an indication of whether this is a cross into the testsuite, and add a new no_cross flag to .lk files that is used to suppress test execution when a cross-compiler is being tested. =20 libctf/ * Makefile.am (check_DEJAGNU): Pass down TEST_CROSS. * Makefile.in: Regenerated. * testsuite/lib/ctf-lib.exp (run_lookup_test): Use it to implement the new no_cross option. * testsuite/libctf-lookup/unnamed-field-info.lk: Mark as no_cross. Diff: --- libctf/Makefile.am | 7 ++++++- libctf/Makefile.in | 7 ++++++- libctf/testsuite/lib/ctf-lib.exp | 12 +++++++++++- libctf/testsuite/libctf-lookup/unnamed-field-info.lk | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libctf/Makefile.am b/libctf/Makefile.am index c959b09e492..b1dbc2f6ba4 100644 --- a/libctf/Makefile.am +++ b/libctf/Makefile.am @@ -92,10 +92,15 @@ check-DEJAGNU: site.exp development.exp r=3D`pwd`; export r; \ LC_ALL=3DC; export LC_ALL; \ EXPECT=3D$(EXPECT); export EXPECT; \ + if [ "@host@" =3D "@target@" ] ; then \ + TEST_CROSS=3Dno; \ + else \ + TEST_CROSS=3Dyes; \ + fi; \ runtest=3D$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ - CC=3D"$(CC)" CC_FOR_TARGET=3D"$(CC_FOR_TARGET)" \ + CC=3D"$(CC)" CC_FOR_TARGET=3D"$(CC_FOR_TARGET)" TEST_CROSS=3D"$${TEST_CR= OSS}" \ CFLAGS=3D"$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/= ../bfd $(ZLIBINC)" \ LIBS=3D"$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ diff --git a/libctf/Makefile.in b/libctf/Makefile.in index c6cb55c9768..3d2696bcc47 100644 --- a/libctf/Makefile.in +++ b/libctf/Makefile.in @@ -1678,10 +1678,15 @@ check-DEJAGNU: site.exp development.exp r=3D`pwd`; export r; \ LC_ALL=3DC; export LC_ALL; \ EXPECT=3D$(EXPECT); export EXPECT; \ + if [ "@host@" =3D "@target@" ] ; then \ + TEST_CROSS=3Dno; \ + else \ + TEST_CROSS=3Dyes; \ + fi; \ runtest=3D$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ - CC=3D"$(CC)" CC_FOR_TARGET=3D"$(CC_FOR_TARGET)" \ + CC=3D"$(CC)" CC_FOR_TARGET=3D"$(CC_FOR_TARGET)" TEST_CROSS=3D"$${TEST_CR= OSS}" \ CFLAGS=3D"$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/= ../bfd $(ZLIBINC)" \ LIBS=3D"$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ diff --git a/libctf/testsuite/lib/ctf-lib.exp b/libctf/testsuite/lib/ctf-li= b.exp index 3ee82a00a33..73b67b45e34 100644 --- a/libctf/testsuite/lib/ctf-lib.exp +++ b/libctf/testsuite/lib/ctf-lib.exp @@ -103,6 +103,9 @@ proc compile_link_one_host_cc { src output additional_a= rgs } { # xfail: GLOB|PROC ... # This test is expected to fail on a specified list of targets. # +# no_cross: +# If set, do not run this test when host !=3D target. +# # Each option may occur at most once unless otherwise mentioned. # # After the option lines come regexp lines. run_lookup_test calls @@ -110,7 +113,7 @@ proc compile_link_one_host_cc { src output additional_a= rgs } { # regexps in FILE.d. # proc run_lookup_test { name } { - global CC_FOR_TARGET CFLAGS_FOR_TARGET LIBS + global CC_FOR_TARGET CFLAGS_FOR_TARGET LIBS TEST_CROSS global copyfile env runtests srcdir subdir verbose =20 if ![runtest_file_p $runtests $name] then { @@ -139,6 +142,7 @@ proc run_lookup_test { name } { set opts(name) {} set opts(source) {} set opts(xfail) {} + set opts(no_cross) {} =20 foreach i $opt_array { set opt_name [lindex $i 0] @@ -156,6 +160,12 @@ proc run_lookup_test { name } { set opts($opt_name) [concat $opts($opt_name) $opt_val] } =20 + if { [llength $opts(no_cross)] !=3D 0 + && "$TEST_CROSS" eq "yes" } { + untested "$subdir/$name not tested when cross-compiling" + return + } + if { [llength $opts(lookup)] =3D=3D 0 } { set opts(lookup) "$file.c" } else { diff --git a/libctf/testsuite/libctf-lookup/unnamed-field-info.lk b/libctf/= testsuite/libctf-lookup/unnamed-field-info.lk index eae6a517d50..680b8e0a4ca 100644 --- a/libctf/testsuite/libctf-lookup/unnamed-field-info.lk +++ b/libctf/testsuite/libctf-lookup/unnamed-field-info.lk @@ -1,2 +1,3 @@ # source: unnamed-field-info-ctf.c +# no_cross: yes Offset validation complete.