From 7f4994679c4419a93909860bc0dc55c922bb2049 Mon Sep 17 00:00:00 2001 From: Jakub Heger Date: Sep 21 2017 07:06:00 +0000 Subject: Added python tests as examples --- diff --git a/examples/tests/python/Regression/download-via-proxy/Makefile b/examples/tests/python/Regression/download-via-proxy/Makefile new file mode 100644 index 0000000..aaed90b --- /dev/null +++ b/examples/tests/python/Regression/download-via-proxy/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/python/Regression/download-via-proxy +# Description: Test for BZ#1190900 (RHSCL python33 problem via proxy) +# Author: Jan Kejda +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# 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/python/Regression/download-via-proxy +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: Jan Kejda " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for BZ#1190900 (RHSCL python33 problem via proxy)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: python" >> $(METADATA) + @echo "Requires: python python-setuptools" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1190900" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/examples/tests/python/Regression/download-via-proxy/PURPOSE b/examples/tests/python/Regression/download-via-proxy/PURPOSE new file mode 100644 index 0000000..7dab887 --- /dev/null +++ b/examples/tests/python/Regression/download-via-proxy/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/python/Regression/download-via-proxy +Description: Test for BZ#1190900 (RHSCL python33 problem via proxy) +Author: Jan Kejda +Bug summary: RHSCL python33 problem via proxy +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1190900 diff --git a/examples/tests/python/Regression/download-via-proxy/runtest.sh b/examples/tests/python/Regression/download-via-proxy/runtest.sh new file mode 100755 index 0000000..1268dc1 --- /dev/null +++ b/examples/tests/python/Regression/download-via-proxy/runtest.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/python/Regression/download-via-proxy +# Description: Test for BZ#1190900 (RHSCL python33 problem via proxy) +# Author: Jan Kejda +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# 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/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="${PACKAGES:-python}" +REQUIRES=${REQUIRES:-} +PYTHON="${PYTHON:-python}" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "mkdir /root/pylib" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "export PYTHONPATH=~/pylib" + rlRun "export HTTP_PROXY=http://squid.brq.redhat.com:3128" + rlRun "export http_proxy=$HTTP_PROXY https_proxy=$HTTP_PROXY ftp_proxy=$HTTP_PROXY" + rlPhaseEnd + + rlPhaseStartTest + rlRun "easy_install -d $PYTHONPATH requests" 0 "Running reproducer" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -rf /root/pylib" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/Makefile b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/Makefile new file mode 100644 index 0000000..fb2504f --- /dev/null +++ b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/python/Regression/for-loop-with-urlopen-doesnt-work +# Description: Test for BZ#1203236 (rh-python34 for loop with urlopen() doesn't work) +# Author: Jan Kejda +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# 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/python/Regression/for-loop-with-urlopen-doesnt-work +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE test.py + +.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: Jan Kejda " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for BZ#1203236 (rh-python34 for loop with urlopen() doesn't work)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: python" >> $(METADATA) + @echo "Requires: python" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1203236" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/PURPOSE b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/PURPOSE new file mode 100644 index 0000000..2d9aeb9 --- /dev/null +++ b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/python/Regression/for-loop-with-urlopen-doesnt-work +Description: Test for BZ#1203236 (rh-python34 for loop with urlopen() doesn't work) +Author: Jan Kejda +Bug summary: rh-python34: for loop with urlopen() doesn't work properly when URL is ftp +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1203236 diff --git a/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/runtest.sh b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/runtest.sh new file mode 100755 index 0000000..878a161 --- /dev/null +++ b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/runtest.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/python/Regression/for-loop-with-urlopen-doesnt-work +# Description: Test for BZ#1203236 (rh-python34 for loop with urlopen() doesn't work) +# Author: Jan Kejda +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# 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/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="${PACKAGES:-python}" +REQUIRES=${REQUIRES:-} +PYTHON="${PYTHON:-python}" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp test.py $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "$PYTHON test.py" 0 "Running reproducer" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/test.py b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/test.py new file mode 100644 index 0000000..e17b3da --- /dev/null +++ b/examples/tests/python/Regression/for-loop-with-urlopen-doesnt-work/test.py @@ -0,0 +1,7 @@ +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen + +for l in urlopen('ftp://ftp.otrs.org/'): + print(l) diff --git a/examples/tests/python/Sanity/asctime/Makefile b/examples/tests/python/Sanity/asctime/Makefile new file mode 100644 index 0000000..59484c7 --- /dev/null +++ b/examples/tests/python/Sanity/asctime/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/python/Sanity/time/asctime +# Description: Sanity test for the time.asctime module +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/python/Sanity/time/asctime +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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Sanity test for the time.asctime module" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: python" >> $(METADATA) + @echo "Requires: python" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/examples/tests/python/Sanity/asctime/PURPOSE b/examples/tests/python/Sanity/asctime/PURPOSE new file mode 100644 index 0000000..a1fa594 --- /dev/null +++ b/examples/tests/python/Sanity/asctime/PURPOSE @@ -0,0 +1,6 @@ +PURPOSE of /CoreOS/python/Sanity/time/asctime +Description: Sanity test for the time.asctime module +Author: Petr Splichal + +For now just a smoke test for python issue #8013. +http://bugs.python.org/issue8013 diff --git a/examples/tests/python/Sanity/asctime/runtest.sh b/examples/tests/python/Sanity/asctime/runtest.sh new file mode 100755 index 0000000..9086315 --- /dev/null +++ b/examples/tests/python/Sanity/asctime/runtest.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/python/Sanity/time/asctime +# Description: Sanity test for the time.asctime module +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 || exit 1 +. /usr/lib/beakerlib/beakerlib.sh || exit 1 + +# Packages to be tested +PACKAGES="${PACKAGES:-python}" +# Other required packages +REQUIRES=${REQUIRES:-} +# Binary name parametrized +PYTHON="${PYTHON:-python}" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlAssertBinaryOrigin $PYTHON + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "$PYTHON -c 'import time; print(time.asctime((12345, 1, 0, 0, 0, 0, 0, 0, 0)))'" \ + 0 "Should not segfault when given a time in the far future" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/examples/tests/python/Sanity/crypt/Makefile b/examples/tests/python/Sanity/crypt/Makefile new file mode 100644 index 0000000..2d64c3f --- /dev/null +++ b/examples/tests/python/Sanity/crypt/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/python/Sanity/crypt +# Description: Sanity test for the crypt module +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/python/Sanity/crypt +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE test_crypt.py + +.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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Sanity test for the crypt module" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: python" >> $(METADATA) + @echo "Requires: python python-test" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/examples/tests/python/Sanity/crypt/PURPOSE b/examples/tests/python/Sanity/crypt/PURPOSE new file mode 100644 index 0000000..939578a --- /dev/null +++ b/examples/tests/python/Sanity/crypt/PURPOSE @@ -0,0 +1,6 @@ +PURPOSE of /CoreOS/python/Sanity/crypt +Description: Sanity test for the crypt module +Author: Petr Splichal + +Check basic functionality of the crypt module and make sure the +recent hash algorithms are supported. diff --git a/examples/tests/python/Sanity/crypt/runtest.sh b/examples/tests/python/Sanity/crypt/runtest.sh new file mode 100755 index 0000000..7aa1781 --- /dev/null +++ b/examples/tests/python/Sanity/crypt/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/python/Sanity/crypt +# Description: Sanity test for the crypt module +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 || exit 1 +. /usr/lib/beakerlib/beakerlib.sh || exit 1 + +# Packages to be tested +PACKAGES="${PACKAGES:-python}" +# Other required packages +REQUIRES=${REQUIRES:-} +# Binary name parametrized +PYTHON="${PYTHON:-python}" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlAssertBinaryOrigin $PYTHON + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp test_crypt.py $TmpDir" 0 "Copying the test" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "$PYTHON test_crypt.py" 0 "Testing the crypt module" | tee output + for algorithm in SHA512 SHA256 MD5 CRYPT; do + rlAssertGrep "METHOD_$algorithm" "output" + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/examples/tests/python/Sanity/crypt/test_crypt.py b/examples/tests/python/Sanity/crypt/test_crypt.py new file mode 100644 index 0000000..03d7d79 --- /dev/null +++ b/examples/tests/python/Sanity/crypt/test_crypt.py @@ -0,0 +1,44 @@ +import unittest +import crypt +import sys + +if sys.version_info >= (3, 0): + from test import support as test_support +else: + from test import test_support + +class CryptTestCase(unittest.TestCase): + + def test_crypt(self): + c = crypt.crypt('mypassword', 'ab') + if test_support.verbose: + print('Test encryption: ', c) + + def test_salt(self): + self.assertEqual(len(crypt._saltchars), 64) + for method in crypt.methods: + salt = crypt.mksalt(method) + self.assertEqual(len(salt), + method.salt_chars + (3 if method.ident else 0)) + + def test_saltedcrypt(self): + for method in crypt.methods: + pw = crypt.crypt('assword', method) + self.assertEqual(len(pw), method.total_size) + pw = crypt.crypt('assword', crypt.mksalt(method)) + self.assertEqual(len(pw), method.total_size) + + def test_methods(self): + # Gurantee that METHOD_CRYPT is the last method in crypt.methods. + self.assertTrue(len(crypt.methods) >= 1) + self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1]) + +def test_main(): + test_support.run_unittest(CryptTestCase) + if test_support.verbose: + print("\nSupported methods:\n" + "~" * 70) + for method in crypt.methods: + print(method) + +if __name__ == "__main__": + test_main() diff --git a/examples/tests/python/Sanity/embedded/Makefile b/examples/tests/python/Sanity/embedded/Makefile new file mode 100644 index 0000000..0cfdcb4 --- /dev/null +++ b/examples/tests/python/Sanity/embedded/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/python/Sanity/embedded +# Description: Smoke test for apps embedding Python +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/python/Sanity/embedded +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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Smoke test for apps embedding Python" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: python" >> $(METADATA) + @echo "Requires: python gedit inkscape fontforge rhythmbox totem xorg-x11-server-Xvfb dbus-x11 gnome-python2-gnome mesa-dri-drivers" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/examples/tests/python/Sanity/embedded/PURPOSE b/examples/tests/python/Sanity/embedded/PURPOSE new file mode 100644 index 0000000..db5c78b --- /dev/null +++ b/examples/tests/python/Sanity/embedded/PURPOSE @@ -0,0 +1,7 @@ +PURPOSE of /CoreOS/python/Sanity/embedded +Description: Smoke test for apps embedding Python +Author: Petr Splichal + +Prepare a virtual display and perform a simple smoke test for GUI +applications embedding Python (for now gedit, inkscape, fontforge, +rhythmbox and totem covered). diff --git a/examples/tests/python/Sanity/embedded/runtest.sh b/examples/tests/python/Sanity/embedded/runtest.sh new file mode 100755 index 0000000..7d9c082 --- /dev/null +++ b/examples/tests/python/Sanity/embedded/runtest.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/python/Sanity/embedded +# Description: Smoke test for apps embedding Python +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 || exit 1 +. /usr/lib/beakerlib/beakerlib.sh || exit 1 + +# Packages to be tested +PACKAGES="${PACKAGES:-python}" +# Other required packages +REQUIRES=${REQUIRES:-} +# Binary name parametrized +PYTHON="${PYTHON:-python}" + +# On RHEL5 only totem available in the base repo +if rlIsRHEL 5; then + AppList="totem" +# inkscape & rhythmbox not available for s390x +elif [[ $(uname -i) =~ "s390" ]]; then + AppList="fontforge totem" +# rhythmbox is not available for rhel-7 server +elif rlIsRHEL '>=7'; then + AppList="gedit inkscape fontforge totem" +else + AppList="gedit inkscape fontforge rhythmbox totem" +fi + +rlJournalStart + rlPhaseStartSetup + # check packages + rlAssertRpm --all + rlAssertBinaryOrigin $PYTHON + for app in $AppList; do + rlAssertRpm $app + done + + # start virtual display + rlRun "rlVirtualXStart $TEST" 0 "Starting Virtual X Server" + export DISPLAY=$(rlVirtualXGetDisplay $TEST) + rlPhaseEnd + + rlPhaseStartTest + # run the app, wait for a few seconds and attempt to kill it + for app in $AppList; do + rlRun "$app &" 0 "Running $app" + rlRun "sleep 10; kill $!" 0 "Checking $app" + done + rlPhaseEnd + + rlPhaseStartCleanup + # stop virtual display + rlRun "rlVirtualXStop $TEST" 0 "Stopping virtual X server" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/examples/tests/python/Sanity/expat/Makefile b/examples/tests/python/Sanity/expat/Makefile new file mode 100644 index 0000000..b26f46d --- /dev/null +++ b/examples/tests/python/Sanity/expat/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/python/Sanity/xml/parsers/expat +# Description: Smoke test for the xml.parsers.expat +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/python/Sanity/xml/parsers/expat +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE test.py + +.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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Smoke test for the xml.parsers.expat" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: python" >> $(METADATA) + @echo "Requires: PyXML python" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/examples/tests/python/Sanity/expat/PURPOSE b/examples/tests/python/Sanity/expat/PURPOSE new file mode 100644 index 0000000..94ada3d --- /dev/null +++ b/examples/tests/python/Sanity/expat/PURPOSE @@ -0,0 +1,8 @@ +PURPOSE of /CoreOS/python/Sanity/xml/parsers/expat +Description: Smoke test for the xml.parsers.expat +Author: Petr Splichal + +Simple smoke test for the xml.parsers.expat module. Checks the +functionality twice, with PyXML and without PyXML installed, as +PyXML, if present, overrides the internal expat parser, which +now should use the system libexpat rather than its own copy. diff --git a/examples/tests/python/Sanity/expat/runtest.sh b/examples/tests/python/Sanity/expat/runtest.sh new file mode 100755 index 0000000..356a34a --- /dev/null +++ b/examples/tests/python/Sanity/expat/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/python/Sanity/xml/parsers/expat +# Description: Smoke test for the xml.parsers.expat +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 || exit 1 +. /usr/lib/beakerlib/beakerlib.sh || exit 1 + +# Packages to be tested +PACKAGES="${PACKAGES:-python}" +# Other required packages +REQUIRES=${REQUIRES:-} +# Binary name parametrized +PYTHON="${PYTHON:-python}" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlAssertBinaryOrigin $PYTHON + rlRun "PyXmlDir=$(rpm -ql PyXML | grep '_xmlplus$' | uniq)" + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "cp test.py $TmpDir" 0 "Copying the test script" + rlRun "pushd $TmpDir" + rlPhaseEnd + + scenario="With_PyXML Without_PyXML" + # PyXML package not available in RHEL-7 + rlIsRHEL '>=7' && scenario="Without_PyXML" + for way in $scenario; do + rlPhaseStartTest "$way" + # disable PyXML in second round + if [[ $way =~ 'Without' && -n $PyXmlDir ]]; then + rlRun "mv $PyXmlDir{,.hidden}" 0 "Hiding PyXML" + fi + rlRun "$PYTHON test.py | tee output" 0 "Running test script" + rlAssertGrep "Start element: parent {u?'id': u?'top'}" "output" -E + rlAssertGrep "Start element: child1 {u?'name': u?'paul'}" "output" -E + rlAssertGrep "Character data: u?'Text goes here'" "output" -E + rlAssertGrep "End element: child1" "output" + rlAssertGrep "End element: parent" "output" + rlPhaseEnd + done + + rlPhaseStartCleanup + if [[ -n $PyXmlDir ]]; then + rlRun "mv $PyXmlDir{.hidden,}" 0 "Restoring PyXML" + fi + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/examples/tests/python/Sanity/expat/test.py b/examples/tests/python/Sanity/expat/test.py new file mode 100644 index 0000000..81e128f --- /dev/null +++ b/examples/tests/python/Sanity/expat/test.py @@ -0,0 +1,23 @@ +import xml.parsers.expat + +# 3 handler functions +def start_element(name, attrs): + print("\nStart element: %s %s" % (name, attrs)) + +def end_element(name): + print("End element: %s \n" % (name)) + +def char_data(data): + print("Character data: %s" % (repr(data))) + +p = xml.parsers.expat.ParserCreate() + +p.StartElementHandler = start_element +p.EndElementHandler = end_element +p.CharacterDataHandler = char_data + +p.Parse(""" + + Text goes here + More text +""", 1)