From ec6924f4f5a47555946ee9261d0ecfc40102f2ad Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Mon, 21 Oct 2019 17:21:24 +0900 Subject: [PATCH] Add %%check to run local test programs --- anthy-unicode-HEAD.patch | 131 +++++++++++++++++++++++++++++++++++++++ anthy-unicode.spec | 20 +++++- 2 files changed, 150 insertions(+), 1 deletion(-) diff --git a/anthy-unicode-HEAD.patch b/anthy-unicode-HEAD.patch index e69de29..8b33186 100644 --- a/anthy-unicode-HEAD.patch +++ b/anthy-unicode-HEAD.patch @@ -0,0 +1,131 @@ +From 0d057d4927820e1138af9045be98eddff99fb43f Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Mon, 21 Oct 2019 15:14:39 +0900 +Subject: [PATCH] test: Add prediction and test-matrix in Makefile + +--- + test/Makefile.am | 6 +++++- + test/prediction.c | 4 ++-- + 2 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/test/Makefile.am b/test/Makefile.am +index 628a0d7..946d4d3 100644 +--- a/test/Makefile.am ++++ b/test/Makefile.am +@@ -5,12 +5,16 @@ EXTRA_DIST = test.txt test.exp prediction.c test-matrix.c + INCLUDES = -I$(top_srcdir)/ -DSRCDIR=\"$(srcdir)\" \ + -DTEST_HOME=\""`pwd`"\" + +-noinst_PROGRAMS = anthy checklib ++noinst_PROGRAMS = anthy checklib prediction test-matrix + anthy_SOURCES = main.c + checklib_SOURCES = check.c ++prediction_SOURCES = prediction.c ++test_matrix_SOURCES = test-matrix.c + + anthy_LDADD = ../src-util/libconvdb.la ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la + checklib_LDADD = ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la ++prediction_LDADD = ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la ++test_matrix_LDADD = ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la + + mostlyclean-local: + -rm -rf .anthy* +diff --git a/test/prediction.c b/test/prediction.c +index 421a7c5..74f7140 100644 +--- a/test/prediction.c ++++ b/test/prediction.c +@@ -3,7 +3,7 @@ + #include + + +-/* Makefile $B$N(B $(srcdir) ($B@EE*%G!<%?%U%!%$%k$N4p=`%G%#%l%/%H%j(B) */ ++/* Makefile の $(srcdir) (静的データファイルの基準ディレクトリ) */ + #ifndef SRCDIR + # define SRCDIR "." + #endif +@@ -11,7 +11,7 @@ + static void + init_lib(void) + { +- /* $B4{$K%$%s%9%H!<%k$5$l$F$$$k%U%!%$%k$N1F6A$r +Date: Mon, 21 Oct 2019 16:26:10 +0900 +Subject: [PATCH] src-worddic: Fix buffer overflow in record_stat.base_fn + +test/anthy causes a buffer overflow in anthy_quit() in Fedora build +because ENCODING_SUFFIX will be appended to base_fn. +--- + src-worddic/record.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src-worddic/record.c b/src-worddic/record.c +index 6572536..5d71f88 100644 +--- a/src-worddic/record.c ++++ b/src-worddic/record.c +@@ -2021,7 +2021,7 @@ static void + setup_filenames(const char *id, struct record_stat *rst) + { + const char *home = anthy_get_user_dir(0); +- int base_len = strlen(home) + strlen(id) + 5; ++ int base_len = strlen (home) + strlen (id) + strlen (ENCODING_SUFFIX) + 1; + + /* 基本ファイル */ + rst->base_fn = (char*) malloc(base_len + +-- +2.21.0 + +From 686845b1e40e51a543fd24284ba4f5cbc3df643b Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Mon, 21 Oct 2019 17:07:25 +0900 +Subject: [PATCH] test: Fix to run check in build + +When I tried to fix an unused return variable, I deleted anthy_get_stat() +by mistake and revert it now. +Also set a local DIC_FILE for the build. +--- + test/check.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/test/check.c b/test/check.c +index 02cf08e..f67dbac 100644 +--- a/test/check.c ++++ b/test/check.c +@@ -9,6 +9,9 @@ init(void) + { + int res; + ++ anthy_conf_override("CONFFILE", "../anthy-unicode.conf"); ++ anthy_conf_override("HOME", TEST_HOME); ++ anthy_conf_override("DIC_FILE", "../mkanthydic/anthy.dic"); + res = anthy_init(); + if (res) { + printf("failed to init\n"); +@@ -16,6 +19,9 @@ init(void) + } + anthy_quit(); + /* init again */ ++ anthy_conf_override("CONFFILE", "../anthy-unicode.conf"); ++ anthy_conf_override("HOME", TEST_HOME); ++ anthy_conf_override("DIC_FILE", "../mkanthydic/anthy.dic"); + res = anthy_init(); + if (res) { + printf("failed to init\n"); +@@ -85,6 +91,7 @@ shake_test(const char *str) + for (i = 0; i < 50; i++) { + int nth, rsz; + struct anthy_conv_stat cs; ++ anthy_get_stat(ac, &cs); + nth = rand() % cs.nr_segment; + rsz = (rand() % 3) - 1; + anthy_resize_segment(ac, nth, rsz); +-- +2.21.0 + diff --git a/anthy-unicode.spec b/anthy-unicode.spec index 5c3e331..b1bbe33 100644 --- a/anthy-unicode.spec +++ b/anthy-unicode.spec @@ -1,9 +1,10 @@ %global pkg anthy-unicode %bcond_with xemacs +%bcond_without autoreconf Name: anthy-unicode Version: 1.0.0.20191015 -Release: 1%{?dist} +Release: 2%{?dist} # The entire source code is LGPLv2+ and dictionaries is GPLv2. the corpus data is under Public Domain. License: LGPLv2+ and GPLv2 and Public Domain URL: https://github.com/fujiwarat/anthy-unicode/wiki @@ -13,11 +14,17 @@ BuildRequires: git %if 0%{?rhel} == 0 BuildRequires: xemacs %endif +%if %{with autoreconf} +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool +%endif Source0: https://github.com/fujiwarat/anthy-unicode/releases/download/%{version}/%{name}-%{version}.tar.gz Source1: %{name}-init.el # Upstreamed patches #Patch0: %%{name}-HEAD.patch +Patch0: %{name}-HEAD.patch Summary: Japanese character set input library for Unicode @@ -63,6 +70,9 @@ the programs which uses Anthy Unicode. %autosetup -S git %build +%if %{with autoreconf} +autoreconf -f -i -v +%endif %configure --disable-static make %{?_smp_mflags} @@ -94,6 +104,11 @@ cp $RPM_BUILD_ROOT%{_emacs_sitelispdir}/%{pkg}/*.el \ %endif %endif +%check +cd test +env LD_LIBRARY_PATH=../src-main/.libs:../src-worddic/.libs ./anthy --all +env LD_LIBRARY_PATH=../src-main/.libs:../src-worddic/.libs ./checklib + %ldconfig_scriptlets %files @@ -131,6 +146,9 @@ cp $RPM_BUILD_ROOT%{_emacs_sitelispdir}/%{pkg}/*.el \ %changelog +* Mon Oct 21 2019 Takao Fujiwara 1.0.0.20191015-2 +- Add %%check to run local test programs + * Tue Oct 15 2019 Takao Fujiwara 1.0.0.20191015-1 - Release anthy-unicode 1.0.0.20191015