From 6c7c2d2b361fe8bf8120d20ec2d588ada36695fb 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:16:02 +0200 Subject: [PATCH] Import RHEL's regression test for #211163 --- .../Makefile | 61 ++++++++++ .../PURPOSE | 1 + .../main.fmf | 17 +++ .../reproducer.c | 9 ++ .../runtest.sh | 109 ++++++++++++++++++ 5 files changed, 197 insertions(+) create mode 100644 tests/Regression/211163-ltrace-with--c-omit-execl-call/Makefile create mode 100644 tests/Regression/211163-ltrace-with--c-omit-execl-call/PURPOSE create mode 100644 tests/Regression/211163-ltrace-with--c-omit-execl-call/main.fmf create mode 100644 tests/Regression/211163-ltrace-with--c-omit-execl-call/reproducer.c create mode 100755 tests/Regression/211163-ltrace-with--c-omit-execl-call/runtest.sh diff --git a/tests/Regression/211163-ltrace-with--c-omit-execl-call/Makefile b/tests/Regression/211163-ltrace-with--c-omit-execl-call/Makefile new file mode 100644 index 0000000..30571dd --- /dev/null +++ b/tests/Regression/211163-ltrace-with--c-omit-execl-call/Makefile @@ -0,0 +1,61 @@ +# Copyright (c) 2008 Red Hat, Inc. All rights reserved. +# +# 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 3 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 . +# +# Author: Michal Nowak + + +TOPLEVEL_NAMESPACE=/tools +PACKAGE_NAME=ltrace +RELATIVE_PATH=Regression/211163-ltrace-with--c-omit-execl-call + +export TEST=/tools/ltrace/Regression/211163-ltrace-with--c-omit-execl-call +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE reproducer.c + +.PHONY: all install download clean + +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 + @echo "Owner: Michal Nowak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: ltrace with -c omit execl call" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: ltrace" >> $(METADATA) + @echo "Requires: ltrace gcc glibc-devel" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv3+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 211163 528466" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/211163-ltrace-with--c-omit-execl-call/PURPOSE b/tests/Regression/211163-ltrace-with--c-omit-execl-call/PURPOSE new file mode 100644 index 0000000..4dd4371 --- /dev/null +++ b/tests/Regression/211163-ltrace-with--c-omit-execl-call/PURPOSE @@ -0,0 +1 @@ +ltrace with -c omit execl call diff --git a/tests/Regression/211163-ltrace-with--c-omit-execl-call/main.fmf b/tests/Regression/211163-ltrace-with--c-omit-execl-call/main.fmf new file mode 100644 index 0000000..aa6cfa6 --- /dev/null +++ b/tests/Regression/211163-ltrace-with--c-omit-execl-call/main.fmf @@ -0,0 +1,17 @@ +summary: ltrace with -c omit execl call +description: | + ltrace with -c omit execl call +contact: Michal Nowak +component: +- ltrace +test: ./runtest.sh +framework: beakerlib +recommend: +- ltrace +- gcc +- glibc-devel +duration: 5m +link: +- relates: https://bugzilla.redhat.com/show_bug.cgi?id=211163 +extra-summary: /tools/ltrace/Regression/211163-ltrace-with--c-omit-execl-call +extra-task: /tools/ltrace/Regression/211163-ltrace-with--c-omit-execl-call diff --git a/tests/Regression/211163-ltrace-with--c-omit-execl-call/reproducer.c b/tests/Regression/211163-ltrace-with--c-omit-execl-call/reproducer.c new file mode 100644 index 0000000..7a7847e --- /dev/null +++ b/tests/Regression/211163-ltrace-with--c-omit-execl-call/reproducer.c @@ -0,0 +1,9 @@ +#include +#include + +int main() +{ + execl("/bin/ls","ls",0); + return 0; +} + diff --git a/tests/Regression/211163-ltrace-with--c-omit-execl-call/runtest.sh b/tests/Regression/211163-ltrace-with--c-omit-execl-call/runtest.sh new file mode 100755 index 0000000..68b0814 --- /dev/null +++ b/tests/Regression/211163-ltrace-with--c-omit-execl-call/runtest.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +# Copyright (c) 2008 Red Hat, Inc. All rights reserved. +# +# 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 3 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 . +# +# Author: Michal Nowak + +# source the test script helpers +. /usr/bin/rhts_environment.sh +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE=$(rpm -qf $(which ltrace)) + +rlJournalStart + rlPhaseStartSetup "Gathering information & compiling" + rlAssertRpm $PACKAGE + rlAssertRpm $(rpm -qf $(which gcc)) + rlShowRunningKernel + + rlRun "gcc reproducer.c -o reproducer" 0 "Compiling the reproducer" + rlPhaseEnd + + rlPhaseStartTest "Counting the number of calls noted by ltrace" + rlRun "ltrace -o ltrace-test-c.log -c ./reproducer" 0 "Execute reproducer" + rlRun "cat -n ltrace-test-c.log" + # Check if exec is not omitted (rhbz#797761) + rlAssertGrep "exec" ltrace-test-c.log + + # Check if ltrace is able to trace system binaries with execl /bin/ls (rhbz#1618748/rhbz#1655368/rhbz#1731119) + if rlIsRHEL 8; then + case "$PACKAGE" in + ltrace*) + # bz#1655368 was fixed on ltrace-0.7.91-28.el8.x86_64, but it is still reproducible on ppc64le + if [ "$(arch)" = "ppc64le" ]; then + rlLogWarning "RHEL8 ltrace fails to trace system binaries on ppc64le due to bz#1618748/bz#1655368, hence skipping failure checking" + skip_test=1 + fi + ;; + gcc-toolset-*) + if [ "$(arch)" = "ppc64le" ]; then + rlLogWarning "RHEL8 gcc-toolset-*-ltrace fails to trace system binaries on ppc64le due to bz#1731119, hence skipping failure checking" + skip_test=1 + fi + ;; + esac + elif rlIsRHEL 9 && [[ $PACKAGE =~ ^ltrace ]] && [ "$(arch)" = "ppc64le" ]; then + rlLogWarning "RHEL-9 ltrace fails to trace system binaries on ppc64le due to bz#1906881, hence skipping failure checking" + skip_test=1 + elif rlIsFedora 33 && [ "$(arch)" = "ppc64le" ]; then + rlLogWarning "FC33 ltrace fails to trace system binaries on ppc64le due to bz#1902770, hence skipping failure checking" + skip_test=1 + fi + + rlRun "n_lines_c=$(grep -c . ltrace-test-c.log)" + if [ $n_lines_c -gt 20 ]; then + if [ $skip_test ]; then + rlLogWarning "Test was skipped but it seems ok. Review skip check." + fi + else + if [ $skip_test ]; then + rlLogInfo"'ltrace -c ./reproducer' does not report more than 20 lines of trace summary output (expected failure)" + else + rlFail "'ltrace -c ./reproducer' does not report more than 20 lines of trace summary output" + fi + fi + rlPhaseEnd + + rlPhaseStartTest "Looking for SEGFAULT of reproducer under ltrace" + rlRun "ltrace -o ltrace-test.log ./reproducer" 0 "Execute reproducer" + rlRun "cat -n ltrace-test.log" + # Check if neither segfault nor 'unexpected breakpoint' errors occur (rhbz#211163) + rlAssertNotGrep "SIGSEGV" ltrace-test.log + rlAssertNotGrep "unexpected breakpoint" ltrace-test.log + # Check if exec is not omitted (rhbz#797761) + rlAssertGrep "exec" ltrace-test.log + + # Check if ltrace is able to trace system binaries with execl /bin/ls (rhbz#1618748/rhbz#1655368/rhbz#1731119) + rlRun "n_lines=$(grep -c . ltrace-test.log)" + if [ $n_lines -gt 20 ]; then + if [ $skip_test ]; then + rlLogWarning "Test was skipped but it seems ok. Review skip check." + fi + else + if [ $skip_test ]; then + rlLogInfo"'ltrace ./reproducer' does not report more than 20 lines of trace summary output (expected failure)" + else + rlFail "'ltrace ./reproducer' does not report more than 20 lines of trace summary output" + fi + fi + rlPhaseEnd + + rlPhaseStartCleanup "Doing clean-up" + rlBundleLogs "ltrace-outputs" ltrace-test.log ltrace-test-c.log + rlRun "rm -f ltrace-test.log ltrace-test-c.log reproducer" + rlPhaseEnd + rlJournalPrintText +rlJournalEnd