From edd5d606039121a7bec769439a9fef77301bd194 Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Fri, 18 Apr 2025 17:32:14 +0900 Subject: [PATCH] test --- .fmf/version | 1 + plans/test.fmf | 5 + tests/Makefile | 76 ----------- tests/context.vala | 84 ------------- .../install4-g-d-t/build.sh | 10 ++ .../install4-g-d-t/main.fmf | 18 +++ .../install5-tmt/main.fmf | 5 + tests/ibus-desktop-testing/main.fmf | 3 + tests/ibus-desktop-testing/run/main.fmf | 5 + tests/ibus-desktop-testing/run/test.sh | 9 ++ tests/main.fmt | 1 + tests/prepare-source.sh | 25 ---- tests/test-case.vala | 118 ------------------ tests/tests.yml | 31 ----- 14 files changed, 57 insertions(+), 334 deletions(-) create mode 100644 .fmf/version create mode 100644 plans/test.fmf delete mode 100644 tests/Makefile delete mode 100644 tests/context.vala create mode 100755 tests/ibus-desktop-testing/install4-g-d-t/build.sh create mode 100644 tests/ibus-desktop-testing/install4-g-d-t/main.fmf create mode 100644 tests/ibus-desktop-testing/install5-tmt/main.fmf create mode 100644 tests/ibus-desktop-testing/main.fmf create mode 100644 tests/ibus-desktop-testing/run/main.fmf create mode 100755 tests/ibus-desktop-testing/run/test.sh create mode 100644 tests/main.fmt delete mode 100755 tests/prepare-source.sh delete mode 100644 tests/test-case.vala delete mode 100644 tests/tests.yml diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/plans/test.fmf b/plans/test.fmf new file mode 100644 index 0000000..c1627f9 --- /dev/null +++ b/plans/test.fmf @@ -0,0 +1,5 @@ +summary: Basic smoke test +discover: + how: fmf +execute: + how: tmt diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index d3c7251..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -LIBKKC_VERSION = 0.3.5 -TOP_LIBKKC_BUILD_DIR = . -TOP_LIBKKC_SRC_DIR = . -#DEBUG_LIBS = -L$(TOP_LIBKKC_BUILD_DIR)/libkkc-$(LIBKKC_VERSION)/libkkc/.libs - -COMMON_CFLAGS = \ - -DHAVE_CONFIG_H -I. -pipe -Wall -Werror=format-security \ - -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong \ - -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables \ - -fstack-clash-protection -fcf-protection -fPIC \ - -g -O2 \ - $(NULL) -PKG_CONFIG_CFLAGS = \ - $(shell pkg-config --cflags marisa gee-0.8 json-glib-1.0 glib-2.0) \ - -I$(TOP_LIBKKC_SRC_DIR)/libkkc-$(LIBKKC_VERSION) \ - $(NULL) -CFLAGS = $(COMMON_CFLAGS) $(PKG_CONFIG_CFLAGS) - -COMMON_LIBS = \ - -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 \ - -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong \ - -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables \ - -fstack-clash-protection -fcf-protection -g -O0 \ - -Wl,-z -Wl,relro -Wl,-z -Wl,now \ - $(NULL) -PKG_CONFIG_LIBS = \ - $(shell pkg-config --libs marisa gee-0.8 json-glib-1.0 glib-2.0) \ - $(DEBUG_LIBS) -lkkc - $(NULL) -LDFLAGS = $(COMMON_LIBS) $(PKG_CONFIG_LIBS) - - -all: context - -context.c: context.vala - valac --disable-warnings --vapidir=. \ - --vapidir=$(TOP_LIBKKC_SRC_DIR)/libkkc-$(LIBKKC_VERSION)/libkkc \ - --pkg gobject-2.0 --pkg gio-2.0 --pkg gee-0.8 --pkg json-glib-1.0 \ - --pkg kkc-internals-1.0 -g --target-glib=2.24 \ - -C context.vala test-case.vala \ - $(NULL) - -context.o: context.c - gcc $(COMMON_CFLAGS) $(CFLAGS) -g -O0 -c -o context.o context.c - gcc $(COMMON_CFLAGS) $(CFLAGS) -g -O0 -c -o test-case.o test-case.c - -context: context.o - gcc $(LDFLAGS) -o context context.o test-case.o - -clean: - rm *.o *.c context - -run-debug: - env LD_LIBRARY_PATH=$(TOP_LIBKKC_BUILD_DIR)/libkkc-$(LIBKKC_VERSION)/libkkc/.libs gdb ./context - -run: - ./context - -data/models/sorted3/data.3gram.filter: - mkdir -p data/models/sorted3 - cp $(TOP_LIBKKC_SRC_DIR)/libkkc-$(LIBKKC_VERSION)/data/templates/libkkc-data/data/models/sorted3/metadata.json \ - data/models/sorted3/. - cp $(TOP_LIBKKC_SRC_DIR)/libkkc-$(LIBKKC_VERSION)/tests/data/models/text3/data.arpa \ - data/models/sorted3/. - python3 $(TOP_LIBKKC_SRC_DIR)/libkkc-$(LIBKKC_VERSION)/data/templates/libkkc-data/tools/sortlm.py \ - data/models/sorted3/data.arpa \ - data/models/sorted3/data - python3 $(TOP_LIBKKC_SRC_DIR)/libkkc-$(LIBKKC_VERSION)/data/templates/libkkc-data/tools/genfilter.py \ - data/models/sorted3/data.2gram \ - data/models/sorted3/data.2gram.filter \ - 12 - python3 $(TOP_LIBKKC_SRC_DIR)/libkkc-$(LIBKKC_VERSION)/data/templates/libkkc-data/tools/genfilter.py \ - data/models/sorted3/data.3gram \ - data/models/sorted3/data.3gram.filter \ - 10 - diff --git a/tests/context.vala b/tests/context.vala deleted file mode 100644 index 8e66d9b..0000000 --- a/tests/context.vala +++ /dev/null @@ -1,84 +0,0 @@ -class ContextTests : Kkc.TestCase { - struct Conversion { - string sequence; - string result; - } - const Conversion eras[] = { - { "s h o u w a", "昭和" }, - { "h e i s e i", "平成" }, - { "r e i w a", "令和" }, - }; - Kkc.Context context; - - public ContextTests() { - base("Context"); - add_test("era candidate", this.test_eras_candidate); - add_test("era commit", this.test_eras_commit); - } - - void test_eras_candidate() { - foreach (var era in eras) - test_era_candidate(era); - } - - void test_eras_commit() { - foreach (var era in eras) - test_era_commit(era); - } - - private void test_era_candidate(Conversion era) { - context.process_key_events(era.sequence + " SPC SPC"); - assert(context.candidates.get(0).output == era.result); - context.process_key_events("SPC"); - assert (context.candidates.get(0).output == era.result); - context.reset (); - context.clear_output (); - } - - private void test_era_commit(Conversion era) { - context.process_key_events(era.sequence + " SPC RET"); - assert(context.has_output()); - assert(context.peek_output() == era.result); - assert(context.has_output()); - context.reset(); - context.clear_output(); - } - - public override void set_up() { - try { - // Loading /usr/lib64/libkkc/models/sorted3/metadata.json - var model = Kkc.LanguageModel.load("sorted3"); - context = new Kkc.Context(model); - } catch(Kkc.LanguageModelError e) { - stderr.printf("%s\n", e.message); - } - -#if 0 - try { - var srcdir = Environment.get_variable("srcdir"); - assert(srcdir != null); - var dictionary = new Kkc.SystemSegmentDictionary( - Path.build_filename(srcdir, "system-segment-dictionary")); - context.dictionaries.add(dictionary); - } catch(Error e) { - stderr.printf("%s\n", e.message); - } -#endif - - context.dictionaries.add(new Kkc.EmptySegmentDictionary()); - } - - public override void tear_down() { - context = null; - } -} - -int main(string[] args) { - Intl.setlocale(LocaleCategory.ALL, ""); - Test.init(ref args); - Kkc.init(); - TestSuite root = TestSuite.get_root(); - root.add_suite(new ContextTests().get_suite()); - Test.run(); - return 0; -} diff --git a/tests/ibus-desktop-testing/install4-g-d-t/build.sh b/tests/ibus-desktop-testing/install4-g-d-t/build.sh new file mode 100755 index 0000000..0129438 --- /dev/null +++ b/tests/ibus-desktop-testing/install4-g-d-t/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartTest + rlRun -t "pwd" + rlRun -t "find ." + rlPhaseEnd +rlJournalEnd diff --git a/tests/ibus-desktop-testing/install4-g-d-t/main.fmf b/tests/ibus-desktop-testing/install4-g-d-t/main.fmf new file mode 100644 index 0000000..fe9166f --- /dev/null +++ b/tests/ibus-desktop-testing/install4-g-d-t/main.fmf @@ -0,0 +1,18 @@ +summary: Install GNOME installed-tests testing harness +description: + gnome-desktop-testing package is required by IBus CI(ibus-desktop-testing) + and it's available in Fedora only at present. +require: + - git + - make + - gcc + - diffutils + - autoconf + - automake + - libtool + - glib2-devel + - systemd-devel + - type: library + url: https://gitlab.com/redhat/centos-stream/tests/gnome-desktop-testing.git + name: /gnome-desktop-testing +test: ./build.sh diff --git a/tests/ibus-desktop-testing/install5-tmt/main.fmf b/tests/ibus-desktop-testing/install5-tmt/main.fmf new file mode 100644 index 0000000..332864f --- /dev/null +++ b/tests/ibus-desktop-testing/install5-tmt/main.fmf @@ -0,0 +1,5 @@ +summary: Install TMT packages +description: + The test script is calling the beakerlib script. +require: + - beakerlib diff --git a/tests/ibus-desktop-testing/main.fmf b/tests/ibus-desktop-testing/main.fmf new file mode 100644 index 0000000..b4d0642 --- /dev/null +++ b/tests/ibus-desktop-testing/main.fmf @@ -0,0 +1,3 @@ +summary: gnome-desktop-testing tests +# common test for sub tests +test: env diff --git a/tests/ibus-desktop-testing/run/main.fmf b/tests/ibus-desktop-testing/run/main.fmf new file mode 100644 index 0000000..d2434b1 --- /dev/null +++ b/tests/ibus-desktop-testing/run/main.fmf @@ -0,0 +1,5 @@ +summary: Run tests +description: + Run CI with ibus-desktop-testing-runner in GNOME Wayland. +duration: 15m +test: ./test.sh diff --git a/tests/ibus-desktop-testing/run/test.sh b/tests/ibus-desktop-testing/run/test.sh new file mode 100755 index 0000000..9e43fe4 --- /dev/null +++ b/tests/ibus-desktop-testing/run/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartTest + rlRun -t "echo test" + rlPhaseEnd +rlJournalEnd diff --git a/tests/main.fmt b/tests/main.fmt new file mode 100644 index 0000000..e89cb45 --- /dev/null +++ b/tests/main.fmt @@ -0,0 +1 @@ +contact: Takao Fujiwara diff --git a/tests/prepare-source.sh b/tests/prepare-source.sh deleted file mode 100755 index 1262668..0000000 --- a/tests/prepare-source.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -LIBKKC_VERSION=0.3.5 - -if [ ! -d libkkc-$LIBKKC_VERSION ] ; then - wget https://github.com/ueno/libkkc/releases/download/v$LIBKKC_VERSION/libkkc-${LIBKKC_VERSION}.tar.gz - zcat libkkc-${LIBKKC_VERSION}.tar.gz | tar xfv - -fi - -if [ -f context.c ] ; then - rm *.c -fi - -if [ -f context.o ] ; then - rm *.o -fi - -if [ -f context ] ; then - rm context -fi - -pwd -ls -echo test -make diff --git a/tests/test-case.vala b/tests/test-case.vala deleted file mode 100644 index da74f7e..0000000 --- a/tests/test-case.vala +++ /dev/null @@ -1,118 +0,0 @@ -/* testcase.vala - * - * Copyright (C) 2009 Julien Peeters - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - - * This library 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 - * Lesser General Public License for more details. - - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Author: - * Julien Peeters - * - * Copied from libgee/tests/testcase.vala. - */ - -public abstract class Kkc.TestCase : Object -{ - private GLib.TestSuite _suite; - private Adaptor[] _adaptors = new Adaptor[0]; - - public delegate void TestMethod (); - - public TestCase (string name) - { - this._suite = new GLib.TestSuite (name); - } - - public void add_test (string name, TestMethod test) - { - var adaptor = new Adaptor (name, test, this); - this._adaptors += adaptor; - - this._suite.add (new GLib.TestCase ( - adaptor.name, adaptor.set_up, adaptor.run, adaptor.tear_down)); - } - - public virtual void set_up () - { - } - - public virtual void tear_down () - { - } - - public GLib.TestSuite get_suite () - { - return this._suite; - } - - private class Adaptor - { - public string name { get; private set; } - private unowned TestMethod _test; - private TestCase _test_case; - - public Adaptor (string name, TestMethod test, TestCase test_case) - { - this._name = name; - this._test = test; - this._test_case = test_case; - } - - public void set_up (void* fixture) - { - GLib.set_printerr_handler (Adaptor._printerr_func_stack_trace); - Log.set_default_handler (this._log_func_stack_trace); - - this._test_case.set_up (); - } - - private static void _printerr_func_stack_trace (string? text) - { - if (text == null || str_equal (text, "")) - return; - - stderr.printf (text); - - /* Print a stack trace since we've hit some major issue */ - GLib.on_error_stack_trace ("libtool --mode=execute gdb"); - } - - private void _log_func_stack_trace (string? log_domain, - LogLevelFlags log_levels, - string message) - { - Log.default_handler (log_domain, log_levels, message); - - /* Print a stack trace for any message at the warning level or above - */ - if ((log_levels & - (LogLevelFlags.LEVEL_WARNING | LogLevelFlags.LEVEL_ERROR | - LogLevelFlags.LEVEL_CRITICAL)) - != 0) - { - GLib.on_error_stack_trace ("libtool --mode=execute gdb"); - } - } - - public void run (void* fixture) - { - this._test (); - } - - public void tear_down (void* fixture) - { - this._test_case.tear_down (); - } - } -} diff --git a/tests/tests.yml b/tests/tests.yml deleted file mode 100644 index d4fa154..0000000 --- a/tests/tests.yml +++ /dev/null @@ -1,31 +0,0 @@ -- hosts: localhost - roles: - - role: standard-test-source - tags: - - always - - role: standard-test-basic - tags: - - classic - required_packages: - - bash - - gcc - - gzip - - libkkc - - libkkc-data - - make - - tar - - vala - - wget - - glib2-devel - - json-glib-devel - - libgee-devel - - libkkc-devel - - marisa-devel - tests: - - prepare-source: - dir: . - run: ./prepare-source.sh - - smoke1: - dir: . - run: ./context -