summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2018-04-03 17:51:09 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2018-04-03 17:51:09 +0900
commitcb4b5458b3b021786d9ee9ebc5e065d7eeda359e (patch)
tree238fdd5d52f6f855488f55bcf2a2c1a29ff33ea0
parent9d577ef3bbdca8dbf8a2cfe283c0e1e246cf6ba7 (diff)
downloadibus-anthy-cb4b5458b3b021786d9ee9ebc5e065d7eeda359e.tar.gz
tests: Enabled tests on console
-rw-r--r--tests/Makefile.am57
-rwxr-xr-xtests/test-build.sh142
-rwxr-xr-xtests/test-console.sh168
3 files changed, 313 insertions, 54 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9a74820..45cc01c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,62 +20,11 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
check:
- ARGS="--exit"; \
- if test x$(FORCE_TEST) != x ; then \
- ARGS="$$ARGS --force"; \
- fi; \
- ANTHY_SCHEMA_FILE=org.freedesktop.ibus.engine.anthy.gschema.xml; \
- if test \! -f $(builddir)/../data/$$ANTHY_SCHEMA_FILE ; then \
- echo "Not found $(builddir)/../data/$$ANTHY_SCHEMA_FILE"; \
- exit -1; \
- fi; \
- SCHEMA_TMPDIR=`mktemp -d`; \
- if test $$? -ne 0 ; then \
- echo "FAILED mktemp"; \
- exit -1; \
- fi; \
- cp $(builddir)/../data/$$ANTHY_SCHEMA_FILE $$SCHEMA_TMPDIR; \
- glib-compile-schemas $$SCHEMA_TMPDIR; \
- if test $$? -ne 0 ; then \
- echo "FAILED glib-compile-schemas $$SCHEMA_TMPDIR"; \
- exit -1; \
- fi; \
- if test \! -f $$SCHEMA_TMPDIR/gschemas.compiled ; then \
- echo "Not found $$SCHEMA_TMPDIR/gschemas.compiled"; \
- exit -1; \
- fi; \
- ls $(builddir)/../gir/Anthy*.typelib > /dev/null; \
- if test $$? -ne 0 ; then \
- echo "Not found $(builddir)/../gir/Anthy*.typelib"; \
- exit -1; \
- fi; \
- ibus-daemon --daemonize --verbose; \
- sleep 1; \
- SUSER=`echo "$$USER" | cut -c 1-7`; \
- ps -ef | grep "$$SUSER" | grep ibus | grep -v grep; \
- export GSETTINGS_SCHEMA_DIR=$$SCHEMA_TMPDIR; \
- export GI_TYPELIB_PATH=$(builddir)/../gir; \
- LD_LIBRARY_PATH=$(builddir)/../gir/.libs; \
- export LD_LIBRARY_PATH=$${LD_LIBRARY_PATH}:$(builddir)/../gir; \
- export GTK_IM_MODULE=ibus; \
- echo "#### Starting Python3 API test $$ARGS"; \
- env IBUS_ANTHY_ENGINE_PATH=$(srcdir)/../engine/python3 \
- IBUS_ANTHY_SETUP_PATH=$(srcdir)/../setup/python3 \
- python3 -u $(srcdir)/anthytest.py $$ARGS; \
- if test $$? -ne 0 ; then \
- exit -1; \
- fi; \
- if test x$(FORCE_TEST) = x ; then \
- rm -r $$HOME/.anthy; \
- fi; \
- echo "#### Starting Python2 API test"; \
- env IBUS_ANTHY_ENGINE_PATH=$(srcdir)/../engine/python2 \
- IBUS_ANTHY_SETUP_PATH=$(srcdir)/../setup/python2 \
- python2 -u $(srcdir)/anthytest.py $$ARGS; \
- rm -rf $$SCHEMA_TMPDIR; \
- ibus exit
+ bash -x test-build.sh --builddir=$(builddir) --srcdir=$(srcdir)
EXTRA_DIST = \
anthycases.py \
anthytest.py \
+ test-build.sh \
+ test-console.sh \
$(NULL)
diff --git a/tests/test-build.sh b/tests/test-build.sh
new file mode 100755
index 0000000..75060cf
--- /dev/null
+++ b/tests/test-build.sh
@@ -0,0 +1,142 @@
+#!/bin/sh
+# vim:set noet ts=4:
+#
+# ibus-anthy - The Anthy engine for IBus
+#
+# Copyright (c) 2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2018 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+
+# This test runs $(top_builddir)/engine/python*/engine.py before install anthy
+
+BUILDDIR=".";
+SRCDIR=".";
+ANTHY_SCHEMA_FILE=org.freedesktop.ibus.engine.anthy.gschema.xml;
+SCHEMA_TMPDIR="";
+FORCE_TEST="";
+RUN_ARGS="--exit";
+
+usage()
+{
+ echo -e \
+"This test runs top_builddir/engine/python*/engine.py before install anthy\n" \
+"$PROGNAME [OPTIONS…]\n" \
+"\n" \
+"OPTIONS:\n" \
+"-h, --help This help\n" \
+"-v, --version Show version\n" \
+"-b, --builddir=BUILDDIR Set the BUILDDIR\n" \
+"-s, --srcdir=SOURCEDIR Set the SOURCEDIR\n" \
+"-f, --force Run test suite forcibly\n" \
+""
+}
+
+parse_args()
+{
+ # This is GNU getopt. "sudo port getopt" in BSD?
+ ARGS=`getopt -o hvb:s: --long help,version,builddir:,srcdir: \
+ -- "$@"`;
+ eval set -- "$ARGS"
+ while [ 1 ] ; do
+ case "$1" in
+ -h | --help ) usage; exit 0;;
+ -v | --version ) echo -e "$VERSION"; exit 0;;
+ -b | --builddir ) BUILDDIR="$2"; shift 2;;
+ -s | --srcdir ) SRCDIR="$2"; shift 2;;
+ -f | --force ) FORCE_TEST="1"; shift;;
+ -- ) shift; break;;
+ * ) usage; exit 1;;
+ esac;
+ done;
+}
+
+init_environment()
+{
+ if test x$FORCE_TEST != x ; then
+ RUN_ARGS="$RUN_ARGS --force";
+ fi;
+ if test ! -f $BUILDDIR/../data/$ANTHY_SCHEMA_FILE ; then
+ echo "Not found $BUILDDIR/../data/$ANTHY_SCHEMA_FILE";
+ exit -1;
+ fi;
+ SCHEMA_TMPDIR=`mktemp -d`;
+ if test $? -ne 0 ; then
+ echo "FAILED mktemp";
+ exit -1;
+ fi;
+ cp $BUILDDIR/../data/$ANTHY_SCHEMA_FILE $SCHEMA_TMPDIR;
+ glib-compile-schemas $SCHEMA_TMPDIR;
+ if test $? -ne 0 ; then
+ echo "FAILED glib-compile-schemas $SCHEMA_TMPDIR";
+ exit -1;
+ fi;
+ if test ! -f $SCHEMA_TMPDIR/gschemas.compiled ; then
+ echo "Not found $SCHEMA_TMPDIR/gschemas.compiled";
+ exit -1;
+ fi;
+ ls $BUILDDIR/../gir/Anthy*.typelib > /dev/null;
+ if test $? -ne 0 ; then
+ echo "Not found $BUILDDIR/../gir/Anthy*.typelib";
+ exit -1;
+ fi;
+}
+
+run_ibus_daemon()
+{
+ ibus-daemon --daemonize --verbose;
+ sleep 1;
+ SUSER=`echo "$USER" | cut -c 1-7`;
+ ps -ef | grep "$SUSER" | grep ibus | grep -v grep;
+}
+
+run_test_suite()
+{
+ export GSETTINGS_SCHEMA_DIR=$SCHEMA_TMPDIR;
+ export GI_TYPELIB_PATH=$BUILDDIR/../gir;
+ LD_LIBRARY_PATH=$BUILDDIR/../gir/.libs;
+ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$BUILDDIR/../gir;
+ export GTK_IM_MODULE=ibus;
+
+ for i in 3 2 ; do
+ echo "#### Starting Python$i API test $RUN_ARGS";
+ env IBUS_ANTHY_ENGINE_PATH=$SRCDIR/../engine/python$i \
+ IBUS_ANTHY_SETUP_PATH=$SRCDIR/../setup/python$i \
+ python$i -u $SRCDIR/anthytest.py $RUN_ARGS;
+ if test $? -ne 0 ; then
+ exit -1;
+ fi;
+ if test x$FORCE_TEST = x ; then
+ rm -r $HOME/.anthy;
+ fi;
+ done;
+}
+
+finit()
+{
+ rm -rf $SCHEMA_TMPDIR;
+ ibus exit;
+}
+
+main()
+{
+ parse_args $@;
+ init_environment;
+ run_ibus_daemon;
+ run_test_suite;
+ finit;
+}
+
+main $@;
diff --git a/tests/test-console.sh b/tests/test-console.sh
new file mode 100755
index 0000000..3cb8ec6
--- /dev/null
+++ b/tests/test-console.sh
@@ -0,0 +1,168 @@
+#!/bin/sh
+# vim:set noet ts=4:
+#
+# ibus-anthy - The Anthy engine for IBus
+#
+# Copyright (c) 2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2018 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+
+# This test runs /usr/share/ibus-anthy/engine/engine.py after install anthy
+
+PROGNAME=`basename $0`;
+VERSION=0.1;
+DISPLAY=:99.0;
+BUILDDIR=".";
+SRCDIR=".";
+HAVE_GRAPHICS=1;
+DESKTOP_COMMAND="gnome-session";
+PYTHON="python3";
+PID_XORG=0;
+PID_GNOME_SESSION=0;
+FORCE_TEST="";
+RUN_ARGS="--exit";
+
+usage()
+{
+ echo -e \
+"This test runs /usr/share/ibus-anthy/engine/engine.py after install anthy\n" \
+"$PROGNAME [OPTIONS…]\n" \
+"\n" \
+"OPTIONS:\n" \
+"-h, --help This help\n" \
+"-v, --version Show version\n" \
+"-b, --builddir=BUILDDIR Set the BUILDDIR\n" \
+"-s, --srcdir=SOURCEDIR Set the SOURCEDIR\n" \
+"-c, --no-graphics Use Xvfb instead of Xorg\n" \
+"-p, --python=PATH Use the PATH of python2 or python3\n" \
+"-d, --desktop=DESKTOP Run DESTKTOP. The default is gnome-session\n"\
+"-f, --force Run test suite forcibly\n" \
+""
+}
+
+parse_args()
+{
+ # This is GNU getopt. "sudo port getopt" in BSD?
+ ARGS=`getopt -o hvb:s:cp:d:f --long help,version,builddir:,srcdir:,no-graphics,python:,desktop:,force \
+ -- "$@"`;
+ eval set -- "$ARGS"
+ while [ 1 ] ; do
+ case "$1" in
+ -h | --help ) usage; exit 0;;
+ -v | --version ) echo -e "$VERSION"; exit 0;;
+ -b | --builddir ) BUILDDIR="$2"; shift 2;;
+ -s | --srcdir ) SRCDIR="$2"; shift 2;;
+ -c | --no-graphics ) HAVE_GRAPHICS=0; shift;;
+ -p | --python ) PYTHON="$2"; shift 2;;
+ -d | --desktop ) DESKTOP_COMMAND="$2"; shift 2;;
+ -f | --force ) FORCE_TEST="1"; shift;;
+ -- ) shift; break;;
+ * ) usage; exit 1;;
+ esac;
+ done;
+}
+
+init_desktop()
+{
+ if test x$FORCE_TEST != x ; then
+ RUN_ARGS="$RUN_ARGS --force";
+ fi;
+
+ if test ! -f $HOME/.config/gnome-initial-setup-done ; then
+ if test ! -f /var/lib/AccountsService/users/$USER ; then
+ mkdir -p /var/lib/AccountsService/users
+ cat >> /var/lib/AccountsService/users/$USER << _EOF
+[User]
+Language=ja_JP.UTF-8
+XSession=gnome
+SystemAccount=false
+_EOF
+ fi
+ mkdir -p $HOME/.config
+ touch $HOME/.config/gnome-initial-setup-done
+ fi
+}
+
+run_dbus_daemon()
+{
+ a=`ps -ef | grep dbus-daemon | grep "\-\-system" | grep -v session | grep -v grep`
+ if test x"$a" = x ; then
+ eval `dbus-launch --sh-syntax`
+ fi
+ SUSER=`echo "$USER" | cut -c 1-7`;
+ a=`ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | grep session | grep -v grep`
+ if test x"$a" = x ; then
+ systemctl --user start dbus
+ export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus
+ fi
+ systemctl --user status dbus | col -b
+ ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | egrep 'session|system' | grep -v grep
+ systemctl --user show-environment | col -b
+}
+
+run_desktop()
+{
+ if test $HAVE_GRAPHICS -eq 1 ; then
+ /usr/libexec/Xorg.wrap -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xorg.log -config ./xorg.conf -configdir . $DISPLAY &
+ else
+ /usr/bin/Xvfb $DISPLAY -noreset +extension GLX +extension RANDR +extension RENDER -screen 0 1280x1024x24 &
+ fi;
+ PID_XORG=$!;
+ sleep 1;
+ export DISPLAY=$DISPLAY;
+ $DESKTOP_COMMAND &
+ PID_GNOME_SESSION=$!;
+ sleep 30;
+ if test "$DESKTOP_COMMAND" != "gnome-session" ; then
+ ibus-daemon --daemonize --verbose;
+ sleep 1;
+ fi
+}
+
+run_test_suite()
+{
+ rm -rf /root/.anthy;
+ cd `dirname $0`;
+
+ echo "#### Starting $PYTHON API test $RUN_ARGS";
+ $PYTHON -u $SRCDIR/anthytest.py $RUN_ARGS;
+ if test $? -ne 0 ; then
+ exit -1;
+ fi;
+ if test x$FORCE_TEST = x ; then
+ rm -r $HOME/.anthy;
+ fi;
+}
+
+finit()
+{
+ if "test $DESKTOP_COMMAND" != "gnome-session" ; then
+ ibus exit;
+ fi;
+ kill $PID_GNOME_SESSION $PID_XORG;
+}
+
+main()
+{
+ parse_args $@;
+ init_desktop;
+ run_dbus_daemon;
+ run_desktop;
+ run_test_suite;
+ finit;
+}
+
+main $@;