From e0e2de73c31fcb6e1366b9e5489c263e91adae8b Mon Sep 17 00:00:00 2001 From: Serhii Turivnyi Date: Dec 13 2017 10:27:07 +0000 Subject: Add CI tests using the standard test interface --- diff --git a/tests/Cannot-handle-file-names-with-integrated-spaces/Makefile b/tests/Cannot-handle-file-names-with-integrated-spaces/Makefile new file mode 100644 index 0000000..5530481 --- /dev/null +++ b/tests/Cannot-handle-file-names-with-integrated-spaces/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/patch/Regression/Cannot-handle-file-names-with-integrated-spaces +# Description: Test for bz431887 (Cannot handle file names with integrated spaces) +# Author: Ondrej Moris +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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=/CoreOS/patch/Regression/Cannot-handle-file-names-with-integrated-spaces +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) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Ondrej Moris " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for bz431887 (Cannot handle file names with integrated spaces)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: patch" >> $(METADATA) + @echo "Requires: patch" >> $(METADATA) + @echo "Requires: expect" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 431887" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Cannot-handle-file-names-with-integrated-spaces/PURPOSE b/tests/Cannot-handle-file-names-with-integrated-spaces/PURPOSE new file mode 100644 index 0000000..72fce4b --- /dev/null +++ b/tests/Cannot-handle-file-names-with-integrated-spaces/PURPOSE @@ -0,0 +1,27 @@ +PURPOSE of /CoreOS/patch/Regression/Cannot-handle-file-names-with-integrated-spaces +Description: Test for bz431887 (Cannot handle file names with integrated spaces) +Author: Ondrej Moris +Bug summary: Cannot handle file names with integrated spaces +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=431887 + +Description: + +Description of problem: +If the file name for the file to be patched in a patch file has spaces, it +cannot be handled by patch. + +Version-Release number of selected component (if applicable): +patch-2.5.4-29.2.2 + +How reproducible: +create a patch of a file with spaces in path +try to apply the patch + +Actual results: +patch asks for the file name to patch + +Expected results: +Just the patched file + +Additional info: +Note that this bug is fixed upstream on 2003-05-18! diff --git a/tests/Cannot-handle-file-names-with-integrated-spaces/runtest.sh b/tests/Cannot-handle-file-names-with-integrated-spaces/runtest.sh new file mode 100644 index 0000000..eb4d3ef --- /dev/null +++ b/tests/Cannot-handle-file-names-with-integrated-spaces/runtest.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/patch/Regression/Cannot-handle-file-names-with-integrated-spaces +# Description: Test for bz431887 (Cannot handle file names with integrated spaces) +# Author: Ondrej Moris +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="patch" + +function apply_patch { +expect < \"f i r s t\"" 0 + rlRun "echo \"2\" > \"s e c o n d\"" 0 + rlAssertExists "f i r s t" + rlAssertExists "s e c o n d" + rlAssertDiffer "f i r s t" "s e c o n d" + rlRun "diff -u f\ i\ r\ s\ t s\ e\ c\ o\ n\ d > spaces.patch" 1 + rlRun "apply_patch" 0 "Patching file with spaces in its name" + rlAssertExists "f i r s t" + rlAssertExists "s e c o n d" + rlAssertNotDiffer "f i r s t" "s e c o n d" + + rlPhaseEnd + + rlPhaseStartCleanup + + rlRun "rm -f f\ i\ r\ s\ t s\ e\ c\ o\ n\ d spaces.patch" + + rlPhaseEnd + +rlJournalPrintText + +rlJournalEnd diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..088f40c --- /dev/null +++ b/tests/README @@ -0,0 +1 @@ +WORKING ON: Please don't migrate to dist-git diff --git a/tests/Regression-wrong-name-used-when-adding-new-file/Makefile b/tests/Regression-wrong-name-used-when-adding-new-file/Makefile new file mode 100644 index 0000000..e3b1235 --- /dev/null +++ b/tests/Regression-wrong-name-used-when-adding-new-file/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/patch/Regression/Regression-wrong-name-used-when-adding-new-file +# Description: Test for Regression: wrong name used when adding new file +# Author: Karel Srot +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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=/CoreOS/patch/Regression/Regression-wrong-name-used-when-adding-new-file +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) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Karel Srot " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for Regression: wrong name used when adding new file" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: patch" >> $(METADATA) + @echo "Requires: patch" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression-wrong-name-used-when-adding-new-file/PURPOSE b/tests/Regression-wrong-name-used-when-adding-new-file/PURPOSE new file mode 100644 index 0000000..9b30bad --- /dev/null +++ b/tests/Regression-wrong-name-used-when-adding-new-file/PURPOSE @@ -0,0 +1,55 @@ +PURPOSE of /CoreOS/patch/Regression/Regression-wrong-name-used-when-adding-new-file +Description: Test for Regression: wrong name used when adding new file +Author: Karel Srot +Bug summary: Regression: wrong name used when adding new file + +Description: + ++++ This bug was initially created as a clone of Bug #549122 +++ + +Description of problem: +Regression: Suffix inside of new files of patch files are added to new files. +Take http://cvs.fedoraproject.org/viewvc/devel/popt/popt-1.13-multilib.patch +for example for reproducing: + +With patch-2.6-1, "%patch0 -p1 -b .multilib" causes: +-rw-r--r-- 1 tux tux 256 Dec 20 15:26 footer_no_timestamp.html.multilib +-rw-r--r-- 1 tux tux 0 Dec 20 15:26 footer_no_timestamp.html.multilib.multilib + +-rw-r--r-- 1 tux tux 51543 Dec 20 15:26 Doxyfile.in +-rw-r--r-- 1 tux tux 51519 May 25 2007 Doxyfile.in.multilib + +With patch-2.5.4-36, "%patch0 -p1 -b .multilib" causes: +-rw-r--r-- 1 tux tux 256 Dec 20 15:32 footer_no_timestamp.html +---------- 1 tux tux 0 Dec 20 15:32 footer_no_timestamp.html.multilib + +-rw-r--r-- 1 tux tux 51543 Dec 20 15:32 Doxyfile.in +-rw-r--r-- 1 tux tux 51519 May 25 2007 Doxyfile.in.multilib + +You see what I mean? If the file is created by the patch file, the suffix +inside of the patch is appended to the new created file. That behaviour has +been introduced with the new version and it looks like a regression to me. + +Version-Release number of selected component (if applicable): +patch-2.6-1 +patch-2.5.4-36 + +How reproducible: +Everytime, see above. + +Actual results: +Regression: Suffixes inside of patches at new files are added to new files + +Expected results: +Good old behaviour like at patch-2.5.4-36. + +--- Additional comment from twaugh@redhat.com on 2009-12-21 05:17:27 EDT --- + +Verified. + +Affects F-12 and F-11 as well. + +--- Additional comment from twaugh@redhat.com on 2009-12-21 11:44:02 EDT --- + +Reported upstream: + https://savannah.gnu.org/bugs/index.php?28367 diff --git a/tests/Regression-wrong-name-used-when-adding-new-file/runtest.sh b/tests/Regression-wrong-name-used-when-adding-new-file/runtest.sh new file mode 100755 index 0000000..68a6dda --- /dev/null +++ b/tests/Regression-wrong-name-used-when-adding-new-file/runtest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/patch/Regression/Regression-wrong-name-used-when-adding-new-file +# Description: Test for Regression: wrong name used when adding new file +# Author: Karel Srot +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="patch" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "mkdir a b && touch a/file && echo content > b/file.new" 0 "Preparing test environment" + rlRun "diff -u a/file b/file.new > test.patch" 1 "Preparing a patch" + rlPhaseEnd + + rlPhaseStartTest + rlRun "patch -p1 -b -z .backup -i test.patch" 0 "Patching the test file" + rlAssertExists file + rlAssertExists file.backup + rlAssertNotExists file.new + rlAssertNotExists file.new.backup + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..6238138 --- /dev/null +++ b/tests/inventory @@ -0,0 +1,3 @@ +#!/bin/bash +export TEST_DOCKER_EXTRA_ARGS="--security-opt seccomp:unconfined" +exec merge-standard-inventory "$@" diff --git a/tests/selftest/Makefile b/tests/selftest/Makefile new file mode 100644 index 0000000..6968848 --- /dev/null +++ b/tests/selftest/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/patch/Sanity/selftest +# Description: Executes upstream test suite +# Author: Miroslav Vadkerti +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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=/CoreOS/patch/Sanity/selftest +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) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Miroslav Vadkerti " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Executes upstream test suite" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: patch" >> $(METADATA) + @echo "Requires: patch gcc rpm-build automake libselinux-devel ed libattr-devel" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL3 -RHEL4 -RHELServer5 -RHELClient5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/selftest/PURPOSE b/tests/selftest/PURPOSE new file mode 100644 index 0000000..9d47bfd --- /dev/null +++ b/tests/selftest/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/patch/Sanity/selftest +Description: Executes upstream test suite +Author: Miroslav Vadkerti diff --git a/tests/selftest/runtest.sh b/tests/selftest/runtest.sh new file mode 100755 index 0000000..1e8bb6d --- /dev/null +++ b/tests/selftest/runtest.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/patch/Sanity/selftest +# Description: Executes the upstream test suite comming with the package +# Author: Miroslav Vadkerti +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="patch" +PACKAGES="patch gcc rpm-build automake libselinux-devel" +UPSTREAMPKG="patch-*" +BUILDLOG=`mktemp` +TESTLOG=`mktemp` +TARGET=$(echo `uname -m` | egrep ppc) +if [[ $TARGET != "" ]]; then TARGET="--target `uname -m`"; fi +TOPDIR=`mktemp -d` +SPEC="$TOPDIR/SPECS/$PACKAGE*.spec" +TESTDIR="$TOPDIR/BUILD/$UPSTREAMPKG/" + +rlJournalStart + rlPhaseStartSetup + for PKG in $PACKAGES; do + rlAssertRpm $PKG + done + rlPhaseEnd + + rlPhaseStartTest + rlFetchSrcForInstalled $PACKAGE + rlRun "rpm -ivh --define '_topdir $TOPDIR' $PACKAGE*.src.rpm" 0 "Installing $PACKAGE src rpm" + echo "+ Building $PACKAGE (Log: $BUILDLOG)" + echo "+ Build command: rpmbuild -bc $SPEC $TARGET" + rlRun "rpmbuild --define '_topdir $TOPDIR' -bc $SPEC $TARGET &> $BUILDLOG" + echo "+ Buildlog:" + tail -n 100 $BUILDLOG + rlRun "pushd ." + rlRun "cd $TESTDIR" + rlRun "make check &> $TESTLOG" + cat $TESTLOG + if rlIsRHEL 6; then + rlAssertGrep 'All tests succeeded!' $TESTLOG + else + rlAssertNotGrep "FAILED" $TESTLOG + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -rf $PACKAGE*.src.rpm" 0 "Removing source rpm" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..204700a --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,21 @@ +--- +# This first play always runs on the local staging system +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + tests: + - Cannot-handle-file-names-with-integrated-spaces + - Regression-wrong-name-used-when-adding-new-file + - selftest + required_packages: + - patch + - expect + - gcc + - rpm-build + - automake + - libselinux-devel + - ed + - libattr-devel + - wget