From f20f6a9ea6142c1f833e298849d80e8440609d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kadl=C4=8D=C3=ADk?= Date: Wed, 19 May 2021 13:24:04 +0200 Subject: [PATCH] Import RHEL's regression test for #1158713 Note: I've prefixed the test with "bz1158713-" because ltrace's repo in Fedora ignores "ltrace-*/". See the .gitignore file. --- .../Makefile | 63 +++++++++++ .../PURPOSE | 5 + .../main.fmf | 18 +++ .../runtest.sh | 107 ++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/Makefile create mode 100644 tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/PURPOSE create mode 100644 tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/main.fmf create mode 100755 tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/runtest.sh diff --git a/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/Makefile b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/Makefile new file mode 100644 index 0000000..29d9876 --- /dev/null +++ b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +# Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program 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 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./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: Martin Cermak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 10m" >> $(METADATA) + @echo "RunFor: ltrace" >> $(METADATA) + @echo "Requires: ltrace gcc gawk" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1158713" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/PURPOSE b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/PURPOSE new file mode 100644 index 0000000..87ed099 --- /dev/null +++ b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +Author: Martin Cermak +Bug summary: ltrace assigns wrong names to glibc PLT slots +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1158713 diff --git a/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/main.fmf b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/main.fmf new file mode 100644 index 0000000..8beae33 --- /dev/null +++ b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/main.fmf @@ -0,0 +1,18 @@ +summary: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +description: | + Bug summary: ltrace assigns wrong names to glibc PLT slots + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1158713 +contact: Martin Cermak +component: +- ltrace +test: ./runtest.sh +framework: beakerlib +recommend: +- ltrace +- gcc +- gawk +duration: 10m +link: +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1158713 +extra-summary: /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +extra-task: /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots diff --git a/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/runtest.sh b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/runtest.sh new file mode 100755 index 0000000..9758773 --- /dev/null +++ b/tests/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots/runtest.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/ltrace/Regression/bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +# Description: bz1158713-ltrace-assigns-wrong-names-to-glibc-PLT-slots +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program 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 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="$(rpm -qf $(which ltrace))" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlAssertRpm $(rpm -qf $(which gcc)) + rlRun "TMPD=$(mktemp -d)" + rlRun "pushd $TMPD" + + cat > test.c < +#include +#include +#include + +int main() +{ + char *s = malloc(1000); + + // trigger a free() call from libc: + setpwent(); + getpwent(); + endpwent(); + + // print maps + sprintf(s, "grep -F '[heap]' /proc/%d/maps", getpid()); + system (s); + + free(s); +} +EOFA + + cat > test.awk < limit_max) { + print "ERROR 2 ("addrs[i]">"limit_max")" + exit 2 + } + } +} +EOFB + + rlRun "gcc test.c -o test" + rlPhaseEnd + + rlPhaseStartTest + rlRun "ltrace -e free ./test |& tee log | awk -f test.awk" || \ + rlRun "cat log" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TMPD" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd