cf6e767
#!/bin/bash
cf6e767
. /usr/share/beakerlib/beakerlib.sh || exit 1
cf6e767
cf6e767
NAME=ibus-table
4f5ba21
XFWB_SCRIPT=$(pwd)/xwfb-script.sh
cf6e767
cf6e767
rlJournalStart
cf6e767
    rlPhaseStartSetup
cf6e767
        rlAssertRpm ${NAME}
cf6e767
        rlAssertRpm gnome-desktop-testing
cf6e767
        rlAssertRpm gnome-shell-extension-no-overview
cf6e767
        rlAssertBinaryOrigin gnome-desktop-testing-runner gnome-desktop-testing
cf6e767
        rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
cf6e767
        rlRun "pushd $tmp"
cf6e767
    rlPhaseEnd
cf6e767
4f5ba21
#    rlPhaseStartTest
4f5ba21
#        rlRun "ibus-desktop-testing-runner \
4f5ba21
#          --no-graphics \
4f5ba21
#          --runner=gnome \
4f5ba21
#          --timeout=1500 \
4f5ba21
#          --tests=${NAME} \
4f5ba21
#          --output=${NAME}.log \
4f5ba21
#          --result=test.log \
4f5ba21
#          " 0 "Running ${NAME} tests"
4f5ba21
#        echo "==== ${NAME}.log: ===="
4f5ba21
#        cat ${NAME}.log
4f5ba21
#        echo "==== EOF ${NAME}.log: ===="
4f5ba21
#        echo "==== test.log ===="
4f5ba21
#        cat test.log
4f5ba21
#        echo "==== EOF test.log: ===="
4f5ba21
#        rlAssertNotGrep FAIL test.log
4f5ba21
#        rlFileSubmit ${NAME}.log
4f5ba21
#        rlFileSubmit test.log
4f5ba21
#    rlPhaseEnd
4f5ba21
cf6e767
    rlPhaseStartTest
4f5ba21
        rlRun -t -l "pushd /usr/libexec/installed-tests/ibus-table" \
4f5ba21
              0 "Change to directory of installed tests"
4f5ba21
        TEST_FILES="test_*.py"
4f5ba21
        # When running locally with `tmt run -vvv -a provision -h local`
4f5ba21
        # DISPLAY might be set here and XDG_SESSION_TYPE might be "x11".
4f5ba21
        # In that case, all tests, including the graphical test_0_gtk.py
4f5ba21
        # will run fine in this "for" loop. Otherwise the graphical
4f5ba21
        # test_0_gtk.py in this for loop will be skipped:
4f5ba21
        for test_file in ${TEST_FILES}
4f5ba21
        do
4f5ba21
            rlRun -t -s "./run_tests ${test_file}" 0
4f5ba21
            echo "==== START of `cat ${rlRun_LOG}`: log of ${test_file} ===="
4f5ba21
            cat ${rlRun_LOG}
4f5ba21
            echo "==== END of `cat ${rlRun_LOG}`: log of ${test_file} ===="
4f5ba21
            rlAssertNotGrep FAIL ${rlRun_LOG}
4f5ba21
            rlGetTestState
4f5ba21
            rlLog "Number of failed asserts so far: ${ECODE}"
4f5ba21
            rlFileSubmit ${rlRun_LOG}
4f5ba21
        done
4f5ba21
        if [ -z "${DISPLAY:-}" ]; then
4f5ba21
            rlLogInfo "DISPLAY is empty or unset."
4f5ba21
            rlLogInfo "Therefore, use xfwb-run to run the graphical test_0_gtk.py:"
4f127aa
            rlRun -t -s "xwfb-run -c mutter -e $tmp/xwfb-run.log -n 99 $XFWB_SCRIPT" \
4f5ba21
                  0 "Running test_0_gtk.py in xfwb-run"
4f5ba21
            echo "==== START of `cat ${rlRun_LOG}`: log of xwfb-run ===="
4f5ba21
            cat ${rlRun_LOG}
4f5ba21
            echo "==== END of `cat ${rlRun_LOG}`: log of xwfb-run ===="
4f5ba21
            rlAssertNotGrep FAIL ${rlRun_LOG}
4f5ba21
            rlGetTestState
4f5ba21
            rlLog "Total number of failed asserts: ${ECODE}"
4f5ba21
            rlFileSubmit ${rlRun_LOG}
4f5ba21
            rlFileSubmit xwfb-run.log
4f5ba21
        fi
4f5ba21
        rlGetTestState
4f5ba21
        rlLog "Total number of failed asserts: ${ECODE}"
4f5ba21
        rlRun "popd" 0
cf6e767
    rlPhaseEnd
cf6e767
cf6e767
    rlPhaseStartCleanup
cf6e767
        rlRun "popd"
cf6e767
        rlRun "rm -r $tmp" 0 "Remove tmp directory"
cf6e767
    rlPhaseEnd
cf6e767
rlJournalEnd