rasibley / rpms / python3

Forked from rpms/python3 6 years ago
Clone
Blob Blame History Raw
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#   runtest.sh of /CoreOS/python/sys
#   Description: Sanity test for the sys module
#   Author: Petr Splichal <psplicha@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#   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 Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1

# Packages to be tested
PACKAGES="${PACKAGES:-python3}"
# Other required packages
REQUIRES=${REQUIRES:-}
# Binary name parametrized
PYTHON="${PYTHON:-python3}"

# print("linux2" if sys.version_info < (3, 3) else "linux") for python2.4 on RHEL5
PLATFORM_CMD='import sys; print(sys.version_info < (3, 3) and "linux2" or "linux")'

rlJournalStart
    rlPhaseStartSetup
        rlAssertRpm --all
        rlAssertBinaryOrigin $PYTHON
        rlRun "TMP=\$(mktemp -d)" 0 "Creating tmp directory"
        rlRun "pushd $TMP"
    rlPhaseEnd

    rlPhaseStartTest
        rlRun -l "$PYTHON -V" 0 "Query version of the binary"
        PLATFORM_STR=$($PYTHON -c "$PLATFORM_CMD")
        rlRun "$PYTHON -c 'import sys; print(sys.platform)' | tee output" \
                0 "Inspecting the value of sys.platform"
        rlAssertGrep $PLATFORM_STR "output"
    rlPhaseEnd

    rlPhaseStartCleanup
        rlRun "popd"
        rlRun "rm -r $TMP" 0 "Removing tmp directory"
    rlPhaseEnd
rlJournalPrintText
rlJournalEnd