diff --git a/.gitignore b/.gitignore index e69de29..17e66e6 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/dwz-0.14.tar.xz diff --git a/dwz.spec b/dwz.spec new file mode 100644 index 0000000..14b87a2 --- /dev/null +++ b/dwz.spec @@ -0,0 +1,49 @@ +%global __python /usr/bin/python3 +%{?scl_package:%global scl gcc-toolset-14} +%global scl_prefix gcc-toolset-14- +BuildRequires: scl-utils-build +%{?scl:%scl_package gcc} +Summary: DWARF optimization and duplicate removal tool +Name: %{?scl_prefix}dwz +Version: 0.14 +Release: 0%{?dist} +License: GPLv2+ and GPLv3+ +# git archive --format=tar --remote=git://sourceware.org/git/dwz.git \ +# --prefix=dwz-%%{version}/ dwz-%%{version} \ +# | bzip2 -9 > dwz-%%{version}.tar.bz2 +Source: dwz-%{version}.tar.xz +BuildRequires: gcc, gcc-c++, gdb, elfutils-libelf-devel, dejagnu +BuildRequires: make +%{?scl:Requires:%scl_runtime} + +%description +The dwz package contains a program that attempts to optimize DWARF +debugging information contained in ELF shared libraries and ELF executables +for size, by replacing DWARF information representation with equivalent +smaller representation where possible and by reducing the amount of +duplication using techniques from DWARF standard appendix E - creating +DW_TAG_partial_unit compilation units (CUs) for duplicated information +and using DW_TAG_imported_unit to import it into each CU that needs it. + +%prep +%setup -q -n dwz + +%build +%make_build CFLAGS='%{optflags}' LDFLAGS='%{build_ldflags}' \ + prefix=%{_prefix} mandir=%{_mandir} bindir=%{_bindir} + +%install +rm -rf %{buildroot} +%make_install prefix=%{_prefix} mandir=%{_mandir} bindir=%{_bindir} + +%check +make check + +%files +%license COPYING COPYING3 COPYING.RUNTIME +%{_bindir}/dwz +%{_mandir}/man1/dwz.1* + +%changelog +* Mon Apr 29 2024 Marek Polacek 0.14-0 +- new package (RHEL-29852) diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..8a619e4 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/sources b/sources new file mode 100644 index 0000000..00bbdcd --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (dwz-0.14.tar.xz) = 62c39f79723ca99305dbb08d1d24a17699b9a84dd98c30904103da116831b1253bf1edbfb905c76fdc4d48305bd1ea0046314c5619209c40a1e624b8ae4908b1 diff --git a/tests/dwz-quick-test/Makefile b/tests/dwz-quick-test/Makefile new file mode 100644 index 0000000..d3407b9 --- /dev/null +++ b/tests/dwz-quick-test/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/dwz/dwz-quick-test +# Description: Quick sanity test +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/dwz/dwz-quick-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE something.c cmd.txt + +.PHONY: all install download clean + +run: $(FILES) build + scl enable gcc-toolset-14 ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Miroslav Franc " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Quick sanity test" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 2m" >> $(METADATA) + @echo "RunFor: dwz" >> $(METADATA) + @echo "Requires: dwz gcc gdb glibc-debuginfo" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/dwz-quick-test/PURPOSE b/tests/dwz-quick-test/PURPOSE new file mode 100644 index 0000000..c5b39d4 --- /dev/null +++ b/tests/dwz-quick-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/dwz/dwz-quick-test +Description: Quick sanity test +Author: Miroslav Franc diff --git a/tests/dwz-quick-test/cmd.txt b/tests/dwz-quick-test/cmd.txt new file mode 100644 index 0000000..c807bca --- /dev/null +++ b/tests/dwz-quick-test/cmd.txt @@ -0,0 +1,7 @@ +b f +r +s +p x +p/x var +c +q diff --git a/tests/dwz-quick-test/runtest.sh b/tests/dwz-quick-test/runtest.sh new file mode 100755 index 0000000..ae80250 --- /dev/null +++ b/tests/dwz-quick-test/runtest.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/dwz/dwz-quick-test +# Description: Quick sanity test +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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 Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm gcc + rlAssertRpm gdb + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp something.c cmd.txt $TmpDir" + rlRun "pushd $TmpDir" + rlRun "gcc -g -O0 something.c -o something.out" + rlRun "cp something.out something.dwz" + rlPhaseEnd + + rlPhaseStartTest "no crash + saved space" + rlRun "dwz something.dwz" + rlRun "[[ $(wc -c log 2>&1" + rlRun "[[ $(grep -c 'hello, world' log) -eq 2 ]]" + rlAssertGrep '$1 = -1' log + rlAssertGrep '$2 = 0x2a' log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/dwz-quick-test/something.c b/tests/dwz-quick-test/something.c new file mode 100644 index 0000000..4dd3b6e --- /dev/null +++ b/tests/dwz-quick-test/something.c @@ -0,0 +1,21 @@ +#include + +void f (int x); + +int +main (int argc, char *argv[]) +{ + int a = -1; + + f(a); + + return 0; +} + +void +f (int x) +{ + static int var __attribute__ ((used)) = 42; + if(x) + puts("hello, world"); +} diff --git a/tests/inventory b/tests/inventory new file mode 100755 index 0000000..3ca7992 --- /dev/null +++ b/tests/inventory @@ -0,0 +1,4 @@ +#!/bin/bash +export TEST_DOCKER_EXTRA_ARGS="--cap-add=SYS_PTRACE" +exec merge-standard-inventory "$@" + diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..8b9cdeb --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,21 @@ +- hosts: localhost + tags: + - classic + - container # needs SYS_PTRACE + pre_tasks: + - name: Install deguginfo-install + shell: dnf -y install "dnf-command(debuginfo-install)" + - name: Install debuginfo for packages + shell: dnf -y debuginfo-install --best {{item}} + with_items: + - glibc + roles: + - role: standard-test-beakerlib + tests: + - dwz-quick-test + required_packages: + - gcc-toolset-14-dwz + - gcc-toolset-14-runtime + - gcc + - gdb + - glibc-debuginfo