From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 42B2C3858D35 for ; Sat, 17 Jun 2023 19:57:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42B2C3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from csb.redhat.com (deer0x03.wildebeest.org [172.31.17.133]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id D80BD313ACAA; Sat, 17 Jun 2023 21:57:24 +0200 (CEST) Received: by csb.redhat.com (Postfix, from userid 10916) id AFAAEDD100; Sat, 17 Jun 2023 21:57:24 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [COMMITTED] tests: Split up run-strip-reloc.sh test in three subtests Date: Sat, 17 Jun 2023 21:57:08 +0200 Message-Id: <20230617195708.725042-1-mark@klomp.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3035.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This test can take a very long time under valgrind (on s390x). Split it into three tests for kernel modules, self-test and ppc64. That way the tests can run in parallel and each individual test produces a result (so the buildbot won't time out). Also change the comparison to elfcmp instead of doing readelf -a on both and compare the textual output. * tests/run-strip-reloc.sh: Split out generic part into... * tests/strip-reloc-subr.sh: ...this file. * tests/run-strip-reloc-ko.sh: New file. * tests/run-strip-reloc-ppc64.sh: New file. * tests/run-strip-reloc-self.sh: New file. * tests/Makefile.am (TESTS): Remove run-strip-reloc.sh. Add run-strip-reloc-ko.sh, run-strip-reloc-self.sh and run-strip-reloc-ppc64.sh (EXTRA_DIST): Remove run-strip-reloc.sh. Add strip-reloc-subr.sh, run-strip-reloc-ko.sh, run-strip-reloc-self.sh and run-strip-reloc-ppc64.sh. Signed-off-by: Mark Wielaard --- tests/Makefile.am | 8 +- tests/run-strip-reloc-ko.sh | 51 +++++++++++ tests/run-strip-reloc-ppc64.sh | 15 ++++ tests/run-strip-reloc-self.sh | 20 +++++ tests/run-strip-reloc.sh | 156 --------------------------------- tests/strip-reloc-subr.sh | 79 +++++++++++++++++ 6 files changed, 171 insertions(+), 158 deletions(-) create mode 100755 tests/run-strip-reloc-ko.sh create mode 100755 tests/run-strip-reloc-ppc64.sh create mode 100755 tests/run-strip-reloc-self.sh delete mode 100755 tests/run-strip-reloc.sh create mode 100755 tests/strip-reloc-subr.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index e60aa6bc..0c77f658 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -118,7 +118,9 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ run-strip-test9.sh run-strip-test10.sh run-strip-test11.sh \ run-strip-test12.sh \ run-strip-nothing.sh run-strip-g.sh run-annobingroup.sh \ - run-strip-groups.sh run-strip-reloc.sh run-strip-strmerge.sh \ + run-strip-groups.sh run-strip-strmerge.sh \ + run-strip-reloc-ko.sh run-strip-reloc-self.sh \ + run-strip-reloc-ppc64.sh \ run-strip-nobitsalign.sh run-strip-remove-keep.sh \ run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-test3.sh \ run-unstrip-test4.sh run-unstrip-M.sh run-elfstrmerge-test.sh \ @@ -304,7 +306,9 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ testfile-annobingroup-x86_64.o.bz2 \ run-strip-strmerge.sh run-strip-nobitsalign.sh \ testfile-nobitsalign.bz2 testfile-nobitsalign.strip.bz2 \ - run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \ + run-strip-reloc-ko.sh run-strip-reloc-self.sh \ + run-strip-reloc-ppc64.sh strip-reloc-subr.sh \ + hello_i386.ko.bz2 hello_x86_64.ko.bz2 \ hello_ppc64.ko.bz2 hello_s390.ko.bz2 hello_aarch64.ko.bz2 \ hello_m68k.ko.bz2 hello_riscv64.ko.bz2 hello_csky.ko.bz2 \ hello_arc_hs4.ko.bz2 \ diff --git a/tests/run-strip-reloc-ko.sh b/tests/run-strip-reloc-ko.sh new file mode 100755 index 00000000..55fa74db --- /dev/null +++ b/tests/run-strip-reloc-ko.sh @@ -0,0 +1,51 @@ +#! /bin/sh + +. $srcdir/strip-reloc-subr.sh + +testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko \ + hello_aarch64.ko hello_m68k.ko hello_riscv64.ko hello_csky.ko \ + hello_arc_hs4.ko + +# Most simple hello world kernel module for various architectures. +# Make sure that it contains debuginfo with CONFIG_DEBUG_INFO=y. +# :::::::::::::: +# Makefile +# :::::::::::::: +# obj-m := hello.o +# hello-y := init.o exit.o +# +# all: +# make -C /lib/modules/$(shell uname -r)/build M=$(PWD) \ +# CONFIG_DEBUG_INFO=y modules +# :::::::::::::: +# init.c +# :::::::::::::: +# #include +# #include +# +# int init_module(void) +# { +# printk(KERN_INFO "Hello, world!\n"); +# return 0; +# } +# :::::::::::::: +# exit.c +# :::::::::::::: +# #include +# #include +# +# void cleanup_module() +# { +# printk(KERN_INFO "Goodbye, World!\n"); +# } +runtest hello_i386.ko 1 +runtest hello_x86_64.ko 1 +runtest hello_ppc64.ko 1 +runtest hello_s390.ko 1 +runtest hello_aarch64.ko 1 +runtest hello_m68k.ko 1 +runtest hello_riscv64.ko 1 +runtest hello_csky.ko 1 +runtest hello_arc_hs4.ko 1 + +exit $runtest_status diff --git a/tests/run-strip-reloc-ppc64.sh b/tests/run-strip-reloc-ppc64.sh new file mode 100755 index 00000000..239c34d9 --- /dev/null +++ b/tests/run-strip-reloc-ppc64.sh @@ -0,0 +1,15 @@ +#! /bin/sh + +. $srcdir/strip-reloc-subr.sh + +# See run-readelf-zdebug-rel.sh +testfiles testfile-debug-rel-ppc64.o +runtest testfile-debug-rel-ppc64.o 1 + +testfiles testfile-debug-rel-ppc64-z.o +runtest testfile-debug-rel-ppc64-z.o 1 + +testfiles testfile-debug-rel-ppc64-g.o +runtest testfile-debug-rel-ppc64-g.o 1 + +exit $runtest_status diff --git a/tests/run-strip-reloc-self.sh b/tests/run-strip-reloc-self.sh new file mode 100755 index 00000000..68ed4cc2 --- /dev/null +++ b/tests/run-strip-reloc-self.sh @@ -0,0 +1,20 @@ +#! /bin/sh + +. $srcdir/strip-reloc-subr.sh + +# self test, shouldn't impact non-ET_REL files at all. +runtest ${abs_top_builddir}/src/strip 0 +runtest ${abs_top_builddir}/src/strip.o 1 + +# Copy ET_REL file for self-test and make sure to run with/without +# elf section compression. +tempfiles strip-uncompressed.o strip-compressed.o +testrun ${abs_top_builddir}/src/elfcompress -o strip-uncompressed.o -t none \ + ${abs_top_builddir}/src/strip.o +testrun ${abs_top_builddir}/src/elfcompress -o strip-compressed.o -t zlib \ + --force ${abs_top_builddir}/src/strip.o + +runtest strip-uncompressed.o 1 +runtest strip-compressed.o 1 + +exit $runtest_status diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh deleted file mode 100755 index 3b3585a6..00000000 --- a/tests/run-strip-reloc.sh +++ /dev/null @@ -1,156 +0,0 @@ -#! /bin/sh -# Copyright (C) 2011, 2013 Red Hat, Inc. -# This file is part of elfutils. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# elfutils 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. $srcdir/test-subr.sh - -if test -n "$ELFUTILS_MEMORY_SANITIZER"; then - echo "binaries linked with memory sanitizer are too big" - exit 77 -fi - -testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko \ - hello_aarch64.ko hello_m68k.ko hello_riscv64.ko hello_csky.ko \ - hello_arc_hs4.ko - -tempfiles readelf.out readelf.out1 readelf.out2 -tempfiles out.stripped1 out.debug1 out.stripped2 out.debug2 - -status=0 -runtest() { - infile=$1 - is_ET_REL=$2 - outfile1=out.stripped1 - debugfile1=out.debug1 - outfile2=out.stripped2 - debugfile2=out.debug2 - - echo "runtest $infile" - - rm -f $outfile1 $debugfile1 $outfile2 $debugfile2 - - testrun ${abs_top_builddir}/src/strip -o $outfile1 -f $debugfile1 $infile || - { echo "*** failure strip $infile"; status=1; } - - testrun ${abs_top_builddir}/src/strip --reloc-debug-sections -o $outfile2 \ - -f $debugfile2 $infile || - { echo "*** failure strip --reloc-debug-sections $infile"; status=1; } - - # shouldn't make any difference for stripped files. - testrun ${abs_top_builddir}/src/readelf -a $outfile1 > readelf.out || - { echo "*** failure readelf -a outfile1 $infile"; status=1; } - - testrun_compare ${abs_top_builddir}/src/readelf -a $outfile2 < readelf.out || - { echo "*** failure compare stripped files $infile"; status=1; } - - # debug files however should be smaller, when ET_REL. - SIZE1=$(stat -c%s $debugfile1) - SIZE2=$(stat -c%s $debugfile2) - test \( \( $is_ET_REL -eq 1 \) -a \( $SIZE1 -gt $SIZE2 \) \) \ - -o \( \( $is_ET_REL -eq 0 \) -a \( $SIZE1 -eq $SIZE2 \) \) || - { echo "*** failure --reloc-debug-sections not smaller $infile"; status=1; } - - # Strip of DWARF section lines, offset will not match. - # Everything else should match. - testrun ${abs_top_builddir}/src/readelf -N -w $debugfile1 \ - | grep -v ^DWARF\ section > readelf.out1 || - { echo "*** failure readelf -N -w debugfile1 $infile"; status=1; } - - testrun ${abs_top_builddir}/src/readelf -N -w $debugfile2 \ - | grep -v ^DWARF\ section > readelf.out2 || - { echo "*** failure readelf -N -w debugfile2 $infile"; status=1; } - - testrun_compare cat readelf.out1 < readelf.out2 || - { echo "*** failure readelf -N -w compare $infile"; status=1; } - - testrun ${abs_top_builddir}/src/strip --reloc-debug-sections-only \ - $debugfile1 || - { echo "*** failure strip --reloc-debug-sections-only $debugfile1"; \ - status=1; } - - cmp $debugfile1 $debugfile2 || - { echo "*** failure --reloc-debug-sections[-only] $debugfile1 $debugfile2"; \ - status=1; } -} - -# Most simple hello world kernel module for various architectures. -# Make sure that it contains debuginfo with CONFIG_DEBUG_INFO=y. -# :::::::::::::: -# Makefile -# :::::::::::::: -# obj-m := hello.o -# hello-y := init.o exit.o -# -# all: -# make -C /lib/modules/$(shell uname -r)/build M=$(PWD) \ -# CONFIG_DEBUG_INFO=y modules -# :::::::::::::: -# init.c -# :::::::::::::: -# #include -# #include -# -# int init_module(void) -# { -# printk(KERN_INFO "Hello, world!\n"); -# return 0; -# } -# :::::::::::::: -# exit.c -# :::::::::::::: -# #include -# #include -# -# void cleanup_module() -# { -# printk(KERN_INFO "Goodbye, World!\n"); -# } -runtest hello_i386.ko 1 -runtest hello_x86_64.ko 1 -runtest hello_ppc64.ko 1 -runtest hello_s390.ko 1 -runtest hello_aarch64.ko 1 -runtest hello_m68k.ko 1 -runtest hello_riscv64.ko 1 -runtest hello_csky.ko 1 -runtest hello_arc_hs4.ko 1 - -# self test, shouldn't impact non-ET_REL files at all. -runtest ${abs_top_builddir}/src/strip 0 -runtest ${abs_top_builddir}/src/strip.o 1 - -# Copy ET_REL file for self-test and make sure to run with/without -# elf section compression. -tempfiles strip-uncompressed.o strip-compressed.o -testrun ${abs_top_builddir}/src/elfcompress -o strip-uncompressed.o -t none \ - ${abs_top_builddir}/src/strip.o -testrun ${abs_top_builddir}/src/elfcompress -o strip-compressed.o -t zlib \ - --force ${abs_top_builddir}/src/strip.o - -runtest strip-uncompressed.o 1 -runtest strip-compressed.o 1 - -# See run-readelf-zdebug-rel.sh -testfiles testfile-debug-rel-ppc64.o -runtest testfile-debug-rel-ppc64.o 1 - -testfiles testfile-debug-rel-ppc64-z.o -runtest testfile-debug-rel-ppc64-z.o 1 - -testfiles testfile-debug-rel-ppc64-g.o -runtest testfile-debug-rel-ppc64-g.o 1 - -exit $status diff --git a/tests/strip-reloc-subr.sh b/tests/strip-reloc-subr.sh new file mode 100755 index 00000000..c4d55ced --- /dev/null +++ b/tests/strip-reloc-subr.sh @@ -0,0 +1,79 @@ +#! /bin/sh +# Copyright (C) 2011, 2013 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +if test -n "$ELFUTILS_MEMORY_SANITIZER"; then + echo "binaries linked with memory sanitizer are too big" + exit 77 +fi + +tempfiles readelf.out1 readelf.out2 +tempfiles out.stripped1 out.debug1 out.stripped2 out.debug2 + +runtest_status=0 +runtest() { + infile=$1 + is_ET_REL=$2 + outfile1=out.stripped1 + debugfile1=out.debug1 + outfile2=out.stripped2 + debugfile2=out.debug2 + + echo "runtest $infile" + + rm -f $outfile1 $debugfile1 $outfile2 $debugfile2 + + testrun ${abs_top_builddir}/src/strip -o $outfile1 -f $debugfile1 $infile || + { echo "*** failure strip $infile"; runtest_status=1; } + + testrun ${abs_top_builddir}/src/strip --reloc-debug-sections -o $outfile2 \ + -f $debugfile2 $infile || + { echo "*** failure strip --reloc-debug-sections $infile"; runtest_status=1; } + + testrun ${abs_top_builddir}/src/elfcmp $outfile1 $outfile2 || + { echo "*** failure compare stripped files $infile"; runtest_status=1; } + + # debug files however should be smaller, when ET_REL. + SIZE1=$(stat -c%s $debugfile1) + SIZE2=$(stat -c%s $debugfile2) + test \( \( $is_ET_REL -eq 1 \) -a \( $SIZE1 -gt $SIZE2 \) \) \ + -o \( \( $is_ET_REL -eq 0 \) -a \( $SIZE1 -eq $SIZE2 \) \) || + { echo "*** failure --reloc-debug-sections not smaller $infile"; runtest_status=1; } + + # Strip of DWARF section lines, offset will not match. + # Everything else should match. + testrun ${abs_top_builddir}/src/readelf -N -w $debugfile1 \ + | grep -v ^DWARF\ section > readelf.out1 || + { echo "*** failure readelf -N -w debugfile1 $infile"; runtest_status=1; } + + testrun ${abs_top_builddir}/src/readelf -N -w $debugfile2 \ + | grep -v ^DWARF\ section > readelf.out2 || + { echo "*** failure readelf -N -w debugfile2 $infile"; runtest_status=1; } + + testrun_compare cat readelf.out1 < readelf.out2 || + { echo "*** failure readelf -N -w compare $infile"; runtest_status=1; } + + testrun ${abs_top_builddir}/src/strip --reloc-debug-sections-only \ + $debugfile1 || + { echo "*** failure strip --reloc-debug-sections-only $debugfile1"; \ + runtest_status=1; } + + cmp $debugfile1 $debugfile2 || + { echo "*** failure --reloc-debug-sections[-only] $debugfile1 $debugfile2"; \ + runtest_status=1; } +} -- 2.39.3