Compare commits

...

No commits in common. "c8s" and "c8" have entirely different histories.
c8s ... c8

12 changed files with 2 additions and 345 deletions

4
.gitignore vendored
View File

@ -1,3 +1 @@
/tests/artifacts
/tests/libkkc-0.3.5.tar.gz.orig
/libkkc-data-0.2.7.tar.xz
SOURCES/libkkc-data-0.2.7.tar.xz

1
.libkkc-data.metadata Normal file
View File

@ -0,0 +1 @@
6e5d833744f8311908f12168dcf697633efc2795 SOURCES/libkkc-data-0.2.7.tar.xz

View File

@ -1,7 +0,0 @@
--- !Policy
product_versions:
- rhel-8
decision_context: osci_compose_gate
rules:
# this is the testcase identifier, which OSCI pipeline uses
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -1 +0,0 @@
SHA512 (libkkc-data-0.2.7.tar.xz) = 61c0cd8c0fa41ed8df49cac6709eebb245cc965d7e192b1ba945e95f2fc46aca8aa48c16e1977a12c157c55dab6b9f4c30f4905806725eca6e697b762eb7cbd7

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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 <contact@julienpeeters.fr>
*
* 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 ();
}
}
}

View File

@ -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