From c9e5162ae9163e021409224108ca63c6bf3a2d13 Mon Sep 17 00:00:00 2001 From: Merlin Mathesius Date: Sep 25 2017 21:43:53 +0000 Subject: Initial commit for Atomic Host Tests --- diff --git a/tests/backup-file-not-cleared/Makefile b/tests/backup-file-not-cleared/Makefile new file mode 100644 index 0000000..8a37baf --- /dev/null +++ b/tests/backup-file-not-cleared/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/sed/Regression/backup-file-not-cleared +# Description: Test for tmp file not clear after registered to rhevm +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 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/sed/Regression/backup-file-not-cleared +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: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for tmp file not clear after registered to rhevm" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: sed" >> $(METADATA) + @echo "Requires: sed" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/backup-file-not-cleared/PURPOSE b/tests/backup-file-not-cleared/PURPOSE new file mode 100644 index 0000000..fce5d82 --- /dev/null +++ b/tests/backup-file-not-cleared/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/sed/Regression/backup-file-not-cleared +Description: Test for tmp file not clear after registered to rhevm +Author: Petr Muller +Bug summary: tmp file not clear after registered to rhevm diff --git a/tests/backup-file-not-cleared/runtest.sh b/tests/backup-file-not-cleared/runtest.sh new file mode 100755 index 0000000..19f7312 --- /dev/null +++ b/tests/backup-file-not-cleared/runtest.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sed/Regression/backup-file-not-cleared +# Description: Test for tmp file not clear after registered to rhevm +# Author: Petr Muller +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 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 + +PACKAGE="sed" + +rlJournalStart + rlPhaseStartSetup + rlRun "mkdir TMP" + rlRun "cd TMP" + rlRun "echo 'some content' > somefile" + rlRun "echo 'changed content' > somefile-expected" + rlRun "touch filelist" + cat > filelist-golden << EOF +./filelist +./filelist-golden +./somefile +./somefile-expected +EOF + rlPhaseEnd + + rlPhaseStartTest + rlRun "sed -i --copy 's/some/changed/' somefile" + rlRun "find . -type f | sort -f > filelist" + + rlAssertNotDiffer filelist filelist-golden + if [ $? -ne 0 ] + then + rlLog "Differences found: " + diff -u filelist-golden filelist | while read line + do + rlLog "\"$line\"" + done + fi + + rlAssertNotDiffer somefile somefile-expected + if [ $? -ne 0 ] + then + rlLog "Differences found: " + diff -u somefile-expected somefile | while read line + do + rlLog "\"$line\"" + done + fi + + rlRun "rm -f sed*" + rlRun "echo 'some content' > somefile" + rlRun "sed -i-fxpected --copy 's/some/changed/' somefile" + rlRun "find . -type f | sort > filelist" + echo "./somefile-fxpected" >> filelist-golden + rlAssertExists somefile-fxpected + sort filelist-golden -o filelist-golden + + rlAssertNotDiffer filelist filelist-golden + if [ $? -ne 0 ] + then + rlLog "Differences found: " + diff -u filelist-golden filelist | while read line + do + rlLog "\"$line\"" + done + fi + + rlAssertNotDiffer somefile somefile-expected + if [ $? -ne 0 ] + then + rlLog "Differences found: " + diff -u somefile-expected somefile | while read line + do + rlLog "\"$line\"" + done + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "cd .." + rlRun "rm -rf TMP" + rlPhaseEnd +rlJournalEnd diff --git a/tests/handle-escapes-correctly/Makefile b/tests/handle-escapes-correctly/Makefile new file mode 100644 index 0000000..16469a1 --- /dev/null +++ b/tests/handle-escapes-correctly/Makefile @@ -0,0 +1,49 @@ +# The toplevel namespace within which the test lives. +TOPLEVEL_NAMESPACE=/CoreOS + +# The name of the package under test: +PACKAGE_NAME=sed + +# The path of the test below the package: +RELATIVE_PATH=handle-escapes-correctly + +# Version of the Test. Used with make tag. +export TESTVERSION=1.1 + +# The compiled namespace of the test. +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) + +.PHONY: all install download clean + +BUILT_FILES= # executables to be built should be added here, they will be generated on the system under test. +FILES=$(METADATA) runtest.sh Makefile handle-escapes-correctly.sh + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x ./runtest.sh + chmod a+x ./handle-escapes-correctly.sh + +clean: + rm -f *~ $(BUILT_FILES) + +# Include Common Makefile +include /usr/share/rhts/lib/rhts-make.include + +# Generate the testinfo.desc here: +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: Bastien Nocera " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "License: RH Internal Test" >> $(METADATA) + @echo "Description: Tests if sed handles escapes correctly">> $(METADATA) + @echo "TestTime: 1m" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME) " >> $(METADATA) # add any other packages for which your test ought to run here + @echo "Requires: $(PACKAGE_NAME) " >> $(METADATA) # add any other requirements for the script to run here + @echo "Priority: Normal" >> $(METADATA) + @echo "Type: Regression " >> $(METADATA) + rhts-lint $(METADATA) + diff --git a/tests/handle-escapes-correctly/handle-escapes-correctly.sh b/tests/handle-escapes-correctly/handle-escapes-correctly.sh new file mode 100755 index 0000000..fa21c50 --- /dev/null +++ b/tests/handle-escapes-correctly/handle-escapes-correctly.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Tests if sed handles escapes correctly + +ACTUALFILE=`mktemp` +EXPECTEDFILE=`mktemp` +RETVAL=1 + +echo '' | sed -e ' i\\co' > $ACTUALFILE +printf '\x0f\n\n' > $EXPECTEDFILE + +if diff $EXPECTEDFILE $ACTUALFILE > /dev/null; then + RETVAL=0 + echo "Succeeded" +else + echo "Failed" +fi + +rm -f $ACTUALFILE $EXPECTEDFILE + +exit $RETVAL diff --git a/tests/handle-escapes-correctly/runtest.sh b/tests/handle-escapes-correctly/runtest.sh new file mode 100755 index 0000000..59492f5 --- /dev/null +++ b/tests/handle-escapes-correctly/runtest.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# Package: Package under test (will be used to get version info on executed +# tests). If RPM query results on PACKAGE are null, then pass value of +# PACKAGE variable for Version +PACKAGE=sed + +# source the test script helpers +# BUG: This line is intentionally left commented out. +# When I have the helper packages installed the line below should be +# uncommented +. /usr/bin/rhts-environment.sh + +# Commands in this section are provided by test developer. +# --------------------------------------------- + + +# Assume the test will pass. +result=PASS + +# Run the acutal test and redirect the output to the log file +# So if need be we will have the debug info after the fact. +./handle-escapes-correctly.sh > $OUTPUTFILE +if [ $? -ne 0 ]; then + result=FAIL +fi + +echo $result + +# Then file the results in the database +#------------------------------------------------ +report_result $TEST $result + diff --git a/tests/handle-escapes-correctly/runtest.yml b/tests/handle-escapes-correctly/runtest.yml new file mode 100755 index 0000000..c2510e1 --- /dev/null +++ b/tests/handle-escapes-correctly/runtest.yml @@ -0,0 +1,7 @@ +- hosts: '{{ hosts | default("localhost") }}' + vars: + package: sed + OUTPUTFILE: ./outputfile + tasks: + - name: Runtest + script: "./handle-escapes-correctly.sh > {{ OUTPUTFILE }}" diff --git a/tests/inventory b/tests/inventory new file mode 100755 index 0000000..b118a5a --- /dev/null +++ b/tests/inventory @@ -0,0 +1,3 @@ +#!/bin/bash +export TEST_DOCKER_EXTRA_ARGS="--privileged" +exec merge-standard-inventory "$@" diff --git a/tests/sed-does-not-handle-inline-edits-of-symlinks-with/Makefile b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/Makefile new file mode 100644 index 0000000..5c0a319 --- /dev/null +++ b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with +# Description: Test for sed does not handle inline edits of symlinks with +# Author: Marek Polacek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with +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: Marek Polacek " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for sed does not handle inline edits of symlinks with" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: sed" >> $(METADATA) + @echo "Requires: sed" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/sed-does-not-handle-inline-edits-of-symlinks-with/PURPOSE b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/PURPOSE new file mode 100644 index 0000000..0dabe03 --- /dev/null +++ b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/PURPOSE @@ -0,0 +1,34 @@ +PURPOSE of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with +Description: Test for sed does not handle inline edits of symlinks with +Author: Marek Polacek +Bug summary: sed does not handle inline edits of symlinks with no dir portion + +Description: + +Description of problem: + +When executing on a symlink in present working directory, sed does not build the original path correctly, thus failing to follow the symlink. + +Version-Release number of selected component (if applicable): + +sed-4.1.5-5.fc6 + +How reproducible: + +Always. + +Steps to Reproduce: +1. echo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" >1 +2. ln -s 1 2 +3. sed -i -e 's/z/a/g' 2 + +Actual results: + +sed: ck_follow_symlink: couldn't lstat 2/1: Not a directory + +Expected results: + +All z's in the file should be replaced with a's. + + +Additional info: diff --git a/tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.sh b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.sh new file mode 100755 index 0000000..0cda046 --- /dev/null +++ b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with +# Description: Test for sed does not handle inline edits of symlinks with +# Author: Marek Polacek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGE="sed" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + # Prepare the test file + rlRun "echo 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' > 1" 0 + # Create a symlink + rlRun "ln -s 1 2" 0 + rlPhaseEnd + + rlPhaseStartTest + # Try to replace characters + rlRun "sed -i -e 's/z/a/g' 2 " 0 "Replace all z's with a's" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.yml b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.yml new file mode 100755 index 0000000..6d342ee --- /dev/null +++ b/tests/sed-does-not-handle-inline-edits-of-symlinks-with/runtest.yml @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sed/Regression/sed-does-not-handle-inline-edits-of-symlinks-with +# Description: Test for sed does not handle inline edits of symlinks with +# Author: Marek Polacek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- hosts: '{{ hosts | default("localhost") }}' + vars: + package: sed + tasks: + - name: Make TmpDir + command: "mktemp -d" + register: TmpDir + - name: Prepare the test file + lineinfile: + create: yes + dest: "{{ TmpDir.stdout }}/1" + line: 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' + - name: Create a sym link + file: + src: "{{ TmpDir.stdout }}/1" + dest: "{{ TmpDir.stdout }}/2" + state: link + - block: + - name: Runtest - Try to replace characters + shell: "sed -i -e 's/z/a/g' 2 " + args: + warn: no + chdir: "{{ TmpDir.stdout }}" + always: + - name: Cleanup + file: + path: "{{ TmpDir.stdout }}" + state: absent diff --git a/tests/sed-needs-to-support-c-copy-option/Makefile b/tests/sed-needs-to-support-c-copy-option/Makefile new file mode 100644 index 0000000..3298910 --- /dev/null +++ b/tests/sed-needs-to-support-c-copy-option/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option +# Description: Test for sed needs to support -c/--copy option +# 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/sed/Regression/sed-needs-to-support-c-copy-option +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 sed needs to support -c/--copy option" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: sed" >> $(METADATA) + @echo "Requires: sed" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/sed-needs-to-support-c-copy-option/PURPOSE b/tests/sed-needs-to-support-c-copy-option/PURPOSE new file mode 100644 index 0000000..d9872ba --- /dev/null +++ b/tests/sed-needs-to-support-c-copy-option/PURPOSE @@ -0,0 +1,33 @@ +PURPOSE of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option +Description: Test for sed needs to support -c/--copy option +Author: Karel Srot +Bug summary: sed needs to support -c/--copy option + +Description: + +Description of problem: +sed on bind-mounted files fails in rename step. In previous versions this was fixed by using -c/--copy functionality which appears to have been removed in 4.2.1-4. + +Bind mounts are used in stateless systems for persistent data. + +Version-Release number of selected component (if applicable): +4.2.1-4 + +How reproducible: +Always + +Steps to Reproduce: +1. touch file1 file2 +2. mount --bind file1 file2 +3. echo "test" > file1 +4. sed -i "s/test/fail/g" file2 + +Actual results: +sed: cannot rename ./sedfnZpvY: Device or resource busy + + +Expected results: +sed script completes. + +Additional info: +As of 4.2.1-4, the -c/--copy options did not exist at all. Using them resulted in the printing of the help message. Using 4.2.1-5 from koji reintroduced the -c/--copy option support, but the above sed command still fails. diff --git a/tests/sed-needs-to-support-c-copy-option/runtest.sh b/tests/sed-needs-to-support-c-copy-option/runtest.sh new file mode 100755 index 0000000..1c8ec25 --- /dev/null +++ b/tests/sed-needs-to-support-c-copy-option/runtest.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option +# Description: Test for sed needs to support -c/--copy option +# 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 +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGE="sed" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "echo 'test' > file1" 0 "Prepare test files" + rlRun "touch file2" + rlRun "mount -n --bind file1 file2" + rlRun "grep test file2" 0 "Verify tests files" + rlPhaseEnd + + rlPhaseStartTest + rlRun "sed -i 's/test/passed/' file2 &> out1" 4 "Executing sed -i" + rlAssertGrep "cannot rename" out1 + rlAssertGrep "test" file2 + rlRun "sed -i -c 's/test/passed/' file2 &> out2" 0 "Executing sed -i -c" + rlAssertNotGrep "cannot rename" out2 + rlAssertGrep "passed" file2 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "umount file2" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/sed-needs-to-support-c-copy-option/runtest.yml b/tests/sed-needs-to-support-c-copy-option/runtest.yml new file mode 100755 index 0000000..b104eb0 --- /dev/null +++ b/tests/sed-needs-to-support-c-copy-option/runtest.yml @@ -0,0 +1,93 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option +# Description: Test for sed needs to support -c/--copy option +# 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- hosts: '{{ hosts | default("localhost") }}' + vars: + package: sed + tasks: + - name: Make TmpDir + command: "mktemp -d" + register: TmpDir + - name: Prepare test files + lineinfile: + dest: "{{ TmpDir.stdout }}/file1" + create: yes + line: "test" + - name: Prepare second test file + file: + dest: "{{ TmpDir.stdout }}/file2" + state: touch + - name: Bind mount files. Dont write to /etc so dont use mount module + shell: "mount -n --bind file1 file2" + args: + warn: no + chdir: "{{ TmpDir.stdout }}" + - name: Verify tests files + command: "grep test file2" + args: + chdir: "{{ TmpDir.stdout }}" + - block: + - name: Runtest - executing sed -i + shell: "sed -i 's/test/passed/' file2 &> out1" + args: + warn: no + chdir: "{{ TmpDir.stdout }}" + register: sedi + failed_when: sedi.rc != 4 + - name: Runtest - grep out1 + command: grep "cannot rename" out1 + args: + chdir: "{{ TmpDir.stdout }}" + - name: Runtest - grep file2 + command: grep "test" file2 + args: + chdir: "{{ TmpDir.stdout }}" + - name: Runtest - executing sed -i -c + shell: "sed -i -c 's/test/passed/' file2 &> out2" + args: + warn: no + chdir: "{{ TmpDir.stdout }}" + - name: Runtest - grep out2 + command: grep "cannot rename" out2 + args: + chdir: "{{ TmpDir.stdout }}" + register: out2 + failed_when: out2.rc != 1 + - name: Runtest - grep file2 + command: grep "passed" file2 + args: + chdir: "{{ TmpDir.stdout }}" + always: + - name: Cleanup file + shell: "umount file2" + args: + chdir: "{{ TmpDir.stdout }}" + - name: Cleanup dir + file: + path: "{{ TmpDir.stdout }}" + state: absent diff --git a/tests/sed-reports-syntax-errors-with-some-multibyte/Makefile b/tests/sed-reports-syntax-errors-with-some-multibyte/Makefile new file mode 100644 index 0000000..cb8566d --- /dev/null +++ b/tests/sed-reports-syntax-errors-with-some-multibyte/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte +# Description: Test for sed reports syntax errors with some multibyte +# Author: Marek Polacek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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/sed/Regression/sed-reports-syntax-errors-with-some-multibyte +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: Marek Polacek " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for sed reports syntax errors with some multibyte" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: sed" >> $(METADATA) + @echo "Requires: sed glibc-all-langpacks" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/sed-reports-syntax-errors-with-some-multibyte/PURPOSE b/tests/sed-reports-syntax-errors-with-some-multibyte/PURPOSE new file mode 100644 index 0000000..c11cde1 --- /dev/null +++ b/tests/sed-reports-syntax-errors-with-some-multibyte/PURPOSE @@ -0,0 +1,45 @@ +PURPOSE of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte +Description: Test for sed reports syntax errors with some multibyte +Author: Marek Polacek +Bug summary: sed reports syntax errors with some multibyte characters + +Description: + +Description of problem: + +Using a multibyte character that ends with 0x5c (backslash) can cause sed to report syntax errors. + + +Version-Release number of selected component (if applicable): sed-4.1.5-5 + + +How reproducible: Always + + +Steps to Reproduce: +1. Start with your shell in a UTF-8 locale, eg en-US.UTF-8 (you can probably do this in a different locale, but it definitely works if you start in a UTF-8 locale). + +2. Run the follow commands to construct a sed script: + + U2010=$(echo -ne '\x20\x10' | iconv -f ucs-2be) + echo "echo '$U2010' | sed 's/$U2010/hyphen/g'" | iconv -t gbk > /tmp/script + +3. Run the shell script in a locale that uses the gbk character set: + + LC_ALL=zh_CN.gbk sh /tmp/script 2>&1 | iconv -f gbk + +Actual results: + The script reports an error: + + sed:-e 表达式 #1,字符 13:unterminated `s' command + +Expected results: + + The single word "hyphen" + + +Additional info: + +The error arises because the character U+2010 (HYPHEN) is encoded as \xa9\x5c in the gbk encoding. Sed sees the "\x5c" as a backslash escaping the following character which, in this case, is the "/" that we hope is going to terminate the pattern; it doesn't and so we get a syntax error. + +Of course, this is just one character in one encoding. There are likely to be many others and this is just one example. I have another example for SJIS, (U+8868) but SJIS isn't a good encoding to use for reporting bugs :-). diff --git a/tests/sed-reports-syntax-errors-with-some-multibyte/runtest.sh b/tests/sed-reports-syntax-errors-with-some-multibyte/runtest.sh new file mode 100755 index 0000000..a8c6106 --- /dev/null +++ b/tests/sed-reports-syntax-errors-with-some-multibyte/runtest.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sed/Regression/sed-reports-syntax-errors-with-some-multibyte +# Description: Test for sed reports syntax errors with some multibyte +# Author: Marek Polacek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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 +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGE="sed" + +# as explained in the PURPOSE file, we need to start in a UTF-8 locale +export LC_ALL=en_US.UTF-8 + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + # Construct a sed script + rlRun "U2010=\$(echo -ne '\x20\x10' | iconv -f ucs-2be)" 0 + rlRun "echo \"echo '$U2010' | sed 's/$U2010/hyphen/g'\" | iconv -t gbk > script" 0 + rlRun "set -o pipefail" + rlPhaseEnd + + rlPhaseStartTest + # Run the shell script in a locale that uses the gbk character set + rlRun "LC_ALL=zh_CN.gbk sh ./script 2>&1 | iconv -f gbk" 0 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/selftest/Makefile b/tests/selftest/Makefile new file mode 100644 index 0000000..cc25659 --- /dev/null +++ b/tests/selftest/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/sed/Sanity/selftest +# Description: Execute test suite comming with sed +# 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/sed/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: Execute test suite comming with sed" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: sed" >> $(METADATA) + @echo "Requires: sed" >> $(METADATA) + @echo "Requires: gcc rpm-build automake libselinux-devel glibc-devel yum-utils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/selftest/PURPOSE b/tests/selftest/PURPOSE new file mode 100644 index 0000000..ae50f2c --- /dev/null +++ b/tests/selftest/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/sed/Sanity/selftest +Description: Execute test suite comming with sed +Author: Miroslav Vadkerti diff --git a/tests/selftest/runtest.sh b/tests/selftest/runtest.sh new file mode 100755 index 0000000..8b69564 --- /dev/null +++ b/tests/selftest/runtest.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sed/Sanity/selftest +# Description: Execute test suite comming with sed +# 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 +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGE="sed" +PACKAGES="sed gcc rpm-build automake libselinux-devel glibc-devel" +UPSTREAMPKG="sed-*" +BUILDLOG=`mktemp` +TESTLOG=`mktemp` +TARGET=$(echo `uname -m` | egrep ppc) +if [[ $TARGET != "" ]]; then + if rlIsRHEL 4; then + TARGET="--target ppc" + else + TARGET="--target `uname -m`" + fi +fi + +rlJournalStart + rlPhaseStartSetup + for PKG in $PACKAGES; do + rlAssertRpm $PKG + done + rlFetchSrcForInstalled $PACKAGE + # make sure all deps installed + if ! rlIsRHEL 3 4 5; then + rlRun "yum-builddep -y *.src.rpm" 0-255 + fi + rlPhaseEnd + + rlPhaseStartTest + rlRun "rpm -ivh $PACKAGE*.src.rpm" 0 "Installing $PACKAGE src rpm" +SRCDIR="/usr/src/redhat" +if ! rlIsRHEL 3 4 5; then + SRCDIR="$HOME/rpmbuild/" + echo "+ RHEL6+ detected: SRCDIR=$SRCDIR" +fi +SPEC="$SRCDIR/SPECS/$PACKAGE*.spec" +TESTDIR="$SRCDIR/BUILD/$UPSTREAMPKG/" + echo "+ Building $PACKAGE (Log: $BUILDLOG)" + echo "+ Build command: rpmbuild -bc $SPEC $TARGET" + rlRun "rpmbuild -bc $SPEC $TARGET &> $BUILDLOG" + echo "+ Buildlog:" + tail -n 100 $BUILDLOG + rlRun "pushd ." + rlRun "cd $TESTDIR" + # disable test known to fail when run as root + rlRun "sed -i 's/testsuite\/panic-tests.sh//' Makefile.in" + rlRun "make check &> $TESTLOG" + cat $TESTLOG + rlAssertNotGrep "^FAIL" $TESTLOG + 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..821e66c --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,44 @@ +--- +# Tests for classic and docker container environments +- hosts: localhost + tags: + - classic + - container + roles: + - role: standard-test-beakerlib + tests: + - selftest + - backup-file-not-cleared + - handle-escapes-correctly + - sed-does-not-handle-inline-edits-of-symlinks-with + - sed-needs-to-support-c-copy-option + - sed-reports-syntax-errors-with-some-multibyte + - uppercase-operand + required_packages: + - wget # beakerlib needs wget command + - findutils # backup-file-not-cleared needs find command + - glibc-langpack-en # sed-reports-syntax-errors-with-some-multibyte needs en_US.UTF-8 locale + - glibc-langpack-zh # sed-reports-syntax-errors-with-some-multibyte needs zh_CN.gbk locale + - glibc-langpack-ru # selftest needs ru_RU.UTF-8 locale + - gcc # selftest needs gcc package + - rpm-build # selftest needs rpm-build package + - automake # selftest needs automake package + - libselinux-devel # selftest needs libselinux-devel package + - glibc-devel # selftest needs glibc-devel package + - yum-utils # selftest needs yum-utils package + - libacl-devel # selftest needs libacl-devel package + +# Tests for Atomic Host +- hosts: localhost + tags: + - atomic + roles: + - role: standard-test-beakerlib + tests: + #- selftest # cannot run under Atomic + - backup-file-not-cleared + - handle-escapes-correctly + - sed-does-not-handle-inline-edits-of-symlinks-with + - sed-needs-to-support-c-copy-option + #- sed-reports-syntax-errors-with-some-multibyte # needs glibc-langpack-zh + - uppercase-operand diff --git a/tests/uppercase-operand/Makefile b/tests/uppercase-operand/Makefile new file mode 100644 index 0000000..da37af9 --- /dev/null +++ b/tests/uppercase-operand/Makefile @@ -0,0 +1,61 @@ +# Makefile - uppercase-operand +# Author: Petr Muller +# Location: /CoreOS/sed/Regression/uppercase-operand/Makefile + +# Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character + +# Copyright (c) 2008 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. + + + +TOPLEVEL_NAMESPACE=/CoreOS +PACKAGE_NAME=sed +RELATIVE_PATH=Regression/uppercase-operand + +export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile + +.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 + @touch $(METADATA) + @echo "Owner: Petr Muller " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 1m" >> $(METADATA) + @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) + @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/uppercase-operand/PURPOSE b/tests/uppercase-operand/PURPOSE new file mode 100644 index 0000000..ea59d9d --- /dev/null +++ b/tests/uppercase-operand/PURPOSE @@ -0,0 +1,9 @@ +Test Name: uppercase-operand +Author: Petr Muller +Location: /CoreOS/sed/Regression/uppercase-operand + +Short Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character + + +Long Description: +Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character diff --git a/tests/uppercase-operand/runtest.sh b/tests/uppercase-operand/runtest.sh new file mode 100755 index 0000000..b5748a6 --- /dev/null +++ b/tests/uppercase-operand/runtest.sh @@ -0,0 +1,83 @@ +# runtest.sh - uppercase-operand +# Author: Petr Muller +# Location: /CoreOS/sed/Regression/uppercase-operand/runtest.sh + +# Description: Verifiies that sed correctly processes an 'u' operand, which returns uppercase of matched character + +# Copyright (c) 2008 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. + + +PACKAGE=sed + +RESULT=FAIL +SCORE=0 + +if rpm -q $PACKAGE &>/dev/null; then + PKG_VERS=$( rpm -q ${PACKAGE} --queryformat %{version} ) + PKG_RELEASE=$( rpm -q ${PACKAGE} --queryformat %{release} ) +fi + +# Include rhts environment +. /usr/bin/rhts-environment.sh + +function Log { + echo -e ":: [`date +%H:%M:%S`] :: $1" >> $OUTPUTFILE +} + +function HeaderLog { + echo -e "\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" >> $OUTPUTFILE + echo -e ":: [`date +%H:%M:%S`] :: $1" >> $OUTPUTFILE + echo -e "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n" >>$OUTPUTFILE +} + +HeaderLog "Starting $PACKAGE RHTS Test" + +if rpm -q $PACKAGE &>/dev/null; then + Log "Running $PACKAGE-$PKG_VERS-$PKG_RELEASE" +else + Log "WARNING: Unable to locate $PACKAGE" +fi + + #################### + # Begin Test-Case + # Find result should be PASS or FAIL + #################### + +HeaderLog "Starting Test-Case" + +testcase='i shouLD be In UpPeR CaSe, yeah, I should' +Log "Testcase: '$testcase'" +res=`echo $testcase | sed -e 's/[a-z]/\u&/g'` +Log "Result: $res" + + #################### + # Check Results + #################### + +HeaderLog "Checking Results" +if [ "$res" == "I SHOULD BE IN UPPER CASE, YEAH, I SHOULD" ] +then + RESULT=PASS + Log "Seems correct: PASS" +else + RESULT=FAIL + Log "Didn't get what we expected: FAIL" +fi + +HeaderLog "Reporting Results" + +Log "TEST: $TEST | RESULT: $RESULT\n" +report_result $TEST $RESULT + +HeaderLog "End of $PACKAGE RHTS Test"