#!/bin/bash

export G_MESSAGES_DEBUG='all'
export TMPDIR=$AUTOPKGTEST_TMP

OUTPUT_LOG=$AUTOPKGTEST_TMP/ibus-installed-tests-output.log
RESULT_LOG=$AUTOPKGTEST_TMP/ibus-installed-tests-result.log

/usr/libexec/ibus-desktop-testing-runner \
    --no-graphics \
    --runner=gnome \
    --tests=ibus \
    --output=$OUTPUT_LOG \
    --result=$RESULT_LOG
RETVAL=$?

echo "======================================================================"
echo "=== ibus-desktop-testing-runner returned: $RETVAL"
echo "======================================================================"

echo "======================================================================"
echo "=== BEGINNING of output log"
echo "======================================================================"
cat $OUTPUT_LOG
echo "======================================================================"
echo "=== END of output log"
echo "======================================================================"
echo

echo "======================================================================"
echo "=== BEGINNING of result log"
echo "======================================================================"
cat $RESULT_LOG
echo "======================================================================"
echo "=== END of result log"
echo "======================================================================"
echo

if [ $RETVAL -eq 0 ] && grep "^FAIL: 0$" $RESULT_LOG; then
    echo "======================================================================"
    echo "=== RESULT: PASS
    echo "======================================================================"
    exit 0
else
    echo "======================================================================"
    echo "=== RESULT: FAIL
    echo "======================================================================"
    exit 1
fi
