Add CI tests using the standard test interface

This commit is contained in:
Bruno Goncalves 2017-10-13 15:16:34 +02:00
parent 39af8068bb
commit 4778af1c70
7 changed files with 299 additions and 0 deletions

63
tests/fuzz/Makefile Normal file
View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/expat/Sanity/fuzz
# Description: Feed expat with various random input
# Author: Petr Splichal <psplicha@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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/expat/Sanity/fuzz
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: Petr Splichal <psplicha@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Feed expat with various random input" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 90m" >> $(METADATA)
@echo "RunFor: expat" >> $(METADATA)
@echo "Requires: expat" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

7
tests/fuzz/PURPOSE Normal file
View File

@ -0,0 +1,7 @@
PURPOSE of /CoreOS/expat/Sanity/fuzz
Description: Feed expat with various random input
Author: Petr Splichal <psplicha@redhat.com>
This is a simple fuzzer. Tries to feed the expat library with
various random input. Makes sure it does not crash on it. Files
triggering possible failures are submitted to the scheduler.

58
tests/fuzz/runtest.sh Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/expat/Sanity/fuzz
# Description: Feed expat with various random input
# Author: Petr Splichal <psplicha@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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="expat"
COUNT=${COUNT:-1000}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
for i in `seq -w $COUNT`; do
rlRun "dd if=/dev/urandom of=file$i.xml bs=1024 count=100" \
0 "Creating file$i.xml with random content"
if ! rlRun "xmlwf file$i.xml"; then
rlFileSubmit "file$i.xml"
fi
done
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

63
tests/smoke/Makefile Normal file
View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/expat/Sanity/smoke
# Description: Basic functionality test using xmlwf
# Author: Petr Splichal <psplicha@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2009 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/expat/Sanity/smoke
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: Petr Splichal <psplicha@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Basic functionality test using xmlwf" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: expat" >> $(METADATA)
@echo "Requires: expat" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

3
tests/smoke/PURPOSE Normal file
View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/expat/Sanity/smoke
Description: Basic functionality test using xmlwf
Author: Petr Splichal <psplicha@redhat.com>

93
tests/smoke/runtest.sh Executable file
View File

@ -0,0 +1,93 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/expat/Sanity/smoke
# Description: Basic functionality test using xmlwf
# Author: Petr Splichal <psplicha@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2009 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="expat"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
# create test xml documents
rlRun "echo '<?xml version=\"1.0\"?>' > empty.xml" 0 "Creating empty.xml"
rlRun "echo '<tag> <one><two></one></two> </tag>' > nesting.xml" \
0 "Creating nesting.xml"
rlRun "echo '<tag> <quote without=quote>is bad</quote> </tag>' > quoting.xml" \
0 "Creating quoting.xml"
rlRun "echo '<one>content</one><two>content</two>' > roots.xml" \
0 "Creating roots.xml"
rlRun "echo '<!DOCTYPE tag [ <!ENTITY ent SYSTEM \"nesting.xml\"> ]> <tag>&ent;</tag>' > external.xml" \
0 "Creating empty.xml"
rlRun "echo '<tag>Content with <nothing/> something <dive level=\"3\">nested</dive>.</tag>' > well.xml" \
0 "Creating well.xml"
rlRun "echo '<tag>ěščřžýáíé, 測試, בדיקה, परीक्षण, テスト, 테스트, тестирование, ทดสอบ</tag>'> utf8.xml" \
0 "Creating utf8.xml"
rlPhaseEnd
rlPhaseStartTest
# emtpy
rlRun "xmlwf empty.xml | tee output" 0 "Testing empty xml"
rlAssertGrep "no element found" "output"
# proper nesting
rlRun "xmlwf nesting.xml | tee output" 0 "Testing proper nesting"
rlAssertGrep "mismatched tag" "output"
# quoting
rlRun "xmlwf < quoting.xml | tee output" 0 "Testing quoting (and redirection)"
rlAssertGrep "invalid token" "output"
# two roots
rlRun "cat roots.xml | xmlwf | tee output" 0 "Testing proper nesting (and pipe)"
rlAssertGrep "junk after document element" "output"
# external
rlRun "xmlwf -p external.xml | tee output" 0 "Testing external entity"
rlAssertGrep "mismatched tag" "output"
rlAssertGrep "error in processing external entity" "output"
# well formed
rlRun "xmlwf well.xml | tee output" 0 "Testing well formed document"
rlAssertNotDiffer "output" "/dev/null"
# utf8 characters
rlRun "xmlwf utf8.xml | tee output" 0 "Testing document with utf8 characters"
rlAssertNotDiffer "output" "/dev/null"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

12
tests/tests.yml Normal file
View File

@ -0,0 +1,12 @@
---
# This first play always runs on the local staging system
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
- container
- atomic
tests:
- smoke
- fuzz