From 95e9eaea2359d8028cd9ee1a083600a2927d6e85 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 #430856 --- .../Makefile | 82 +++++++++++++++++++ .../PURPOSE | 11 +++ .../main.fmf | 20 +++++ .../reproducer/Makefile | 21 +++++ .../reproducer/bfdtest.c | 7 ++ .../reproducer/libbfdtest.c | 10 +++ .../reproducer/libbfdtest.h | 1 + .../runtest.sh | 49 +++++++++++ 8 files changed, 201 insertions(+) create mode 100644 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/Makefile create mode 100644 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/PURPOSE create mode 100644 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/main.fmf create mode 100644 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/Makefile create mode 100644 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/bfdtest.c create mode 100644 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.c create mode 100644 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.h create mode 100755 tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/runtest.sh diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/Makefile b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/Makefile new file mode 100644 index 0000000..da0828b --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/Makefile @@ -0,0 +1,82 @@ +# +# Copyright (c) 2006 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 v.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. +# +# Author: Michal Nowak + +# The toplevel namespace within which the test lives. +TOPLEVEL_NAMESPACE=tools + +# The name of the package under test: +PACKAGE_NAME=binutils + +# The path of the test below the package: +RELATIVE_PATH=Sanity/430856-libbfd.a-not-compiled-with-fPIC + +# Version of the Test. Used with make tag. +export TESTVERSION=1.1 + +# The combined namespace of the test. +export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) + + +# A phony target is one that is not really the name of a file. +# It is just a name for some commands to be executed when you +# make an explicit request. There are two reasons to use a +# phony target: to avoid a conflict with a file of the same +# name, and to improve performance. +.PHONY: all install download clean + +# executables to be built should be added here, they will be generated on the system under test. +BUILT_FILES= + +# data files, .c files, scripts anything needed to either compile the test and/or run it. +FILES=$(METADATA) runtest.sh Makefile PURPOSE bz430856.tar.gz + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ *.rpm $(BUILT_FILES) + +# You may need to add other targets e.g. to build executables from source code +# Add them here: + + +# Include Common Makefile +include /usr/share/rhts/lib/rhts-make.include + +# Generate the testinfo.desc here: +$(METADATA): Makefile + @touch $(METADATA) +# Change to the test owner's name + @echo "Owner: Michal Nowak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: libbfd.a not compiled with -fPIC">> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) +# add any other packages for which your test ought to run here + @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: $(PACKAGE_NAME)-devel" >> $(METADATA) + @echo "Requires: gcc glibc-headers" >> $(METADATA) +# add any other requirements for the script to run here + +# You may need other fields here; see the documentation + rhts-lint $(METADATA) + diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/PURPOSE b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/PURPOSE new file mode 100644 index 0000000..7700573 --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/PURPOSE @@ -0,0 +1,11 @@ +Would it be possible to have /usr/lib64/libbfd.a in binutils +compiled with -fPIC? Otherwise, shared apps can't link against +libbfd. In binutils.spec, libiberty.a is already recreated +with -fPIC, is there some reason the same isn't done for +libbfd? + +From binutils.spec: + + # Rebuild libiberty.a with -fPIC + make -C libiberty clean + make CFLAGS="-g -fPIC $RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64" -C libiberty diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/main.fmf b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/main.fmf new file mode 100644 index 0000000..3b9df28 --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/main.fmf @@ -0,0 +1,20 @@ +summary: libbfd.a not compiled with -fPIC +description: "Would it be possible to have /usr/lib64/libbfd.a in binutils\ncompiled\ + \ with -fPIC? Otherwise, shared apps can't link against\nlibbfd. In binutils.spec,\ + \ libiberty.a is already recreated \nwith -fPIC, is there some reason the same\ + \ isn't done for \nlibbfd?\n\nFrom binutils.spec:\n\n # Rebuild libiberty.a with\ + \ -fPIC\n make -C libiberty clean\n make CFLAGS=\"-g -fPIC $RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64\"\ + \ -C libiberty\n" +contact: Michal Nowak +component: +- binutils +test: ./runtest.sh +framework: beakerlib +recommend: +- binutils +- binutils-devel +- gcc +- glibc-headers +duration: 5m +extra-summary: /tools/binutils/Sanity/430856-libbfd.a-not-compiled-with-fPIC +extra-task: /tools/binutils/Sanity/430856-libbfd.a-not-compiled-with-fPIC diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/Makefile b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/Makefile new file mode 100644 index 0000000..c8c5081 --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/Makefile @@ -0,0 +1,21 @@ +CC=gcc +CFLAGS=-g -Wall + +all: test + +libbfdtest.so bfdtest: Makefile + +libbfdtest.so: libbfdtest.c libbfdtest.h + $(CC) $(CFLAGS) -shared -o $@ -fPIC $< -lbfd -liberty + +bfdtest: bfdtest.c libbfdtest.h libbfdtest.so + $(CC) -o $@ $< -L. -Wl,-rpath,. -lbfdtest -ldl + +.PHONY: test +test: bfdtest + ./$< + @echo OK + +clean: + $(RM) libbfdtest.so bfdtest + diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/bfdtest.c b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/bfdtest.c new file mode 100644 index 0000000..cc8038e --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/bfdtest.c @@ -0,0 +1,7 @@ +#include "libbfdtest.h" + +int +main (void) +{ + return libbfdtest () ? 0 : 1; +} diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.c b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.c new file mode 100644 index 0000000..b3ec8fe --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.c @@ -0,0 +1,10 @@ +#include + +#include "libbfdtest.h" + +int +libbfdtest (void) +{ + bfd_set_error (bfd_error_no_error); + return bfd_get_error () == bfd_error_no_error; +} diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.h b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.h new file mode 100644 index 0000000..f67d25b --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/reproducer/libbfdtest.h @@ -0,0 +1 @@ +extern int libbfdtest (void); diff --git a/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/runtest.sh b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/runtest.sh new file mode 100755 index 0000000..2638e8e --- /dev/null +++ b/tests/Regression/430856-libbfd.a-not-compiled-with-fPIC/runtest.sh @@ -0,0 +1,49 @@ +#!/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 + rlAssertRpm $PACKAGE + rlShowPackageVersion $PACKAGE + rlShowRunningKernel + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + cp reproducer/* $TmpDir + rlRun "pushd $TmpDir" + rlRun "make clean" 0 "Make clean" + rlPhaseEnd + + rlPhaseStartTest + rlRun "make" 0 "Build the files" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd + rlJournalPrintText +rlJournalEnd