From 37dced47bc78c7bc06c02bc3b5364ca3842bb80c Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 28 Apr 2020 05:33:32 -0400 Subject: [PATCH] import ibus-1.5.19-11.el8 --- ...us-1470673-emoji-warn-instead-assert.patch | 48 + SOURCES/ibus-1682157-ci.patch | 2393 +++++++++++++++++ .../ibus-1750836-server-auth-observer.patch | 179 ++ SOURCES/ibus-2076-fix-16-candidates.patch | 26 + SOURCES/ibus-xx-emoji-compose.patch | 134 + SOURCES/ibus-xx-setup-env.patch | 60 + SPECS/ibus.spec | 81 +- 7 files changed, 2918 insertions(+), 3 deletions(-) create mode 100644 SOURCES/ibus-1470673-emoji-warn-instead-assert.patch create mode 100644 SOURCES/ibus-1682157-ci.patch create mode 100644 SOURCES/ibus-1750836-server-auth-observer.patch create mode 100644 SOURCES/ibus-2076-fix-16-candidates.patch create mode 100644 SOURCES/ibus-xx-emoji-compose.patch create mode 100644 SOURCES/ibus-xx-setup-env.patch diff --git a/SOURCES/ibus-1470673-emoji-warn-instead-assert.patch b/SOURCES/ibus-1470673-emoji-warn-instead-assert.patch new file mode 100644 index 0000000..35710f8 --- /dev/null +++ b/SOURCES/ibus-1470673-emoji-warn-instead-assert.patch @@ -0,0 +1,48 @@ +From 0f5084e07c215d74adc4eeeda40b374855cce59a Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 11 Jan 2019 12:56:42 +0900 +Subject: [PATCH] src/ibuscomposetable: Replace assert with warning for + .XCompose + +BUG=rhbz#1470673 +--- + src/ibuscomposetable.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c +index b843e7e1..1c0ece41 100644 +--- a/src/ibuscomposetable.c ++++ b/src/ibuscomposetable.c +@@ -1,7 +1,7 @@ + /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ + /* ibus - The Input Bus + * Copyright (C) 2013-2014 Peng Huang +- * Copyright (C) 2013-2018 Takao Fujiwara ++ * Copyright (C) 2013-2019 Takao Fujiwara + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public +@@ -98,14 +98,16 @@ parse_compose_value (IBusComposeData *compose_data, + uch = words[1][1]; + + /* The escaped string "\"" is separated with '\\' and '"'. */ +- if (uch == '\0' && words[2][0] == '"') ++ if (uch == '\0' && words[2][0] == '"') { + uch = '"'; + /* The escaped octal */ +- else if (uch >= '0' && uch <= '8') ++ } else if (uch >= '0' && uch <= '8') { + uch = g_ascii_strtoll(words[1] + 1, NULL, 8); + /* If we need to handle other escape sequences. */ +- else if (uch != '\\') +- g_assert_not_reached (); ++ } else if (uch != '\\') { ++ g_warning ("Invalid backslash: %s: %s", val, line); ++ goto fail; ++ } + } + + if (g_utf8_get_char (g_utf8_next_char (words[1])) > 0) { +-- +2.21.0 + diff --git a/SOURCES/ibus-1682157-ci.patch b/SOURCES/ibus-1682157-ci.patch new file mode 100644 index 0000000..28dc8ed --- /dev/null +++ b/SOURCES/ibus-1682157-ci.patch @@ -0,0 +1,2393 @@ +From c360cbd830943a4bfb0ece9cc07b99a426dc2121 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Mon, 9 Apr 2018 11:57:09 +0900 +Subject: [PATCH] src/tests: Add ibus-compose.env + +--- + src/tests/ibus-compose.env | 3 +++ + 1 file changed, 3 insertions(+) + create mode 100644 src/tests/ibus-compose.env + +diff --git a/src/tests/ibus-compose.env b/src/tests/ibus-compose.env +new file mode 100644 +index 00000000..734ab8fa +--- /dev/null ++++ b/src/tests/ibus-compose.env +@@ -0,0 +1,3 @@ ++LANG=el_GR.UTF-8 ++LANG=fi_FI.UTF-8 ++LANG=pt_BR.UTF-8 +-- +2.21.0 + +From b497de5bc6525769e03b65c73fc991d4aa006223 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Wed, 20 Mar 2019 17:44:26 +0900 +Subject: [PATCH] test: Set GTK_IM_MODULE in test-console.sh + +--- + src/tests/Makefile.am | 4 ++-- + 2 files changed, 14 insertions(+), 2 deletions(-) + +diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am +index e337a59b..e2ff5ea7 100644 +--- a/src/tests/Makefile.am ++++ b/src/tests/Makefile.am +@@ -3,7 +3,7 @@ + # ibus - The Input Bus + # + # Copyright (c) 2007-2015 Peng Huang +-# Copyright (c) 2015-2018 Takao Fujiwara ++# Copyright (c) 2015-2019 Takao Fujiwara + # Copyright (c) 2007-2018 Red Hat, Inc. + # + # This library is free software; you can redistribute it and/or +@@ -78,7 +78,7 @@ TESTS_ENVIRONMENT = \ + + LOG_COMPILER = $(srcdir)/runtest + +-EXTRA_DIST = runtest ++EXTRA_DIST = runtest ibus-compose.env + + ibus_bus_SOURCES = ibus-bus.c + ibus_bus_LDADD = $(prog_ldadd) +-- +2.21.0 + +From ac492f31b435b9464d591094d470bc94027168e8 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 28 Jun 2019 21:15:07 +0900 +Subject: [PATCH] src/tests: Fix ibus-compose for IBusComposeTableEx + +Recently IBusComposeTablEx has been integrated and the return value of +ibus_compose_table_new_with_file() is also changed and ibus-compose +needs to be updated. + +Clear IBusComposeTablePrivate in ibus_compose_table_list_add_array() +for the ibus-compose testing. + +Clear compose_buffer in IBusEngineSimple. + +Use g_get_language_names_with_category instead() of g_get_locale_variants(). + +Add ibus-compose.emoji for the tests of long compose sequences and +multiple compose output characters. + +IBUS_COMPOSE_CACHE_DIR variable is added for the temporary caches. +--- + src/ibuscomposetable.c | 15 ++-- + src/tests/Makefile.am | 2 +- + src/tests/ibus-compose.c | 10 +++ + src/tests/ibus-compose.emoji | 11 +++ + src/tests/ibus-compose.env | 1 + + src/tests/runtest | 4 +- + 9 files changed, 174 insertions(+), 47 deletions(-) + create mode 100644 src/tests/ibus-compose.emoji + +diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c +index 4ac54e25..5fd37f10 100644 +--- a/src/ibuscomposetable.c ++++ b/src/ibuscomposetable.c +@@ -497,13 +497,18 @@ static gchar * + ibus_compose_hash_get_cache_path (guint32 hash) + { + gchar *basename = NULL; ++ const gchar *cache_dir; + gchar *dir = NULL; + gchar *path = NULL; + + basename = g_strdup_printf ("%08x.cache", hash); + +- dir = g_build_filename (g_get_user_cache_dir (), +- "ibus", "compose", NULL); ++ if ((cache_dir = g_getenv ("IBUS_COMPOSE_CACHE_DIR"))) { ++ dir = g_strdup (cache_dir); ++ } else { ++ dir = g_build_filename (g_get_user_cache_dir (), ++ "ibus", "compose", NULL); ++ } + path = g_build_filename (dir, basename, NULL); + if (g_mkdir_with_parents (dir, 0755) != 0) { + g_warning ("Failed to mkdir %s", dir); +@@ -1068,7 +1073,7 @@ ibus_compose_table_list_add_array (GSList *compose_tables, + for (i = 0; i < length; i++) + ibus_compose_seqs[i] = data[i]; + +- compose_table = g_new (IBusComposeTable, 1); ++ compose_table = g_new0 (IBusComposeTable, 1); + compose_table->data = ibus_compose_seqs; + compose_table->max_seq_len = max_seq_len; + compose_table->n_seqs = n_seqs; +diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am +index e2ff5ea7..a58504a3 100644 +--- a/src/tests/Makefile.am ++++ b/src/tests/Makefile.am +@@ -78,7 +78,7 @@ TESTS_ENVIRONMENT = \ + + LOG_COMPILER = $(srcdir)/runtest + +-EXTRA_DIST = runtest ibus-compose.env ++EXTRA_DIST = runtest ibus-compose.emoji ibus-compose.env + + ibus_bus_SOURCES = ibus-bus.c + ibus_bus_LDADD = $(prog_ldadd) +diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c +index e2ff5ea7..a58504a3 100644 +--- a/src/tests/ibus-compose.c ++++ b/src/tests/ibus-compose.c +@@ -7,8 +7,10 @@ + #define NC "\033[0m" + + IBusBus *m_bus; ++gchar *m_compose_file; + IBusComposeTable *m_compose_table; + IBusEngine *m_engine; ++gchar *m_srcdir; + int m_retval; + + static gboolean window_focus_in_event_cb (GtkWidget *entry, +@@ -31,8 +33,11 @@ create_engine_cb (IBusFactory *factory, + engine_path, + ibus_bus_get_connection (m_bus)); + g_free (engine_path); +- langs = g_get_language_names (); +- for (l = langs; *l; l++) { ++ if (m_compose_file) { ++ compose_path = g_build_filename (m_srcdir, m_compose_file, NULL); ++ } else { ++ langs = g_get_language_names (); ++ for (l = langs; *l; l++) { + if (g_str_has_prefix (*l, "en_US")) + break; + if (g_strcmp0 (*l, "C") == 0) +@@ -41,10 +46,11 @@ create_engine_cb (IBusFactory *factory, + *l, + "Compose", + NULL); + if (g_file_test (compose_path, G_FILE_TEST_EXISTS)) + break; + g_free (compose_path); + compose_path = NULL; ++ } + } + if (compose_path != NULL) { + m_compose_table = ibus_compose_table_new_with_file (compose_path); +@@ -248,6 +254,9 @@ main (int argc, char *argv[]) + ibus_init (); + gtk_init (&argc, &argv); + ++ m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup ("."); ++ m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE")); ++ + if (!register_ibus_engine ()) + return -1; + +diff --git a/src/tests/ibus-compose.emoji b/src/tests/ibus-compose.emoji +new file mode 100644 +index 00000000..7fbf82cf +--- /dev/null ++++ b/src/tests/ibus-compose.emoji +@@ -0,0 +1,2 @@ ++ : "♌" U264C # LEO ++ : "∫" +diff --git a/src/tests/ibus-compose.env b/src/tests/ibus-compose.env +index 734ab8fa..a9e289e4 100644 +--- a/src/tests/ibus-compose.env ++++ b/src/tests/ibus-compose.env +@@ -1,3 +1,4 @@ + LANG=el_GR.UTF-8 + LANG=fi_FI.UTF-8 + LANG=pt_BR.UTF-8 ++LANG=en_US.UTF-8 COMPOSE_FILE=ibus-compose.emoji +diff --git a/src/tests/runtest b/src/tests/runtest +index 4e980c71..35ccc5a0 100755 +--- a/src/tests/runtest ++++ b/src/tests/runtest +@@ -184,7 +184,9 @@ run_test_case() + export GTK_IM_MODULE=ibus + fi + +- "../$tst" ${1+"$@"} ++ export IBUS_COMPOSE_CACHE_DIR=$PWD ++ ++ "../$tst" ../$top_srcdir/src/tests ${1+"$@"} + + retval=`expr $retval \| $?` + +-- +2.21.0 + +From 76dec798d5cf6cdaa96c3373f9c0e1cd13eb31f5 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 28 Jun 2019 21:28:32 +0900 +Subject: [PATCH] src/tests: Use GTest for ibus-compose + +--- + src/tests/ibus-compose.c | 45 ++++++++++++++++++++++++++++------------ + 1 file changed, 32 insertions(+), 13 deletions(-) + +diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c +index e1911b32..09c687c2 100644 +--- a/src/tests/ibus-compose.c ++++ b/src/tests/ibus-compose.c +@@ -11,7 +11,6 @@ gchar *m_compose_file; + IBusComposeTable *m_compose_table; + IBusEngine *m_engine; + gchar *m_srcdir; +-int m_retval; + + static gboolean window_focus_in_event_cb (GtkWidget *entry, + GdkEventFocus *event, +@@ -111,8 +110,7 @@ register_ibus_engine () + static gboolean + finit (gpointer data) + { +- m_retval = -1; +- g_warning ("time out"); ++ g_test_incomplete ("time out"); + gtk_main_quit (); + return FALSE; + } +@@ -127,7 +125,9 @@ set_engine_cb (GObject *object, GAsyncRe + int index_stride; + + if (!ibus_bus_set_global_engine_async_finish (bus, res, &error)) { +- g_warning ("set engine failed: %s", error->message); ++ gchar *msg = g_strdup_printf ("set engine failed: %s", error->message); ++ g_test_incomplete (msg); ++ g_free (msg); + g_error_free (error); + return; + } +@@ -210,7 +210,7 @@ window_inserted_text_cb (GtkEntryBuffer + test = GREEN "PASS" NC; + } else { + test = RED "FAIL" NC; +- m_retval = -1; ++ g_test_fail (); + } + g_print ("%05d/%05d %s expected: %04X typed: %04X\n", + seq, +@@ -249,20 +249,39 @@ create_window () + gtk_widget_show_all (window); + } + ++static void ++test_compose (void) ++{ ++ if (!register_ibus_engine ()) { ++ g_test_fail (); ++ return; ++ } ++ ++ create_window (); ++ gtk_main (); ++ ++} ++ + int + main (int argc, char *argv[]) + { ++ const gchar *test_name; ++ gchar *test_path; ++ + ibus_init (); ++ g_test_init (&argc, &argv, NULL); + gtk_init (&argc, &argv); + + m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup ("."); + m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE")); ++#if GLIB_CHECK_VERSION (2, 58, 0) ++ test_name = g_get_language_names_with_category ("LC_CTYPE")[0]; ++#else ++ test_name = g_getenv ("LANG"); ++#endif ++ test_path = g_build_filename ("/ibus-compose", test_name, NULL); ++ g_test_add_func (test_path, test_compose); ++ g_free (test_path); + +- if (!register_ibus_engine ()) +- return -1; +- +- create_window (); +- gtk_main (); +- +- return m_retval; ++ return g_test_run (); + } +-- +2.21.0 + +From af00f4156b5c79c526eab18c49da80affd41ebee Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 12 Jul 2019 21:12:38 +0900 +Subject: [PATCH] src/tests: Install IBus tests into gnome-desktop-testing + +--- + configure.ac | 13 +++++++++++ + src/tests/Makefile.am | 39 ++++++++++++++++++++++++++++++- + src/tests/ibus-compose-locales.in | 23 ++++++++++++++++++ + src/tests/ibus-compose.c | 10 ++++++-- + src/tests/meta.test.in | 4 ++++ + src/tests/runtest | 4 ++-- + 6 files changed, 88 insertions(+), 5 deletions(-) + create mode 100755 src/tests/ibus-compose-locales.in + create mode 100644 src/tests/meta.test.in + +diff --git a/configure.ac b/configure.ac +index b5a87b56..f1df3ac1 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -595,6 +595,18 @@ PKG_CHECK_MODULES(XTEST, + ) + AM_CONDITIONAL([ENABLE_XTEST], [test x"$enable_xtest" = x"yes"]) + ++# --enable-install-tests ++AC_ARG_ENABLE(install-tests, ++ AS_HELP_STRING([--enable-install-tests], ++ [Enable to install tests]), ++ [enable_install_tests=$enableval], ++ [enable_install_tests=no] ++) ++AM_CONDITIONAL([ENABLE_INSTALL_TESTS], [test x"$enable_install_tests" = x"yes"]) ++if test x"$enable_install_tests" = x"no"; then ++ enable_install_tests="no (disabled, use --enable-install-tests to enable)" ++fi ++ + + # --disable-emoji-dict option. + AC_ARG_ENABLE(emoji-dict, +@@ -773,5 +785,6 @@ Build options: + Enable Unicode dict $enable_unicode_dict + UCD directory $UCD_DIR + Run test cases $enable_tests ++ Install tests $enable_install_tests + ]) + +diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am +index a58504a3..ff31111b 100644 +--- a/src/tests/Makefile.am ++++ b/src/tests/Makefile.am +@@ -78,7 +78,44 @@ TESTS_ENVIRONMENT = \ + + LOG_COMPILER = $(srcdir)/runtest + +-EXTRA_DIST = runtest ibus-compose.emoji ibus-compose.env ++if ENABLE_INSTALL_TESTS ++test_metas_in = meta.test.in ++test_execs = $(TESTS:ibus-compose=ibus-compose-locales) ++test_metas = $(addsuffix .test, $(test_execs)) ++test_sources_DATA = \ ++ $(test_metas) \ ++ ibus-compose.emoji \ ++ ibus-compose.env \ ++ $(NULL) ++test_sourcesdir = $(datadir)/installed-tests/ibus ++ ++test_execs_PROGRAMS = $(TESTS) ++if ENABLE_GTK3 ++test_execs_SCRIPTS = ibus-compose-locales ++endif ++test_execsdir = $(libexecdir)/installed-tests/ibus ++endif ++ ++$(test_metas): $(test_metas_in) $(test_programs) ++ f=`echo $@ | sed -e 's/\.test//'`; \ ++ TEST_EXEC=$(test_execsdir)/$$f; \ ++ sed -e "s|@TEST_EXEC[@]|$$TEST_EXEC|g" $(test_metas_in) > $@.tmp; \ ++ mv $@.tmp $@; \ ++ $(NULL) ++ ++ibus-compose-locales: ibus-compose-locales.in ++ SRCDIR=$(test_sourcesdir); \ ++ sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \ ++ mv $@.tmp $@; \ ++ $(NULL) ++ ++EXTRA_DIST = \ ++ $(test_metas_in) \ ++ runtest \ ++ ibus-compose.emoji \ ++ ibus-compose.env \ ++ ibus-compose-locales.in \ ++ $(NULL) + + ibus_bus_SOURCES = ibus-bus.c + ibus_bus_LDADD = $(prog_ldadd) +diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in +new file mode 100755 +index 00000000..8d2384d1 +--- /dev/null ++++ b/src/tests/ibus-compose-locales.in +@@ -0,0 +1,23 @@ ++#!/bin/sh ++ ++SRCDIR=@SRCDIR@ ++BUILDDIR=`dirname $0` ++ ++ ++export IBUS_COMPOSE_CACHE_DIR=$PWD ++ ++for var in `cat $SRCDIR/ibus-compose.env` ++do ++ IS_COMMENT=`echo "$var" | grep "^#"` ++ if [ "x$IS_COMMENT" != x ] ; then ++ continue ++ fi ++ env $var $BUILDDIR/ibus-compose $SRCDIR $@ ++ ++ CACHE_FILES=`ls *.cache` ++ if [ x"$CACHE_FILES" != x ] ; then ++ echo "Clean $CACHE_FILES" ++ rm $CACHE_FILES ++ fi ++done ++ +diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c +index 09c687c2..c8d3c126 100644 +--- a/src/tests/ibus-compose.c ++++ b/src/tests/ibus-compose.c +@@ -351,6 +347,14 @@ main (int argc, char *argv[]) + + ibus_init (); + g_test_init (&argc, &argv, NULL); ++ /* FIXME: ++ * IBusIMContext opens GtkIMContextSimple as the slave and ++ * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the ++ * multiple outputs in el_GR's compose causes a warning in gtkcomposetable ++ * and the warning always causes a fatal in GTest: ++ " "GTK+ supports to output one char only: " ++ */ ++ g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); + gtk_init (&argc, &argv); + + m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup ("."); +diff --git a/src/tests/meta.test.in b/src/tests/meta.test.in +new file mode 100644 +index 00000000..ae2b2991 +--- /dev/null ++++ b/src/tests/meta.test.in +@@ -0,0 +1,4 @@ ++[Test] ++Type=session ++Exec=@TEST_EXEC@ --tap ++Output=TAP +diff --git a/src/tests/runtest b/src/tests/runtest +index 35ccc5a0..1fcc9283 100755 +--- a/src/tests/runtest ++++ b/src/tests/runtest +@@ -200,7 +200,7 @@ if test -f $envfile ; then + ENVS="`cat $envfile`" + fi; + if test x"$ENVS" = x ; then +- run_test_case ++ run_test_case $@ + else + LANG_backup=$LANG + i=1 +@@ -212,7 +212,7 @@ else + export $e + echo "Run `func_basename $tst` on $e" + echo "=======================" +- run_test_case ++ run_test_case $@ + echo "" + i=`expr $i + 1` + done +-- +2.21.0 + +From 2a4f9518d42b618d8111fa5f9f885757524758a0 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 12 Jul 2019 21:12:40 +0900 +Subject: [PATCH] src/tests: Rename test-console.sh to + ibus-desktop-testing-runner + +--- + src/tests/Makefile.am | 9 +++++++++ + .../tests/ibus-desktop-testing-runner.in | 0 + 2 files changed, 9 insertions(+) + rename test/test-console.sh => src/tests/ibus-desktop-testing-runner.in (100%) + +diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am +index ff31111b..b9aad29a 100644 +--- a/src/tests/Makefile.am ++++ b/src/tests/Makefile.am +@@ -79,6 +79,7 @@ TESTS_ENVIRONMENT = \ + LOG_COMPILER = $(srcdir)/runtest + + if ENABLE_INSTALL_TESTS ++bin_SCRIPTS = ibus-desktop-testing-runner + test_metas_in = meta.test.in + test_execs = $(TESTS:ibus-compose=ibus-compose-locales) + test_metas = $(addsuffix .test, $(test_execs)) +@@ -109,12 +110,20 @@ ibus-compose-locales: ibus-compose-locales.in + mv $@.tmp $@; \ + $(NULL) + ++ ibus-desktop-testing-runner.in \ ++ibus-desktop-testing-runner: ibus-desktop-testing-runner.in ++ SRCDIR=$(test_sourcesdir); \ ++ sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \ ++ mv $@.tmp $@; \ ++ $(NULL) ++ + EXTRA_DIST = \ + $(test_metas_in) \ + runtest \ + ibus-compose.emoji \ + ibus-compose.env \ + ibus-compose-locales.in \ ++ ibus-desktop-testing-runner.in \ + $(NULL) + + ibus_bus_SOURCES = ibus-bus.c +diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in +new file mode 100755 +index 00000000..7fbf82cf +--- /dev/null ++++ b/src/tests/ibus-desktop-testing-runner.in +@@ -0,0 +1,255 @@ ++#!/bin/sh ++# -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- ++# vim:set noet ts=4: ++# ++# ibus-anthy - The Anthy engine for IBus ++# ++# Copyright (c) 2018-2019 Takao Fujiwara ++# Copyright (c) 2018 Red Hat, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License along ++# with this program; if not, write to the Free Software Foundation, Inc., ++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ ++# This test runs /usr/bin/ibus-daemon after install ibus ++# ++# # init 3 ++# Login as root ++# # /root/ibus/tests/test-console.sh --tests ibus-compose \ ++# --builddir /root/ibus/src/tests --srcdir /root/ibus/src/tests ++ ++PROGNAME=`basename $0` ++VERSION=0.1 ++DISPLAY=:99.0 ++BUILDDIR="." ++SRCDIR="." ++TEST_LOG=test-suite.log ++HAVE_GRAPHICS=1 ++DESKTOP_COMMAND="gnome-session" ++PID_XORG=0 ++PID_GNOME_SESSION=0 ++TESTS="" ++GREEN='\033[0;32m' ++RED='\033[0;31m' ++NC='\033[0m' ++ ++usage() ++{ ++ echo -e \ ++"This test runs /usr/bin/ibus-daemon after install ibus\n" \ ++"$PROGNAME [OPTIONS…]\n" \ ++"\n" \ ++"OPTIONS:\n" \ ++"-h, --help This help\n" \ ++"-v, --version Show version\n" \ ++"-b, --builddir=BUILDDIR Set the BUILDDIR\n" \ ++"-s, --srcdir=SOURCEDIR Set the SOURCEDIR\n" \ ++"-c, --no-graphics Use Xvfb instead of Xorg\n" \ ++"-d, --desktop=DESKTOP Run DESTKTOP. The default is gnome-session\n" \ ++"-t, --tests=\"TESTS...\" Run TESTS programs which is separated by space\n" \ ++"" ++} ++ ++parse_args() ++{ ++ # This is GNU getopt. "sudo port getopt" in BSD? ++ ARGS=`getopt -o hvb:s:cd:t: --long help,version,builddir:,srcdir:,no-graphics,desktop:,tests:\ ++ -- "$@"`; ++ eval set -- "$ARGS" ++ while [ 1 ] ; do ++ case "$1" in ++ -h | --help ) usage; exit 0;; ++ -v | --version ) echo -e "$VERSION"; exit 0;; ++ -b | --builddir ) BUILDDIR="$2"; shift 2;; ++ -s | --srcdir ) SRCDIR="$2"; shift 2;; ++ -c | --no-graphics ) HAVE_GRAPHICS=0; shift;; ++ -d | --desktop ) DESKTOP_COMMAND="$2"; shift 2;; ++ -t | --tests ) TESTS="$2"; shift 2;; ++ -- ) shift; break;; ++ * ) usage; exit 1;; ++ esac ++ done ++} ++ ++init_desktop() ++{ ++ if test x$FORCE_TEST != x ; then ++ RUN_ARGS="$RUN_ARGS --force" ++ fi ++ ++ if test ! -f $HOME/.config/gnome-initial-setup-done ; then ++ if test ! -f /var/lib/AccountsService/users/$USER ; then ++ mkdir -p /var/lib/AccountsService/users ++ cat >> /var/lib/AccountsService/users/$USER << _EOF ++[User] ++Language=ja_JP.UTF-8 ++XSession=gnome ++SystemAccount=false ++_EOF ++ fi ++ mkdir -p $HOME/.config ++ touch $HOME/.config/gnome-initial-setup-done ++ fi ++ ++ # Prevent from launching a XDG dialog ++ XDG_LOCALE_FILE="$HOME/.config/user-dirs.locale" ++ if test -f $XDG_LOCALE_FILE ; then ++ XDG_LANG_ORIG=`cat $XDG_LOCALE_FILE` ++ XDG_LANG_NEW=`echo $LANG | sed -e 's/\(.*\)\..*/\1/'` ++ if [ "$XDG_LANG_ORIG" != "$XDG_LANG_NEW" ] ; then ++ echo "Overriding XDG locale $XDG_LANG_ORIG with $XDG_LANG_NEW" ++ echo "$XDG_LANG_NEW" > $XDG_LOCALE_FILE ++ fi ++ fi ++} ++ ++run_dbus_daemon() ++{ ++ a=`ps -ef | grep dbus-daemon | grep "\-\-system" | grep -v session | grep -v grep` ++ if test x"$a" = x ; then ++ eval `dbus-launch --sh-syntax` ++ fi ++ SUSER=`echo "$USER" | cut -c 1-7` ++ a=`ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | grep session | grep -v grep` ++ if test x"$a" = x ; then ++ systemctl --user start dbus ++ export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus ++ fi ++ systemctl --user status dbus | col -b ++ ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | egrep 'session|system' | grep -v grep ++ systemctl --user show-environment | col -b ++} ++ ++run_desktop() ++{ ++ if test $HAVE_GRAPHICS -eq 1 ; then ++ /usr/libexec/Xorg.wrap -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xorg.log -config ./xorg.conf -configdir . $DISPLAY & ++ else ++ /usr/bin/Xvfb $DISPLAY -noreset +extension GLX +extension RANDR +extension RENDER -screen 0 1280x1024x24 & ++ fi ++ PID_XORG=$! ++ sleep 1 ++ export DISPLAY=$DISPLAY ++ $DESKTOP_COMMAND & ++ PID_GNOME_SESSION=$! ++ sleep 30 ++ if test "$DESKTOP_COMMAND" != "gnome-session" ; then ++ ibus-daemon --daemonize --verbose ++ sleep 1 ++ fi ++} ++ ++count_case_result() ++{ ++ retval=$1 ++ pass=$2 ++ fail=$3 ++ ++ if test $retval -eq 0 ; then ++ pass=`expr $pass + 1` ++ else ++ fail=`expr $fail + 1` ++ fi ++ echo $pass $fail ++} ++ ++echo_case_result() ++{ ++ retval=$1 ++ tst=$2 ++ log=$3 ++ subtst=${4:-''} ++ ++ if test $retval -eq 0 ; then ++ echo -e "${GREEN}PASS${NC}: $tst $subtst" ++ else ++ echo -e "${RED}FAIL${NC}: $tst $subtst" ++ echo "FAIL: $tst $subtst" >> $TEST_LOG ++ echo "======================" >> $TEST_LOG ++ echo "" >> $TEST_LOG ++ cat "$log" >> $TEST_LOG ++ echo "" >> $TEST_LOG ++ fi ++} ++ ++run_test_suite() ++{ ++ cd `dirname $0` ++ pass=0 ++ fail=0 ++ ++ export GTK_IM_MODULE=ibus ++ export IBUS_COMPOSE_CACHE_DIR=$PWD ++ if test -f $TEST_LOG ; then ++ rm $TEST_LOG ++ fi ++ for tst in $TESTS; do ++ ENVS= ++ if test -f $SRCDIR/${tst}.env ; then ++ ENVS="`cat $SRCDIR/${tst}.env`" ++ fi ++ if test x"$ENVS" = x ; then ++ $BUILDDIR/$tst $SRCDIR >&${tst}.log ++ retval=$? ++ read pass fail << EOF ++ `count_case_result $retval $pass $fail` ++EOF ++ echo_case_result $retval $tst ${tst}.log ++ else ++ LANG_backup=$LANG ++ i=1 ++ for e in $ENVS; do ++ first=`echo "$e" | cut -c1-1` ++ if test x"$first" = x"#" ; then ++ continue ++ fi ++ export $e ++ $BUILDDIR/$tst $SRCDIR >&${tst}.${i}.log ++ retval=$? ++ read pass fail << EOF ++ `count_case_result $retval $pass $fail` ++EOF ++ echo_case_result $retval $tst ${tst}.${i}.log $e ++ i=`expr $i + 1` ++ done ++ export LANG=$LANG_backup ++ fi ++ done ++ echo "" ++ echo -e "# ${GREEN}PASS${NC}: $pass" ++ echo -e "# ${RED}FAIL${NC}: $fail" ++ if test -f ${TEST_LOG} ; then ++ echo "" ++ echo -e "${RED}See ${TEST_LOG}$NC" ++ fi ++} ++ ++finit() ++{ ++ if test "$DESKTOP_COMMAND" != "gnome-session" ; then ++ ibus exit ++ fi ++ kill $PID_GNOME_SESSION $PID_XORG ++} ++ ++main() ++{ ++ parse_args $@ ++ init_desktop ++ run_dbus_daemon ++ run_desktop ++ run_test_suite ++ finit ++} ++ ++main $@ +-- +2.21.0 + +From fa081ac8ea37d2feb7c7f395ad66e7381b4cb65b Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 12 Jul 2019 21:20:32 +0900 +Subject: [PATCH] src/tests: Use gnome-desktop-testing-runner + +--- + src/tests/Makefile.am | 4 +- + src/tests/ibus-desktop-testing-runner.in | 154 ++++++++++++++++++----- + 2 files changed, 123 insertions(+), 35 deletions(-) + +diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am +index b9aad29a..913e42fb 100644 +--- a/src/tests/Makefile.am ++++ b/src/tests/Makefile.am +@@ -105,8 +105,8 @@ $(test_metas): $(test_metas_in) $(test_programs) + $(NULL) + + ibus-compose-locales: ibus-compose-locales.in +- SRCDIR=$(test_sourcesdir); \ +- sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \ ++ INSTALLEDDIR=$(datadir)/installed-tests; \ ++ sed -e "s|@INSTALLEDDIR[@]|$$INSTALLEDDIR|g" $< > $@.tmp; \ + mv $@.tmp $@; \ + $(NULL) + +diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in +index 9e689634..a90c1378 100755 +--- a/src/tests/ibus-desktop-testing-runner.in ++++ b/src/tests/ibus-desktop-testing-runner.in +@@ -2,7 +2,7 @@ + # -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- + # vim:set noet ts=4: + # +-# ibus-anthy - The Anthy engine for IBus ++# ibus - The Input Bus + # + # Copyright (c) 2018-2019 Takao Fujiwara + # Copyright (c) 2018 Red Hat, Inc. +@@ -33,16 +33,32 @@ VERSION=0.1 + DISPLAY=:99.0 + BUILDDIR="." + SRCDIR="." +-TEST_LOG=test-suite.log ++TEST_LOG="test-suite.log" ++RESULT_LOG="" + HAVE_GRAPHICS=1 + DESKTOP_COMMAND="gnome-session" + PID_XORG=0 + PID_GNOME_SESSION=0 ++TESTING_RUNNER="default" + TESTS="" + GREEN='\033[0;32m' + RED='\033[0;31m' + NC='\033[0m' + ++print_log() ++{ ++ if [ x"$RESULT_LOG" != x ] ; then ++ # avoid 'echo -e' before call 'sed'. ++ if [ x"$1" = x'-e' ] ; then ++ shift ++ fi ++ NO_ESCAPE=`echo $@ | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'` ++ echo $NO_ESCAPE >> $RESULT_LOG ++ else ++ echo $@ ++ fi ++} ++ + usage() + { + echo -e \ +@@ -57,13 +73,19 @@ usage() + "-c, --no-graphics Use Xvfb instead of Xorg\n" \ + "-d, --desktop=DESKTOP Run DESTKTOP. The default is gnome-session\n" \ + "-t, --tests=\"TESTS...\" Run TESTS programs which is separated by space\n" \ ++"-r, --runner=RUNNER Run TESTS programs with a test RUNNER.\n" \ ++" RUNNDER = gnome or default.\n" \ ++" default is an embedded runner.\n" \ ++"-o, --output=OUTPUT_FILE OUtput the log to OUTPUT_FILE\n" \ ++"-O, --result=RESULT_FILE OUtput the result to RESULT_FILE\n" \ + "" + } + + parse_args() + { + # This is GNU getopt. "sudo port getopt" in BSD? +- ARGS=`getopt -o hvb:s:cd:t: --long help,version,builddir:,srcdir:,no-graphics,desktop:,tests:\ ++ ARGS=`getopt -o hvb:s:cd:t:r:o:O: --long \ ++ help,version,builddir:,srcdir:,no-graphics,desktop:,tests:,runner:,output:,result:\ + -- "$@"`; + eval set -- "$ARGS" + while [ 1 ] ; do +@@ -75,6 +97,9 @@ parse_args() + -c | --no-graphics ) HAVE_GRAPHICS=0; shift;; + -d | --desktop ) DESKTOP_COMMAND="$2"; shift 2;; + -t | --tests ) TESTS="$2"; shift 2;; ++ -r | --runner ) TESTING_RUNNER="$2"; shift 2;; ++ -o | --output ) TEST_LOG="$2"; shift 2;; ++ -O | --result ) RESULT_LOG="$2"; shift 2;; + -- ) shift; break;; + * ) usage; exit 1;; + esac +@@ -83,18 +108,31 @@ parse_args() + + init_desktop() + { ++ if [ "$RESULT_LOG" != "" ] ; then ++ rm $RESULT_LOG ++ fi ++ if [ "$TEST_LOG" = "" ] ; then ++ print_log -e "${RED}FAIL${NC}: ${RED}ERROR${NC}: a log file is required to get return value with 'read' command" ++ abrt ++ else ++ rm $TEST_LOG ++ fi + if test x$FORCE_TEST != x ; then + RUN_ARGS="$RUN_ARGS --force" + fi + + if test ! -f $HOME/.config/gnome-initial-setup-done ; then ++ IS_SYSTEM_ACCOUNT=false ++ if [ "$USER" = "root" ] ; then ++ IS_SYSTEM_ACCOUNT=true ++ fi + if test ! -f /var/lib/AccountsService/users/$USER ; then + mkdir -p /var/lib/AccountsService/users + cat >> /var/lib/AccountsService/users/$USER << _EOF + [User] + Language=ja_JP.UTF-8 + XSession=gnome +-SystemAccount=false ++SystemAccount=$IS_SYSTEM_ACCOUNT + _EOF + fi + mkdir -p $HOME/.config +@@ -167,71 +205,120 @@ echo_case_result() + { + retval=$1 + tst=$2 +- log=$3 +- subtst=${4:-''} ++ subtst=${3:-''} + + if test $retval -eq 0 ; then +- echo -e "${GREEN}PASS${NC}: $tst $subtst" ++ print_log -e "${GREEN}PASS${NC}: $tst $subtst" + else +- echo -e "${RED}FAIL${NC}: $tst $subtst" +- echo "FAIL: $tst $subtst" >> $TEST_LOG +- echo "======================" >> $TEST_LOG +- echo "" >> $TEST_LOG +- cat "$log" >> $TEST_LOG +- echo "" >> $TEST_LOG ++ print_log -e "${RED}FAIL${NC}: $tst $subtst" ++ print_log "======================" ++ print_log "" + fi + } + +-run_test_suite() ++run_direct_test_cases() + { +- cd `dirname $0` + pass=0 + fail=0 +- +- export GTK_IM_MODULE=ibus +- export IBUS_COMPOSE_CACHE_DIR=$PWD +- if test -f $TEST_LOG ; then +- rm $TEST_LOG +- fi + for tst in $TESTS; do + ENVS= + if test -f $SRCDIR/${tst}.env ; then + ENVS="`cat $SRCDIR/${tst}.env`" + fi + if test x"$ENVS" = x ; then +- $BUILDDIR/$tst $SRCDIR >&${tst}.log ++ $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG + retval=$? + read pass fail << EOF + `count_case_result $retval $pass $fail` + EOF +- echo_case_result $retval $tst ${tst}.log ++ echo_case_result $retval $tst ++ CACHE_FILES=`ls *.cache` ++ if [ x"$CACHE_FILES" != x ] ; then ++ print_log "Clean $CACHE_FILES" ++ rm $CACHE_FILES ++ fi + else + LANG_backup=$LANG + i=1 + for e in $ENVS; do +- first=`echo "$e" | cut -c1-1` ++ first=`echo "$e" | grep '^#'` + if test x"$first" = x"#" ; then + continue + fi + export $e +- $BUILDDIR/$tst $SRCDIR >&${tst}.${i}.log ++ $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG + retval=$? + read pass fail << EOF + `count_case_result $retval $pass $fail` + EOF +- echo_case_result $retval $tst ${tst}.${i}.log $e ++ echo_case_result $retval $tst $e ++ CACHE_FILES=`ls *.cache` ++ if [ x"$CACHE_FILES" != x ] ; then ++ print_log "Clean $CACHE_FILES" ++ rm $CACHE_FILES ++ fi + i=`expr $i + 1` + done + export LANG=$LANG_backup + fi + done ++ echo $pass $fail ++} ++ ++run_gnome_desktop_testing_runner() ++{ ++ pass=0 ++ fail=0 ++ if [ x"$TESTS" = x ] ; then ++ TESTS='ibus' ++ fi ++ for tst in $TESTS; do ++ tst_dir="@INSTALLEDDIR@/$tst" ++ if [ ! -d "$tst_dir" ] ; then ++ print_log -e "${RED}FAIL${NC}: Not found %tst_dir" ++ fail=1 ++ continue ++ fi ++ gnome-desktop-testing-runner $tst 2>>$TEST_LOG 1>>$TEST_LOG ++ retval=$? ++ read pass fail << EOF ++ `count_case_result $retval $pass $fail` ++EOF ++ done ++ echo $pass $fail ++} ++ ++run_test_suite() ++{ ++ pass=0 ++ fail=0 ++ export GTK_IM_MODULE=ibus ++ export IBUS_COMPOSE_CACHE_DIR=$PWD ++ if [ x"$TESTING_RUNNER" = x ] ; then ++ TESTING_RUNNER="default" ++ fi ++ case $TESTING_RUNNER in ++ default) ++ # Get only the last value with do-while. ++ read pass fail << EOF_RUNNER ++ `run_direct_test_cases` ++EOF_RUNNER ++ ;; ++ gnome) ++ read pass fail << EOF_RUNNER ++ `run_gnome_desktop_testing_runner` ++EOF_RUNNER ++ ;; ++ esac + echo "" +- echo -e "# ${GREEN}PASS${NC}: $pass" +- echo -e "# ${RED}FAIL${NC}: $fail" +- if test -f ${TEST_LOG} ; then +- echo "" +- echo -e "${RED}See ${TEST_LOG}$NC" ++ if [ $pass -ne 0 ] ; then ++ print_log -e "${GREEN}PASS${NC}: $pass" + fi ++ if [ $fail -ne 0 ] ; then ++ print_log -e "${RED}FAIL${NC}: $fail" ++ fi ++ echo "" ++ echo "See ${TEST_LOG}" + } + + finit() +@@ -240,14 +327,15 @@ finit() + ibus exit + fi + kill $PID_GNOME_SESSION $PID_XORG ++ echo "Finished $PROGNAME testing" + } + + main() + { + parse_args $@ + init_desktop +- run_dbus_daemon +- run_desktop ++ run_dbus_daemon 2>>$TEST_LOG 1>>$TEST_LOG ++ run_desktop 2>>$TEST_LOG 1>>$TEST_LOG + run_test_suite + finit + } +-- +2.21.0 + +From 85b647a1c57c206779eb0b4b15a734c1b1f29c10 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Wed, 24 Jul 2019 17:27:37 +0900 +Subject: [PATCH] src/tests: Fix IBus test cases for gnome-desktop-testing + +- dconf/config.c: Replaced dconf_client_write_fast() with + dconf_client_write_sync() because + dconf_client_write_fast() does not syn the data when + ibus_config_get_values() is called immediately after + ibus_config_set_value() is called. + +- ibus-compose-locales.in returns the return value of ibus-compose + +- ibus-compose: Set $NO_AT_BRIDGE to suppress a AT_SPI warning + and call g_log_set_always_fatal() because GtkIMContextSimple + does not support multiple compose outputs yet and the API can + suppress a warning. + +- ibus-config: Delete async watch testings which causes several errors + with gnome-shell testing and the testing is now deprecated and + GSettings is recommended. + +- ibus-desktop-testing-runner.in: Support --output=log:stdout to + cat the log to stdout and Use dbus-launch --exit-with-session instead of + --sh-syntax and count PASS of test cases instead of PASS of + gnome-desktop-testing and always run ibus exit and kill + gnome-shell-calendar-server + +- ibus-engine-switch.c: Set xkb:jp::jpn if gnome-shell sets xkb:us::eng + +- ibus-inputcontext.c: Use ibus_bus_get_global_engine() instead of + ibus_bus_list_active_engines() since ibus_bus_list_active_engines() + does not work with gnome-shell and the API is now deprecated. + +- ibus-keypress.c: Set $NO_AT_BRIDGE to suppress a AT_SPI warning +--- + conf/dconf/config.c | 14 +- + src/tests/Makefile.am | 19 +- + src/tests/ibus-compose-locales.in | 4 +- + src/tests/ibus-compose.c | 10 +- + src/tests/ibus-config.c | 283 ----------------------- + src/tests/ibus-desktop-testing-runner.in | 77 +++--- + src/tests/ibus-engine-switch.c | 34 ++- + src/tests/ibus-inputcontext.c | 29 +-- + src/tests/ibus-keypress.c | 4 + + 9 files changed, 126 insertions(+), 348 deletions(-) + +diff --git a/conf/dconf/config.c b/conf/dconf/config.c +index 500ea1d8..30ac137d 100644 +--- a/conf/dconf/config.c ++++ b/conf/dconf/config.c +@@ -335,7 +335,19 @@ ibus_config_dconf_set_value (IBusConfigService *config, + } + + #ifdef DCONF_0_13_4 +- retval = dconf_client_write_fast (client, gkey, value, error); ++ /* Use dconf_client_write_sync() instead of dconf_client_write_fast() ++ * because dconf_client_write_fast() does not sync the data when ++ * ibus_config_get_values() is called immediately after ++ * ibus_config_set_value() is called. ++ * We won't add a new API for the sync only since IBusConfig is ++ * now deprecated and GSettings is recommended. ++ */ ++ retval = dconf_client_write_sync (client, ++ gkey, ++ value, ++ NULL, ++ NULL, ++ error); + #else + retval = dconf_client_write (client, + gkey, +diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am +index 913e42fb..2e75932c 100644 +--- a/src/tests/Makefile.am ++++ b/src/tests/Makefile.am +@@ -55,6 +55,8 @@ TESTS = \ + ibus-util \ + $(NULL) + ++CLEANFILES = ++ + if ENABLE_ENGINE + TESTS += ibus-engine-switch + endif +@@ -90,9 +92,17 @@ test_sources_DATA = \ + $(NULL) + test_sourcesdir = $(datadir)/installed-tests/ibus + ++CLEANFILES += \ ++ $(test_metas) \ ++ ibus-desktop-testing-runner \ ++ $(NULL) ++ + test_execs_PROGRAMS = $(TESTS) + if ENABLE_GTK3 + test_execs_SCRIPTS = ibus-compose-locales ++CLEANFILES += \ ++ ibus-compose-locales \ ++ $(NULL) + endif + test_execsdir = $(libexecdir)/installed-tests/ibus + endif +@@ -105,15 +115,14 @@ $(test_metas): $(test_metas_in) $(test_programs) + $(NULL) + + ibus-compose-locales: ibus-compose-locales.in +- INSTALLEDDIR=$(datadir)/installed-tests; \ +- sed -e "s|@INSTALLEDDIR[@]|$$INSTALLEDDIR|g" $< > $@.tmp; \ ++ SRCDIR=$(test_sourcesdir); \ ++ sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \ + mv $@.tmp $@; \ + $(NULL) + +- ibus-desktop-testing-runner.in \ + ibus-desktop-testing-runner: ibus-desktop-testing-runner.in +- SRCDIR=$(test_sourcesdir); \ +- sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \ ++ INSTALLEDDIR=$(datadir)/installed-tests; \ ++ sed -e "s|@INSTALLEDDIR[@]|$$INSTALLEDDIR|g" $< > $@.tmp; \ + mv $@.tmp $@; \ + $(NULL) + +diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in +index 8d2384d1..fad02965 100755 +--- a/src/tests/ibus-compose-locales.in ++++ b/src/tests/ibus-compose-locales.in +@@ -6,6 +6,7 @@ BUILDDIR=`dirname $0` + + export IBUS_COMPOSE_CACHE_DIR=$PWD + ++retval=0 + for var in `cat $SRCDIR/ibus-compose.env` + do + IS_COMMENT=`echo "$var" | grep "^#"` +@@ -13,6 +14,7 @@ do + continue + fi + env $var $BUILDDIR/ibus-compose $SRCDIR $@ ++ retval=`expr $retval + $?` + + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then +@@ -20,4 +22,4 @@ do + rm $CACHE_FILES + fi + done +- ++exit $retval +diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c +index c8d3c126..db359477 100644 +--- a/src/tests/ibus-compose.c ++++ b/src/tests/ibus-compose.c +@@ -344,20 +344,26 @@ test_compose (void) + int + main (int argc, char *argv[]) + { ++ GLogLevelFlags flags; + const gchar *test_name; + gchar *test_path; + + ibus_init (); ++ /* Avoid a warning of "AT-SPI: Could not obtain desktop path or name" ++ * with gtk_main(). ++ */ ++ g_setenv ("NO_AT_BRIDGE", "1", TRUE); + g_test_init (&argc, &argv, NULL); + /* FIXME: + * IBusIMContext opens GtkIMContextSimple as the slave and + * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the +- * multiple outputs in el_GR's compose causes a warning in gtkcomposetable ++ * multiple outputs in el_GR's compose causes a warning in gtkcomposetable + * and the warning always causes a fatal in GTest: + " "GTK+ supports to output one char only: " + */ +- g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); ++ flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); + gtk_init (&argc, &argv); ++ g_log_set_always_fatal (flags); + + m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup ("."); + m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE")); +diff --git a/src/tests/ibus-config.c b/src/tests/ibus-config.c +index c6141ab5..9b925ad9 100644 +--- a/src/tests/ibus-config.c ++++ b/src/tests/ibus-config.c +@@ -133,254 +133,6 @@ test_config_set_get (void) + g_object_unref (config); + } + +-typedef struct { +- GMainLoop *loop; +- guint timeout_id; +- gchar *section; +- gchar *name; +-} WatchData; +- +-typedef struct { +- gchar *section; +- gchar *name; +-} WatchKey; +- +-typedef struct { +- WatchKey *watched; /* watched keys (null-terminated) */ +- WatchKey *changed; /* changed keys (null-terminated) */ +- WatchKey *notified; /* notified keys (same length as +- changed, not null-terminated) */ +-} WatchTestData; +- +-static WatchKey default_watched[] = { +- { NULL } +-}; +-static WatchKey default_changed[] = { +- { "test/s1", "n1" }, +- { "test/s1", "n2" }, +- { "test/s2", "n1" }, +- { "test/s2", "n2" }, +- { NULL } +-}; +-static WatchKey default_notified[] = { +- { "test/s1", "n1" }, +- { "test/s1", "n2" }, +- { "test/s2", "n1" }, +- { "test/s2", "n2" } +-}; +-static WatchTestData default_data = { +- default_watched, +- default_changed, +- default_notified +-}; +- +-static WatchKey section_watched[] = { +- { "test/s1", NULL }, +- { NULL } +-}; +-static WatchKey section_notified[] = { +- { "test/s1", "n1" }, +- { "test/s1", "n2" }, +- { NULL, NULL }, +- { NULL, NULL }, +-}; +-static WatchTestData section_data = { +- section_watched, +- default_changed, +- section_notified +-}; +- +-static WatchKey section_multiple_watched[] = { +- { "test/s1", NULL }, +- { "test/s2", NULL }, +- { NULL } +-}; +-static WatchKey section_multiple_notified[] = { +- { "test/s1", "n1" }, +- { "test/s1", "n2" }, +- { "test/s2", "n1" }, +- { "test/s2", "n2" }, +-}; +-static WatchTestData section_multiple_data = { +- section_multiple_watched, +- default_changed, +- section_multiple_notified +-}; +- +-static WatchKey section_name_watched[] = { +- { "test/s1", "n1" }, +- { NULL } +-}; +-static WatchKey section_name_notified[] = { +- { "test/s1", "n1" }, +- { NULL, NULL }, +- { NULL, NULL }, +- { NULL, NULL }, +-}; +-static WatchTestData section_name_data = { +- section_name_watched, +- default_changed, +- section_name_notified +-}; +- +-static WatchKey section_name_multiple_watched[] = { +- { "test/s1", "n1" }, +- { "test/s2", "n2" }, +- { NULL } +-}; +-static WatchKey section_name_multiple_notified[] = { +- { "test/s1", "n1" }, +- { NULL, NULL }, +- { NULL, NULL }, +- { "test/s2", "n2" }, +-}; +-static WatchTestData section_name_multiple_data = { +- section_name_multiple_watched, +- default_changed, +- section_name_multiple_notified +-}; +- +-typedef struct { +- IBusConfig *config; +- WatchData data; +-} WatchFixture; +- +-static void +-value_changed_cb (IBusConfig *config, +- const gchar *section, +- const gchar *name, +- GVariant *value, +- gpointer user_data) +-{ +- WatchData *data = (WatchData *) user_data; +- +- data->section = g_strdup (section); +- data->name = g_strdup (name); +- +- g_main_loop_quit (data->loop); +-} +- +-static gboolean +-timeout_cb (gpointer user_data) +-{ +- WatchData *data = (WatchData *) user_data; +- g_main_loop_quit (data->loop); +- data->timeout_id = 0; +- return FALSE; +-} +- +-static void +-change_and_test (IBusConfig *config, +- const gchar *section, +- const gchar *name, +- const gchar *expected_section, +- const gchar *expected_name, +- WatchData *data) +-{ +- gboolean retval; +- GVariant *var; +- +- data->section = NULL; +- data->name = NULL; +- +- /* Unset won't notify value-changed signal. */ +- var = ibus_config_get_values (config, section); +- if (var != NULL) { +- GVariant *value = g_variant_lookup_value (var, name, +- G_VARIANT_TYPE_VARIANT); +- if (value != NULL) { +- ibus_config_unset (config, section, name); +- g_variant_unref (value); +- } +- g_variant_unref (var); +- } +- +- data->timeout_id = g_timeout_add (1, timeout_cb, data); +- g_main_loop_run (data->loop); +- if (data->timeout_id != 0) { +- g_source_remove (data->timeout_id); +- } +- +- retval = ibus_config_set_value (config, section, name, +- g_variant_new_int32 (1)); +- g_assert (retval); +- +- data->timeout_id = g_timeout_add (1, timeout_cb, data); +- g_main_loop_run (data->loop); +- if (data->timeout_id != 0) { +- g_source_remove (data->timeout_id); +- } +- +- g_assert_cmpstr (data->section, ==, expected_section); +- g_assert_cmpstr (data->name, ==, expected_name); +- +- g_free (data->section); +- g_free (data->name); +-} +- +-static void +-watch_fixture_setup (WatchFixture *fixture, gconstpointer user_data) +-{ +- fixture->config = ibus_config_new (ibus_bus_get_connection (bus), +- NULL, +- NULL); +- g_assert (fixture->config); +- +- fixture->data.loop = g_main_loop_new (NULL, FALSE); +- g_signal_connect (fixture->config, "value-changed", +- G_CALLBACK (value_changed_cb), &fixture->data); +-} +- +-static void +-watch_fixture_teardown (WatchFixture *fixture, gconstpointer user_data) +-{ +- g_main_loop_unref (fixture->data.loop); +- +- ibus_proxy_destroy (IBUS_PROXY (fixture->config)); +- g_object_unref (fixture->config); +-} +- +-static void +-test_config_watch (WatchFixture *fixture, gconstpointer user_data) +-{ +- const WatchTestData *data = user_data; +- gint i; +- +- for (i = 0; data->watched[i].section != NULL; i++) { +- ibus_config_watch (fixture->config, +- data->watched[i].section, +- data->watched[i].name); +- } +- for (i = 0; data->changed[i].section != NULL; i++) { +- change_and_test (fixture->config, +- data->changed[i].section, +- data->changed[i].name, +- data->notified[i].section, +- data->notified[i].name, +- &fixture->data); +- } +- for (i = 0; data->watched[i].section != NULL; i++) { +- ibus_config_unwatch (fixture->config, +- data->watched[i].section, +- data->watched[i].name); +- } +- if (i > 0) { +- /* Check if the above unwatch takes effect. */ +- for (i = 0; data->changed[i].section != NULL; i++) { +- change_and_test (fixture->config, +- data->changed[i].section, +- data->changed[i].name, +- NULL, +- NULL, +- &fixture->data); +- } +- } else { +- /* Since we reuse single D-Bus connection, we need to remove the +- default match rule for the next ibus_config_new() call. */ +- ibus_config_unwatch (fixture->config, NULL, NULL); +- } +-} +- + gint + main (gint argc, + gchar **argv) +@@ -390,41 +142,6 @@ main (gint argc, + g_test_init (&argc, &argv, NULL); + bus = ibus_bus_new (); + +- g_test_add ("/ibus/config-watch/default", +- WatchFixture, +- &default_data, +- watch_fixture_setup, +- test_config_watch, +- watch_fixture_teardown); +- +- g_test_add ("/ibus/config-watch/section", +- WatchFixture, +- §ion_data, +- watch_fixture_setup, +- test_config_watch, +- watch_fixture_teardown); +- +- g_test_add ("/ibus/config-watch/section-multiple", +- WatchFixture, +- §ion_multiple_data, +- watch_fixture_setup, +- test_config_watch, +- watch_fixture_teardown); +- +- g_test_add ("/ibus/config-watch/section-name", +- WatchFixture, +- §ion_name_data, +- watch_fixture_setup, +- test_config_watch, +- watch_fixture_teardown); +- +- g_test_add ("/ibus/config-watch/section-name-multiple", +- WatchFixture, +- §ion_name_multiple_data, +- watch_fixture_setup, +- test_config_watch, +- watch_fixture_teardown); +- + g_test_add_func ("/ibus/create-config-async", test_create_config_async); + g_test_add_func ("/ibus/config-set-get", test_config_set_get); + +diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in +index a90c1378..b7a72285 100755 +--- a/src/tests/ibus-desktop-testing-runner.in ++++ b/src/tests/ibus-desktop-testing-runner.in +@@ -34,9 +34,10 @@ DISPLAY=:99.0 + BUILDDIR="." + SRCDIR="." + TEST_LOG="test-suite.log" ++TEST_LOG_STDOUT=0 + RESULT_LOG="" + HAVE_GRAPHICS=1 +-DESKTOP_COMMAND="gnome-session" ++DESKTOP_COMMAND="dbus-launch --exit-with-session gnome-session" + PID_XORG=0 + PID_GNOME_SESSION=0 + TESTING_RUNNER="default" +@@ -109,19 +110,26 @@ parse_args() + init_desktop() + { + if [ "$RESULT_LOG" != "" ] ; then +- rm $RESULT_LOG ++ if [ -f $RESULT_LOG ] ; then ++ rm $RESULT_LOG ++ fi ++ fi ++ HAS_STDOUT=`echo "$TEST_LOG" | grep ':stdout'` ++ if [ x"$HAS_STDOUT" != x ] ; then ++ TEST_LOG=`echo "$TEST_LOG" | sed -e 's|:stdout||'` ++ TEST_LOG_STDOUT=1 + fi + if [ "$TEST_LOG" = "" ] ; then + print_log -e "${RED}FAIL${NC}: ${RED}ERROR${NC}: a log file is required to get return value with 'read' command" +- abrt +- else ++ exit -1 ++ elif [ -f $TEST_LOG ] ; then + rm $TEST_LOG + fi +- if test x$FORCE_TEST != x ; then ++ if [ x$FORCE_TEST != x ] ; then + RUN_ARGS="$RUN_ARGS --force" + fi + +- if test ! -f $HOME/.config/gnome-initial-setup-done ; then ++ if [ ! -f $HOME/.config/gnome-initial-setup-done ] ; then + IS_SYSTEM_ACCOUNT=false + if [ "$USER" = "root" ] ; then + IS_SYSTEM_ACCOUNT=true +@@ -141,7 +149,7 @@ _EOF + + # Prevent from launching a XDG dialog + XDG_LOCALE_FILE="$HOME/.config/user-dirs.locale" +- if test -f $XDG_LOCALE_FILE ; then ++ if [ -f $XDG_LOCALE_FILE ] ; then + XDG_LANG_ORIG=`cat $XDG_LOCALE_FILE` + XDG_LANG_NEW=`echo $LANG | sed -e 's/\(.*\)\..*/\1/'` + if [ "$XDG_LANG_ORIG" != "$XDG_LANG_NEW" ] ; then +@@ -153,19 +161,8 @@ _EOF + + run_dbus_daemon() + { +- a=`ps -ef | grep dbus-daemon | grep "\-\-system" | grep -v session | grep -v grep` +- if test x"$a" = x ; then +- eval `dbus-launch --sh-syntax` +- fi +- SUSER=`echo "$USER" | cut -c 1-7` +- a=`ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | grep session | grep -v grep` +- if test x"$a" = x ; then +- systemctl --user start dbus +- export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus +- fi +- systemctl --user status dbus | col -b +- ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | egrep 'session|system' | grep -v grep +- systemctl --user show-environment | col -b ++ # Use dbus-launch --exit-with-session later instead of --sh-syntax ++ export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus + } + + run_desktop() +@@ -181,7 +178,8 @@ run_desktop() + $DESKTOP_COMMAND & + PID_GNOME_SESSION=$! + sleep 30 +- if test "$DESKTOP_COMMAND" != "gnome-session" ; then ++ HAS_GNOME=`echo $DESKTOP_COMMAND | grep gnome-session` ++ if [ x"$HAS_GNOME" = x ] ; then + ibus-daemon --daemonize --verbose + sleep 1 + fi +@@ -285,6 +283,16 @@ run_gnome_desktop_testing_runner() + `count_case_result $retval $pass $fail` + EOF + done ++ child_pass=`grep '^PASS:' $TEST_LOG | wc -l` ++ child_fail=`grep '^FAIL:' $TEST_LOG | wc -l` ++ if [ $child_pass -ne 0 -o $child_fail -ne 0 ] ; then ++ pass=$child_pass ++ if [ $child_fail -ne 0 ] ; then ++ fail=`expr $child_fail / 2` ++ else ++ fail=0 ++ fi ++ fi + echo $pass $fail + } + +@@ -311,22 +319,29 @@ EOF_RUNNER + ;; + esac + echo "" +- if [ $pass -ne 0 ] ; then +- print_log -e "${GREEN}PASS${NC}: $pass" +- fi +- if [ $fail -ne 0 ] ; then +- print_log -e "${RED}FAIL${NC}: $fail" +- fi ++ print_log -e "${GREEN}PASS${NC}: $pass" ++ print_log -e "${RED}FAIL${NC}: $fail" + echo "" +- echo "See ${TEST_LOG}" ++ if [ $TEST_LOG_STDOUT -eq 1 ] ; then ++ cat $TEST_LOG ++ else ++ echo "See $TEST_LOG" ++ fi + } + + finit() + { +- if test "$DESKTOP_COMMAND" != "gnome-session" ; then +- ibus exit +- fi ++ echo "Killing left gnome-session and Xorg" + kill $PID_GNOME_SESSION $PID_XORG ++ ibus exit ++ SUSER=`echo "$USER" | cut -c 1-7` ++ LEFT_CALENDAR=`ps -ef | grep gnome-shell-calendar-server | grep $SUSER | grep -v grep` ++ if [ x"$LEFT_CALENDAR" != x ] ; then ++ echo "Killing left gnome-shell-calendar-server" ++ echo "$LEFT_CALENDAR" ++ echo "$LEFT_CALENDAR" | awk '{print $2}' | xargs kill ++ fi ++ + echo "Finished $PROGNAME testing" + } + +diff --git a/src/tests/ibus-engine-switch.c b/src/tests/ibus-engine-switch.c +index 5c2bd516..a1eeba2a 100644 +--- a/src/tests/ibus-engine-switch.c ++++ b/src/tests/ibus-engine-switch.c +@@ -13,17 +13,25 @@ static const gchar *engine_names[] = { + AFTER_ENGINE + }; + ++static const gchar *engine_names2[] = { ++ AFTER_ENGINE, ++ BEFORE_ENGINE ++}; ++ + static void +-change_global_engine (void) ++change_global_engine (gboolean reverse) + { + gint i; + + for (i = 0; i < G_N_ELEMENTS (engine_names); i++) { +- ibus_bus_set_global_engine (bus, engine_names[i]); ++ const gchar *engine_name = engine_names[i]; ++ if (reverse) ++ engine_name = engine_names2[i]; ++ ibus_bus_set_global_engine (bus, engine_name); + IBusEngineDesc *engine_desc = ibus_bus_get_global_engine (bus); + g_assert_cmpstr (ibus_engine_desc_get_name (engine_desc), + ==, +- engine_names[i]); ++ engine_name); + g_object_unref (G_OBJECT (engine_desc)); + } + } +@@ -46,6 +54,7 @@ typedef struct { + gint count; + guint timeout_id; + guint idle_id; ++ gboolean reverse; + } GlobalEngineChangedData; + + static void +@@ -70,7 +79,7 @@ static gboolean + change_global_engine_cb (gpointer user_data) + { + GlobalEngineChangedData *data = (GlobalEngineChangedData *) user_data; +- change_global_engine (); ++ change_global_engine (data->reverse); + data->idle_id = 0; + return FALSE; + } +@@ -78,12 +87,25 @@ change_global_engine_cb (gpointer user_data) + static void + test_global_engine (void) + { ++ GLogLevelFlags flags; ++ IBusEngineDesc *desc; + GlobalEngineChangedData data; + guint handler_id; + + if (!ibus_bus_get_use_global_engine (bus)) + return; + ++ /* "No global engine." warning is not critical message. */ ++ flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); ++ desc = ibus_bus_get_global_engine (bus); ++ g_log_set_always_fatal (flags); ++ if (desc && ++ !g_strcmp0 (BEFORE_ENGINE, ibus_engine_desc_get_name (desc))) { ++ data.reverse = TRUE; ++ } else { ++ data.reverse = FALSE; ++ } ++ + data.count = 0; + + handler_id = g_signal_connect (bus, +@@ -141,7 +163,7 @@ test_context_engine_set_by_global (void) + /* ibus_bus_set_global_engine() changes focused context engine. */ + ibus_input_context_focus_in (context); + +- change_global_engine (); ++ change_global_engine (FALSE); + + /* ibus_input_context_set_engine() does not take effect when + global engine is used. */ +@@ -170,7 +192,7 @@ test_context_engine_set_by_focus (void) + + ibus_input_context_focus_in (context); + +- change_global_engine (); ++ change_global_engine (FALSE); + + /* When focus is lost, context engine is set to "dummy". */ + ibus_input_context_focus_in (another_context); +diff --git a/src/tests/ibus-inputcontext.c b/src/tests/ibus-inputcontext.c +index fab183aa..ed04bd64 100644 +--- a/src/tests/ibus-inputcontext.c ++++ b/src/tests/ibus-inputcontext.c +@@ -37,18 +37,6 @@ fatal_handler(const gchar *log_domain, + return TRUE; + } + +-static gchar * +-get_last_engine_id (const GList *engines) +-{ +- const char *result = NULL; +- for (; engines; engines = g_list_next (engines)) { +- IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data); +- g_assert (engine_desc); +- result = ibus_engine_desc_get_name (engine_desc); +- } +- return g_strdup (result); +-} +- + static void + call_basic_ipcs (IBusInputContext *context) + { +@@ -68,18 +56,23 @@ call_basic_ipcs (IBusInputContext *context) + static void + test_input_context (void) + { +- GList *engines; +- gchar *active_engine_name = NULL; + IBusInputContext *context; ++ GLogLevelFlags flags; + IBusEngineDesc *engine_desc; ++ gchar *active_engine_name = NULL; + gchar *current_ic; + + context = ibus_bus_create_input_context (bus, "test"); + call_basic_ipcs (context); + +- engines = ibus_bus_list_active_engines (bus); +- if (engines != NULL) { +- active_engine_name = get_last_engine_id (engines); ++ /* "No global engine." warning is not critical message. */ ++ flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); ++ engine_desc = ibus_bus_get_global_engine (bus); ++ g_log_set_always_fatal (flags); ++ if (engine_desc != NULL) { ++ active_engine_name = g_strdup (ibus_engine_desc_get_name(engine_desc)); ++ g_object_unref (engine_desc); ++ engine_desc = NULL; + } else { + active_engine_name = g_strdup ("dummy"); + } +@@ -111,8 +104,6 @@ test_input_context (void) + g_object_unref (context); + + g_free (active_engine_name); +- g_list_foreach (engines, (GFunc) g_object_unref, NULL); +- g_list_free (engines); + } + + static void +diff --git a/src/tests/ibus-keypress.c b/src/tests/ibus-keypress.c +index 17920226..dd1b0042 100644 +--- a/src/tests/ibus-keypress.c ++++ b/src/tests/ibus-keypress.c +@@ -288,6 +288,10 @@ int + main (int argc, char *argv[]) + { + ibus_init (); ++ /* Avoid a warning of "AT-SPI: Could not obtain desktop path or name" ++ * with gtk_main(). ++ */ ++ g_setenv ("NO_AT_BRIDGE", "1", TRUE); + g_test_init (&argc, &argv, NULL); + gtk_init (&argc, &argv); + +-- +2.21.0 + +From f4463c0433c5f48a4fb2830e8c2ae9619fbb18d1 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Mon, 29 Jul 2019 19:05:43 +0900 +Subject: [PATCH] src/tests: Fix a fatal error with g_warning + +I set g_log_set_always_fatal() before gtk_init() in ibus-compose for +a compose warning of GtkIMContextSimple but actually the warning is +output during gtk_main() due to GtkIMContextSimple.set_client_window() +so I moved g_log_set_always_fatal() before gtk_main() in ibus-compose.c. + +Also set IFS in ibus-compose-locales to set the delimiter to '\n' for +for-loop arguments. +--- + src/tests/ibus-compose-locales.in | 8 ++++++++ + src/tests/ibus-compose.c | 21 ++++++++++----------- + 2 files changed, 18 insertions(+), 11 deletions(-) + +diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in +index fad02965..f650b584 100755 +--- a/src/tests/ibus-compose-locales.in ++++ b/src/tests/ibus-compose-locales.in +@@ -7,19 +7,27 @@ BUILDDIR=`dirname $0` + export IBUS_COMPOSE_CACHE_DIR=$PWD + + retval=0 ++# Let for-loop notice '\n' as a delimiter ++IFS=$'\n' + for var in `cat $SRCDIR/ibus-compose.env` + do ++ # Revert IFS to recognize env a=foo b=foo ++ IFS=' ' + IS_COMMENT=`echo "$var" | grep "^#"` + if [ "x$IS_COMMENT" != x ] ; then + continue + fi ++ echo "# Starting $var $BUILDDIR/ibus-compose $SRCDIR $@" + env $var $BUILDDIR/ibus-compose $SRCDIR $@ + retval=`expr $retval + $?` ++ echo "# Finished $var $BUILDDIR/ibus-compose $SRCDIR $@ with $retval" + + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then + echo "Clean $CACHE_FILES" + rm $CACHE_FILES + fi ++ IFS=$'\n' + done ++IFS=' ' + exit $retval +diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c +index db359477..4b4c56e7 100644 +--- a/src/tests/ibus-compose.c ++++ b/src/tests/ibus-compose.c +@@ -331,20 +331,28 @@ create_window () + static void + test_compose (void) + { ++ GLogLevelFlags flags; + if (!register_ibus_engine ()) { + g_test_fail (); + return; + } + + create_window (); ++ /* FIXME: ++ * IBusIMContext opens GtkIMContextSimple as the slave and ++ * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the ++ * multiple outputs in el_GR's compose causes a warning in gtkcomposetable ++ * and the warning always causes a fatal in GTest: ++ " "GTK+ supports to output one char only: " ++ */ ++ flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); + gtk_main (); +- ++ g_log_set_always_fatal (flags); + } + + int + main (int argc, char *argv[]) + { +- GLogLevelFlags flags; + const gchar *test_name; + gchar *test_path; + +@@ -354,16 +362,7 @@ main (int argc, char *argv[]) + */ + g_setenv ("NO_AT_BRIDGE", "1", TRUE); + g_test_init (&argc, &argv, NULL); +- /* FIXME: +- * IBusIMContext opens GtkIMContextSimple as the slave and +- * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the +- * multiple outputs in el_GR's compose causes a warning in gtkcomposetable +- * and the warning always causes a fatal in GTest: +- " "GTK+ supports to output one char only: " +- */ +- flags = g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); + gtk_init (&argc, &argv); +- g_log_set_always_fatal (flags); + + m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup ("."); + m_compose_file = g_strdup (g_getenv ("COMPOSE_FILE")); +-- +2.21.0 + +From 7dde99600777f195da614130950ecbd339439d35 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Wed, 31 Jul 2019 16:27:49 +0900 +Subject: [PATCH] src/tests: Fix wrong echo with direct runner in + ibus-desktop-testing-runner + +The wrong echo prevent from counting the test results in the direct +testing runner. +--- + src/tests/ibus-desktop-testing-runner.in | 33 +++++++++++++----------- + 1 file changed, 18 insertions(+), 15 deletions(-) + +diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in +index b7a72285..3045d601 100755 +--- a/src/tests/ibus-desktop-testing-runner.in ++++ b/src/tests/ibus-desktop-testing-runner.in +@@ -153,7 +153,7 @@ _EOF + XDG_LANG_ORIG=`cat $XDG_LOCALE_FILE` + XDG_LANG_NEW=`echo $LANG | sed -e 's/\(.*\)\..*/\1/'` + if [ "$XDG_LANG_ORIG" != "$XDG_LANG_NEW" ] ; then +- echo "Overriding XDG locale $XDG_LANG_ORIG with $XDG_LANG_NEW" ++ echo "# Overriding XDG locale $XDG_LANG_ORIG with $XDG_LANG_NEW" + echo "$XDG_LANG_NEW" > $XDG_LOCALE_FILE + fi + fi +@@ -206,11 +206,9 @@ echo_case_result() + subtst=${3:-''} + + if test $retval -eq 0 ; then +- print_log -e "${GREEN}PASS${NC}: $tst $subtst" ++ echo "PASS: $tst $subtst" >>$TEST_LOG + else +- print_log -e "${RED}FAIL${NC}: $tst $subtst" +- print_log "======================" +- print_log "" ++ echo "FAIL: $tst $subtst" >>$TEST_LOG + fi + } + +@@ -232,32 +230,37 @@ EOF + echo_case_result $retval $tst + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then +- print_log "Clean $CACHE_FILES" ++ echo "# Clean $CACHE_FILES" >>$TEST_LOG + rm $CACHE_FILES + fi + else +- LANG_backup=$LANG + i=1 ++ # Let for-loop notice '\n' as a delimiter ++ IFS=$'\n' + for e in $ENVS; do ++ # Revert IFS to recognize env a=foo b=foo ++ IFS=' ' + first=`echo "$e" | grep '^#'` + if test x"$first" = x"#" ; then + continue + fi +- export $e +- $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG ++ echo "# Starting $e $BUILDDIR/$tst $SRCDIR" >>$TEST_LOG ++ env $e $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG + retval=$? ++ echo "# Finished $e $BUILDDIR/$tst $SRCDIR with $retval" >>$TEST_LOG + read pass fail << EOF + `count_case_result $retval $pass $fail` + EOF + echo_case_result $retval $tst $e + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then +- print_log "Clean $CACHE_FILES" ++ echo "# Clean $CACHE_FILES" >>$TEST_LOG + rm $CACHE_FILES + fi + i=`expr $i + 1` ++ IFS=$'\n' + done +- export LANG=$LANG_backup ++ IFS=' ' + fi + done + echo $pass $fail +@@ -325,24 +328,24 @@ EOF_RUNNER + if [ $TEST_LOG_STDOUT -eq 1 ] ; then + cat $TEST_LOG + else +- echo "See $TEST_LOG" ++ echo "# See $TEST_LOG" + fi + } + + finit() + { +- echo "Killing left gnome-session and Xorg" ++ echo "# Killing left gnome-session and Xorg" + kill $PID_GNOME_SESSION $PID_XORG + ibus exit + SUSER=`echo "$USER" | cut -c 1-7` + LEFT_CALENDAR=`ps -ef | grep gnome-shell-calendar-server | grep $SUSER | grep -v grep` + if [ x"$LEFT_CALENDAR" != x ] ; then +- echo "Killing left gnome-shell-calendar-server" ++ echo "# Killing left gnome-shell-calendar-server" + echo "$LEFT_CALENDAR" + echo "$LEFT_CALENDAR" | awk '{print $2}' | xargs kill + fi + +- echo "Finished $PROGNAME testing" ++ echo "# Finished $PROGNAME testing" + } + + main() +-- +2.21.0 + +From 28c10d64d282fa9fbc35a7bc44a096f6137d5e46 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Tue, 13 Aug 2019 20:06:51 +0900 +Subject: [PATCH] src/tests: Set XDG_SESSION_TYPE in + ibus-desktop-testing-runner + +mutter 3.33.90 or later exits the session without loginctl. +Now ibus-desktop-testing-runner has XDG_SESSION_TYPE forcibly +not to exit gnome-shell. +--- + src/tests/ibus-desktop-testing-runner.in | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in +index 3045d601..141e9b5b 100755 +--- a/src/tests/ibus-desktop-testing-runner.in ++++ b/src/tests/ibus-desktop-testing-runner.in +@@ -157,6 +157,8 @@ _EOF + echo "$XDG_LANG_NEW" > $XDG_LOCALE_FILE + fi + fi ++ # `su` command does not run loginctl ++ export XDG_SESSION_TYPE='x11' + } + + run_dbus_daemon() +@@ -175,6 +177,7 @@ run_desktop() + PID_XORG=$! + sleep 1 + export DISPLAY=$DISPLAY ++ echo "Running $DESKTOP_COMMAND with $USER in `tty`" + $DESKTOP_COMMAND & + PID_GNOME_SESSION=$! + sleep 30 +-- +2.21.0 + +From bccf94d5ec1c5fc80d5aeac622f2ab8007d5a28a Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 29 Nov 2019 20:28:49 +0900 +Subject: [PATCH] src/tests: RHEL codereview for ibus-desktop-testing-runner + +--- + src/tests/ibus-desktop-testing-runner.in | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in +index 141e9b5b..72537cd4 100755 +--- a/src/tests/ibus-desktop-testing-runner.in ++++ b/src/tests/ibus-desktop-testing-runner.in +@@ -28,6 +28,10 @@ + # # /root/ibus/tests/test-console.sh --tests ibus-compose \ + # --builddir /root/ibus/src/tests --srcdir /root/ibus/src/tests + ++# POSIX sh has no 'echo -e' ++: ${ECHO:='/usr/bin/echo'} ++ ++ + PROGNAME=`basename $0` + VERSION=0.1 + DISPLAY=:99.0 +@@ -54,15 +58,15 @@ print_log() + shift + fi + NO_ESCAPE=`echo $@ | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'` +- echo $NO_ESCAPE >> $RESULT_LOG ++ $ECHO $NO_ESCAPE >> $RESULT_LOG + else +- echo $@ ++ $ECHO $@ + fi + } + + usage() + { +- echo -e \ ++ $ECHO -e \ + "This test runs /usr/bin/ibus-daemon after install ibus\n" \ + "$PROGNAME [OPTIONS…]\n" \ + "\n" \ +@@ -92,7 +96,7 @@ parse_args() + while [ 1 ] ; do + case "$1" in + -h | --help ) usage; exit 0;; +- -v | --version ) echo -e "$VERSION"; exit 0;; ++ -v | --version ) $ECHO -e "$VERSION"; exit 0;; + -b | --builddir ) BUILDDIR="$2"; shift 2;; + -s | --srcdir ) SRCDIR="$2"; shift 2;; + -c | --no-graphics ) HAVE_GRAPHICS=0; shift;; +@@ -121,7 +125,7 @@ init_desktop() + fi + if [ "$TEST_LOG" = "" ] ; then + print_log -e "${RED}FAIL${NC}: ${RED}ERROR${NC}: a log file is required to get return value with 'read' command" +- exit -1 ++ exit 255 + elif [ -f $TEST_LOG ] ; then + rm $TEST_LOG + fi +@@ -291,7 +295,7 @@ EOF + done + child_pass=`grep '^PASS:' $TEST_LOG | wc -l` + child_fail=`grep '^FAIL:' $TEST_LOG | wc -l` +- if [ $child_pass -ne 0 -o $child_fail -ne 0 ] ; then ++ if [ $child_pass -ne 0 ] || [ $child_fail -ne 0 ] ; then + pass=$child_pass + if [ $child_fail -ne 0 ] ; then + fail=`expr $child_fail / 2` +-- +2.21.0 + +From d50627f0b7a000ee13ea6dcc02a4162be1fa853d Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Tue, 3 Dec 2019 21:42:49 +0900 +Subject: [PATCH] src/tests: RHEL codereview #2 for ibus-desktop-testing-runner + +--- + src/tests/ibus-compose-locales.in | 21 +++++++-------- + src/tests/ibus-desktop-testing-runner.in | 33 ++++++++++++------------ + 2 files changed, 27 insertions(+), 27 deletions(-) + +diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in +index f650b584..b36165fe 100755 +--- a/src/tests/ibus-compose-locales.in ++++ b/src/tests/ibus-compose-locales.in +@@ -7,27 +7,26 @@ BUILDDIR=`dirname $0` + export IBUS_COMPOSE_CACHE_DIR=$PWD + + retval=0 +-# Let for-loop notice '\n' as a delimiter +-IFS=$'\n' +-for var in `cat $SRCDIR/ibus-compose.env` ++# Deleted for var in `cat *.env` because IFS=$'\n' is not supported in POSIX sh ++while read var + do +- # Revert IFS to recognize env a=foo b=foo +- IFS=' ' + IS_COMMENT=`echo "$var" | grep "^#"` + if [ "x$IS_COMMENT" != x ] ; then + continue + fi +- echo "# Starting $var $BUILDDIR/ibus-compose $SRCDIR $@" +- env $var $BUILDDIR/ibus-compose $SRCDIR $@ ++ # Use $* instead of $@ not to mix strings and integers ++ echo "# Starting $var $BUILDDIR/ibus-compose $SRCDIR $*" ++ # Need to enclose $@ with double quotes not to split the array. ++ env $var $BUILDDIR/ibus-compose $SRCDIR "$@" + retval=`expr $retval + $?` +- echo "# Finished $var $BUILDDIR/ibus-compose $SRCDIR $@ with $retval" ++ echo "# Finished $var $BUILDDIR/ibus-compose $SRCDIR $* with $retval" + + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then + echo "Clean $CACHE_FILES" + rm $CACHE_FILES + fi +- IFS=$'\n' +-done +-IFS=' ' ++done << EOF_ENVS ++`cat $SRCDIR/ibus-compose.env` ++EOF_ENVS + exit $retval +diff --git a/src/tests/ibus-desktop-testing-runner.in b/src/tests/ibus-desktop-testing-runner.in +index 72537cd4..981941d5 100755 +--- a/src/tests/ibus-desktop-testing-runner.in ++++ b/src/tests/ibus-desktop-testing-runner.in +@@ -30,6 +30,8 @@ + + # POSIX sh has no 'echo -e' + : ${ECHO:='/usr/bin/echo'} ++# POSIX sh has $UID ++: ${UID:='`id -u`'} + + + PROGNAME=`basename $0` +@@ -57,10 +59,10 @@ print_log() + if [ x"$1" = x'-e' ] ; then + shift + fi +- NO_ESCAPE=`echo $@ | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'` ++ NO_ESCAPE=`echo "$@" | sed -e 's/\\\033\\[0;3.m//g' -e 's/\\\033\\[0m//g'` + $ECHO $NO_ESCAPE >> $RESULT_LOG + else +- $ECHO $@ ++ $ECHO "$@" + fi + } + +@@ -231,9 +233,9 @@ run_direct_test_cases() + if test x"$ENVS" = x ; then + $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG + retval=$? +- read pass fail << EOF ++ read pass fail << EOF_COUNT + `count_case_result $retval $pass $fail` +-EOF ++EOF_COUNT + echo_case_result $retval $tst + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then +@@ -242,11 +244,9 @@ EOF + fi + else + i=1 +- # Let for-loop notice '\n' as a delimiter +- IFS=$'\n' +- for e in $ENVS; do +- # Revert IFS to recognize env a=foo b=foo +- IFS=' ' ++ # Deleted for var in "$ENVS" because IFS=$'\n' is not supported ++ # in POSIX sh ++ while read e ; do + first=`echo "$e" | grep '^#'` + if test x"$first" = x"#" ; then + continue +@@ -255,9 +255,9 @@ EOF + env $e $BUILDDIR/$tst $SRCDIR 2>>$TEST_LOG 1>>$TEST_LOG + retval=$? + echo "# Finished $e $BUILDDIR/$tst $SRCDIR with $retval" >>$TEST_LOG +- read pass fail << EOF ++ read pass fail << EOF_COUNT + `count_case_result $retval $pass $fail` +-EOF ++EOF_COUNT + echo_case_result $retval $tst $e + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then +@@ -265,9 +265,9 @@ EOF + rm $CACHE_FILES + fi + i=`expr $i + 1` +- IFS=$'\n' +- done +- IFS=' ' ++ done << EOF_ENVS ++ `echo "$ENVS"` ++EOF_ENVS + fi + done + echo $pass $fail +@@ -357,7 +357,7 @@ finit() + + main() + { +- parse_args $@ ++ parse_args "$@" + init_desktop + run_dbus_daemon 2>>$TEST_LOG 1>>$TEST_LOG + run_desktop 2>>$TEST_LOG 1>>$TEST_LOG +@@ -365,4 +365,5 @@ main() + finit + } + +-main $@ ++# Need to enclose $@ with double quotes not to split the array. ++main "$@" +-- +2.21.0 + diff --git a/SOURCES/ibus-1750836-server-auth-observer.patch b/SOURCES/ibus-1750836-server-auth-observer.patch new file mode 100644 index 0000000..aa3c78b --- /dev/null +++ b/SOURCES/ibus-1750836-server-auth-observer.patch @@ -0,0 +1,179 @@ +From 3d442dbf936d197aa11ca0a71663c2bc61696151 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 13 Sep 2019 15:59:03 +0900 +Subject: [PATCH] bus: Implement GDBusAuthObserver callback + +ibus uses a GDBusServer with G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS, +and doesn't set a GDBusAuthObserver, which allows anyone who can connect +to its AF_UNIX socket to authenticate and be authorized to send method calls. +It also seems to use an abstract AF_UNIX socket, which does not have +filesystem permissions, so the practical effect might be that a local +attacker can connect to another user's ibus service and make arbitrary +method calls. + +BUGS=rhbz#1717958 +--- + bus/server.c | 89 ++++++++++++++++++++++++++++++++++++++++++---------- + 1 file changed, 73 insertions(+), 16 deletions(-) + +diff --git a/bus/server.c b/bus/server.c +index 3a626230..2439de14 100644 +--- a/bus/server.c ++++ b/bus/server.c +@@ -2,7 +2,8 @@ + /* vim:set et sts=4: */ + /* bus - The Input Bus + * Copyright (C) 2008-2010 Peng Huang +- * Copyright (C) 2008-2010 Red Hat, Inc. ++ * Copyright (C) 2011-2019 Takao Fujiwara ++ * Copyright (C) 2008-2019 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public +@@ -70,16 +71,63 @@ _restart_server (void) + } + + /** ++ * bus_allow_mechanism_cb: ++ * @observer: A #GDBusAuthObserver. ++ * @mechanism: The name of the mechanism. ++ * @user_data: always %NULL. ++ * ++ * Check if @mechanism can be used to authenticate the other peer. ++ * Returns: %TRUE if the peer's mechanism is allowed. ++ */ ++static gboolean ++bus_allow_mechanism_cb (GDBusAuthObserver *observer, ++ const gchar *mechanism, ++ G_GNUC_UNUSED gpointer user_data) ++{ ++ if (g_strcmp0 (mechanism, "EXTERNAL") == 0) ++ return TRUE; ++ return FALSE; ++} ++ ++/** ++ * bus_authorize_authenticated_peer_cb: ++ * @observer: A #GDBusAuthObserver. ++ * @stream: A #GIOStream. ++ * @credentials: A #GCredentials. ++ * @user_data: always %NULL. ++ * ++ * Check if a peer who has already authenticated should be authorized. ++ * Returns: %TRUE if the peer's credential is authorized. ++ */ ++static gboolean ++bus_authorize_authenticated_peer_cb (GDBusAuthObserver *observer, ++ GIOStream *stream, ++ GCredentials *credentials, ++ G_GNUC_UNUSED gpointer user_data) ++{ ++ gboolean authorized = FALSE; ++ if (credentials) { ++ GCredentials *own_credentials = g_credentials_new (); ++ if (g_credentials_is_same_user (credentials, own_credentials, NULL)) ++ authorized = TRUE; ++ g_object_unref (own_credentials); ++ } ++ return authorized; ++} ++ ++/** + * bus_new_connection_cb: +- * @user_data: always NULL. +- * @returns: TRUE when the function can handle the connection. ++ * @observer: A #GDBusAuthObserver. ++ * @dbus_connection: A #GDBusconnection. ++ * @user_data: always %NULL. + * + * Handle incoming connections. ++ * Returns: %TRUE when the function can handle the connection. + */ + static gboolean +-bus_new_connection_cb (GDBusServer *server, +- GDBusConnection *dbus_connection, +- gpointer user_data) ++bus_new_connection_cb (GDBusServer *server, ++ GDBusConnection *dbus_connection, ++ G_GNUC_UNUSED gpointer user_data) + { + BusConnection *connection = bus_connection_new (dbus_connection); + bus_dbus_impl_new_connection (dbus, connection); +@@ -94,9 +142,9 @@ bus_new_connection_cb (GDBusServer * + } + + static void +-_server_connect_start_portal_cb (GObject *source_object, +- GAsyncResult *res, +- gpointer user_data) ++_server_connect_start_portal_cb (GObject *source_object, ++ GAsyncResult *res, ++ G_GNUC_UNUSED gpointer user_data) + { + GVariant *result; + GError *error = NULL; +@@ -113,9 +161,9 @@ _server_connect_start_portal_cb (GObject + } + + static void +-bus_acquired_handler (GDBusConnection *connection, +- const gchar *name, +- gpointer user_data) ++bus_acquired_handler (GDBusConnection *connection, ++ const gchar *name, ++ G_GNUC_UNUSED gpointer user_data) + { + g_dbus_connection_call (connection, + IBUS_SERVICE_PORTAL, +@@ -136,22 +184,27 @@ void + bus_server_init (void) + { + GError *error = NULL; ++ GDBusServerFlags flags = G_DBUS_SERVER_FLAGS_NONE; ++ gchar *guid; ++ GDBusAuthObserver *observer; + + dbus = bus_dbus_impl_get_default (); + ibus = bus_ibus_impl_get_default (); + bus_dbus_impl_register_object (dbus, (IBusService *)ibus); + + /* init server */ +- GDBusServerFlags flags = G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS; +- gchar *guid = g_dbus_generate_guid (); +- if (!g_str_has_prefix (g_address, "unix:tmpdir=")) { +- g_error ("Your socket address does not have the format unix:tmpdir=$DIR; %s", +- g_address); ++ guid = g_dbus_generate_guid (); ++ observer = g_dbus_auth_observer_new (); ++ if (!g_str_has_prefix (g_address, "unix:tmpdir=") && ++ !g_str_has_prefix (g_address, "unix:path=")) { ++ g_error ("Your socket address does not have the format unix:tmpdir=$DIR " ++ "or unix:path=$FILE; %s", g_address); ++ + } + server = g_dbus_server_new_sync ( + g_address, /* the place where the socket file lives, e.g. /tmp, abstract namespace, etc. */ + flags, guid, +- NULL /* observer */, ++ observer, + NULL /* cancellable */, + &error); + if (server == NULL) { +@@ -161,7 +214,13 @@ bus_server_init (void) + } + g_free (guid); + +- g_signal_connect (server, "new-connection", G_CALLBACK (bus_new_connection_cb), NULL); ++ g_signal_connect (observer, "allow-mechanism", ++ G_CALLBACK (bus_allow_mechanism_cb), NULL); ++ g_signal_connect (observer, "authorize-authenticated-peer", ++ G_CALLBACK (bus_authorize_authenticated_peer_cb), NULL); ++ g_object_unref (observer); ++ g_signal_connect (server, "new-connection", ++ G_CALLBACK (bus_new_connection_cb), NULL); + + g_dbus_server_start (server); + +-- +2.21.0 + diff --git a/SOURCES/ibus-2076-fix-16-candidates.patch b/SOURCES/ibus-2076-fix-16-candidates.patch new file mode 100644 index 0000000..9e86f15 --- /dev/null +++ b/SOURCES/ibus-2076-fix-16-candidates.patch @@ -0,0 +1,26 @@ +From 6aab10f2e5a8e10dac9b007eff19b26990461790 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Thu, 14 Feb 2019 17:37:39 +0900 +Subject: [PATCH] ui/gtk3: Fix assert with 16 candidates + +BUG=https://github.com/ibus/ibus/issues/2076 +--- + ui/gtk3/candidatearea.vala | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ui/gtk3/candidatearea.vala b/ui/gtk3/candidatearea.vala +index f590cf3a..781ecd1e 100644 +--- a/ui/gtk3/candidatearea.vala ++++ b/ui/gtk3/candidatearea.vala +@@ -109,7 +109,7 @@ class CandidateArea : Gtk.Box { + m_focus_candidate = focus_candidate; + m_show_cursor = show_cursor; + +- assert(candidates.length < 16); ++ assert(candidates.length <= 16); + for (int i = 0 ; i < 16 ; i++) { + Gtk.Label label = m_candidates[i]; + bool visible = false; +-- +2.21.0 + diff --git a/SOURCES/ibus-xx-emoji-compose.patch b/SOURCES/ibus-xx-emoji-compose.patch new file mode 100644 index 0000000..1567dde --- /dev/null +++ b/SOURCES/ibus-xx-emoji-compose.patch @@ -0,0 +1,134 @@ +From 8375f391e1b9bfc048ff14fd458f689d853064ac Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Thu, 28 Feb 2019 15:26:11 +0900 +Subject: [PATCH] ui/gtk3: Do not add emojis in compose category to emoji + variants + +Any emojis in compose category have variants and should be shown by default. +--- + bindings/vala/IBus-1.0-custom.vala | 4 ++ + ui/gtk3/emojier.vala | 74 ++++++++++++++++++++++++++---- + 2 files changed, 68 insertions(+), 10 deletions(-) + +diff --git a/bindings/vala/IBus-1.0-custom.vala b/bindings/vala/IBus-1.0-custom.vala +index 7d34a8bd..ec46fc90 100644 +--- a/bindings/vala/IBus-1.0-custom.vala ++++ b/bindings/vala/IBus-1.0-custom.vala +@@ -17,4 +17,8 @@ namespace IBus { + public class PanelService : IBus.Service { + public void panel_extension_register_keys(string first_property_name, ...); + } ++ public class EmojiData : IBus.Serializable { ++ [CCode (cname = "ibus_emoji_data_new", has_construct_function = true)] ++ public EmojiData (string first_property_name, ...); ++ } + } +diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala +index aedeb4cb..fc15cffe 100644 +--- a/ui/gtk3/emojier.vala ++++ b/ui/gtk3/emojier.vala +@@ -389,6 +389,14 @@ public class IBusEmojier : Gtk.ApplicationWindow { + } + make_emoji_dict(m_current_lang_id); + } ++ add_variants_to_component(); ++ ++ GLib.List annotations = ++ m_annotation_to_emojis_dict.get_keys(); ++ foreach (unowned string annotation in annotations) { ++ if (m_emoji_max_seq_len < annotation.length) ++ m_emoji_max_seq_len = annotation.length; ++ } + update_favorite_emoji_dict(); + } + +@@ -430,11 +438,54 @@ public class IBusEmojier : Gtk.ApplicationWindow { + update_annotation_to_emojis_dict(data); + update_category_to_emojis_dict(data, lang); + } +- GLib.List annotations = +- m_annotation_to_emojis_dict.get_keys(); +- foreach (unowned string annotation in annotations) { +- if (m_emoji_max_seq_len < annotation.length) +- m_emoji_max_seq_len = annotation.length; ++ } ++ ++ ++ private static void add_variants_to_component() { ++ string category = "Component"; ++ unowned GLib.SList hits = ++ m_category_to_emojis_dict.lookup(category); ++ if (hits == null) { ++ category = "component"; ++ hits = m_category_to_emojis_dict.lookup(category); ++ } ++ if (hits == null) ++ return; ++ GLib.SList emoji_list = ++ new GLib.SList(); ++ GLib.SList annotations = new GLib.SList(); ++ annotations.append("zero"); ++ IBus.EmojiData _data; ++ _data = new IBus.EmojiData("emoji", "\u200d", ++ "annotations", annotations, ++ "description", ++ "ZERO WIDTH JOINER", ++ "category", category); ++ emoji_list.append(_data); ++ annotations = null; ++ annotations.append("text"); ++ annotations.append("variation"); ++ annotations.append("selector"); ++ _data = new IBus.EmojiData("emoji", "\ufe0e", ++ "annotations", annotations, ++ "description", ++ "VARIATION SELECTOR-15", ++ "category", category); ++ emoji_list.append(_data); ++ annotations = null; ++ annotations.append("emoji"); ++ annotations.append("variation"); ++ annotations.append("selector"); ++ _data = new IBus.EmojiData("emoji", "\ufe0f", ++ "annotations", annotations, ++ "description", ++ "VARIATION SELECTOR-16", ++ "category", category); ++ emoji_list.append(_data); ++ foreach (IBus.EmojiData data in emoji_list) { ++ update_emoji_to_data_dict(data, "en"); ++ update_annotation_to_emojis_dict(data); ++ update_category_to_emojis_dict(data, "en"); + } + } + +@@ -583,10 +634,12 @@ public class IBusEmojier : Gtk.ApplicationWindow { + category = EMOJI_CATEGORY_OTHERS; + if (lang == "en") { + bool has_variant = false; +- foreach (unichar ch in EMOJI_VARIANT_LIST) { +- if (emoji.index_of_char(ch) >= 0) { +- has_variant = true; +- break; ++ if (category.ascii_casecmp("component") != 0) { ++ foreach (unichar ch in EMOJI_VARIANT_LIST) { ++ if (emoji.index_of_char(ch) >= 0) { ++ has_variant = true; ++ break; ++ } + } + } + // If emoji includes variants (skin colors and items), +@@ -606,7 +659,8 @@ public class IBusEmojier : Gtk.ApplicationWindow { + if (variants.find_custom(emoji, GLib.strcmp) == null) { + if (variants == null) + variants.append(base_emoji); +- variants.append(emoji); ++ if (base_emoji != emoji) ++ variants.append(emoji); + m_emoji_to_emoji_variants_dict.replace( + base_emoji, + variants.copy_deep(GLib.strdup)); +-- +2.21.0 + diff --git a/SOURCES/ibus-xx-setup-env.patch b/SOURCES/ibus-xx-setup-env.patch new file mode 100644 index 0000000..fd68479 --- /dev/null +++ b/SOURCES/ibus-xx-setup-env.patch @@ -0,0 +1,60 @@ +From 1cb5032e85d85f496e349236d1b74f17fb8db966 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Tue, 23 Apr 2019 15:40:45 +0900 +Subject: [PATCH] configure: Move ibus-setup from configure.ac to Makefile.am + +@localedir@ can be extracted to ${datarootdir}/locale and +it needs datarootdir=/usr/share in case configure.ac is used +and deleting the datarootdir line caused a regression. +All variables can be extracted in Makefile.am with sed. +--- + configure.ac | 1 - + setup/Makefile.am | 13 +++++++++++-- + 2 files changed, 11 insertions(+), 3 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 9518e808..7503f3e8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -724,7 +724,6 @@ ibus/interface/Makefile + ui/Makefile + ui/gtk3/Makefile + setup/Makefile +-setup/ibus-setup + bindings/Makefile + bindings/pygobject/Makefile + bindings/vala/Makefile +diff --git a/setup/Makefile.am b/setup/Makefile.am +index cb4dd8d1..34c8f136 100644 +--- a/setup/Makefile.am ++++ b/setup/Makefile.am +@@ -3,8 +3,8 @@ + # ibus - The Input Bus + # + # Copyright (c) 2007-2014 Peng Huang +-# Copyright (c) 2015-2017 Takao Fujiwara +-# Copyright (c) 2007-2017 Red Hat, Inc. ++# Copyright (c) 2015-2019 Takao Fujiwara ++# Copyright (c) 2007-2019 Red Hat, Inc. + # + # This library is free software; you can redistribute it and/or + # modify it under the terms of the GNU Lesser General Public +@@ -40,6 +40,15 @@ ibussetup_DATA = \ + bin_SCRIPTS = ibus-setup + ibussetupdir = $(pkgdatadir)/setup + ++ibus-setup: ibus-setup.in ++ $(AM_V_GEN) sed -e "s|\@datarootdir\@|$(datarootdir)|g" \ ++ -e "s|\@localedir\@|$(localedir)|g" \ ++ -e "s|\@libexecdir\@|$(libexecdir)|g" \ ++ -e "s|\@prefix\@|$(prefix)|g" \ ++ -e "s|\@PYTHON\@|$(PYTHON)|g" \ ++ $< > $@.tmp && \ ++ mv $@.tmp $@ ++ + desktop_in_files = ibus-setup.desktop.in + desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) + desktopdir = $(datadir)/applications +-- +2.21.0 + diff --git a/SPECS/ibus.spec b/SPECS/ibus.spec index 8a1fe8c..5b98784 100644 --- a/SPECS/ibus.spec +++ b/SPECS/ibus.spec @@ -31,7 +31,7 @@ Name: ibus Version: 1.5.19 -Release: 4%{?dist} +Release: 11%{?dist} Summary: Intelligent Input Bus for Linux OS License: LGPLv2+ Group: System Environment/Libraries @@ -41,9 +41,23 @@ Source1: %{name}-xinput Source2: %{name}.conf.5 Source3: https://fujiwara.fedorapeople.org/ibus/po/%{name}-po-1.5.19-20180822.tar.gz # Patch0: %%{name}-HEAD.patch +# RHEL 8.0 From upstreamed patches Patch0: %{name}-HEAD.patch -# Under testing #1349148 #1385349 #1350291 #1406699 #1432252 #1601577 -Patch1: %{name}-1385349-segv-bus-proxy.patch +# RHEL 8.2 Fix not to assert with wrong compose files +Patch1: %{name}-1470673-emoji-warn-instead-assert.patch +# RHEL 8.2 Fix not to assert with 16 candidates +Patch2: %{name}-2076-fix-16-candidates.patch +# RHEL 8.2 Show emoji compose in the top category +Patch3: %{name}-xx-emoji-compose.patch +# RHEL 8.2 Extract $(datarootdir) in ibus-setup +Patch4: %{name}-xx-setup-env.patch +# RHEL 8.2 CVE 2019-14822 +Patch5: %{name}-1750836-server-auth-observer.patch +# RHEL 8.2 Bug 1682157 - Integrate ibus-desktop-testing and test cases +Patch6: %{name}-1682157-ci.patch + +# RHEL 8.0 Under testing #1349148 #1385349 #1350291 #1406699 #1432252 #1601577 +Patch100: %{name}-1385349-segv-bus-proxy.patch BuildRequires: gettext-devel BuildRequires: libtool @@ -236,10 +250,33 @@ BuildArch: noarch %description devel-docs The ibus-devel-docs package contains developer documentation for IBus +%package desktop-testing +Summary: Wrapper of InstalledTests Runner for IBus +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description desktop-testing +GNOME desktop testing runner implements the InstalledTests specification +and IBus also needs focus events to enable input contexts on text widgets. +The wrapper script runs gnome-session for the focus events and GNOME +desktop testing runner internally. + +%package tests +Summary: Tests for the %{name} package +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description tests +The %{name}-tests package contains tests that can be used to verify +the functionality of the installed %{name} package. + %prep %autosetup -S git # cp client/gtk2/ibusimcontext.c client/gtk3/ibusimcontext.c || : +cp client/gtk2/ibusimcontext.c client/gtk3/ibusimcontext.c || : zcat %SOURCE3 | tar xfv - @@ -273,6 +310,7 @@ autoreconf -f -i -v --disable-appindicator \ %endif --enable-introspection \ + --enable-install-tests \ %{nil} make -C ui/gtk3 maintainer-clean-generic @@ -300,6 +338,12 @@ install -pm 644 -D %{SOURCE1} $RPM_BUILD_ROOT%{_xinputconf} echo "NoDisplay=true" >> $RPM_BUILD_ROOT%{_datadir}/applications/ibus-setup.desktop #echo "X-GNOME-Autostart-enabled=false" >> $RPM_BUILD_ROOT%%{_sysconfdir}/xdg/autostart/ibus.desktop +# Delete unused prefix line in Fedora only +if test `grep '^prefix' $RPM_BUILD_ROOT%{_bindir}/ibus-setup | wc -l` = 1 ; then + sed -i -e '/^prefix/d' $RPM_BUILD_ROOT%{_bindir}/ibus-setup +fi + + desktop-file-install --delete-original \ --dir $RPM_BUILD_ROOT%{_datadir}/applications \ $RPM_BUILD_ROOT%{_datadir}/applications/* @@ -424,7 +468,38 @@ dconf update || : %dir %{_datadir}/gtk-doc/html %{_datadir}/gtk-doc/html/* +%files desktop-testing +%{_bindir}/ibus-desktop-testing-runner + +%files tests +%dir %{_libexecdir}/installed-tests +%{_libexecdir}/installed-tests/ibus +%dir %{_datadir}/installed-tests +%{_datadir}/installed-tests/ibus + %changelog +* Thu Jan 09 2020 Takao Fujiwara - 1.5.19-11 +- Resolves: #1750836 - Fix CVE-2019-14822 + +* Thu Dec 12 2019 Takao Fujiwara - 1.5.19-10 +- Resolves: #1750836 - Revert Hangul fix for 8.2 schedule + +* Tue Dec 03 2019 Takao Fujiwara - 1.5.19-9 +- Resolves: #1682157 - Fix RHEL 8.2 covscan #2 + +* Sat Nov 30 2019 Takao Fujiwara - 1.5.19-8 +- Resolves: #1682157 - Fix libibus dependency in ibus-tests with rpmdiff + +* Fri Nov 29 2019 Takao Fujiwara - 1.5.19-7 +- Resolves: #1682157 - Fix RHEL 8.2 covscan + +* Fri Nov 29 2019 Takao Fujiwara - 1.5.19-6 +- Resolves: #1682157 - Add CI + +* Fri Nov 29 2019 Takao Fujiwara - 1.5.19-5 +- Resolves: #1713606 - Fix hangul preedit commit with mouse click +- Resolves: #1682157 - Integrate ibus-desktop-testing and test cases + * Tue Nov 06 2018 Takao Fujiwara - 1.5.19-4 - Delete Requires ibus in ibus-gtk* for Flatpak - Update upstreamed patches