From 8e50243c4515987ad58032ae263bae3a0732dfcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kadl=C4=8D=C3=ADk?= Date: Tue, 4 May 2021 12:54:49 +0200 Subject: [PATCH] Import RHEL's regression test for #241252 --- tests/Regression/241252/Makefile | 62 ++++++++++++++++++++++++++ tests/Regression/241252/main.fmf | 12 +++++ tests/Regression/241252/runtest.sh | 62 ++++++++++++++++++++++++++ tests/Regression/241252/x.i | 62 ++++++++++++++++++++++++++ tests/Regression/241252/y.i | 71 ++++++++++++++++++++++++++++++ 5 files changed, 269 insertions(+) create mode 100644 tests/Regression/241252/Makefile create mode 100644 tests/Regression/241252/main.fmf create mode 100755 tests/Regression/241252/runtest.sh create mode 100644 tests/Regression/241252/x.i create mode 100644 tests/Regression/241252/y.i diff --git a/tests/Regression/241252/Makefile b/tests/Regression/241252/Makefile new file mode 100644 index 0000000..e362619 --- /dev/null +++ b/tests/Regression/241252/Makefile @@ -0,0 +1,62 @@ +# Copyright (c) 2009 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# Testcases for this bugzilla were provided by Jakub Jelinek +# I've only wrapped them to RHTS + +TOPLEVEL_NAMESPACE=/tools +PACKAGE_NAME=binutils +RELATIVE_PATH=bugzillas/241252 + +export TESTVERSION=1.0 + +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) + +.PHONY: all install download clean + +FILES=$(METADATA) \ + runtest.sh \ + Makefile \ + x.i \ + y.i + +run: $(FILES) #build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: Michal Nowak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: Regression test for bz241252." >> $(METADATA) + @echo "TestTime: 3m" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: $(PACKAGE_NAME) gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "Releases: -RHEL4" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/241252/main.fmf b/tests/Regression/241252/main.fmf new file mode 100644 index 0000000..89c443c --- /dev/null +++ b/tests/Regression/241252/main.fmf @@ -0,0 +1,12 @@ +summary: Regression test for bz241252. +contact: Michal Nowak +component: +- binutils +test: ./runtest.sh +framework: beakerlib +recommend: +- binutils +- gcc +duration: 3m +extra-summary: /tools/binutils/bugzillas/241252 +extra-task: /tools/binutils/bugzillas/241252 diff --git a/tests/Regression/241252/runtest.sh b/tests/Regression/241252/runtest.sh new file mode 100755 index 0000000..8f7afe9 --- /dev/null +++ b/tests/Regression/241252/runtest.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="binutils" + +rlJournalStart + rlPhaseStartSetup Setup + rlAssertRpm $PACKAGE + rlShowRunningKernel + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + cp x.i y.i $TmpDir + rlRun "pushd $TmpDir" + + rlRun "gcc -c -O2 -fpic -o x.o x.i -g" 0 "Compile test case 'x'" + rlRun "gcc -c -O2 -fpic -o y.o y.i -g" 0 "Compile test case 'y'" + rlRun "gcc -Wl,--unique -o x [xy].o" 0 "Link 'x' and 'y'" + + # Note: debug_ranges replaced by debug_rnglist (since DWARF 5 in Fedora 34) + rlLogInfo 'x.o + y.o:' + rlLogInfo "$( readelf -WS [xy].o | grep debug_rnglist | grep PROGBITS )" + rlLogInfo 'x:' + rlLogInfo "$( readelf -WS x | grep debug_rnglist )" + rlPhaseEnd + + rlPhaseStartTest Testing + if [ $( readelf -WS [xy].o | grep debug_rnglist | grep PROGBITS | wc -l ) -eq 2 ] \ + && [ $( readelf -WS x | grep debug_rnglist | wc -l ) -eq 1 ]; then + rlPass "Debug ranges sections were merged" + else + rlFail "Debug ranges sections were not merged" + fi + rlPhaseEnd + + rlPhaseStartCleanup Cleanup + rlRun "popd" + rlRun "rm -r $TmpDir $rlRun_LOG" 0 "Removing tmp directory" + rlPhaseEnd + rlJournalPrintText +rlJournalEnd diff --git a/tests/Regression/241252/x.i b/tests/Regression/241252/x.i new file mode 100644 index 0000000..0a81c5d --- /dev/null +++ b/tests/Regression/241252/x.i @@ -0,0 +1,62 @@ +extern void __assert_fail (const char *, const char *, unsigned int, const char *) + __attribute__ ((__nothrow__, __noreturn__)); + +struct gst; +struct gs; + +extern void bar (void *) __attribute__ ((__nothrow__)); + +typedef int (*gf) (struct gst *, struct gs *, + const unsigned char **, const unsigned char *, + unsigned char **, unsigned long *, int, int); + +struct gst +{ + gf fct; + int min_needed_from; +}; + +struct gs +{ + unsigned char *outbuf; + unsigned char *outbufend; + int flags; + int invocation_counter; + int internal_use; +}; + +typedef struct gi +{ + unsigned long nsteps; + struct gst *steps; + struct gs data [10]; +} *gt; + +int +foo (gt cd, const unsigned char **inbuf, + const unsigned char *inbufend, unsigned char **outbuf, + unsigned char *outbufend, unsigned long *irreversible) +{ + unsigned long last_step; + int result; + last_step = cd->nsteps - 1; + *irreversible = 0; + cd->data[last_step].outbuf = outbuf != ((void *)0) ? *outbuf : ((void *)0); + cd->data[last_step].outbufend = outbufend; + gf fct = cd->steps->fct; + if (inbuf == ((void *)0) || *inbuf == ((void *)0)) + result = (bar ((void *) (fct)), (*(fct)) (cd->steps, cd->data, ((void *)0), ((void *)0), ((void *)0), irreversible, cd->data[last_step].outbuf == ((void *)0) ? 2 : 1, 0)); + else + { + const unsigned char *last_start; + ((outbuf != ((void *)0) && *outbuf != ((void *)0)) ? (void) (0) : __assert_fail ("outbuf != ((void *)0) && *outbuf != ((void *)0)", "gconv.c", 67, "foo")); + do + { + last_start = *inbuf; + result = (bar ((void *) (fct)), (*(fct)) (cd->steps, cd->data, inbuf, inbufend, ((void *)0), irreversible, 0, 0)); + } + while (result == 4 && last_start != *inbuf + && *inbuf + cd->steps->min_needed_from <= inbufend); + } + return result; +} diff --git a/tests/Regression/241252/y.i b/tests/Regression/241252/y.i new file mode 100644 index 0000000..b5dc13b --- /dev/null +++ b/tests/Regression/241252/y.i @@ -0,0 +1,71 @@ +extern void __assert_fail (const char *, const char *, unsigned int, const char *) + __attribute__ ((__nothrow__, __noreturn__)); + +struct gst; +struct gs; + +extern void bar (void *) __attribute__ ((__nothrow__)); + +void bar (void *x) +{ +} + +typedef int (*gf) (struct gst *, struct gs *, + const unsigned char **, const unsigned char *, + unsigned char **, unsigned long *, int, int); + +struct gst +{ + gf fct; + int min_needed_from; +}; + +struct gs +{ + unsigned char *outbuf; + unsigned char *outbufend; + int flags; + int invocation_counter; + int internal_use; +}; + +typedef struct gi +{ + unsigned long nsteps; + struct gst *steps; + struct gs data [10]; +} *gt; + +int +baz (gt cd, const unsigned char **inbuf, + const unsigned char *inbufend, unsigned char **outbuf, + unsigned char *outbufend, unsigned long *irreversible) +{ + unsigned long last_step; + int result; + last_step = cd->nsteps - 1; + *irreversible = 0; + cd->data[last_step].outbuf = outbuf != ((void *)0) ? *outbuf : ((void *)0); + cd->data[last_step].outbufend = outbufend; + gf fct = cd->steps->fct; + if (inbuf == ((void *)0) || *inbuf == ((void *)0)) + result = (bar ((void *) (fct)), (*(fct)) (cd->steps, cd->data, ((void *)0), ((void *)0), ((void *)0), irreversible, cd->data[last_step].outbuf == ((void *)0) ? 2 : 1, 0)); + else + { + const unsigned char *last_start; + ((outbuf != ((void *)0) && *outbuf != ((void *)0)) ? (void) (0) : __assert_fail ("outbuf != ((void *)0) && *outbuf != ((void *)0)", "gconv.c", 67, "foo")); + do + { + last_start = *inbuf; + result = (bar ((void *) (fct)), (*(fct)) (cd->steps, cd->data, inbuf, inbufend, ((void *)0), irreversible, 0, 0)); + } + while (result == 4 && last_start != *inbuf + && *inbuf + cd->steps->min_needed_from <= inbufend); + } + return result; +} + +int +main (void) +{ +}