Blame SOURCES/ibus-1682157-ci.patch

3dab36
From c360cbd830943a4bfb0ece9cc07b99a426dc2121 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Mon, 9 Apr 2018 11:57:09 +0900
3dab36
Subject: [PATCH] src/tests: Add ibus-compose.env
3dab36
3dab36
---
3dab36
 src/tests/ibus-compose.env | 3 +++
3dab36
 1 file changed, 3 insertions(+)
3dab36
 create mode 100644 src/tests/ibus-compose.env
3dab36
3dab36
diff --git a/src/tests/ibus-compose.env b/src/tests/ibus-compose.env
3dab36
new file mode 100644
3dab36
index 00000000..734ab8fa
3dab36
--- /dev/null
3dab36
+++ b/src/tests/ibus-compose.env
3dab36
@@ -0,0 +1,3 @@
3dab36
+LANG=el_GR.UTF-8
3dab36
+LANG=fi_FI.UTF-8
3dab36
+LANG=pt_BR.UTF-8
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From b497de5bc6525769e03b65c73fc991d4aa006223 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Wed, 20 Mar 2019 17:44:26 +0900
3dab36
Subject: [PATCH] test: Set GTK_IM_MODULE in test-console.sh
3dab36
3dab36
---
3dab36
 src/tests/Makefile.am |  4 ++--
3dab36
 2 files changed, 14 insertions(+), 2 deletions(-)
3dab36
3dab36
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
3dab36
index e337a59b..e2ff5ea7 100644
3dab36
--- a/src/tests/Makefile.am
3dab36
+++ b/src/tests/Makefile.am
3dab36
@@ -3,7 +3,7 @@
3dab36
 # ibus - The Input Bus
3dab36
 #
3dab36
 # Copyright (c) 2007-2015 Peng Huang <shawn.p.huang@gmail.com>
3dab36
-# Copyright (c) 2015-2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
3dab36
+# Copyright (c) 2015-2019 Takao Fujiwara <takao.fujiwara1@gmail.com>
3dab36
 # Copyright (c) 2007-2018 Red Hat, Inc.
3dab36
 #
3dab36
 # This library is free software; you can redistribute it and/or
3dab36
@@ -78,7 +78,7 @@ TESTS_ENVIRONMENT = \
3dab36
 
3dab36
 LOG_COMPILER = $(srcdir)/runtest
3dab36
 
3dab36
-EXTRA_DIST = runtest
3dab36
+EXTRA_DIST = runtest ibus-compose.env
3dab36
 
3dab36
 ibus_bus_SOURCES = ibus-bus.c
3dab36
 ibus_bus_LDADD = $(prog_ldadd)
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From ac492f31b435b9464d591094d470bc94027168e8 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Fri, 28 Jun 2019 21:15:07 +0900
3dab36
Subject: [PATCH] src/tests: Fix ibus-compose for IBusComposeTableEx
3dab36
3dab36
Recently IBusComposeTablEx has been integrated and the return value of
3dab36
ibus_compose_table_new_with_file() is also changed and ibus-compose
3dab36
needs to be updated.
3dab36
3dab36
Clear IBusComposeTablePrivate in ibus_compose_table_list_add_array()
3dab36
for the ibus-compose testing.
3dab36
3dab36
Clear compose_buffer in IBusEngineSimple.
3dab36
3dab36
Use g_get_language_names_with_category instead() of g_get_locale_variants().
3dab36
3dab36
Add ibus-compose.emoji for the tests of long compose sequences and
3dab36
multiple compose output characters.
3dab36
3dab36
IBUS_COMPOSE_CACHE_DIR variable is added for the temporary caches.
3dab36
---
3dab36
 src/ibuscomposetable.c       |  15 ++--
3dab36
 src/tests/Makefile.am        |   2 +-
3dab36
 src/tests/ibus-compose.c     |  10 +++
3dab36
 src/tests/ibus-compose.emoji |  11 +++
3dab36
 src/tests/ibus-compose.env   |   1 +
3dab36
 src/tests/runtest            |   4 +-
3dab36
 9 files changed, 174 insertions(+), 47 deletions(-)
3dab36
 create mode 100644 src/tests/ibus-compose.emoji
3dab36
3dab36
diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c
3dab36
index 4ac54e25..5fd37f10 100644
3dab36
--- a/src/ibuscomposetable.c
3dab36
+++ b/src/ibuscomposetable.c
3dab36
@@ -497,13 +497,18 @@ static gchar *
3dab36
 ibus_compose_hash_get_cache_path (guint32 hash)
3dab36
 {
3dab36
     gchar *basename = NULL;
3dab36
+    const gchar *cache_dir;
3dab36
     gchar *dir = NULL;
3dab36
     gchar *path = NULL;
3dab36
 
3dab36
     basename = g_strdup_printf ("%08x.cache", hash);
3dab36
 
3dab36
-    dir = g_build_filename (g_get_user_cache_dir (),
3dab36
-                            "ibus", "compose", NULL);
3dab36
+    if ((cache_dir = g_getenv ("IBUS_COMPOSE_CACHE_DIR"))) {
3dab36
+        dir = g_strdup (cache_dir);
3dab36
+    } else {
3dab36
+        dir = g_build_filename (g_get_user_cache_dir (),
3dab36
+                                "ibus", "compose", NULL);
3dab36
+    }
3dab36
     path = g_build_filename (dir, basename, NULL);
3dab36
     if (g_mkdir_with_parents (dir, 0755) != 0) {
3dab36
         g_warning ("Failed to mkdir %s", dir);
3dab36
@@ -1068,7 +1073,7 @@ ibus_compose_table_list_add_array (GSList        *compose_tables,
3dab36
     for (i = 0; i < length; i++)
3dab36
         ibus_compose_seqs[i] = data[i];
3dab36
 
3dab36
-    compose_table = g_new (IBusComposeTable, 1);
3dab36
+    compose_table = g_new0 (IBusComposeTable, 1);
3dab36
     compose_table->data = ibus_compose_seqs;
3dab36
     compose_table->max_seq_len = max_seq_len;
3dab36
     compose_table->n_seqs = n_seqs;
3dab36
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
3dab36
index e2ff5ea7..a58504a3 100644
3dab36
--- a/src/tests/Makefile.am
3dab36
+++ b/src/tests/Makefile.am
3dab36
@@ -78,7 +78,7 @@ TESTS_ENVIRONMENT = \
3dab36
 
3dab36
 LOG_COMPILER = $(srcdir)/runtest
3dab36
 
3dab36
-EXTRA_DIST = runtest ibus-compose.env
3dab36
+EXTRA_DIST = runtest ibus-compose.emoji ibus-compose.env
3dab36
 
3dab36
 ibus_bus_SOURCES = ibus-bus.c
3dab36
 ibus_bus_LDADD = $(prog_ldadd)
3dab36
diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c
3dab36
index e2ff5ea7..a58504a3 100644
3dab36
--- a/src/tests/ibus-compose.c
3dab36
+++ b/src/tests/ibus-compose.c
3dab36
@@ -7,8 +7,10 @@
3dab36
 #define NC    "\033[0m"
3dab36
 
3dab36
 IBusBus *m_bus;
3dab36
+gchar *m_compose_file;
3dab36
 IBusComposeTable *m_compose_table;
3dab36
 IBusEngine *m_engine;
3dab36
+gchar *m_srcdir;
3dab36
 int m_retval;
3dab36
 
3dab36
 static gboolean window_focus_in_event_cb (GtkWidget     *entry,
3dab36
@@ -31,8 +33,11 @@ create_engine_cb (IBusFactory *factory,
3dab36
                                           engine_path,
3dab36
                                           ibus_bus_get_connection (m_bus));
3dab36
     g_free (engine_path);
3dab36
-    langs = g_get_language_names ();
3dab36
-    for (l = langs; *l; l++) {
3dab36
+    if (m_compose_file) {
3dab36
+      compose_path = g_build_filename (m_srcdir, m_compose_file, NULL);
3dab36
+    } else {
3dab36
+      langs = g_get_language_names ();
3dab36
+      for (l = langs; *l; l++) {
3dab36
         if (g_str_has_prefix (*l, "en_US"))
3dab36
             break;
3dab36
         if (g_strcmp0 (*l, "C") == 0)
3dab36
@@ -41,10 +46,11 @@ create_engine_cb (IBusFactory *factory,
3dab36
                                          *l,
3dab36
                                          "Compose",
3dab36
                                          NULL);
3dab36
         if (g_file_test (compose_path, G_FILE_TEST_EXISTS))
3dab36
             break;
3dab36
         g_free (compose_path);
3dab36
         compose_path = NULL;
3dab36
+      }
3dab36
     }
3dab36
     if (compose_path != NULL) {
3dab36
         m_compose_table = ibus_compose_table_new_with_file (compose_path);
3dab36
@@ -248,6 +254,9 @@ main (int argc, char *argv[])
3dab36
     ibus_init ();
3dab36
     gtk_init (&argc, &argv);
3dab36
 
3dab36
+    m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup (".");
3dab36
+    m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE"));
3dab36
+
3dab36
     if (!register_ibus_engine ())
3dab36
         return -1;
3dab36
 
3dab36
diff --git a/src/tests/ibus-compose.emoji b/src/tests/ibus-compose.emoji
3dab36
new file mode 100644
3dab36
index 00000000..7fbf82cf
3dab36
--- /dev/null
3dab36
+++ b/src/tests/ibus-compose.emoji
3dab36
@@ -0,0 +1,2 @@
3dab36
+<Multi_key> <Multi_key> <l> <e> <o>             : "♌"  U264C   # LEO
3dab36
+<Multi_key> <Multi_key>  <n> <t>             : "∫"
3dab36
diff --git a/src/tests/ibus-compose.env b/src/tests/ibus-compose.env
3dab36
index 734ab8fa..a9e289e4 100644
3dab36
--- a/src/tests/ibus-compose.env
3dab36
+++ b/src/tests/ibus-compose.env
3dab36
@@ -1,3 +1,4 @@
3dab36
 LANG=el_GR.UTF-8
3dab36
 LANG=fi_FI.UTF-8
3dab36
 LANG=pt_BR.UTF-8
3dab36
+LANG=en_US.UTF-8 COMPOSE_FILE=ibus-compose.emoji
3dab36
diff --git a/src/tests/runtest b/src/tests/runtest
3dab36
index 4e980c71..35ccc5a0 100755
3dab36
--- a/src/tests/runtest
3dab36
+++ b/src/tests/runtest
3dab36
@@ -184,7 +184,9 @@ run_test_case()
3dab36
         export GTK_IM_MODULE=ibus
3dab36
     fi
3dab36
 
3dab36
-    "../$tst" ${1+"$@"}
3dab36
+    export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
+
3dab36
+    "../$tst" ../$top_srcdir/src/tests ${1+"$@"}
3dab36
 
3dab36
     retval=`expr $retval \| $?`
3dab36
 
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From 76dec798d5cf6cdaa96c3373f9c0e1cd13eb31f5 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Fri, 28 Jun 2019 21:28:32 +0900
3dab36
Subject: [PATCH] src/tests: Use GTest for ibus-compose
3dab36
3dab36
---
3dab36
 src/tests/ibus-compose.c | 45 ++++++++++++++++++++++++++++------------
3dab36
 1 file changed, 32 insertions(+), 13 deletions(-)
3dab36
3dab36
diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c
3dab36
index e1911b32..09c687c2 100644
3dab36
--- a/src/tests/ibus-compose.c
3dab36
+++ b/src/tests/ibus-compose.c
3dab36
@@ -11,7 +11,6 @@ gchar *m_compose_file;
3dab36
 IBusComposeTable *m_compose_table;
3dab36
 IBusEngine *m_engine;
3dab36
 gchar *m_srcdir;
3dab36
-int m_retval;
3dab36
 
3dab36
 static gboolean window_focus_in_event_cb (GtkWidget     *entry,
3dab36
                                           GdkEventFocus *event,
3dab36
@@ -111,8 +110,7 @@ register_ibus_engine ()
3dab36
 static gboolean
3dab36
 finit (gpointer data)
3dab36
 {
3dab36
-    m_retval = -1;
3dab36
-    g_warning ("time out");
3dab36
+    g_test_incomplete ("time out");
3dab36
     gtk_main_quit ();
3dab36
     return FALSE;
3dab36
 }
3dab36
@@ -127,7 +125,9 @@ set_engine_cb (GObject *object, GAsyncRe
3dab36
     int index_stride;
3dab36
 
3dab36
     if (!ibus_bus_set_global_engine_async_finish (bus, res, &error)) {
3dab36
-        g_warning ("set engine failed: %s", error->message);
3dab36
+        gchar *msg = g_strdup_printf ("set engine failed: %s", error->message);
3dab36
+        g_test_incomplete (msg);
3dab36
+        g_free (msg);
3dab36
         g_error_free (error);
3dab36
         return;
3dab36
     }
3dab36
@@ -210,7 +210,7 @@ window_inserted_text_cb (GtkEntryBuffer
3dab36
         test = GREEN "PASS" NC;
3dab36
     } else {
3dab36
         test = RED "FAIL" NC;
3dab36
-        m_retval = -1;
3dab36
+        g_test_fail ();
3dab36
     }
3dab36
     g_print ("%05d/%05d %s expected: %04X typed: %04X\n",
3dab36
              seq,
3dab36
@@ -249,20 +249,39 @@ create_window ()
3dab36
     gtk_widget_show_all (window);
3dab36
 }
3dab36
 
3dab36
+static void
3dab36
+test_compose (void)
3dab36
+{
3dab36
+    if (!register_ibus_engine ()) {
3dab36
+        g_test_fail ();
3dab36
+        return;
3dab36
+    }
3dab36
+
3dab36
+    create_window ();
3dab36
+    gtk_main ();
3dab36
+
3dab36
+}
3dab36
+
3dab36
 int
3dab36
 main (int argc, char *argv[])
3dab36
 {
3dab36
+    const gchar *test_name;
3dab36
+    gchar *test_path;
3dab36
+
3dab36
     ibus_init ();
3dab36
+    g_test_init (&argc, &argv, NULL);
3dab36
     gtk_init (&argc, &argv);
3dab36
 
3dab36
     m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup (".");
3dab36
     m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE"));
3dab36
+#if GLIB_CHECK_VERSION (2, 58, 0)
3dab36
+    test_name = g_get_language_names_with_category ("LC_CTYPE")[0];
3dab36
+#else
3dab36
+    test_name = g_getenv ("LANG");
3dab36
+#endif
3dab36
+    test_path = g_build_filename ("/ibus-compose", test_name, NULL);
3dab36
+    g_test_add_func (test_path, test_compose);
3dab36
+    g_free (test_path);
3dab36
 
3dab36
-    if (!register_ibus_engine ())
3dab36
-        return -1;
3dab36
-
3dab36
-    create_window ();
3dab36
-    gtk_main ();
3dab36
-
3dab36
-    return m_retval;
3dab36
+    return g_test_run ();
3dab36
 }
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From af00f4156b5c79c526eab18c49da80affd41ebee Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Fri, 12 Jul 2019 21:12:38 +0900
3dab36
Subject: [PATCH] src/tests: Install IBus tests into gnome-desktop-testing
3dab36
3dab36
---
3dab36
 configure.ac                      | 13 +++++++++++
3dab36
 src/tests/Makefile.am             | 39 ++++++++++++++++++++++++++++++-
3dab36
 src/tests/ibus-compose-locales.in | 23 ++++++++++++++++++
3dab36
 src/tests/ibus-compose.c          | 10 ++++++--
3dab36
 src/tests/meta.test.in            |  4 ++++
3dab36
 src/tests/runtest                 |  4 ++--
3dab36
 6 files changed, 88 insertions(+), 5 deletions(-)
3dab36
 create mode 100755 src/tests/ibus-compose-locales.in
3dab36
 create mode 100644 src/tests/meta.test.in
3dab36
3dab36
diff --git a/configure.ac b/configure.ac
3dab36
index b5a87b56..f1df3ac1 100644
3dab36
--- a/configure.ac
3dab36
+++ b/configure.ac
3dab36
@@ -595,6 +595,18 @@ PKG_CHECK_MODULES(XTEST,
3dab36
 )
3dab36
 AM_CONDITIONAL([ENABLE_XTEST], [test x"$enable_xtest" = x"yes"])
3dab36
 
3dab36
+# --enable-install-tests
3dab36
+AC_ARG_ENABLE(install-tests,
3dab36
+    AS_HELP_STRING([--enable-install-tests],
3dab36
+                   [Enable to install tests]),
3dab36
+    [enable_install_tests=$enableval],
3dab36
+    [enable_install_tests=no]
3dab36
+)
3dab36
+AM_CONDITIONAL([ENABLE_INSTALL_TESTS], [test x"$enable_install_tests" = x"yes"])
3dab36
+if test x"$enable_install_tests" = x"no"; then
3dab36
+    enable_install_tests="no (disabled, use --enable-install-tests to enable)"
3dab36
+fi
3dab36
+
3dab36
 
3dab36
 # --disable-emoji-dict option.
3dab36
 AC_ARG_ENABLE(emoji-dict,
3dab36
@@ -773,5 +785,6 @@ Build options:
3dab36
   Enable Unicode dict           $enable_unicode_dict
3dab36
   UCD directory                 $UCD_DIR
3dab36
   Run test cases                $enable_tests
3dab36
+  Install tests                 $enable_install_tests
3dab36
 ])
3dab36
 
3dab36
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
3dab36
index a58504a3..ff31111b 100644
3dab36
--- a/src/tests/Makefile.am
3dab36
+++ b/src/tests/Makefile.am
3dab36
@@ -78,7 +78,44 @@ TESTS_ENVIRONMENT = \
3dab36
 
3dab36
 LOG_COMPILER = $(srcdir)/runtest
3dab36
 
3dab36
-EXTRA_DIST = runtest ibus-compose.emoji ibus-compose.env
3dab36
+if ENABLE_INSTALL_TESTS
3dab36
+test_metas_in = meta.test.in
3dab36
+test_execs = $(TESTS:ibus-compose=ibus-compose-locales)
3dab36
+test_metas = $(addsuffix .test, $(test_execs))
3dab36
+test_sources_DATA = \
3dab36
+    $(test_metas) \
3dab36
+    ibus-compose.emoji \
3dab36
+    ibus-compose.env \
3dab36
+    $(NULL)
3dab36
+test_sourcesdir = $(datadir)/installed-tests/ibus
3dab36
+
3dab36
+test_execs_PROGRAMS = $(TESTS)
3dab36
+if ENABLE_GTK3
3dab36
+test_execs_SCRIPTS = ibus-compose-locales
3dab36
+endif
3dab36
+test_execsdir = $(libexecdir)/installed-tests/ibus
3dab36
+endif
3dab36
+
3dab36
+$(test_metas): $(test_metas_in) $(test_programs)
3dab36
+	f=`echo $@ | sed -e 's/\.test//'`; \
3dab36
+	TEST_EXEC=$(test_execsdir)/$$f; \
3dab36
+	sed -e "s|@TEST_EXEC[@]|$$TEST_EXEC|g" $(test_metas_in) > $@.tmp; \
3dab36
+	mv $@.tmp $@; \
3dab36
+	$(NULL)
3dab36
+
3dab36
+ibus-compose-locales: ibus-compose-locales.in
3dab36
+	SRCDIR=$(test_sourcesdir); \
3dab36
+	sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \
3dab36
+	mv $@.tmp $@; \
3dab36
+	$(NULL)
3dab36
+
3dab36
+EXTRA_DIST = \
3dab36
+    $(test_metas_in) \
3dab36
+    runtest \
3dab36
+    ibus-compose.emoji \
3dab36
+    ibus-compose.env \
3dab36
+    ibus-compose-locales.in \
3dab36
+    $(NULL)
3dab36
 
3dab36
 ibus_bus_SOURCES = ibus-bus.c
3dab36
 ibus_bus_LDADD = $(prog_ldadd)
3dab36
diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in
3dab36
new file mode 100755
3dab36
index 00000000..8d2384d1
3dab36
--- /dev/null
3dab36
+++ b/src/tests/ibus-compose-locales.in
3dab36
@@ -0,0 +1,23 @@
3dab36
+#!/bin/sh
3dab36
+
3dab36
+SRCDIR=@SRCDIR@
3dab36
+BUILDDIR=`dirname $0`
3dab36
+
3dab36
+
3dab36
+export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
+
3dab36
+for var in `cat $SRCDIR/ibus-compose.env`
3dab36
+do
3dab36
+    IS_COMMENT=`echo "$var" | grep "^#"`
3dab36
+    if [ "x$IS_COMMENT" != x ] ; then
3dab36
+        continue
3dab36
+    fi
3dab36
+    env $var $BUILDDIR/ibus-compose $SRCDIR $@
3dab36
+
3dab36
+    CACHE_FILES=`ls *.cache`
3dab36
+    if [ x"$CACHE_FILES" != x ] ; then
3dab36
+        echo "Clean $CACHE_FILES"
3dab36
+        rm $CACHE_FILES
3dab36
+    fi
3dab36
+done
3dab36
+
3dab36
diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c
3dab36
index 09c687c2..c8d3c126 100644
3dab36
--- a/src/tests/ibus-compose.c
3dab36
+++ b/src/tests/ibus-compose.c
3dab36
@@ -351,6 +347,14 @@ main (int argc, char *argv[])
3dab36
 
3dab36
     ibus_init ();
3dab36
     g_test_init (&argc, &argv, NULL);
3dab36
+    /* FIXME:
3dab36
+     * IBusIMContext opens GtkIMContextSimple as the slave and
3dab36
+     * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the
3dab36
+     * multiple outputs in el_GR's compose causes a warning in gtkcomposetable 
3dab36
+     * and the warning always causes a fatal in GTest:
3dab36
+     " "GTK+ supports to output one char only: "
3dab36
+     */
3dab36
+    g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
3dab36
     gtk_init (&argc, &argv);
3dab36
 
3dab36
     m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup (".");
3dab36
diff --git a/src/tests/meta.test.in b/src/tests/meta.test.in
3dab36
new file mode 100644
3dab36
index 00000000..ae2b2991
3dab36
--- /dev/null
3dab36
+++ b/src/tests/meta.test.in
3dab36
@@ -0,0 +1,4 @@
3dab36
+[Test]
3dab36
+Type=session
3dab36
+Exec=@TEST_EXEC@ --tap
3dab36
+Output=TAP
3dab36
diff --git a/src/tests/runtest b/src/tests/runtest
3dab36
index 35ccc5a0..1fcc9283 100755
3dab36
--- a/src/tests/runtest
3dab36
+++ b/src/tests/runtest
3dab36
@@ -200,7 +200,7 @@ if test -f $envfile ; then
3dab36
     ENVS="`cat $envfile`"
3dab36
 fi;
3dab36
 if test x"$ENVS" = x ; then
3dab36
-    run_test_case
3dab36
+    run_test_case $@
3dab36
 else
3dab36
     LANG_backup=$LANG
3dab36
     i=1
3dab36
@@ -212,7 +212,7 @@ else
3dab36
         export $e
3dab36
         echo "Run `func_basename $tst` on $e"
3dab36
         echo "======================="
3dab36
-        run_test_case
3dab36
+        run_test_case $@
3dab36
         echo ""
3dab36
         i=`expr $i + 1`
3dab36
     done
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From 2a4f9518d42b618d8111fa5f9f885757524758a0 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Fri, 12 Jul 2019 21:12:40 +0900
3dab36
Subject: [PATCH] src/tests: Rename test-console.sh to
3dab36
 ibus-desktop-testing-runner
3dab36
3dab36
---
3dab36
 src/tests/Makefile.am                                    | 9 +++++++++
3dab36
 .../tests/ibus-desktop-testing-runner.in                 | 0
3dab36
 2 files changed, 9 insertions(+)
3dab36
 rename test/test-console.sh => src/tests/ibus-desktop-testing-runner.in (100%)
3dab36
3dab36
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
3dab36
index ff31111b..b9aad29a 100644
3dab36
--- a/src/tests/Makefile.am
3dab36
+++ b/src/tests/Makefile.am
3dab36
@@ -79,6 +79,7 @@ TESTS_ENVIRONMENT = \
3dab36
 LOG_COMPILER = $(srcdir)/runtest
3dab36
 
3dab36
 if ENABLE_INSTALL_TESTS
3dab36
+bin_SCRIPTS = ibus-desktop-testing-runner
3dab36
 test_metas_in = meta.test.in
3dab36
 test_execs = $(TESTS:ibus-compose=ibus-compose-locales)
3dab36
 test_metas = $(addsuffix .test, $(test_execs))
3dab36
@@ -109,12 +110,20 @@ ibus-compose-locales: ibus-compose-locales.in
3dab36
 	mv $@.tmp $@; \
3dab36
 	$(NULL)
3dab36
 
3dab36
+    ibus-desktop-testing-runner.in \
3dab36
+ibus-desktop-testing-runner: ibus-desktop-testing-runner.in
3dab36
+	SRCDIR=$(test_sourcesdir); \
3dab36
+	sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \
3dab36
+	mv $@.tmp $@; \
3dab36
+	$(NULL)
3dab36
+
3dab36
 EXTRA_DIST = \
3dab36
     $(test_metas_in) \
3dab36
     runtest \
3dab36
     ibus-compose.emoji \
3dab36
     ibus-compose.env \
3dab36
     ibus-compose-locales.in \
3dab36
+    ibus-desktop-testing-runner.in \
3dab36
     $(NULL)
3dab36
 
3dab36
 ibus_bus_SOURCES = ibus-bus.c
3dab36
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
3dab36
new file mode 100755
3dab36
index 00000000..7fbf82cf
3dab36
--- /dev/null
3dab36
+++ b/src/tests/ibus-desktop-testing-runner.in
3dab36
@@ -0,0 +1,255 @@
3dab36
+#!/bin/sh
3dab36
+# -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*-
3dab36
+# vim:set noet ts=4:
3dab36
+#
3dab36
+# ibus-anthy - The Anthy engine for IBus
3dab36
+#
3dab36
+# Copyright (c) 2018-2019 Takao Fujiwara <takao.fujiwara1@gmail.com>
3dab36
+# Copyright (c) 2018 Red Hat, Inc.
3dab36
+#
3dab36
+# This program is free software; you can redistribute it and/or modify
3dab36
+# it under the terms of the GNU General Public License as published by
3dab36
+# the Free Software Foundation; either version 2 of the License, or
3dab36
+# (at your option) any later version.
3dab36
+#
3dab36
+# This program is distributed in the hope that it will be useful,
3dab36
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3dab36
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3dab36
+# GNU General Public License for more details.
3dab36
+#
3dab36
+# You should have received a copy of the GNU General Public License along
3dab36
+# with this program; if not, write to the Free Software Foundation, Inc.,
3dab36
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3dab36
+
3dab36
+# This test runs /usr/bin/ibus-daemon after install ibus
3dab36
+#
3dab36
+# # init 3
3dab36
+# Login as root
3dab36
+# # /root/ibus/tests/test-console.sh --tests ibus-compose \
3dab36
+#   --builddir /root/ibus/src/tests --srcdir /root/ibus/src/tests
3dab36
+
3dab36
+PROGNAME=`basename $0`
3dab36
+VERSION=0.1
3dab36
+DISPLAY=:99.0
3dab36
+BUILDDIR="."
3dab36
+SRCDIR="."
3dab36
+TEST_LOG=test-suite.log
3dab36
+HAVE_GRAPHICS=1
3dab36
+DESKTOP_COMMAND="gnome-session"
3dab36
+PID_XORG=0
3dab36
+PID_GNOME_SESSION=0
3dab36
+TESTS=""
3dab36
+GREEN='\033[0;32m'
3dab36
+RED='\033[0;31m'
3dab36
+NC='\033[0m'
3dab36
+
3dab36
+usage()
3dab36
+{
3dab36
+    echo -e \
3dab36
+"This test runs /usr/bin/ibus-daemon after install ibus\n"                     \
3dab36
+"$PROGNAME [OPTIONS…]\n"                                                       \
3dab36
+"\n"                                                                           \
3dab36
+"OPTIONS:\n"                                                                   \
3dab36
+"-h, --help                       This help\n"                                 \
3dab36
+"-v, --version                    Show version\n"                              \
3dab36
+"-b, --builddir=BUILDDIR          Set the BUILDDIR\n"                          \
3dab36
+"-s, --srcdir=SOURCEDIR           Set the SOURCEDIR\n"                         \
3dab36
+"-c, --no-graphics                Use Xvfb instead of Xorg\n"                  \
3dab36
+"-d, --desktop=DESKTOP            Run DESTKTOP. The default is gnome-session\n" \
3dab36
+"-t, --tests=\"TESTS...\"           Run TESTS programs which is separated by space\n" \
3dab36
+""
3dab36
+}
3dab36
+
3dab36
+parse_args()
3dab36
+{
3dab36
+    # This is GNU getopt. "sudo port getopt" in BSD?
3dab36
+    ARGS=`getopt -o hvb:s:cd:t: --long help,version,builddir:,srcdir:,no-graphics,desktop:,tests:\
3dab36
+        -- "$@"`;
3dab36
+    eval set -- "$ARGS"
3dab36
+    while [ 1 ] ; do
3dab36
+        case "$1" in
3dab36
+        -h | --help )        usage; exit 0;;
3dab36
+        -v | --version )     echo -e "$VERSION"; exit 0;;
3dab36
+        -b | --builddir )    BUILDDIR="$2"; shift 2;;
3dab36
+        -s | --srcdir )      SRCDIR="$2"; shift 2;;
3dab36
+        -c | --no-graphics ) HAVE_GRAPHICS=0; shift;;
3dab36
+        -d | --desktop )     DESKTOP_COMMAND="$2"; shift 2;;
3dab36
+        -t | --tests )       TESTS="$2"; shift 2;;
3dab36
+        -- )                 shift; break;;
3dab36
+        * )                  usage; exit 1;;
3dab36
+        esac
3dab36
+    done
3dab36
+}
3dab36
+
3dab36
+init_desktop()
3dab36
+{
3dab36
+    if test x$FORCE_TEST != x ; then
3dab36
+        RUN_ARGS="$RUN_ARGS --force"
3dab36
+    fi
3dab36
+
3dab36
+    if test ! -f $HOME/.config/gnome-initial-setup-done ; then
3dab36
+        if test ! -f /var/lib/AccountsService/users/$USER ; then
3dab36
+            mkdir -p /var/lib/AccountsService/users
3dab36
+            cat >> /var/lib/AccountsService/users/$USER << _EOF
3dab36
+[User]
3dab36
+Language=ja_JP.UTF-8
3dab36
+XSession=gnome
3dab36
+SystemAccount=false
3dab36
+_EOF
3dab36
+        fi
3dab36
+        mkdir -p $HOME/.config
3dab36
+        touch $HOME/.config/gnome-initial-setup-done
3dab36
+    fi
3dab36
+
3dab36
+    # Prevent from launching a XDG dialog
3dab36
+    XDG_LOCALE_FILE="$HOME/.config/user-dirs.locale"
3dab36
+    if test -f $XDG_LOCALE_FILE ; then
3dab36
+        XDG_LANG_ORIG=`cat $XDG_LOCALE_FILE`
3dab36
+        XDG_LANG_NEW=`echo $LANG | sed -e 's/\(.*\)\..*/\1/'`
3dab36
+        if [ "$XDG_LANG_ORIG" != "$XDG_LANG_NEW" ] ; then
3dab36
+            echo "Overriding XDG locale $XDG_LANG_ORIG with $XDG_LANG_NEW"
3dab36
+            echo "$XDG_LANG_NEW" > $XDG_LOCALE_FILE
3dab36
+        fi
3dab36
+    fi
3dab36
+}
3dab36
+
3dab36
+run_dbus_daemon()
3dab36
+{
3dab36
+    a=`ps -ef | grep dbus-daemon | grep "\-\-system" | grep -v session | grep -v grep`
3dab36
+    if test x"$a" = x ; then
3dab36
+        eval `dbus-launch --sh-syntax`
3dab36
+    fi
3dab36
+    SUSER=`echo "$USER" | cut -c 1-7`
3dab36
+    a=`ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | grep session | grep -v grep`
3dab36
+    if test x"$a" = x ; then
3dab36
+        systemctl --user start dbus
3dab36
+        export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus
3dab36
+    fi
3dab36
+    systemctl --user status dbus | col -b
3dab36
+    ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | egrep 'session|system' | grep -v grep
3dab36
+    systemctl --user show-environment | col -b
3dab36
+}
3dab36
+
3dab36
+run_desktop()
3dab36
+{
3dab36
+    if test $HAVE_GRAPHICS -eq 1 ; then
3dab36
+        /usr/libexec/Xorg.wrap -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xorg.log -config ./xorg.conf -configdir . $DISPLAY &
3dab36
+    else
3dab36
+        /usr/bin/Xvfb $DISPLAY -noreset +extension GLX +extension RANDR +extension RENDER -screen 0 1280x1024x24 &
3dab36
+    fi
3dab36
+    PID_XORG=$!
3dab36
+    sleep 1
3dab36
+    export DISPLAY=$DISPLAY
3dab36
+    $DESKTOP_COMMAND &
3dab36
+    PID_GNOME_SESSION=$!
3dab36
+    sleep 30
3dab36
+    if test "$DESKTOP_COMMAND" != "gnome-session" ; then
3dab36
+        ibus-daemon --daemonize --verbose
3dab36
+        sleep 1
3dab36
+    fi
3dab36
+}
3dab36
+
3dab36
+count_case_result()
3dab36
+{
3dab36
+    retval=$1
3dab36
+    pass=$2
3dab36
+    fail=$3
3dab36
+
3dab36
+    if test $retval -eq  0 ; then
3dab36
+        pass=`expr $pass + 1`
3dab36
+    else
3dab36
+        fail=`expr $fail + 1`
3dab36
+    fi
3dab36
+    echo $pass $fail
3dab36
+}
3dab36
+
3dab36
+echo_case_result()
3dab36
+{
3dab36
+    retval=$1
3dab36
+    tst=$2
3dab36
+    log=$3
3dab36
+    subtst=${4:-''}
3dab36
+
3dab36
+    if test $retval -eq  0 ; then
3dab36
+        echo -e "${GREEN}PASS${NC}: $tst $subtst"
3dab36
+    else
3dab36
+        echo -e "${RED}FAIL${NC}: $tst $subtst"
3dab36
+        echo "FAIL: $tst $subtst" >> $TEST_LOG
3dab36
+        echo "======================" >> $TEST_LOG
3dab36
+        echo "" >> $TEST_LOG
3dab36
+        cat "$log" >> $TEST_LOG
3dab36
+        echo "" >> $TEST_LOG
3dab36
+    fi
3dab36
+}
3dab36
+
3dab36
+run_test_suite()
3dab36
+{
3dab36
+    cd `dirname $0`
3dab36
+    pass=0
3dab36
+    fail=0
3dab36
+
3dab36
+    export GTK_IM_MODULE=ibus
3dab36
+    export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
+    if test -f $TEST_LOG ; then
3dab36
+        rm $TEST_LOG
3dab36
+    fi
3dab36
+    for tst in $TESTS; do
3dab36
+        ENVS=
3dab36
+        if test -f $SRCDIR/${tst}.env ; then
3dab36
+            ENVS="`cat $SRCDIR/${tst}.env`"
3dab36
+        fi
3dab36
+        if test x"$ENVS" = x ; then
3dab36
+            $BUILDDIR/$tst $SRCDIR >&${tst}.log
3dab36
+            retval=$?
3dab36
+            read pass fail << EOF
3dab36
+            `count_case_result $retval $pass $fail`
3dab36
+EOF
3dab36
+            echo_case_result $retval $tst ${tst}.log
3dab36
+        else
3dab36
+            LANG_backup=$LANG
3dab36
+            i=1
3dab36
+            for e in $ENVS; do
3dab36
+                first=`echo "$e" | cut -c1-1`
3dab36
+                if test x"$first" = x"#" ; then
3dab36
+                    continue
3dab36
+                fi
3dab36
+                export $e
3dab36
+                $BUILDDIR/$tst $SRCDIR >&${tst}.${i}.log
3dab36
+                retval=$?
3dab36
+                read pass fail << EOF
3dab36
+                `count_case_result $retval $pass $fail`
3dab36
+EOF
3dab36
+                echo_case_result $retval $tst ${tst}.${i}.log $e
3dab36
+                i=`expr $i + 1`
3dab36
+            done
3dab36
+            export LANG=$LANG_backup
3dab36
+        fi
3dab36
+    done
3dab36
+    echo ""
3dab36
+    echo -e "# ${GREEN}PASS${NC}: $pass"
3dab36
+    echo -e "# ${RED}FAIL${NC}: $fail"
3dab36
+    if test -f ${TEST_LOG} ; then
3dab36
+        echo ""
3dab36
+        echo -e "${RED}See ${TEST_LOG}$NC"
3dab36
+    fi
3dab36
+}
3dab36
+
3dab36
+finit()
3dab36
+{
3dab36
+    if test "$DESKTOP_COMMAND" != "gnome-session" ; then
3dab36
+        ibus exit
3dab36
+    fi
3dab36
+    kill $PID_GNOME_SESSION $PID_XORG
3dab36
+}
3dab36
+
3dab36
+main()
3dab36
+{
3dab36
+    parse_args $@
3dab36
+    init_desktop
3dab36
+    run_dbus_daemon
3dab36
+    run_desktop
3dab36
+    run_test_suite
3dab36
+    finit
3dab36
+}
3dab36
+
3dab36
+main $@
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From fa081ac8ea37d2feb7c7f395ad66e7381b4cb65b Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Fri, 12 Jul 2019 21:20:32 +0900
3dab36
Subject: [PATCH] src/tests: Use gnome-desktop-testing-runner
3dab36
3dab36
---
3dab36
 src/tests/Makefile.am                    |   4 +-
3dab36
 src/tests/ibus-desktop-testing-runner.in | 154 ++++++++++++++++++-----
3dab36
 2 files changed, 123 insertions(+), 35 deletions(-)
3dab36
3dab36
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
3dab36
index b9aad29a..913e42fb 100644
3dab36
--- a/src/tests/Makefile.am
3dab36
+++ b/src/tests/Makefile.am
3dab36
@@ -105,8 +105,8 @@ $(test_metas): $(test_metas_in) $(test_programs)
3dab36
 	$(NULL)
3dab36
 
3dab36
 ibus-compose-locales: ibus-compose-locales.in
3dab36
-	SRCDIR=$(test_sourcesdir); \
3dab36
-	sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \
3dab36
+	INSTALLEDDIR=$(datadir)/installed-tests; \
3dab36
+	sed -e "s|@INSTALLEDDIR[@]|$$INSTALLEDDIR|g" $< > $@.tmp; \
3dab36
 	mv $@.tmp $@; \
3dab36
 	$(NULL)
3dab36
 
3dab36
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
3dab36
index 9e689634..a90c1378 100755
3dab36
--- a/src/tests/ibus-desktop-testing-runner.in
3dab36
+++ b/src/tests/ibus-desktop-testing-runner.in
3dab36
@@ -2,7 +2,7 @@
3dab36
 # -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*-
3dab36
 # vim:set noet ts=4:
3dab36
 #
3dab36
-# ibus-anthy - The Anthy engine for IBus
3dab36
+# ibus - The Input Bus
3dab36
 #
3dab36
 # Copyright (c) 2018-2019 Takao Fujiwara <takao.fujiwara1@gmail.com>
3dab36
 # Copyright (c) 2018 Red Hat, Inc.
3dab36
@@ -33,16 +33,32 @@ VERSION=0.1
3dab36
 DISPLAY=:99.0
3dab36
 BUILDDIR="."
3dab36
 SRCDIR="."
3dab36
-TEST_LOG=test-suite.log
3dab36
+TEST_LOG="test-suite.log"
3dab36
+RESULT_LOG=""
3dab36
 HAVE_GRAPHICS=1
3dab36
 DESKTOP_COMMAND="gnome-session"
3dab36
 PID_XORG=0
3dab36
 PID_GNOME_SESSION=0
3dab36
+TESTING_RUNNER="default"
3dab36
 TESTS=""
3dab36
 GREEN='\033[0;32m'
3dab36
 RED='\033[0;31m'
3dab36
 NC='\033[0m'
3dab36
 
3dab36
+print_log()
3dab36
+{
3dab36
+    if [ x"$RESULT_LOG" != x ] ; then
3dab36
+        # avoid 'echo -e' before call 'sed'.
3dab36
+        if [ x"$1" = x'-e' ] ; then
3dab36
+            shift
3dab36
+        fi
3dab36
+        NO_ESCAPE=`echo $@ | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'`
3dab36
+        echo $NO_ESCAPE >> $RESULT_LOG
3dab36
+    else
3dab36
+        echo $@
3dab36
+    fi
3dab36
+}
3dab36
+
3dab36
 usage()
3dab36
 {
3dab36
     echo -e \
3dab36
@@ -57,13 +73,19 @@ usage()
3dab36
 "-c, --no-graphics                Use Xvfb instead of Xorg\n"                  \
3dab36
 "-d, --desktop=DESKTOP            Run DESTKTOP. The default is gnome-session\n" \
3dab36
 "-t, --tests=\"TESTS...\"           Run TESTS programs which is separated by space\n" \
3dab36
+"-r, --runner=RUNNER              Run TESTS programs with a test RUNNER.\n"    \
3dab36
+"                                 RUNNDER = gnome or default.\n"               \
3dab36
+"                                 default is an embedded runner.\n"            \
3dab36
+"-o, --output=OUTPUT_FILE         OUtput the log to OUTPUT_FILE\n"             \
3dab36
+"-O, --result=RESULT_FILE         OUtput the result to RESULT_FILE\n"          \
3dab36
 ""
3dab36
 }
3dab36
 
3dab36
 parse_args()
3dab36
 {
3dab36
     # This is GNU getopt. "sudo port getopt" in BSD?
3dab36
-    ARGS=`getopt -o hvb:s:cd:t: --long help,version,builddir:,srcdir:,no-graphics,desktop:,tests:\
3dab36
+    ARGS=`getopt -o hvb:s:cd:t:r:o:O: --long \
3dab36
+          help,version,builddir:,srcdir:,no-graphics,desktop:,tests:,runner:,output:,result:\
3dab36
         -- "$@"`;
3dab36
     eval set -- "$ARGS"
3dab36
     while [ 1 ] ; do
3dab36
@@ -75,6 +97,9 @@ parse_args()
3dab36
         -c | --no-graphics ) HAVE_GRAPHICS=0; shift;;
3dab36
         -d | --desktop )     DESKTOP_COMMAND="$2"; shift 2;;
3dab36
         -t | --tests )       TESTS="$2"; shift 2;;
3dab36
+        -r | --runner )      TESTING_RUNNER="$2"; shift 2;;
3dab36
+        -o | --output )      TEST_LOG="$2"; shift 2;;
3dab36
+        -O | --result )      RESULT_LOG="$2"; shift 2;;
3dab36
         -- )                 shift; break;;
3dab36
         * )                  usage; exit 1;;
3dab36
         esac
3dab36
@@ -83,18 +108,31 @@ parse_args()
3dab36
 
3dab36
 init_desktop()
3dab36
 {
3dab36
+    if [ "$RESULT_LOG" != "" ] ; then
3dab36
+        rm $RESULT_LOG
3dab36
+    fi
3dab36
+    if [ "$TEST_LOG" = "" ] ; then
3dab36
+        print_log -e "${RED}FAIL${NC}: ${RED}ERROR${NC}: a log file is required to get return value with 'read' command"
3dab36
+        abrt
3dab36
+    else
3dab36
+        rm $TEST_LOG
3dab36
+    fi
3dab36
     if test x$FORCE_TEST != x ; then
3dab36
         RUN_ARGS="$RUN_ARGS --force"
3dab36
     fi
3dab36
 
3dab36
     if test ! -f $HOME/.config/gnome-initial-setup-done ; then
3dab36
+        IS_SYSTEM_ACCOUNT=false
3dab36
+        if [ "$USER" = "root" ] ; then
3dab36
+            IS_SYSTEM_ACCOUNT=true
3dab36
+        fi
3dab36
         if test ! -f /var/lib/AccountsService/users/$USER ; then
3dab36
             mkdir -p /var/lib/AccountsService/users
3dab36
             cat >> /var/lib/AccountsService/users/$USER << _EOF
3dab36
 [User]
3dab36
 Language=ja_JP.UTF-8
3dab36
 XSession=gnome
3dab36
-SystemAccount=false
3dab36
+SystemAccount=$IS_SYSTEM_ACCOUNT
3dab36
 _EOF
3dab36
         fi
3dab36
         mkdir -p $HOME/.config
3dab36
@@ -167,71 +205,120 @@ echo_case_result()
3dab36
 {
3dab36
     retval=$1
3dab36
     tst=$2
3dab36
-    log=$3
3dab36
-    subtst=${4:-''}
3dab36
+    subtst=${3:-''}
3dab36
 
3dab36
     if test $retval -eq  0 ; then
3dab36
-        echo -e "${GREEN}PASS${NC}: $tst $subtst"
3dab36
+        print_log -e "${GREEN}PASS${NC}: $tst $subtst"
3dab36
     else
3dab36
-        echo -e "${RED}FAIL${NC}: $tst $subtst"
3dab36
-        echo "FAIL: $tst $subtst" >> $TEST_LOG
3dab36
-        echo "======================" >> $TEST_LOG
3dab36
-        echo "" >> $TEST_LOG
3dab36
-        cat "$log" >> $TEST_LOG
3dab36
-        echo "" >> $TEST_LOG
3dab36
+        print_log -e "${RED}FAIL${NC}: $tst $subtst"
3dab36
+        print_log "======================"
3dab36
+        print_log ""
3dab36
     fi
3dab36
 }
3dab36
 
3dab36
-run_test_suite()
3dab36
+run_direct_test_cases()
3dab36
 {
3dab36
-    cd `dirname $0`
3dab36
     pass=0
3dab36
     fail=0
3dab36
-
3dab36
-    export GTK_IM_MODULE=ibus
3dab36
-    export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
-    if test -f $TEST_LOG ; then
3dab36
-        rm $TEST_LOG
3dab36
-    fi
3dab36
     for tst in $TESTS; do
3dab36
         ENVS=
3dab36
         if test -f $SRCDIR/${tst}.env ; then
3dab36
             ENVS="`cat $SRCDIR/${tst}.env`"
3dab36
         fi
3dab36
         if test x"$ENVS" = x ; then
3dab36
-            $BUILDDIR/$tst $SRCDIR >&${tst}.log
3dab36
+            $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
             retval=$?
3dab36
             read pass fail << EOF
3dab36
             `count_case_result $retval $pass $fail`
3dab36
 EOF
3dab36
-            echo_case_result $retval $tst ${tst}.log
3dab36
+            echo_case_result $retval $tst
3dab36
+            CACHE_FILES=`ls *.cache`
3dab36
+            if [ x"$CACHE_FILES" != x ] ; then
3dab36
+                print_log "Clean $CACHE_FILES"
3dab36
+                rm $CACHE_FILES
3dab36
+            fi
3dab36
         else
3dab36
             LANG_backup=$LANG
3dab36
             i=1
3dab36
             for e in $ENVS; do
3dab36
-                first=`echo "$e" | cut -c1-1`
3dab36
+                first=`echo "$e" | grep '^#'`
3dab36
                 if test x"$first" = x"#" ; then
3dab36
                     continue
3dab36
                 fi
3dab36
                 export $e
3dab36
-                $BUILDDIR/$tst $SRCDIR >&${tst}.${i}.log
3dab36
+                $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
                 retval=$?
3dab36
                 read pass fail << EOF
3dab36
                 `count_case_result $retval $pass $fail`
3dab36
 EOF
3dab36
-                echo_case_result $retval $tst ${tst}.${i}.log $e
3dab36
+                echo_case_result $retval $tst $e
3dab36
+                CACHE_FILES=`ls *.cache`
3dab36
+                if [ x"$CACHE_FILES" != x ] ; then
3dab36
+                    print_log "Clean $CACHE_FILES"
3dab36
+                    rm $CACHE_FILES
3dab36
+                fi
3dab36
                 i=`expr $i + 1`
3dab36
             done
3dab36
             export LANG=$LANG_backup
3dab36
         fi
3dab36
     done
3dab36
+    echo $pass $fail
3dab36
+}
3dab36
+
3dab36
+run_gnome_desktop_testing_runner()
3dab36
+{
3dab36
+    pass=0
3dab36
+    fail=0
3dab36
+    if [ x"$TESTS" = x ] ; then
3dab36
+        TESTS='ibus'
3dab36
+    fi
3dab36
+    for tst in $TESTS; do
3dab36
+        tst_dir="@INSTALLEDDIR@/$tst"
3dab36
+        if [ ! -d "$tst_dir" ] ; then
3dab36
+            print_log -e "${RED}FAIL${NC}: Not found %tst_dir"
3dab36
+            fail=1
3dab36
+            continue
3dab36
+        fi
3dab36
+        gnome-desktop-testing-runner $tst 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
+        retval=$?
3dab36
+        read pass fail << EOF
3dab36
+        `count_case_result $retval $pass $fail`
3dab36
+EOF
3dab36
+    done
3dab36
+    echo $pass $fail
3dab36
+}
3dab36
+
3dab36
+run_test_suite()
3dab36
+{
3dab36
+    pass=0
3dab36
+    fail=0
3dab36
+    export GTK_IM_MODULE=ibus
3dab36
+    export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
+    if [ x"$TESTING_RUNNER" = x ] ; then
3dab36
+        TESTING_RUNNER="default"
3dab36
+    fi
3dab36
+    case $TESTING_RUNNER in
3dab36
+    default)
3dab36
+        # Get only the last value with do-while.
3dab36
+        read pass fail << EOF_RUNNER
3dab36
+        `run_direct_test_cases`
3dab36
+EOF_RUNNER
3dab36
+        ;;
3dab36
+    gnome)
3dab36
+        read pass fail << EOF_RUNNER
3dab36
+        `run_gnome_desktop_testing_runner`
3dab36
+EOF_RUNNER
3dab36
+        ;;
3dab36
+    esac
3dab36
     echo ""
3dab36
-    echo -e "# ${GREEN}PASS${NC}: $pass"
3dab36
-    echo -e "# ${RED}FAIL${NC}: $fail"
3dab36
-    if test -f ${TEST_LOG} ; then
3dab36
-        echo ""
3dab36
-        echo -e "${RED}See ${TEST_LOG}$NC"
3dab36
+    if [ $pass -ne 0 ] ; then
3dab36
+        print_log -e "${GREEN}PASS${NC}: $pass"
3dab36
     fi
3dab36
+    if [ $fail -ne 0 ] ; then
3dab36
+        print_log -e "${RED}FAIL${NC}: $fail"
3dab36
+    fi
3dab36
+    echo ""
3dab36
+    echo "See ${TEST_LOG}"
3dab36
 }
3dab36
 
3dab36
 finit()
3dab36
@@ -240,14 +327,15 @@ finit()
3dab36
         ibus exit
3dab36
     fi
3dab36
     kill $PID_GNOME_SESSION $PID_XORG
3dab36
+    echo "Finished $PROGNAME testing"
3dab36
 }
3dab36
 
3dab36
 main()
3dab36
 {
3dab36
     parse_args $@
3dab36
     init_desktop
3dab36
-    run_dbus_daemon
3dab36
-    run_desktop
3dab36
+    run_dbus_daemon 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
+    run_desktop 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
     run_test_suite
3dab36
     finit
3dab36
 }
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From 85b647a1c57c206779eb0b4b15a734c1b1f29c10 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Wed, 24 Jul 2019 17:27:37 +0900
3dab36
Subject: [PATCH] src/tests: Fix IBus test cases for gnome-desktop-testing
3dab36
3dab36
- dconf/config.c: Replaced dconf_client_write_fast() with
3dab36
  dconf_client_write_sync() because
3dab36
  dconf_client_write_fast() does not syn the data when
3dab36
  ibus_config_get_values() is called immediately after
3dab36
  ibus_config_set_value() is called.
3dab36
3dab36
- ibus-compose-locales.in returns the return value of ibus-compose
3dab36
3dab36
- ibus-compose: Set $NO_AT_BRIDGE to suppress a AT_SPI warning
3dab36
  and call g_log_set_always_fatal() because GtkIMContextSimple
3dab36
  does not support multiple compose outputs yet and the API can
3dab36
  suppress a warning.
3dab36
3dab36
- ibus-config: Delete async watch testings which causes several errors
3dab36
  with gnome-shell testing and the testing is now deprecated and
3dab36
  GSettings is recommended.
3dab36
3dab36
- ibus-desktop-testing-runner.in: Support --output=log:stdout to
3dab36
  cat the log to stdout and Use dbus-launch --exit-with-session instead of
3dab36
  --sh-syntax and count PASS of test cases instead of PASS of
3dab36
  gnome-desktop-testing and always run ibus exit and kill
3dab36
  gnome-shell-calendar-server
3dab36
3dab36
- ibus-engine-switch.c: Set xkb:jp::jpn if gnome-shell sets xkb:us::eng
3dab36
3dab36
- ibus-inputcontext.c: Use ibus_bus_get_global_engine() instead of
3dab36
  ibus_bus_list_active_engines() since ibus_bus_list_active_engines()
3dab36
  does not work with gnome-shell and the API is now deprecated.
3dab36
3dab36
- ibus-keypress.c: Set $NO_AT_BRIDGE to suppress a AT_SPI warning
3dab36
---
3dab36
 conf/dconf/config.c                      |  14 +-
3dab36
 src/tests/Makefile.am                    |  19 +-
3dab36
 src/tests/ibus-compose-locales.in        |   4 +-
3dab36
 src/tests/ibus-compose.c                 |  10 +-
3dab36
 src/tests/ibus-config.c                  | 283 -----------------------
3dab36
 src/tests/ibus-desktop-testing-runner.in |  77 +++---
3dab36
 src/tests/ibus-engine-switch.c           |  34 ++-
3dab36
 src/tests/ibus-inputcontext.c            |  29 +--
3dab36
 src/tests/ibus-keypress.c                |   4 +
3dab36
 9 files changed, 126 insertions(+), 348 deletions(-)
3dab36
3dab36
diff --git a/conf/dconf/config.c b/conf/dconf/config.c
3dab36
index 500ea1d8..30ac137d 100644
3dab36
--- a/conf/dconf/config.c
3dab36
+++ b/conf/dconf/config.c
3dab36
@@ -335,7 +335,19 @@ ibus_config_dconf_set_value (IBusConfigService *config,
3dab36
     }
3dab36
 
3dab36
 #ifdef DCONF_0_13_4
3dab36
-    retval = dconf_client_write_fast (client, gkey, value, error);
3dab36
+    /* Use dconf_client_write_sync() instead of dconf_client_write_fast()
3dab36
+     * because dconf_client_write_fast() does not sync the data when
3dab36
+     * ibus_config_get_values() is called immediately after
3dab36
+     * ibus_config_set_value() is called.
3dab36
+     * We won't add a new API for the sync only since IBusConfig is
3dab36
+     * now deprecated and GSettings is recommended.
3dab36
+     */
3dab36
+    retval = dconf_client_write_sync (client,
3dab36
+                                      gkey,
3dab36
+                                      value,
3dab36
+                                      NULL,
3dab36
+                                      NULL,
3dab36
+                                      error);
3dab36
 #else
3dab36
     retval = dconf_client_write (client,
3dab36
                                  gkey,
3dab36
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
3dab36
index 913e42fb..2e75932c 100644
3dab36
--- a/src/tests/Makefile.am
3dab36
+++ b/src/tests/Makefile.am
3dab36
@@ -55,6 +55,8 @@ TESTS = \
3dab36
     ibus-util                       \
3dab36
     $(NULL)
3dab36
 
3dab36
+CLEANFILES =
3dab36
+
3dab36
 if ENABLE_ENGINE
3dab36
 TESTS += ibus-engine-switch
3dab36
 endif
3dab36
@@ -90,9 +92,17 @@ test_sources_DATA = \
3dab36
     $(NULL)
3dab36
 test_sourcesdir = $(datadir)/installed-tests/ibus
3dab36
 
3dab36
+CLEANFILES += \
3dab36
+    $(test_metas) \
3dab36
+    ibus-desktop-testing-runner \
3dab36
+    $(NULL)
3dab36
+
3dab36
 test_execs_PROGRAMS = $(TESTS)
3dab36
 if ENABLE_GTK3
3dab36
 test_execs_SCRIPTS = ibus-compose-locales
3dab36
+CLEANFILES += \
3dab36
+    ibus-compose-locales \
3dab36
+    $(NULL)
3dab36
 endif
3dab36
 test_execsdir = $(libexecdir)/installed-tests/ibus
3dab36
 endif
3dab36
@@ -105,15 +115,14 @@ $(test_metas): $(test_metas_in) $(test_programs)
3dab36
 	$(NULL)
3dab36
 
3dab36
 ibus-compose-locales: ibus-compose-locales.in
3dab36
-	INSTALLEDDIR=$(datadir)/installed-tests; \
3dab36
-	sed -e "s|@INSTALLEDDIR[@]|$$INSTALLEDDIR|g" $< > $@.tmp; \
3dab36
+	SRCDIR=$(test_sourcesdir); \
3dab36
+	sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \
3dab36
 	mv $@.tmp $@; \
3dab36
 	$(NULL)
3dab36
 
3dab36
-    ibus-desktop-testing-runner.in \
3dab36
 ibus-desktop-testing-runner: ibus-desktop-testing-runner.in
3dab36
-	SRCDIR=$(test_sourcesdir); \
3dab36
-	sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \
3dab36
+	INSTALLEDDIR=$(datadir)/installed-tests; \
3dab36
+	sed -e "s|@INSTALLEDDIR[@]|$$INSTALLEDDIR|g" $< > $@.tmp; \
3dab36
 	mv $@.tmp $@; \
3dab36
 	$(NULL)
3dab36
 
3dab36
diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in
3dab36
index 8d2384d1..fad02965 100755
3dab36
--- a/src/tests/ibus-compose-locales.in
3dab36
+++ b/src/tests/ibus-compose-locales.in
3dab36
@@ -6,6 +6,7 @@ BUILDDIR=`dirname $0`
3dab36
 
3dab36
 export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
 
3dab36
+retval=0
3dab36
 for var in `cat $SRCDIR/ibus-compose.env`
3dab36
 do
3dab36
     IS_COMMENT=`echo "$var" | grep "^#"`
3dab36
@@ -13,6 +14,7 @@ do
3dab36
         continue
3dab36
     fi
3dab36
     env $var $BUILDDIR/ibus-compose $SRCDIR $@
3dab36
+    retval=`expr $retval + $?`
3dab36
 
3dab36
     CACHE_FILES=`ls *.cache`
3dab36
     if [ x"$CACHE_FILES" != x ] ; then
3dab36
@@ -20,4 +22,4 @@ do
3dab36
         rm $CACHE_FILES
3dab36
     fi
3dab36
 done
3dab36
-
3dab36
+exit $retval
3dab36
diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c
3dab36
index c8d3c126..db359477 100644
3dab36
--- a/src/tests/ibus-compose.c
3dab36
+++ b/src/tests/ibus-compose.c
3dab36
@@ -344,20 +344,26 @@ test_compose (void)
3dab36
 int
3dab36
 main (int argc, char *argv[])
3dab36
 {
3dab36
+    GLogLevelFlags flags;
3dab36
     const gchar *test_name;
3dab36
     gchar *test_path;
3dab36
 
3dab36
     ibus_init ();
3dab36
+    /* Avoid a warning of "AT-SPI: Could not obtain desktop path or name"
3dab36
+     * with gtk_main().
3dab36
+     */
3dab36
+    g_setenv ("NO_AT_BRIDGE", "1", TRUE);
3dab36
     g_test_init (&argc, &argv, NULL);
3dab36
     /* FIXME:
3dab36
      * IBusIMContext opens GtkIMContextSimple as the slave and
3dab36
      * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the
3dab36
-     * multiple outputs in el_GR's compose causes a warning in gtkcomposetable 
3dab36
+     * multiple outputs in el_GR's compose causes a warning in gtkcomposetable
3dab36
      * and the warning always causes a fatal in GTest:
3dab36
      " "GTK+ supports to output one char only: "
3dab36
      */
3dab36
-    g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
3dab36
+    flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
3dab36
     gtk_init (&argc, &argv);
3dab36
+    g_log_set_always_fatal (flags);
3dab36
 
3dab36
     m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup (".");
3dab36
     m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE"));
3dab36
diff --git a/src/tests/ibus-config.c b/src/tests/ibus-config.c
3dab36
index c6141ab5..9b925ad9 100644
3dab36
--- a/src/tests/ibus-config.c
3dab36
+++ b/src/tests/ibus-config.c
3dab36
@@ -133,254 +133,6 @@ test_config_set_get (void)
3dab36
     g_object_unref (config);
3dab36
 }
3dab36
 
3dab36
-typedef struct {
3dab36
-    GMainLoop *loop;
3dab36
-    guint timeout_id;
3dab36
-    gchar *section;
3dab36
-    gchar *name;
3dab36
-} WatchData;
3dab36
-
3dab36
-typedef struct {
3dab36
-    gchar *section;
3dab36
-    gchar *name;
3dab36
-} WatchKey;
3dab36
-
3dab36
-typedef struct {
3dab36
-    WatchKey *watched;          /* watched keys (null-terminated) */
3dab36
-    WatchKey *changed;          /* changed keys (null-terminated) */
3dab36
-    WatchKey *notified;         /* notified keys (same length as
3dab36
-                                   changed, not null-terminated) */
3dab36
-} WatchTestData;
3dab36
-
3dab36
-static WatchKey default_watched[] = {
3dab36
-    { NULL }
3dab36
-};
3dab36
-static WatchKey default_changed[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { "test/s1", "n2" },
3dab36
-    { "test/s2", "n1" },
3dab36
-    { "test/s2", "n2" },
3dab36
-    { NULL }
3dab36
-};
3dab36
-static WatchKey default_notified[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { "test/s1", "n2" },
3dab36
-    { "test/s2", "n1" },
3dab36
-    { "test/s2", "n2" }
3dab36
-};
3dab36
-static WatchTestData default_data = {
3dab36
-    default_watched,
3dab36
-    default_changed,
3dab36
-    default_notified
3dab36
-};
3dab36
-
3dab36
-static WatchKey section_watched[] = {
3dab36
-    { "test/s1", NULL },
3dab36
-    { NULL }
3dab36
-};
3dab36
-static WatchKey section_notified[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { "test/s1", "n2" },
3dab36
-    { NULL, NULL },
3dab36
-    { NULL, NULL },
3dab36
-};
3dab36
-static WatchTestData section_data = {
3dab36
-    section_watched,
3dab36
-    default_changed,
3dab36
-    section_notified
3dab36
-};
3dab36
-
3dab36
-static WatchKey section_multiple_watched[] = {
3dab36
-    { "test/s1", NULL },
3dab36
-    { "test/s2", NULL },
3dab36
-    { NULL }
3dab36
-};
3dab36
-static WatchKey section_multiple_notified[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { "test/s1", "n2" },
3dab36
-    { "test/s2", "n1" },
3dab36
-    { "test/s2", "n2" },
3dab36
-};
3dab36
-static WatchTestData section_multiple_data = {
3dab36
-    section_multiple_watched,
3dab36
-    default_changed,
3dab36
-    section_multiple_notified
3dab36
-};
3dab36
-
3dab36
-static WatchKey section_name_watched[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { NULL }
3dab36
-};
3dab36
-static WatchKey section_name_notified[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { NULL, NULL },
3dab36
-    { NULL, NULL },
3dab36
-    { NULL, NULL },
3dab36
-};
3dab36
-static WatchTestData section_name_data = {
3dab36
-    section_name_watched,
3dab36
-    default_changed,
3dab36
-    section_name_notified
3dab36
-};
3dab36
-
3dab36
-static WatchKey section_name_multiple_watched[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { "test/s2", "n2" },
3dab36
-    { NULL }
3dab36
-};
3dab36
-static WatchKey section_name_multiple_notified[] = {
3dab36
-    { "test/s1", "n1" },
3dab36
-    { NULL, NULL },
3dab36
-    { NULL, NULL },
3dab36
-    { "test/s2", "n2" },
3dab36
-};
3dab36
-static WatchTestData section_name_multiple_data = {
3dab36
-    section_name_multiple_watched,
3dab36
-    default_changed,
3dab36
-    section_name_multiple_notified
3dab36
-};
3dab36
-
3dab36
-typedef struct {
3dab36
-    IBusConfig *config;
3dab36
-    WatchData data;
3dab36
-} WatchFixture;
3dab36
-
3dab36
-static void
3dab36
-value_changed_cb (IBusConfig  *config,
3dab36
-                  const gchar *section,
3dab36
-                  const gchar *name,
3dab36
-                  GVariant    *value,
3dab36
-                  gpointer     user_data)
3dab36
-{
3dab36
-    WatchData *data = (WatchData *) user_data;
3dab36
-
3dab36
-    data->section = g_strdup (section);
3dab36
-    data->name = g_strdup (name);
3dab36
-
3dab36
-    g_main_loop_quit (data->loop);
3dab36
-}
3dab36
-
3dab36
-static gboolean
3dab36
-timeout_cb (gpointer user_data)
3dab36
-{
3dab36
-    WatchData *data = (WatchData *) user_data;
3dab36
-    g_main_loop_quit (data->loop);
3dab36
-    data->timeout_id = 0;
3dab36
-    return FALSE;
3dab36
-}
3dab36
-
3dab36
-static void
3dab36
-change_and_test (IBusConfig  *config,
3dab36
-                 const gchar *section,
3dab36
-                 const gchar *name,
3dab36
-                 const gchar *expected_section,
3dab36
-                 const gchar *expected_name,
3dab36
-                 WatchData   *data)
3dab36
-{
3dab36
-    gboolean retval;
3dab36
-    GVariant *var;
3dab36
-
3dab36
-    data->section = NULL;
3dab36
-    data->name = NULL;
3dab36
-
3dab36
-    /* Unset won't notify value-changed signal. */
3dab36
-    var = ibus_config_get_values (config, section);
3dab36
-    if (var != NULL) {
3dab36
-        GVariant *value = g_variant_lookup_value (var, name,
3dab36
-                                                  G_VARIANT_TYPE_VARIANT);
3dab36
-        if (value != NULL) {
3dab36
-            ibus_config_unset (config, section, name);
3dab36
-            g_variant_unref (value);
3dab36
-        }
3dab36
-        g_variant_unref (var);
3dab36
-    }
3dab36
-
3dab36
-    data->timeout_id = g_timeout_add (1, timeout_cb, data);
3dab36
-    g_main_loop_run (data->loop);
3dab36
-    if (data->timeout_id != 0) {
3dab36
-        g_source_remove (data->timeout_id);
3dab36
-    }
3dab36
-
3dab36
-    retval = ibus_config_set_value (config, section, name,
3dab36
-                                    g_variant_new_int32 (1));
3dab36
-    g_assert (retval);
3dab36
-
3dab36
-    data->timeout_id = g_timeout_add (1, timeout_cb, data);
3dab36
-    g_main_loop_run (data->loop);
3dab36
-    if (data->timeout_id != 0) {
3dab36
-        g_source_remove (data->timeout_id);
3dab36
-    }
3dab36
-
3dab36
-    g_assert_cmpstr (data->section, ==, expected_section);
3dab36
-    g_assert_cmpstr (data->name, ==, expected_name);
3dab36
-
3dab36
-    g_free (data->section);
3dab36
-    g_free (data->name);
3dab36
-}
3dab36
-
3dab36
-static void
3dab36
-watch_fixture_setup (WatchFixture *fixture, gconstpointer user_data)
3dab36
-{
3dab36
-    fixture->config = ibus_config_new (ibus_bus_get_connection (bus),
3dab36
-                                       NULL,
3dab36
-                                       NULL);
3dab36
-    g_assert (fixture->config);
3dab36
-
3dab36
-    fixture->data.loop = g_main_loop_new (NULL, FALSE);
3dab36
-    g_signal_connect (fixture->config, "value-changed",
3dab36
-                      G_CALLBACK (value_changed_cb), &fixture->data);
3dab36
-}
3dab36
-
3dab36
-static void
3dab36
-watch_fixture_teardown (WatchFixture *fixture, gconstpointer user_data)
3dab36
-{
3dab36
-    g_main_loop_unref (fixture->data.loop);
3dab36
-
3dab36
-    ibus_proxy_destroy (IBUS_PROXY (fixture->config));
3dab36
-    g_object_unref (fixture->config);
3dab36
-}
3dab36
-
3dab36
-static void
3dab36
-test_config_watch (WatchFixture *fixture, gconstpointer user_data)
3dab36
-{
3dab36
-    const WatchTestData *data = user_data;
3dab36
-    gint i;
3dab36
-
3dab36
-    for (i = 0; data->watched[i].section != NULL; i++) {
3dab36
-        ibus_config_watch (fixture->config,
3dab36
-                           data->watched[i].section,
3dab36
-                           data->watched[i].name);
3dab36
-    }
3dab36
-    for (i = 0; data->changed[i].section != NULL; i++) {
3dab36
-        change_and_test (fixture->config,
3dab36
-                         data->changed[i].section,
3dab36
-                         data->changed[i].name,
3dab36
-                         data->notified[i].section,
3dab36
-                         data->notified[i].name,
3dab36
-                         &fixture->data);
3dab36
-    }
3dab36
-    for (i = 0; data->watched[i].section != NULL; i++) {
3dab36
-        ibus_config_unwatch (fixture->config,
3dab36
-                             data->watched[i].section,
3dab36
-                             data->watched[i].name);
3dab36
-    }
3dab36
-    if (i > 0) {
3dab36
-        /* Check if the above unwatch takes effect. */
3dab36
-        for (i = 0; data->changed[i].section != NULL; i++) {
3dab36
-            change_and_test (fixture->config,
3dab36
-                             data->changed[i].section,
3dab36
-                             data->changed[i].name,
3dab36
-                             NULL,
3dab36
-                             NULL,
3dab36
-                             &fixture->data);
3dab36
-        }
3dab36
-    } else {
3dab36
-        /* Since we reuse single D-Bus connection, we need to remove the
3dab36
-           default match rule for the next ibus_config_new() call.  */
3dab36
-        ibus_config_unwatch (fixture->config, NULL, NULL);
3dab36
-    }
3dab36
-}
3dab36
-
3dab36
 gint
3dab36
 main (gint    argc,
3dab36
       gchar **argv)
3dab36
@@ -390,41 +142,6 @@ main (gint    argc,
3dab36
     g_test_init (&argc, &argv, NULL);
3dab36
     bus = ibus_bus_new ();
3dab36
 
3dab36
-    g_test_add ("/ibus/config-watch/default",
3dab36
-                WatchFixture,
3dab36
-                &default_data,
3dab36
-                watch_fixture_setup,
3dab36
-                test_config_watch,
3dab36
-                watch_fixture_teardown);
3dab36
-
3dab36
-    g_test_add ("/ibus/config-watch/section",
3dab36
-                WatchFixture,
3dab36
-                &section_data,
3dab36
-                watch_fixture_setup,
3dab36
-                test_config_watch,
3dab36
-                watch_fixture_teardown);
3dab36
-
3dab36
-    g_test_add ("/ibus/config-watch/section-multiple",
3dab36
-                WatchFixture,
3dab36
-                &section_multiple_data,
3dab36
-                watch_fixture_setup,
3dab36
-                test_config_watch,
3dab36
-                watch_fixture_teardown);
3dab36
-
3dab36
-    g_test_add ("/ibus/config-watch/section-name",
3dab36
-                WatchFixture,
3dab36
-                &section_name_data,
3dab36
-                watch_fixture_setup,
3dab36
-                test_config_watch,
3dab36
-                watch_fixture_teardown);
3dab36
-
3dab36
-    g_test_add ("/ibus/config-watch/section-name-multiple",
3dab36
-                WatchFixture,
3dab36
-                &section_name_multiple_data,
3dab36
-                watch_fixture_setup,
3dab36
-                test_config_watch,
3dab36
-                watch_fixture_teardown);
3dab36
-
3dab36
     g_test_add_func ("/ibus/create-config-async", test_create_config_async);
3dab36
     g_test_add_func ("/ibus/config-set-get", test_config_set_get);
3dab36
 
3dab36
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
3dab36
index a90c1378..b7a72285 100755
3dab36
--- a/src/tests/ibus-desktop-testing-runner.in
3dab36
+++ b/src/tests/ibus-desktop-testing-runner.in
3dab36
@@ -34,9 +34,10 @@ DISPLAY=:99.0
3dab36
 BUILDDIR="."
3dab36
 SRCDIR="."
3dab36
 TEST_LOG="test-suite.log"
3dab36
+TEST_LOG_STDOUT=0
3dab36
 RESULT_LOG=""
3dab36
 HAVE_GRAPHICS=1
3dab36
-DESKTOP_COMMAND="gnome-session"
3dab36
+DESKTOP_COMMAND="dbus-launch --exit-with-session gnome-session"
3dab36
 PID_XORG=0
3dab36
 PID_GNOME_SESSION=0
3dab36
 TESTING_RUNNER="default"
3dab36
@@ -109,19 +110,26 @@ parse_args()
3dab36
 init_desktop()
3dab36
 {
3dab36
     if [ "$RESULT_LOG" != "" ] ; then
3dab36
-        rm $RESULT_LOG
3dab36
+        if [ -f $RESULT_LOG ] ; then
3dab36
+            rm $RESULT_LOG
3dab36
+        fi
3dab36
+    fi
3dab36
+    HAS_STDOUT=`echo "$TEST_LOG" | grep ':stdout'`
3dab36
+    if [ x"$HAS_STDOUT" != x ] ; then
3dab36
+        TEST_LOG=`echo "$TEST_LOG" | sed -e 's|:stdout||'`
3dab36
+        TEST_LOG_STDOUT=1
3dab36
     fi
3dab36
     if [ "$TEST_LOG" = "" ] ; then
3dab36
         print_log -e "${RED}FAIL${NC}: ${RED}ERROR${NC}: a log file is required to get return value with 'read' command"
3dab36
-        abrt
3dab36
-    else
3dab36
+        exit -1
3dab36
+    elif [ -f $TEST_LOG ] ; then
3dab36
         rm $TEST_LOG
3dab36
     fi
3dab36
-    if test x$FORCE_TEST != x ; then
3dab36
+    if [ x$FORCE_TEST != x ] ; then
3dab36
         RUN_ARGS="$RUN_ARGS --force"
3dab36
     fi
3dab36
 
3dab36
-    if test ! -f $HOME/.config/gnome-initial-setup-done ; then
3dab36
+    if [ ! -f $HOME/.config/gnome-initial-setup-done ] ; then
3dab36
         IS_SYSTEM_ACCOUNT=false
3dab36
         if [ "$USER" = "root" ] ; then
3dab36
             IS_SYSTEM_ACCOUNT=true
3dab36
@@ -141,7 +149,7 @@ _EOF
3dab36
 
3dab36
     # Prevent from launching a XDG dialog
3dab36
     XDG_LOCALE_FILE="$HOME/.config/user-dirs.locale"
3dab36
-    if test -f $XDG_LOCALE_FILE ; then
3dab36
+    if [ -f $XDG_LOCALE_FILE ] ; then
3dab36
         XDG_LANG_ORIG=`cat $XDG_LOCALE_FILE`
3dab36
         XDG_LANG_NEW=`echo $LANG | sed -e 's/\(.*\)\..*/\1/'`
3dab36
         if [ "$XDG_LANG_ORIG" != "$XDG_LANG_NEW" ] ; then
3dab36
@@ -153,19 +161,8 @@ _EOF
3dab36
 
3dab36
 run_dbus_daemon()
3dab36
 {
3dab36
-    a=`ps -ef | grep dbus-daemon | grep "\-\-system" | grep -v session | grep -v grep`
3dab36
-    if test x"$a" = x ; then
3dab36
-        eval `dbus-launch --sh-syntax`
3dab36
-    fi
3dab36
-    SUSER=`echo "$USER" | cut -c 1-7`
3dab36
-    a=`ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | grep session | grep -v grep`
3dab36
-    if test x"$a" = x ; then
3dab36
-        systemctl --user start dbus
3dab36
-        export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus
3dab36
-    fi
3dab36
-    systemctl --user status dbus | col -b
3dab36
-    ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | egrep 'session|system' | grep -v grep
3dab36
-    systemctl --user show-environment | col -b
3dab36
+    # Use dbus-launch --exit-with-session later instead of --sh-syntax
3dab36
+    export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus
3dab36
 }
3dab36
 
3dab36
 run_desktop()
3dab36
@@ -181,7 +178,8 @@ run_desktop()
3dab36
     $DESKTOP_COMMAND &
3dab36
     PID_GNOME_SESSION=$!
3dab36
     sleep 30
3dab36
-    if test "$DESKTOP_COMMAND" != "gnome-session" ; then
3dab36
+    HAS_GNOME=`echo $DESKTOP_COMMAND | grep gnome-session`
3dab36
+    if [ x"$HAS_GNOME" = x ] ; then
3dab36
         ibus-daemon --daemonize --verbose
3dab36
         sleep 1
3dab36
     fi
3dab36
@@ -285,6 +283,16 @@ run_gnome_desktop_testing_runner()
3dab36
         `count_case_result $retval $pass $fail`
3dab36
 EOF
3dab36
     done
3dab36
+    child_pass=`grep '^PASS:' $TEST_LOG | wc -l`
3dab36
+    child_fail=`grep '^FAIL:' $TEST_LOG | wc -l`
3dab36
+    if [ $child_pass -ne 0 -o $child_fail -ne 0 ] ; then
3dab36
+        pass=$child_pass
3dab36
+        if [ $child_fail -ne 0 ] ; then
3dab36
+            fail=`expr $child_fail / 2`
3dab36
+        else
3dab36
+            fail=0
3dab36
+        fi
3dab36
+    fi
3dab36
     echo $pass $fail
3dab36
 }
3dab36
 
3dab36
@@ -311,22 +319,29 @@ EOF_RUNNER
3dab36
         ;;
3dab36
     esac
3dab36
     echo ""
3dab36
-    if [ $pass -ne 0 ] ; then
3dab36
-        print_log -e "${GREEN}PASS${NC}: $pass"
3dab36
-    fi
3dab36
-    if [ $fail -ne 0 ] ; then
3dab36
-        print_log -e "${RED}FAIL${NC}: $fail"
3dab36
-    fi
3dab36
+    print_log -e "${GREEN}PASS${NC}: $pass"
3dab36
+    print_log -e "${RED}FAIL${NC}: $fail"
3dab36
     echo ""
3dab36
-    echo "See ${TEST_LOG}"
3dab36
+    if [ $TEST_LOG_STDOUT -eq 1 ] ; then
3dab36
+        cat $TEST_LOG
3dab36
+    else
3dab36
+        echo "See $TEST_LOG"
3dab36
+    fi
3dab36
 }
3dab36
 
3dab36
 finit()
3dab36
 {
3dab36
-    if test "$DESKTOP_COMMAND" != "gnome-session" ; then
3dab36
-        ibus exit
3dab36
-    fi
3dab36
+    echo "Killing left gnome-session and Xorg"
3dab36
     kill $PID_GNOME_SESSION $PID_XORG
3dab36
+    ibus exit
3dab36
+    SUSER=`echo "$USER" | cut -c 1-7`
3dab36
+    LEFT_CALENDAR=`ps -ef | grep gnome-shell-calendar-server | grep $SUSER | grep -v grep`
3dab36
+    if [ x"$LEFT_CALENDAR" != x ] ; then
3dab36
+        echo "Killing left gnome-shell-calendar-server"
3dab36
+        echo "$LEFT_CALENDAR"
3dab36
+        echo "$LEFT_CALENDAR" | awk '{print $2}' | xargs kill
3dab36
+    fi
3dab36
+
3dab36
     echo "Finished $PROGNAME testing"
3dab36
 }
3dab36
 
3dab36
diff --git a/src/tests/ibus-engine-switch.c b/src/tests/ibus-engine-switch.c
3dab36
index 5c2bd516..a1eeba2a 100644
3dab36
--- a/src/tests/ibus-engine-switch.c
3dab36
+++ b/src/tests/ibus-engine-switch.c
3dab36
@@ -13,17 +13,25 @@ static const gchar *engine_names[] = {
3dab36
     AFTER_ENGINE
3dab36
 };
3dab36
 
3dab36
+static const gchar *engine_names2[] = {
3dab36
+    AFTER_ENGINE,
3dab36
+    BEFORE_ENGINE
3dab36
+};
3dab36
+
3dab36
 static void
3dab36
-change_global_engine (void)
3dab36
+change_global_engine (gboolean reverse)
3dab36
 {
3dab36
     gint i;
3dab36
 
3dab36
     for (i = 0; i < G_N_ELEMENTS (engine_names); i++) {
3dab36
-        ibus_bus_set_global_engine (bus, engine_names[i]);
3dab36
+        const gchar *engine_name = engine_names[i];
3dab36
+        if (reverse)
3dab36
+            engine_name = engine_names2[i];
3dab36
+        ibus_bus_set_global_engine (bus, engine_name);
3dab36
         IBusEngineDesc *engine_desc = ibus_bus_get_global_engine (bus);
3dab36
         g_assert_cmpstr (ibus_engine_desc_get_name (engine_desc),
3dab36
                          ==,
3dab36
-                         engine_names[i]);
3dab36
+                         engine_name);
3dab36
         g_object_unref (G_OBJECT (engine_desc));
3dab36
     }
3dab36
 }
3dab36
@@ -46,6 +54,7 @@ typedef struct {
3dab36
     gint count;
3dab36
     guint timeout_id;
3dab36
     guint idle_id;
3dab36
+    gboolean reverse;
3dab36
 } GlobalEngineChangedData;
3dab36
 
3dab36
 static void
3dab36
@@ -70,7 +79,7 @@ static gboolean
3dab36
 change_global_engine_cb (gpointer user_data)
3dab36
 {
3dab36
     GlobalEngineChangedData *data = (GlobalEngineChangedData *) user_data;
3dab36
-    change_global_engine ();
3dab36
+    change_global_engine (data->reverse);
3dab36
     data->idle_id = 0;
3dab36
     return FALSE;
3dab36
 }
3dab36
@@ -78,12 +87,25 @@ change_global_engine_cb (gpointer user_data)
3dab36
 static void
3dab36
 test_global_engine (void)
3dab36
 {
3dab36
+    GLogLevelFlags flags;
3dab36
+    IBusEngineDesc *desc;
3dab36
     GlobalEngineChangedData data;
3dab36
     guint handler_id;
3dab36
 
3dab36
     if (!ibus_bus_get_use_global_engine (bus))
3dab36
         return;
3dab36
 
3dab36
+    /* "No global engine." warning is not critical message. */
3dab36
+    flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
3dab36
+    desc = ibus_bus_get_global_engine (bus);
3dab36
+    g_log_set_always_fatal (flags);
3dab36
+    if (desc &&
3dab36
+        !g_strcmp0 (BEFORE_ENGINE, ibus_engine_desc_get_name (desc))) {
3dab36
+        data.reverse = TRUE;
3dab36
+    } else {
3dab36
+        data.reverse = FALSE;
3dab36
+    }
3dab36
+
3dab36
     data.count = 0;
3dab36
 
3dab36
     handler_id = g_signal_connect (bus,
3dab36
@@ -141,7 +163,7 @@ test_context_engine_set_by_global (void)
3dab36
     /* ibus_bus_set_global_engine() changes focused context engine. */
3dab36
     ibus_input_context_focus_in (context);
3dab36
 
3dab36
-    change_global_engine ();
3dab36
+    change_global_engine (FALSE);
3dab36
 
3dab36
     /* ibus_input_context_set_engine() does not take effect when
3dab36
        global engine is used. */
3dab36
@@ -170,7 +192,7 @@ test_context_engine_set_by_focus (void)
3dab36
 
3dab36
     ibus_input_context_focus_in (context);
3dab36
 
3dab36
-    change_global_engine ();
3dab36
+    change_global_engine (FALSE);
3dab36
 
3dab36
     /* When focus is lost, context engine is set to "dummy". */
3dab36
     ibus_input_context_focus_in (another_context);
3dab36
diff --git a/src/tests/ibus-inputcontext.c b/src/tests/ibus-inputcontext.c
3dab36
index fab183aa..ed04bd64 100644
3dab36
--- a/src/tests/ibus-inputcontext.c
3dab36
+++ b/src/tests/ibus-inputcontext.c
3dab36
@@ -37,18 +37,6 @@ fatal_handler(const gchar *log_domain,
3dab36
     return TRUE;
3dab36
 }
3dab36
 
3dab36
-static gchar *
3dab36
-get_last_engine_id (const GList *engines)
3dab36
-{
3dab36
-    const char *result = NULL;
3dab36
-    for (; engines; engines = g_list_next (engines)) {
3dab36
-        IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data);
3dab36
-        g_assert (engine_desc);
3dab36
-        result = ibus_engine_desc_get_name (engine_desc);
3dab36
-    }
3dab36
-    return g_strdup (result);
3dab36
-}
3dab36
-
3dab36
 static void
3dab36
 call_basic_ipcs (IBusInputContext *context)
3dab36
 {
3dab36
@@ -68,18 +56,23 @@ call_basic_ipcs (IBusInputContext *context)
3dab36
 static void
3dab36
 test_input_context (void)
3dab36
 {
3dab36
-    GList *engines;
3dab36
-    gchar *active_engine_name = NULL;
3dab36
     IBusInputContext *context;
3dab36
+    GLogLevelFlags flags;
3dab36
     IBusEngineDesc *engine_desc;
3dab36
+    gchar *active_engine_name = NULL;
3dab36
     gchar *current_ic;
3dab36
 
3dab36
     context = ibus_bus_create_input_context (bus, "test");
3dab36
     call_basic_ipcs (context);
3dab36
 
3dab36
-    engines = ibus_bus_list_active_engines (bus);
3dab36
-    if (engines != NULL) {
3dab36
-        active_engine_name = get_last_engine_id (engines);
3dab36
+    /* "No global engine." warning is not critical message. */
3dab36
+    flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
3dab36
+    engine_desc = ibus_bus_get_global_engine (bus);
3dab36
+    g_log_set_always_fatal (flags);
3dab36
+    if (engine_desc != NULL) {
3dab36
+        active_engine_name = g_strdup (ibus_engine_desc_get_name(engine_desc));
3dab36
+        g_object_unref (engine_desc);
3dab36
+        engine_desc = NULL;
3dab36
     } else {
3dab36
         active_engine_name = g_strdup ("dummy");
3dab36
     }
3dab36
@@ -111,8 +104,6 @@ test_input_context (void)
3dab36
     g_object_unref (context);
3dab36
 
3dab36
     g_free (active_engine_name);
3dab36
-    g_list_foreach (engines, (GFunc) g_object_unref, NULL);
3dab36
-    g_list_free (engines);
3dab36
 }
3dab36
 
3dab36
 static void
3dab36
diff --git a/src/tests/ibus-keypress.c b/src/tests/ibus-keypress.c
3dab36
index 17920226..dd1b0042 100644
3dab36
--- a/src/tests/ibus-keypress.c
3dab36
+++ b/src/tests/ibus-keypress.c
3dab36
@@ -288,6 +288,10 @@ int
3dab36
 main (int argc, char *argv[])
3dab36
 {
3dab36
     ibus_init ();
3dab36
+    /* Avoid a warning of "AT-SPI: Could not obtain desktop path or name"
3dab36
+     * with gtk_main().
3dab36
+     */
3dab36
+    g_setenv ("NO_AT_BRIDGE", "1", TRUE);
3dab36
     g_test_init (&argc, &argv, NULL);
3dab36
     gtk_init (&argc, &argv);
3dab36
 
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From f4463c0433c5f48a4fb2830e8c2ae9619fbb18d1 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Mon, 29 Jul 2019 19:05:43 +0900
3dab36
Subject: [PATCH] src/tests: Fix a fatal error with g_warning
3dab36
3dab36
I set g_log_set_always_fatal() before gtk_init() in ibus-compose for
3dab36
a compose warning of GtkIMContextSimple but actually the warning is
3dab36
output during gtk_main() due to GtkIMContextSimple.set_client_window()
3dab36
so I moved g_log_set_always_fatal() before gtk_main() in ibus-compose.c.
3dab36
3dab36
Also set IFS in ibus-compose-locales to set the delimiter to '\n' for
3dab36
for-loop arguments.
3dab36
---
3dab36
 src/tests/ibus-compose-locales.in |  8 ++++++++
3dab36
 src/tests/ibus-compose.c          | 21 ++++++++++-----------
3dab36
 2 files changed, 18 insertions(+), 11 deletions(-)
3dab36
3dab36
diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in
3dab36
index fad02965..f650b584 100755
3dab36
--- a/src/tests/ibus-compose-locales.in
3dab36
+++ b/src/tests/ibus-compose-locales.in
3dab36
@@ -7,19 +7,27 @@ BUILDDIR=`dirname $0`
3dab36
 export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
 
3dab36
 retval=0
3dab36
+# Let for-loop notice '\n' as a delimiter
3dab36
+IFS=$'\n'
3dab36
 for var in `cat $SRCDIR/ibus-compose.env`
3dab36
 do
3dab36
+    # Revert IFS to recognize env a=foo b=foo
3dab36
+    IFS=' '
3dab36
     IS_COMMENT=`echo "$var" | grep "^#"`
3dab36
     if [ "x$IS_COMMENT" != x ] ; then
3dab36
         continue
3dab36
     fi
3dab36
+    echo "# Starting $var $BUILDDIR/ibus-compose $SRCDIR $@"
3dab36
     env $var $BUILDDIR/ibus-compose $SRCDIR $@
3dab36
     retval=`expr $retval + $?`
3dab36
+    echo "# Finished $var $BUILDDIR/ibus-compose $SRCDIR $@ with $retval"
3dab36
 
3dab36
     CACHE_FILES=`ls *.cache`
3dab36
     if [ x"$CACHE_FILES" != x ] ; then
3dab36
         echo "Clean $CACHE_FILES"
3dab36
         rm $CACHE_FILES
3dab36
     fi
3dab36
+    IFS=$'\n'
3dab36
 done
3dab36
+IFS=' '
3dab36
 exit $retval
3dab36
diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c
3dab36
index db359477..4b4c56e7 100644
3dab36
--- a/src/tests/ibus-compose.c
3dab36
+++ b/src/tests/ibus-compose.c
3dab36
@@ -331,20 +331,28 @@ create_window ()
3dab36
 static void
3dab36
 test_compose (void)
3dab36
 {
3dab36
+    GLogLevelFlags flags;
3dab36
     if (!register_ibus_engine ()) {
3dab36
         g_test_fail ();
3dab36
         return;
3dab36
     }
3dab36
 
3dab36
     create_window ();
3dab36
+    /* FIXME:
3dab36
+     * IBusIMContext opens GtkIMContextSimple as the slave and
3dab36
+     * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the
3dab36
+     * multiple outputs in el_GR's compose causes a warning in gtkcomposetable
3dab36
+     * and the warning always causes a fatal in GTest:
3dab36
+     " "GTK+ supports to output one char only: "
3dab36
+     */
3dab36
+    flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
3dab36
     gtk_main ();
3dab36
-
3dab36
+    g_log_set_always_fatal (flags);
3dab36
 }
3dab36
 
3dab36
 int
3dab36
 main (int argc, char *argv[])
3dab36
 {
3dab36
-    GLogLevelFlags flags;
3dab36
     const gchar *test_name;
3dab36
     gchar *test_path;
3dab36
 
3dab36
@@ -354,16 +362,7 @@ main (int argc, char *argv[])
3dab36
      */
3dab36
     g_setenv ("NO_AT_BRIDGE", "1", TRUE);
3dab36
     g_test_init (&argc, &argv, NULL);
3dab36
-    /* FIXME:
3dab36
-     * IBusIMContext opens GtkIMContextSimple as the slave and
3dab36
-     * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the
3dab36
-     * multiple outputs in el_GR's compose causes a warning in gtkcomposetable
3dab36
-     * and the warning always causes a fatal in GTest:
3dab36
-     " "GTK+ supports to output one char only: "
3dab36
-     */
3dab36
-    flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
3dab36
     gtk_init (&argc, &argv);
3dab36
-    g_log_set_always_fatal (flags);
3dab36
 
3dab36
     m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup (".");
3dab36
     m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE"));
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From 7dde99600777f195da614130950ecbd339439d35 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Wed, 31 Jul 2019 16:27:49 +0900
3dab36
Subject: [PATCH] src/tests: Fix wrong echo with direct runner in
3dab36
 ibus-desktop-testing-runner
3dab36
3dab36
The wrong echo prevent from counting the test results in the direct
3dab36
testing runner.
3dab36
---
3dab36
 src/tests/ibus-desktop-testing-runner.in | 33 +++++++++++++-----------
3dab36
 1 file changed, 18 insertions(+), 15 deletions(-)
3dab36
3dab36
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
3dab36
index b7a72285..3045d601 100755
3dab36
--- a/src/tests/ibus-desktop-testing-runner.in
3dab36
+++ b/src/tests/ibus-desktop-testing-runner.in
3dab36
@@ -153,7 +153,7 @@ _EOF
3dab36
         XDG_LANG_ORIG=`cat $XDG_LOCALE_FILE`
3dab36
         XDG_LANG_NEW=`echo $LANG | sed -e 's/\(.*\)\..*/\1/'`
3dab36
         if [ "$XDG_LANG_ORIG" != "$XDG_LANG_NEW" ] ; then
3dab36
-            echo "Overriding XDG locale $XDG_LANG_ORIG with $XDG_LANG_NEW"
3dab36
+            echo "# Overriding XDG locale $XDG_LANG_ORIG with $XDG_LANG_NEW"
3dab36
             echo "$XDG_LANG_NEW" > $XDG_LOCALE_FILE
3dab36
         fi
3dab36
     fi
3dab36
@@ -206,11 +206,9 @@ echo_case_result()
3dab36
     subtst=${3:-''}
3dab36
 
3dab36
     if test $retval -eq  0 ; then
3dab36
-        print_log -e "${GREEN}PASS${NC}: $tst $subtst"
3dab36
+        echo "PASS: $tst $subtst" >>$TEST_LOG
3dab36
     else
3dab36
-        print_log -e "${RED}FAIL${NC}: $tst $subtst"
3dab36
-        print_log "======================"
3dab36
-        print_log ""
3dab36
+        echo "FAIL: $tst $subtst" >>$TEST_LOG
3dab36
     fi
3dab36
 }
3dab36
 
3dab36
@@ -232,32 +230,37 @@ EOF
3dab36
             echo_case_result $retval $tst
3dab36
             CACHE_FILES=`ls *.cache`
3dab36
             if [ x"$CACHE_FILES" != x ] ; then
3dab36
-                print_log "Clean $CACHE_FILES"
3dab36
+                echo "# Clean $CACHE_FILES" >>$TEST_LOG
3dab36
                 rm $CACHE_FILES
3dab36
             fi
3dab36
         else
3dab36
-            LANG_backup=$LANG
3dab36
             i=1
3dab36
+            # Let for-loop notice '\n' as a delimiter
3dab36
+            IFS=$'\n'
3dab36
             for e in $ENVS; do
3dab36
+                # Revert IFS to recognize env a=foo b=foo
3dab36
+                IFS=' '
3dab36
                 first=`echo "$e" | grep '^#'`
3dab36
                 if test x"$first" = x"#" ; then
3dab36
                     continue
3dab36
                 fi
3dab36
-                export $e
3dab36
-                $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
+                echo "# Starting $e $BUILDDIR/$tst $SRCDIR" >>$TEST_LOG
3dab36
+                env $e $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
                 retval=$?
3dab36
+                echo "# Finished $e $BUILDDIR/$tst $SRCDIR with $retval" >>$TEST_LOG
3dab36
                 read pass fail << EOF
3dab36
                 `count_case_result $retval $pass $fail`
3dab36
 EOF
3dab36
                 echo_case_result $retval $tst $e
3dab36
                 CACHE_FILES=`ls *.cache`
3dab36
                 if [ x"$CACHE_FILES" != x ] ; then
3dab36
-                    print_log "Clean $CACHE_FILES"
3dab36
+                    echo "# Clean $CACHE_FILES" >>$TEST_LOG
3dab36
                     rm $CACHE_FILES
3dab36
                 fi
3dab36
                 i=`expr $i + 1`
3dab36
+                IFS=$'\n'
3dab36
             done
3dab36
-            export LANG=$LANG_backup
3dab36
+            IFS=' '
3dab36
         fi
3dab36
     done
3dab36
     echo $pass $fail
3dab36
@@ -325,24 +328,24 @@ EOF_RUNNER
3dab36
     if [ $TEST_LOG_STDOUT -eq 1 ] ; then
3dab36
         cat $TEST_LOG
3dab36
     else
3dab36
-        echo "See $TEST_LOG"
3dab36
+        echo "# See $TEST_LOG"
3dab36
     fi
3dab36
 }
3dab36
 
3dab36
 finit()
3dab36
 {
3dab36
-    echo "Killing left gnome-session and Xorg"
3dab36
+    echo "# Killing left gnome-session and Xorg"
3dab36
     kill $PID_GNOME_SESSION $PID_XORG
3dab36
     ibus exit
3dab36
     SUSER=`echo "$USER" | cut -c 1-7`
3dab36
     LEFT_CALENDAR=`ps -ef | grep gnome-shell-calendar-server | grep $SUSER | grep -v grep`
3dab36
     if [ x"$LEFT_CALENDAR" != x ] ; then
3dab36
-        echo "Killing left gnome-shell-calendar-server"
3dab36
+        echo "# Killing left gnome-shell-calendar-server"
3dab36
         echo "$LEFT_CALENDAR"
3dab36
         echo "$LEFT_CALENDAR" | awk '{print $2}' | xargs kill
3dab36
     fi
3dab36
 
3dab36
-    echo "Finished $PROGNAME testing"
3dab36
+    echo "# Finished $PROGNAME testing"
3dab36
 }
3dab36
 
3dab36
 main()
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From 28c10d64d282fa9fbc35a7bc44a096f6137d5e46 Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Tue, 13 Aug 2019 20:06:51 +0900
3dab36
Subject: [PATCH] src/tests: Set XDG_SESSION_TYPE in
3dab36
 ibus-desktop-testing-runner
3dab36
3dab36
mutter 3.33.90 or later exits the session without loginctl.
3dab36
Now ibus-desktop-testing-runner has XDG_SESSION_TYPE forcibly
3dab36
not to exit gnome-shell.
3dab36
---
3dab36
 src/tests/ibus-desktop-testing-runner.in | 3 +++
3dab36
 1 file changed, 3 insertions(+)
3dab36
3dab36
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
3dab36
index 3045d601..141e9b5b 100755
3dab36
--- a/src/tests/ibus-desktop-testing-runner.in
3dab36
+++ b/src/tests/ibus-desktop-testing-runner.in
3dab36
@@ -157,6 +157,8 @@ _EOF
3dab36
             echo "$XDG_LANG_NEW" > $XDG_LOCALE_FILE
3dab36
         fi
3dab36
     fi
3dab36
+    # `su` command does not run loginctl
3dab36
+    export XDG_SESSION_TYPE='x11'
3dab36
 }
3dab36
 
3dab36
 run_dbus_daemon()
3dab36
@@ -175,6 +177,7 @@ run_desktop()
3dab36
     PID_XORG=$!
3dab36
     sleep 1
3dab36
     export DISPLAY=$DISPLAY
3dab36
+    echo "Running $DESKTOP_COMMAND with $USER in `tty`"
3dab36
     $DESKTOP_COMMAND &
3dab36
     PID_GNOME_SESSION=$!
3dab36
     sleep 30
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From bccf94d5ec1c5fc80d5aeac622f2ab8007d5a28a Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Fri, 29 Nov 2019 20:28:49 +0900
3dab36
Subject: [PATCH] src/tests: RHEL codereview for ibus-desktop-testing-runner
3dab36
3dab36
---
3dab36
 src/tests/ibus-desktop-testing-runner.in | 16 ++++++++++------
3dab36
 1 file changed, 10 insertions(+), 6 deletions(-)
3dab36
3dab36
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
3dab36
index 141e9b5b..72537cd4 100755
3dab36
--- a/src/tests/ibus-desktop-testing-runner.in
3dab36
+++ b/src/tests/ibus-desktop-testing-runner.in
3dab36
@@ -28,6 +28,10 @@
3dab36
 # # /root/ibus/tests/test-console.sh --tests ibus-compose \
3dab36
 #   --builddir /root/ibus/src/tests --srcdir /root/ibus/src/tests
3dab36
 
3dab36
+# POSIX sh has no 'echo -e'
3dab36
+: ${ECHO:='/usr/bin/echo'}
3dab36
+
3dab36
+
3dab36
 PROGNAME=`basename $0`
3dab36
 VERSION=0.1
3dab36
 DISPLAY=:99.0
3dab36
@@ -54,15 +58,15 @@ print_log()
3dab36
             shift
3dab36
         fi
3dab36
         NO_ESCAPE=`echo $@ | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'`
3dab36
-        echo $NO_ESCAPE >> $RESULT_LOG
3dab36
+        $ECHO $NO_ESCAPE >> $RESULT_LOG
3dab36
     else
3dab36
-        echo $@
3dab36
+        $ECHO $@
3dab36
     fi
3dab36
 }
3dab36
 
3dab36
 usage()
3dab36
 {
3dab36
-    echo -e \
3dab36
+    $ECHO -e \
3dab36
 "This test runs /usr/bin/ibus-daemon after install ibus\n"                     \
3dab36
 "$PROGNAME [OPTIONS…]\n"                                                       \
3dab36
 "\n"                                                                           \
3dab36
@@ -92,7 +96,7 @@ parse_args()
3dab36
     while [ 1 ] ; do
3dab36
         case "$1" in
3dab36
         -h | --help )        usage; exit 0;;
3dab36
-        -v | --version )     echo -e "$VERSION"; exit 0;;
3dab36
+        -v | --version )     $ECHO -e "$VERSION"; exit 0;;
3dab36
         -b | --builddir )    BUILDDIR="$2"; shift 2;;
3dab36
         -s | --srcdir )      SRCDIR="$2"; shift 2;;
3dab36
         -c | --no-graphics ) HAVE_GRAPHICS=0; shift;;
3dab36
@@ -121,7 +125,7 @@ init_desktop()
3dab36
     fi
3dab36
     if [ "$TEST_LOG" = "" ] ; then
3dab36
         print_log -e "${RED}FAIL${NC}: ${RED}ERROR${NC}: a log file is required to get return value with 'read' command"
3dab36
-        exit -1
3dab36
+        exit 255
3dab36
     elif [ -f $TEST_LOG ] ; then
3dab36
         rm $TEST_LOG
3dab36
     fi
3dab36
@@ -291,7 +295,7 @@ EOF
3dab36
     done
3dab36
     child_pass=`grep '^PASS:' $TEST_LOG | wc -l`
3dab36
     child_fail=`grep '^FAIL:' $TEST_LOG | wc -l`
3dab36
-    if [ $child_pass -ne 0 -o $child_fail -ne 0 ] ; then
3dab36
+    if [ $child_pass -ne 0 ] || [ $child_fail -ne 0 ] ; then
3dab36
         pass=$child_pass
3dab36
         if [ $child_fail -ne 0 ] ; then
3dab36
             fail=`expr $child_fail / 2`
3dab36
-- 
3dab36
2.21.0
3dab36
3dab36
From d50627f0b7a000ee13ea6dcc02a4162be1fa853d Mon Sep 17 00:00:00 2001
3dab36
From: fujiwarat <takao.fujiwara1@gmail.com>
3dab36
Date: Tue, 3 Dec 2019 21:42:49 +0900
3dab36
Subject: [PATCH] src/tests: RHEL codereview #2 for ibus-desktop-testing-runner
3dab36
3dab36
---
3dab36
 src/tests/ibus-compose-locales.in        | 21 +++++++--------
3dab36
 src/tests/ibus-desktop-testing-runner.in | 33 ++++++++++++------------
3dab36
 2 files changed, 27 insertions(+), 27 deletions(-)
3dab36
3dab36
diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in
3dab36
index f650b584..b36165fe 100755
3dab36
--- a/src/tests/ibus-compose-locales.in
3dab36
+++ b/src/tests/ibus-compose-locales.in
3dab36
@@ -7,27 +7,26 @@ BUILDDIR=`dirname $0`
3dab36
 export IBUS_COMPOSE_CACHE_DIR=$PWD
3dab36
 
3dab36
 retval=0
3dab36
-# Let for-loop notice '\n' as a delimiter
3dab36
-IFS=$'\n'
3dab36
-for var in `cat $SRCDIR/ibus-compose.env`
3dab36
+# Deleted for var in `cat *.env` because IFS=$'\n' is not supported in POSIX sh
3dab36
+while read var
3dab36
 do
3dab36
-    # Revert IFS to recognize env a=foo b=foo
3dab36
-    IFS=' '
3dab36
     IS_COMMENT=`echo "$var" | grep "^#"`
3dab36
     if [ "x$IS_COMMENT" != x ] ; then
3dab36
         continue
3dab36
     fi
3dab36
-    echo "# Starting $var $BUILDDIR/ibus-compose $SRCDIR $@"
3dab36
-    env $var $BUILDDIR/ibus-compose $SRCDIR $@
3dab36
+    # Use $* instead of $@ not to mix strings and integers
3dab36
+    echo "# Starting $var $BUILDDIR/ibus-compose $SRCDIR $*"
3dab36
+    # Need to enclose $@ with double quotes not to split the array.
3dab36
+    env $var $BUILDDIR/ibus-compose $SRCDIR "$@"
3dab36
     retval=`expr $retval + $?`
3dab36
-    echo "# Finished $var $BUILDDIR/ibus-compose $SRCDIR $@ with $retval"
3dab36
+    echo "# Finished $var $BUILDDIR/ibus-compose $SRCDIR $* with $retval"
3dab36
 
3dab36
     CACHE_FILES=`ls *.cache`
3dab36
     if [ x"$CACHE_FILES" != x ] ; then
3dab36
         echo "Clean $CACHE_FILES"
3dab36
         rm $CACHE_FILES
3dab36
     fi
3dab36
-    IFS=$'\n'
3dab36
-done
3dab36
-IFS=' '
3dab36
+done << EOF_ENVS
3dab36
+`cat $SRCDIR/ibus-compose.env`
3dab36
+EOF_ENVS
3dab36
 exit $retval
3dab36
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
3dab36
index 72537cd4..981941d5 100755
3dab36
--- a/src/tests/ibus-desktop-testing-runner.in
3dab36
+++ b/src/tests/ibus-desktop-testing-runner.in
3dab36
@@ -30,6 +30,8 @@
3dab36
 
3dab36
 # POSIX sh has no 'echo -e'
3dab36
 : ${ECHO:='/usr/bin/echo'}
3dab36
+# POSIX sh has $UID
3dab36
+: ${UID:='`id -u`'}
3dab36
 
3dab36
 
3dab36
 PROGNAME=`basename $0`
3dab36
@@ -57,10 +59,10 @@ print_log()
3dab36
         if [ x"$1" = x'-e' ] ; then
3dab36
             shift
3dab36
         fi
3dab36
-        NO_ESCAPE=`echo $@ | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'`
3dab36
+        NO_ESCAPE=`echo "$@" | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'`
3dab36
         $ECHO $NO_ESCAPE >> $RESULT_LOG
3dab36
     else
3dab36
-        $ECHO $@
3dab36
+        $ECHO "$@"
3dab36
     fi
3dab36
 }
3dab36
 
3dab36
@@ -231,9 +233,9 @@ run_direct_test_cases()
3dab36
         if test x"$ENVS" = x ; then
3dab36
             $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
             retval=$?
3dab36
-            read pass fail << EOF
3dab36
+            read pass fail << EOF_COUNT
3dab36
             `count_case_result $retval $pass $fail`
3dab36
-EOF
3dab36
+EOF_COUNT
3dab36
             echo_case_result $retval $tst
3dab36
             CACHE_FILES=`ls *.cache`
3dab36
             if [ x"$CACHE_FILES" != x ] ; then
3dab36
@@ -242,11 +244,9 @@ EOF
3dab36
             fi
3dab36
         else
3dab36
             i=1
3dab36
-            # Let for-loop notice '\n' as a delimiter
3dab36
-            IFS=$'\n'
3dab36
-            for e in $ENVS; do
3dab36
-                # Revert IFS to recognize env a=foo b=foo
3dab36
-                IFS=' '
3dab36
+            # Deleted for var in "$ENVS" because IFS=$'\n' is not supported
3dab36
+            # in POSIX sh
3dab36
+            while read e ; do
3dab36
                 first=`echo "$e" | grep '^#'`
3dab36
                 if test x"$first" = x"#" ; then
3dab36
                     continue
3dab36
@@ -255,9 +255,9 @@ EOF
3dab36
                 env $e $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
                 retval=$?
3dab36
                 echo "# Finished $e $BUILDDIR/$tst $SRCDIR with $retval" >>$TEST_LOG
3dab36
-                read pass fail << EOF
3dab36
+                read pass fail << EOF_COUNT
3dab36
                 `count_case_result $retval $pass $fail`
3dab36
-EOF
3dab36
+EOF_COUNT
3dab36
                 echo_case_result $retval $tst $e
3dab36
                 CACHE_FILES=`ls *.cache`
3dab36
                 if [ x"$CACHE_FILES" != x ] ; then
3dab36
@@ -265,9 +265,9 @@ EOF
3dab36
                     rm $CACHE_FILES
3dab36
                 fi
3dab36
                 i=`expr $i + 1`
3dab36
-                IFS=$'\n'
3dab36
-            done
3dab36
-            IFS=' '
3dab36
+            done << EOF_ENVS
3dab36
+            `echo "$ENVS"`
3dab36
+EOF_ENVS
3dab36
         fi
3dab36
     done
3dab36
     echo $pass $fail
3dab36
@@ -357,7 +357,7 @@ finit()
3dab36
 
3dab36
 main()
3dab36
 {
3dab36
-    parse_args $@
3dab36
+    parse_args "$@"
3dab36
     init_desktop
3dab36
     run_dbus_daemon 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
     run_desktop 2>>$TEST_LOG 1>>$TEST_LOG
3dab36
@@ -365,4 +365,5 @@ main()
3dab36
     finit
3dab36
 }
3dab36
 
3dab36
-main $@
3dab36
+# Need to enclose $@ with double quotes not to split the array.
3dab36
+main "$@"
3dab36
-- 
3dab36
2.21.0
3dab36
bcc6a9
From 74863851e83972e86a5bdb3da3d99784fc8d4955 Mon Sep 17 00:00:00 2001
bcc6a9
From: fujiwarat <takao.fujiwara1@gmail.com>
bcc6a9
Date: Tue, 28 Jan 2020 18:46:13 +0900
bcc6a9
Subject: [PATCH] src/tests: Increase sleep to 3 waiting for IBusConfig
bcc6a9
bcc6a9
Sleep 1 would be too short for ibus-daemon which could run all components.
bcc6a9
ibus-config test requires the running IBusConfig and the test could fail
bcc6a9
in some slow systems.
bcc6a9
Sleep time will be increased to 3 to run all components.
bcc6a9
bcc6a9
BUG=https://github.com/ibus/ibus/issues/2170
bcc6a9
---
bcc6a9
 src/tests/ibus-config.c                  | 4 ++++
bcc6a9
 src/tests/ibus-desktop-testing-runner.in | 2 +-
bcc6a9
 src/tests/runtest                        | 2 +-
bcc6a9
 3 files changed, 6 insertions(+), 2 deletions(-)
bcc6a9
bcc6a9
diff --git a/src/tests/ibus-config.c b/src/tests/ibus-config.c
bcc6a9
index 5e845f10..0d9812a3 100644
bcc6a9
--- a/src/tests/ibus-config.c
bcc6a9
+++ b/src/tests/ibus-config.c
bcc6a9
@@ -16,6 +16,10 @@ finish_create_config_async_success (GObject      *source_object,
bcc6a9
     IBusConfig *config =
bcc6a9
           ibus_config_new_async_finish (res, &error);
bcc6a9
 
bcc6a9
+    if (error) {
bcc6a9
+        g_message ("Failed to generate IBusConfig: %s", error->message);
bcc6a9
+        g_error_free (error);
bcc6a9
+    }
bcc6a9
     g_assert (IBUS_IS_CONFIG (config));
bcc6a9
 
bcc6a9
     /* Since we reuse single D-Bus connection, we need to remove the
bcc6a9
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
index 981941d5..0d9a847c 100755
bcc6a9
--- a/src/tests/ibus-desktop-testing-runner.in
bcc6a9
+++ b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
@@ -190,7 +190,7 @@ run_desktop()
bcc6a9
     HAS_GNOME=`echo $DESKTOP_COMMAND | grep gnome-session`
bcc6a9
     if [ x"$HAS_GNOME" = x ] ; then
bcc6a9
         ibus-daemon --daemonize --verbose
bcc6a9
-        sleep 1
bcc6a9
+        sleep 3
bcc6a9
     fi
bcc6a9
 }
bcc6a9
 
bcc6a9
diff --git a/src/tests/runtest b/src/tests/runtest
bcc6a9
index ed38992f..a6e4194b 100755
bcc6a9
--- a/src/tests/runtest
bcc6a9
+++ b/src/tests/runtest
bcc6a9
@@ -180,7 +180,7 @@ run_test_case()
bcc6a9
         fi
bcc6a9
 
bcc6a9
         # Wait until all necessary components are up.
bcc6a9
-        sleep 1
bcc6a9
+        sleep 3
bcc6a9
 
bcc6a9
         export GTK_IM_MODULE=ibus
bcc6a9
     fi
bcc6a9
-- 
bcc6a9
2.24.1
bcc6a9
bcc6a9
From 7b0d091839a4f1315ba216175fb2787e86f7fa31 Mon Sep 17 00:00:00 2001
bcc6a9
From: fujiwarat <takao.fujiwara1@gmail.com>
bcc6a9
Date: Tue, 3 Mar 2020 17:08:30 +0900
bcc6a9
Subject: [PATCH] src/tests: Delete graves in substitution in
bcc6a9
 ibus-desktop-testing-runner
bcc6a9
bcc6a9
Delete the single quotations to enclose grave chracters because
bcc6a9
DASH saves the single quoted '`id -u`' as the raw string in the command
bcc6a9
substitution not to be extracted.
bcc6a9
bcc6a9
BUG=https://github.com/ibus/ibus/issues/2189
bcc6a9
---
bcc6a9
 src/tests/ibus-desktop-testing-runner.in | 7 ++++---
bcc6a9
 1 file changed, 4 insertions(+), 3 deletions(-)
bcc6a9
bcc6a9
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
index 0d9a847c..f9238e69 100755
bcc6a9
--- a/src/tests/ibus-desktop-testing-runner.in
bcc6a9
+++ b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
@@ -4,7 +4,7 @@
bcc6a9
 #
bcc6a9
 # ibus - The Input Bus
bcc6a9
 #
bcc6a9
-# Copyright (c) 2018-2019 Takao Fujiwara <takao.fujiwara1@gmail.com>
bcc6a9
+# Copyright (c) 2018-2020 Takao Fujiwara <takao.fujiwara1@gmail.com>
bcc6a9
 # Copyright (c) 2018 Red Hat, Inc.
bcc6a9
 #
bcc6a9
 # This program is free software; you can redistribute it and/or modify
bcc6a9
@@ -31,7 +31,8 @@
bcc6a9
 # POSIX sh has no 'echo -e'
bcc6a9
 : ${ECHO:='/usr/bin/echo'}
bcc6a9
 # POSIX sh has $UID
bcc6a9
-: ${UID:='`id -u`'}
bcc6a9
+# DASH saves the graves in '``' as characters not to be extracted
bcc6a9
+: ${UID:=`id -u`}
bcc6a9
 
bcc6a9
 
bcc6a9
 PROGNAME=`basename $0`
bcc6a9
@@ -170,7 +171,7 @@ _EOF
bcc6a9
 run_dbus_daemon()
bcc6a9
 {
bcc6a9
     # Use dbus-launch --exit-with-session later instead of --sh-syntax
bcc6a9
-    export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus
bcc6a9
+    export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus"
bcc6a9
 }
bcc6a9
 
bcc6a9
 run_desktop()
bcc6a9
-- 
bcc6a9
2.24.1
bcc6a9
bcc6a9
From 8da016764cee9616cca4658d1fb311d6b3bfc0df Mon Sep 17 00:00:00 2001
bcc6a9
From: fujiwarat <takao.fujiwara1@gmail.com>
bcc6a9
Date: Wed, 15 Apr 2020 17:55:03 +0900
bcc6a9
Subject: [PATCH] src/tests: Fix to get focus events with su in
bcc6a9
 ibus-desktop-testing-runner
bcc6a9
bcc6a9
GtkWindow haven't received focus events in any test cases since Fedora 31
bcc6a9
whenever Ansible runs ibus-desktop-testing-runner after `su root`.
bcc6a9
Seems su command does not run systemd automatically and now systemd
bcc6a9
requires XDG_RUNTIME_DIR and Ansible requires root access with ssh.
bcc6a9
This fix requires to restart sshd with modified /etc/ssh/sshd_config
bcc6a9
with "PermitRootLogin yes" in order to run with su command.
bcc6a9
bcc6a9
Ansible with ibus-desktop-testin-runner has worked fine if root console
bcc6a9
login is used without this patch because PAM runs systemd by login.
bcc6a9
---
bcc6a9
 src/tests/ibus-desktop-testing-runner.in | 36 ++++++++++++++++++++++--
bcc6a9
 1 file changed, 33 insertions(+), 3 deletions(-)
bcc6a9
bcc6a9
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
index f9238e69..f760fd5b 100755
bcc6a9
--- a/src/tests/ibus-desktop-testing-runner.in
bcc6a9
+++ b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
@@ -49,6 +49,7 @@ PID_XORG=0
bcc6a9
 PID_GNOME_SESSION=0
bcc6a9
 TESTING_RUNNER="default"
bcc6a9
 TESTS=""
bcc6a9
+TIMEOUT=300
bcc6a9
 GREEN='\033[0;32m'
bcc6a9
 RED='\033[0;31m'
bcc6a9
 NC='\033[0m'
bcc6a9
@@ -84,6 +85,7 @@ usage()
bcc6a9
 "-r, --runner=RUNNER              Run TESTS programs with a test RUNNER.\n"    \
bcc6a9
 "                                 RUNNDER = gnome or default.\n"               \
bcc6a9
 "                                 default is an embedded runner.\n"            \
bcc6a9
+"-T, --timeout=TIMEOUT            Set timeout (default TIMEOUT is 300 sec).\n" \
bcc6a9
 "-o, --output=OUTPUT_FILE         OUtput the log to OUTPUT_FILE\n"             \
bcc6a9
 "-O, --result=RESULT_FILE         OUtput the result to RESULT_FILE\n"          \
bcc6a9
 ""
bcc6a9
@@ -92,8 +94,8 @@ usage()
bcc6a9
 parse_args()
bcc6a9
 {
bcc6a9
     # This is GNU getopt. "sudo port getopt" in BSD?
bcc6a9
-    ARGS=`getopt -o hvb:s:cd:t:r:o:O: --long \
bcc6a9
-          help,version,builddir:,srcdir:,no-graphics,desktop:,tests:,runner:,output:,result:\
bcc6a9
+    ARGS=`getopt -o hvb:s:cd:t:r:T:o:O: --long \
bcc6a9
+          help,version,builddir:,srcdir:,no-graphics,desktop:,tests:,runner:,timeout:,output:,result:\
bcc6a9
         -- "$@"`;
bcc6a9
     eval set -- "$ARGS"
bcc6a9
     while [ 1 ] ; do
bcc6a9
@@ -106,6 +108,7 @@ parse_args()
bcc6a9
         -d | --desktop )     DESKTOP_COMMAND="$2"; shift 2;;
bcc6a9
         -t | --tests )       TESTS="$2"; shift 2;;
bcc6a9
         -r | --runner )      TESTING_RUNNER="$2"; shift 2;;
bcc6a9
+        -T | --timeout )     TIMEOUT="$2"; shift 2;;
bcc6a9
         -o | --output )      TEST_LOG="$2"; shift 2;;
bcc6a9
         -O | --result )      RESULT_LOG="$2"; shift 2;;
bcc6a9
         -- )                 shift; break;;
bcc6a9
@@ -166,11 +169,37 @@ _EOF
bcc6a9
     fi
bcc6a9
     # `su` command does not run loginctl
bcc6a9
     export XDG_SESSION_TYPE='x11'
bcc6a9
+    export XDG_SESSION_CLASS=user
bcc6a9
+    # `su` command does not get focus in events without this variable.
bcc6a9
+    # Need to restart sshd after set "PermitRootLogin yes" in sshd_config
bcc6a9
+    if [ "x$XDG_RUNTIME_DIR" = x ] ; then
bcc6a9
+        export XDG_RUNTIME_DIR=/run/user/$UID
bcc6a9
+        is_root_login=`grep "^PermitRootLogin" /etc/ssh/sshd_config | grep yes`
bcc6a9
+        if [ "x$ANSIBLE" != x ] && [ "x$is_root_login" = x ] ; then
bcc6a9
+            print_log -e "${RED}FAIL${NC}: No permission to get focus-in events in GtkWindow with ansible"
bcc6a9
+            echo "su command does not configure necessary login info "         \
bcc6a9
+                 "with systemd and GtkWindow cannot receive focus-events "     \
bcc6a9
+                 "when ibus-desktop-testing-runner is executed by "            \
bcc6a9
+                 "ansible-playbook." >> $TEST_LOG
bcc6a9
+            echo "Enabling root login via sshd, restarting sshd, set "         \
bcc6a9
+                 "XDG_RUNTIME_DIR can resolve the problem under "              \
bcc6a9
+                 "ansible-playbook." >> $TEST_LOG
bcc6a9
+            exit 255
bcc6a9
+        fi
bcc6a9
+    fi
bcc6a9
+    #  Do we need XDG_SESSION_ID and XDG_SEAT?
bcc6a9
+    #export XDG_CONFIG_DIRS=/etc/xdg
bcc6a9
+    #export XDG_SESSION_ID=10
bcc6a9
+    #export XDG_SESSION_DESKTOP=gnome
bcc6a9
+    #export XDG_SEAT=seat0
bcc6a9
 }
bcc6a9
 
bcc6a9
 run_dbus_daemon()
bcc6a9
 {
bcc6a9
     # Use dbus-launch --exit-with-session later instead of --sh-syntax
bcc6a9
+    # GNOME uses a unix:abstract address and it effects gsettings set values
bcc6a9
+    # in each test case.
bcc6a9
+    # TODO: Should we comment out this line?
bcc6a9
     export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus"
bcc6a9
 }
bcc6a9
 
bcc6a9
@@ -288,7 +317,8 @@ run_gnome_desktop_testing_runner()
bcc6a9
             fail=1
bcc6a9
             continue
bcc6a9
         fi
bcc6a9
-        gnome-desktop-testing-runner $tst 2>>$TEST_LOG 1>>$TEST_LOG
bcc6a9
+        gnome-desktop-testing-runner --timeout=$TIMEOUT $tst \
bcc6a9
+                2>>$TEST_LOG 1>>$TEST_LOG
bcc6a9
         retval=$?
bcc6a9
         read pass fail << EOF
bcc6a9
         `count_case_result $retval $pass $fail`
bcc6a9
-- 
bcc6a9
2.24.1
bcc6a9
bcc6a9
From 0b9d9365988a96a2bc31c48624f9c2b8081601b6 Mon Sep 17 00:00:00 2001
bcc6a9
From: fujiwarat <takao.fujiwara1@gmail.com>
bcc6a9
Date: Wed, 22 Apr 2020 20:17:12 +0900
bcc6a9
Subject: [PATCH] client/gtk2: Fix typo
bcc6a9
bcc6a9
---
bcc6a9
 client/gtk2/ibusim.c                     | 4 ++--
bcc6a9
 src/tests/ibus-desktop-testing-runner.in | 2 +-
bcc6a9
 2 files changed, 3 insertions(+), 3 deletions(-)
bcc6a9
bcc6a9
diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
index f760fd5b..4232c549 100755
bcc6a9
--- a/src/tests/ibus-desktop-testing-runner.in
bcc6a9
+++ b/src/tests/ibus-desktop-testing-runner.in
bcc6a9
@@ -173,7 +173,7 @@ _EOF
bcc6a9
     # `su` command does not get focus in events without this variable.
bcc6a9
     # Need to restart sshd after set "PermitRootLogin yes" in sshd_config
bcc6a9
     if [ "x$XDG_RUNTIME_DIR" = x ] ; then
bcc6a9
-        export XDG_RUNTIME_DIR=/run/user/$UID
bcc6a9
+        export XDG_RUNTIME_DIR="/run/user/$UID"
bcc6a9
         is_root_login=`grep "^PermitRootLogin" /etc/ssh/sshd_config | grep yes`
bcc6a9
         if [ "x$ANSIBLE" != x ] && [ "x$is_root_login" = x ] ; then
bcc6a9
             print_log -e "${RED}FAIL${NC}: No permission to get focus-in events in GtkWindow with ansible"
bcc6a9
-- 
bcc6a9
2.24.1
bcc6a9