aboutsummaryrefslogtreecommitdiff
path: root/gfsm/gfsm/src/libgfsm/tests
diff options
context:
space:
mode:
Diffstat (limited to 'gfsm/gfsm/src/libgfsm/tests')
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/.cvsignore38
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/Makefile116
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/NOTES.lookup26
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/alphachurn.c11
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/arctab-1test.c54
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/arytest.c27
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/arytest2.c63
-rwxr-xr-xgfsm/gfsm/src/libgfsm/tests/asciigen.perl17
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/bvtest.c30
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/calc2test.l56
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/calc2test.y89
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/calctest.l52
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/calctest.y118
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/commatest.c8
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/compre2test.c41
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/comprelex.l297
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/compretest.l199
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/compretest.y185
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/ctest.c18
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/dettest.c21
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/flex2test.l174
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/flex3test.l232
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/flextest.l59
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/ftest.c17
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/gbtest.c27
-rwxr-xr-xgfsm/gfsm/src/libgfsm/tests/gfsm-chop.perl40
-rwxr-xr-xgfsm/gfsm/src/libgfsm/tests/gfsm-out-degrees.perl11
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.c210
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.h121
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/gfsmlabdump.c73
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/gscantest.c51
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/intfloat.c31
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/iotest.c180
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/lab2ary.c62
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/labchurn.c23
-rwxr-xr-xgfsm/gfsm/src/libgfsm/tests/labcount.perl28
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/labprobs.h71
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/lkptest.tfst8
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/macrotest.i11
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/memtest-alphabet.c26
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/memtest-automaton.c20
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/memtest-general.c168
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/memtest.c26
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/module/.cvsignore18
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/module/Makefile39
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/module/mod1a.c5
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/module/mod1b.c5
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/module/mod1test.c52
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/nofinal.tfst1
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/offsettest.c101
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/ortest.c7
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/pathtest.c289
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/pathtest.tfst9
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/priotest.c171
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/prtest.c28
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/prtest.tfst8
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/ptest.c25
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/rudtest.c100
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/rudtest.tfst3
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/rudtest2.tfst5
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/seek2test.c259
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/seek3test.c611
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/seektest.c365
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/seektest.dat9
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/settest.c36
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/sizes.bc70
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/sizetest.c16
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/sltest.c25
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/statetest.tfst8
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/structtest.c14
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/tagh-lo.testus8
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/test-255.lab3
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/test-stateset.c61
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/test.lab10
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/test.txt2
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/test2.lab2
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/test2.txt1
-rw-r--r--gfsm/gfsm/src/libgfsm/tests/testme.lab5
78 files changed, 0 insertions, 5506 deletions
diff --git a/gfsm/gfsm/src/libgfsm/tests/.cvsignore b/gfsm/gfsm/src/libgfsm/tests/.cvsignore
deleted file mode 100644
index ef3800b..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/.cvsignore
+++ /dev/null
@@ -1,38 +0,0 @@
-*~
-.*~
-
-*.gfst
-*.output
-*.lex.c
-*.lex.h
-*.tab.c
-*.tab.h
-*.gz
-
-tagh*
-*.dat
-negra*
-lts-grimm.*
-
-offsettest
-priotest
-seek2test
-seek3test
-seektest
-gfsmlabdump
-iotest
-pathtest
-ftest
-memtest-general
-calctest
-calc2test
-flextest
-flex2test
-flex3test
-compretest
-comprelex
-compre2test
-structtest
-
-flextest.c
-flextest.h
diff --git a/gfsm/gfsm/src/libgfsm/tests/Makefile b/gfsm/gfsm/src/libgfsm/tests/Makefile
deleted file mode 100644
index f4ec863..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/Makefile
+++ /dev/null
@@ -1,116 +0,0 @@
-TARGETS = priotest
-
-KNOWN_TARGETS = \
- priotest \
- seek3test \
- seek2test \
- offsettest \
- arctab-1test \
- seektest \
- gfsmlabdump \
- iotest \
- structtest \
- pathtest \
- memtest \
- memtest-general \
- ftest \
- flextest \
- calctest \
- flex2test \
- calc2test \
- flex3test \
- compretest \
- comprelex \
- compre2test
-
-
-CC = gcc
-#CC = ccmalloc --no-wrapper gcc
-LD = $(CC)
-
-CPPFLAGS = -I. -I.. -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
-CFLAGS ?= -O2 -pipe
-#CFLAGS ?= -Wall -g
-#CFLAGS += -Wall -g
-#CFLAGS = -Wall -g
-CFLAGS += -Wall -Winline
-
-LDFLAGS = -L../libgfsm/.libs -L/usr/local/lib -L/usr/lib
-LIBS = -lz -lglib-2.0 -lm
-GFSMLIBS = ../.libs/libgfsm.a
-
-LEX ?= flex
-FLEX ?= flex
-FLEXFLAGS ?=
-BISON ?= bison
-BISONFLAGS ?= --verbose
-
-all: $(TARGETS)
-
-##-- keep intermediate files
-.SECONDARY:
-
-seektest.o: seektest.c labprobs.h
-seektest: seektest.o
-
-##-- flex
-%.lex.c %.lex.h: %.l
- $(FLEX) $(FLEXFLAGS) --outfile="$*.lex.c" --header-file="$*.lex.h" $^
-
-calctest.lex.o: calctest.tab.h
-
-calc2test.lex.o: calc2test.tab.h ../gfsmRegexCompiler.h
-
-compretest.lex.o: compretest.tab.h ../gfsmRegexCompiler.h
-
-comprelex.lex.o: compretest.lex.c compretest.lex.h ../gfsmRegexCompiler.h
-
-##-- gfsmlabdump
-gfsmlabdump: gfsmlabdump.o ../.libs/libgfsm.a
- $(LD) $(LDFLAGS) -o $@ $< $(GFSMLIBS) $(LIBS)
-
-##-- bison
-%.tab.c %.tab.h: %.y
- $(BISON) $(BISONFLAGS) --defines --file-prefix="$*" --name-prefix="$*_yy" $^
-
-##-- flex+bison
-calctest: calctest.lex.o calctest.tab.o $(GFSMLIBS)
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-calc2test: calc2test.lex.o calc2test.tab.o $(GFSMLIBS)
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-flex2test: flex2test.lex.o $(GFSMLIBS)
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-flex3test: flex3test.lex.o $(GFSMLIBS)
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-compretest: compretest.lex.o compretest.tab.o $(GFSMLIBS)
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-comprelex: comprelex.lex.o $(GFSMLIBS)
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-compre2test: compre2test.o $(GFSMLIBS)
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-##-- io
-iotest: iotest.o
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-##-- .c -> .o
-%.o: %.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
-
-##-- clean
-clean:
- rm -f *.o *.lo *.tab.[ch] *.lex.[ch] $(KNOWN_TARGETS)
-
-
-##-- executables
-%test: %test.o
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
-
-%-general: %-general.o
- $(LD) $(LDFLAGS) -o $@ $^ $(GFSMLIBS) $(LIBS)
diff --git a/gfsm/gfsm/src/libgfsm/tests/NOTES.lookup b/gfsm/gfsm/src/libgfsm/tests/NOTES.lookup
deleted file mode 100644
index 538feaf..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/NOTES.lookup
+++ /dev/null
@@ -1,26 +0,0 @@
-lookup (NITERS=524288)
- real 0m3.410s
- user 0m3.403s
- sys 0m0.002s
-
- -> iters/s = 153750.147 = 153.75 K
-
- : lookup @ 153.75 K iters/s
-
-lookup + paths (NITERS=524288)
- real 0m5.880s
- user 0m5.873s
- sys 0m0.002s
-
- -> iters/s = 89164.626 = 89.16 K
-
- : paths @ (52488/(5.88-3.41)) = 21250.2 = 21.25 K iters/s
-
-lookup + paths + strings (NITERS=524288)
- real 0m9.013s
- user 0m9.005s
- sys 0m0.002s
-
- -> iters/s = 58170.199 = 58.17 K
-
- : strings @ (52488/(9.013-5.88)) = 16753.27 = 16.75 K iters/s
diff --git a/gfsm/gfsm/src/libgfsm/tests/alphachurn.c b/gfsm/gfsm/src/libgfsm/tests/alphachurn.c
deleted file mode 100644
index 8ea47a8..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/alphachurn.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <gfsmAlphabet.h>
-#include <stdlib.h>
-
-int main (void) {
- gfsmStringAlphabet *a = gfsm_string_alphabet_new();
-
- gfsm_string_alphabet_load_filename(a,"test.lab");
- gfsm_string_alphabet_save_filename(a,"-");
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/arctab-1test.c b/gfsm/gfsm/src/libgfsm/tests/arctab-1test.c
deleted file mode 100644
index d4cdb4b..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/arctab-1test.c
+++ /dev/null
@@ -1,54 +0,0 @@
-#include <gfsm.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main (int argc, char **argv)
-{
- const char *infilename = "-";
- const char *prog = argv[0];
- gfsmAutomaton *fsm=NULL;
- gfsmError *err=NULL;
- gfsmArcTableIndex *ix=NULL;
- gfsmArcLabelIndex *lx=NULL;
-
- if (argc > 1) { infilename = argv[1]; }
-
- //-- load automaton
- fprintf(stderr, "%s: loading file: '%s'... ", prog,infilename); fflush(stderr);
- fsm = gfsm_automaton_new();
- if ( !(gfsm_automaton_load_bin_filename(fsm,infilename,&err)) ) {
- fprintf(stderr, "FAILED: %s\n", (err ? err->message : "?"));
- exit(1);
- }
- fprintf(stderr, "loaded.\n"); fflush(stderr);
-
- //-- ArcTableIndex
- fprintf(stderr, "%s: creating ArcTableIndex... ", prog); fflush(stderr);
- if ( !(ix = gfsm_automaton_to_arc_table_index(fsm,ix)) ) {
- fprintf(stderr, "FAILED\n");
- exit(2);
- }
- fprintf(stderr, "created.\n"); fflush(stderr);
- //
- //-- sort table (todo: check for existing sort mode?!)
- fprintf(stderr, "%s: sorting ArcTableIndex (priority sort)... ", prog); fflush(stderr);
- gfsm_arc_table_index_priority_sort(ix,gfsmASP_LW,fsm->sr);
- fprintf(stderr, "sorted.\n"); fflush(stderr);
-
- //-- ArcLabelIndex
- fprintf(stderr, "%s: creating ArcLabelIndex... ", prog); fflush(stderr);
- if ( !(lx = gfsm_automaton_to_arc_label_index_lower(fsm,lx)) ) {
- fprintf(stderr, "FAILED\n");
- exit(3);
- }
- fprintf(stderr, "created.\n"); fflush(stderr);
-
- //-- cleanup
- fprintf(stderr, "%s: cleanup... ", prog); fflush(stderr);
- gfsm_automaton_free(fsm);
- gfsm_arc_table_index_free(ix);
- gfsm_arc_label_index_free(lx);
- fprintf(stderr, "done.\n"); fflush(stderr);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/arytest.c b/gfsm/gfsm/src/libgfsm/tests/arytest.c
deleted file mode 100644
index d766b89..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/arytest.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <glib.h>
-#include <stdio.h>
-
-int main (void) {
- GPtrArray *a;
- gpointer p;
- g_mem_set_vtable(glib_mem_profiler_table);
-
- printf("<PROF:1>--------\n");
-
-
- a = g_ptr_array_sized_new(128);
- g_ptr_array_set_size(a,1024);
- p = g_ptr_array_free(a,TRUE);
- printf("p=ptr_array_free()=%p\n", p);
-
- printf("<CHUNKS:1>--------\n");
- //g_mem_chunk_info();
-
- //printf("<CHUNKS:2>--------\n");
- g_blow_chunks();
- //g_mem_chunk_info();
-
- printf("<PROF:2>--------\n");
- g_mem_profile();
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/arytest2.c b/gfsm/gfsm/src/libgfsm/tests/arytest2.c
deleted file mode 100644
index ebef7f5..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/arytest2.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-void print_array(const char *label, GArray *a) {
- int i;
- printf("Array %s: {", label);
- for (i=0; i < a->len; i++) {
- printf(" %d", g_array_index(a,int,i));
- }
- printf(" }\n");
-}
-
-gint compare_int(int *x, int *y) {
- return (*x)-(*y);
- //return (*x < *y ? -1 : (*x > *y ? 1 : 0));
-}
-
-int main (int argc, char **argv) {
- GArray *a1, *a2;
- int i, val;
-
- a1 = g_array_new(FALSE, TRUE, sizeof(int));
- a2 = g_array_new(FALSE, TRUE, sizeof(int));
- for (i=1; i < argc; i++) {
- val = strtol(argv[i],NULL,10);
- g_array_append_val(a1,val);
- }
- print_array("a1", a1);
-
- //-- insert(0,0)
- val = 0;
- g_array_insert_val(a1,0,val);
- printf("--\n");
- print_array("a1/insert(0,0)",a1);
-
- //-- copy a1 into a2
- g_array_append_vals(a2,a1->data,a1->len);
- print_array("a2", a2);
- printf("--\n");
-
- //-- move elements of a1 up one notch
- /*-- NOT ok
- g_array_insert_vals(a1, 1, a1->data, a1->len-1);
- g_array_index(a1,int,0) = 0;
- */
-
- /*-- ok */
- i = 0;
- g_array_insert_val(a1,0,i);
- print_array("a1/moved", a1);
- printf("--\n");
-
- //-- sort
- //g_array_sort(a1,NULL); //-- NOT ok
- g_array_sort(a1,(GCompareFunc)compare_int); //-- ok
- print_array("a1/sorted", a1);
-
- g_array_free(a1,TRUE);
- g_array_free(a2,TRUE);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/asciigen.perl b/gfsm/gfsm/src/libgfsm/tests/asciigen.perl
deleted file mode 100755
index 1cabeb9..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/asciigen.perl
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl -w
-
-@ascii = (ord('A')..ord('Z'),
- ord('a')..ord('z'),
- ord('!')..ord('/'),
- ord('0')..ord('9'),
- ord(':')..ord('?'));
-
-foreach $c (@ascii) {
- print chr($c);
-}
-print "\n";
-
-foreach $c (161..255) {
- printf("\\%o", $c);
-}
-print "\n";
diff --git a/gfsm/gfsm/src/libgfsm/tests/bvtest.c b/gfsm/gfsm/src/libgfsm/tests/bvtest.c
deleted file mode 100644
index 3cf190a..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/bvtest.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <gfsm.h>
-
-int main (int argc, char **argv) {
- int i;
- guint bit;
- gfsmBitVector *bv = gfsm_bitvector_new();
-
- for (i = 0; i <= 16 ; i++) {
- printf("\t%d bits ~= %d bytes @ %d\n",
- i, _gfsm_bitvector_bits2bytes(i), i%8);
- }
-
- for (i = 1; i < argc; i++) {
- sscanf(argv[i], "%u", &bit);
- printf("%s: setting bit=%u : bit2byte=%u\n", *argv, bit, _gfsm_bitvector_bits2bytes(bit));
- gfsm_bitvector_set(bv,bit,1);
- }
-
- printf("%s: vector [bytes=%u ; bits=%u] =\n",
- *argv, bv->len, gfsm_bitvector_size(bv));
- for (bit = 0; bit < gfsm_bitvector_size(bv); bit++) {
- if ((bit%8)==0) fputc(' ', stdout);
- fputc((gfsm_bitvector_get(bv,bit) ? '1' : '0'), stdout);
- }
- printf("\n");
-
- gfsm_bitvector_free(bv);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/calc2test.l b/gfsm/gfsm/src/libgfsm/tests/calc2test.l
deleted file mode 100644
index 7072a4c..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/calc2test.l
+++ /dev/null
@@ -1,56 +0,0 @@
-/*======================================================================
- * Flex Options
- */
-%option outfile="calc2test.lex.c"
-%option header-file="calc2test.lex.h"
-%option prefix="calc2test_yy"
-%option reentrant
-%option 8bit
-%option yylineno
-
-%option bison-bridge
-
-%{
-/*======================================================================
- * User C Header
- */
-
-/* bison stuff */
-#include <gfsmScanner.h>
-#include "calc2test.tab.h"
-
-%}
-
-/*======================================================================
- * Flex Definitions
- */
-
-
-/*======================================================================
- * Flex Rules
- */
-%%
-
-([[:digit:]]*\.?)[[:digit:]]+ { yylval->dbl = strtod(yytext,NULL); return NUMBER;}
-
-\( { return LPAREN; }
-\) { return RPAREN; }
-\+ { return PLUS; }
-\- { return MINUS; }
-\* { return TIMES; }
-\/ { return DIV; }
-
-\n { return NEWLINE; }
-
-[[:space:]] { /* ignore */ }
-
-. { return OTHER; /* ignore */ }
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-//-- wrapper: use default
-GFSM_SCANNER_YYWRAP(calc2test_yy)
diff --git a/gfsm/gfsm/src/libgfsm/tests/calc2test.y b/gfsm/gfsm/src/libgfsm/tests/calc2test.y
deleted file mode 100644
index 4754613..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/calc2test.y
+++ /dev/null
@@ -1,89 +0,0 @@
-/*======================================================================
- * Bison Options
- */
-%pure_parser
-
-%{
-/*======================================================================
- * Bison C Header
- */
-#include <stdio.h>
-#include <gfsmScanner.h>
-#include "calc2test.tab.h"
-#include "calc2test.lex.h"
-
-typedef struct calc2testDataS {
- gfsmScanner scanner;
- double val;
-} calc2testData;
-
-#define YYLEX_PARAM ((calc2testData*)pparam)->scanner.yyscanner
-#define YYPARSE_PARAM pparam
-
-#define YYERROR_VERBOSE 1
-#define calc2test_yyerror(msg) \
- gfsm_scanner_carp((gfsmScanner*)pparam, (msg));
-
-%}
-
-/*======================================================================
- * Bison Definitions
- */
-%union {
- double dbl;
-}
-
-%token <dbl> NUMBER PLUS MINUS TIMES DIV LPAREN RPAREN NEWLINE OTHER
-%type <dbl> expr exprs
-
-%left PLUS MINUS
-%left TIMES DIV
-%nonassoc UMINUS
-
-/*======================================================================
- * Bison Rules
- */
-%%
-
-exprs: /* empty */
- { $$=0; }
- | exprs expr NEWLINE
- { printf("%g\n", $2); ((calc2testData*)pparam)->val=$$=$2; }
- ;
-
-expr: LPAREN expr RPAREN { $$=$2; }
- | MINUS expr { $$=-$2; }
- | expr TIMES expr { $$=$1*$3; }
- | expr DIV expr { $$=$1/$3; }
- | expr PLUS expr { $$=$1+$3; }
- | expr MINUS expr %prec UMINUS { $$=$1-$3; }
- | NUMBER { $$=$1; }
- ;
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-void calc2test_yyerror_func(const char *msg)
-{
- fprintf(stderr, "yyerror: %s\n", msg);
-}
-
-
-int main (void) {
- calc2testData *pparams = g_new0(calc2testData,1);
- gfsm_scanner_init((gfsmScanner*)pparams, "calctest2Scanner", calc2test_yy);
-
- calc2test_yyparse(pparams);
- if (pparams->scanner.err) {
- fprintf(stderr, "Error: %s\n", pparams->scanner.err->message);
- }
-
- printf("Final calctest value=%g\n", pparams->val);
-
- gfsm_scanner_free((gfsmScanner*)pparams);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/calctest.l b/gfsm/gfsm/src/libgfsm/tests/calctest.l
deleted file mode 100644
index 1a03bc1..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/calctest.l
+++ /dev/null
@@ -1,52 +0,0 @@
-/*======================================================================
- * Flex Options
- */
-%option outfile="calctest.lex.c"
-%option header-file="calctest.lex.h"
-%option prefix="calctest_yy"
-%option reentrant
-%option 8bit
-
-%option bison-bridge
-
-%{
-/*======================================================================
- * User C Header
- */
-
-/* bison stuff */
-#include "calctest.tab.h"
-
-%}
-
-/*======================================================================
- * Flex Definitions
- */
-
-
-/*======================================================================
- * Flex Rules
- */
-%%
-
-([[:digit:]]*\.?)[[:digit:]]+ { yylval->dbl = strtod(yytext,NULL); return NUMBER;}
-
-\( { return LPAREN; }
-\) { return RPAREN; }
-\+ { return PLUS; }
-\- { return MINUS; }
-\* { return TIMES; }
-\/ { return DIV; }
-
-\n { return NEWLINE; }
-
-. { return OTHER; /* ignore */ }
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-//-- wrapper: don't
-int calctest_yywrap(yyscan_t yyscanner) { return 1; }
diff --git a/gfsm/gfsm/src/libgfsm/tests/calctest.y b/gfsm/gfsm/src/libgfsm/tests/calctest.y
deleted file mode 100644
index befec0e..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/calctest.y
+++ /dev/null
@@ -1,118 +0,0 @@
-/*======================================================================
- * Bison Options
- */
-%pure_parser
-
-%{
-/*======================================================================
- * Bison C Header
- */
-#include <stdio.h>
-#include <stdarg.h>
-#include "calctest.tab.h"
-#include "calctest.lex.h"
-
-typedef struct _yyparse_param {
- char *name;
- char *filename;
- yyscan_t scanner;
- float val;
-} yyparseParam;
-
-#define YYLEX_PARAM ((yyparseParam*)pparam)->scanner
-#define YYPARSE_PARAM pparam
-
-extern void calctest_yyerror(const char *msg);
-extern void calctest_yycarp(yyparseParam *pparams, const char *fmt, ...);
-
-%}
-
-/*======================================================================
- * Bison Definitions
- */
-%union {
- double dbl;
-}
-
-%token <dbl> NUMBER PLUS MINUS TIMES DIV LPAREN RPAREN NEWLINE OTHER
-%type <dbl> expr exprs
-
-%left PLUS MINUS
-%left TIMES DIV
-%nonassoc UMINUS
-
-/*======================================================================
- * Bison Rules
- */
-%%
-
-exprs: /* empty */
- { $$=0; }
- | exprs expr NEWLINE
- { printf("%g\n", $2); ((yyparseParam*)pparam)->val=$$=$2; }
- ;
-
-expr: LPAREN expr RPAREN { $$=$2; }
- | MINUS expr { $$=-$2; }
- | expr TIMES expr { $$=$1*$3; }
- | expr DIV expr { $$=$1/$3; }
- | expr PLUS expr { $$=$1+$3; }
- | expr MINUS expr %prec UMINUS { $$=$1-$3; }
- | NUMBER { $$=$1; }
- | OTHER
- {
- calctest_yycarp((yyparseParam*)pparam, "Failed to parse expression");
- YYABORT;
- }
- ;
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-void calctest_yyerror(const char *msg)
-{
- fprintf(stderr, "yyerror: %s\n", msg);
-}
-
-void calctest_yycarp(yyparseParam *pparams, const char *fmt, ...)
-{
- va_list ap;
- fprintf(stderr, "%s: ", (pparams->name ? pparams->name : "calctest_parser"));
-
- va_start(ap,fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
-
- fprintf(stderr, " in %s%s%s at line %u, column %u.\n",
- (pparams->filename ? "file \"" : ""),
- (pparams->filename ? pparams->filename : "input"),
- (pparams->filename ? "\"" : ""),
- calctest_yyget_lineno(pparams->scanner),
- calctest_yyget_column(pparams->scanner));
-}
-
-int main (void) {
- yyscan_t scanner;
- yyparseParam pparams;
-
- calctest_yylex_init(&scanner); //-- initialize reentrant flex scanner
-
- pparams.name = NULL;
- pparams.filename = NULL;
- //--
- //pparams.name = "myParser";
- //pparams.filename = "(stdin)";
-
- pparams.scanner = scanner;
-
- calctest_yyparse(&pparams);
-
- calctest_yylex_destroy(pparams.scanner); //-- cleanup reentrant flex scanner
-
- printf("Final calctest value=%g\n", pparams.val);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/commatest.c b/gfsm/gfsm/src/libgfsm/tests/commatest.c
deleted file mode 100644
index b704970..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/commatest.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdio.h>
-
-int main (void) {
- int x = 0;
-
- x = 1, printf("foo\n"), printf("bar\n"), x=2, printf("%d\n", x);
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/compre2test.c b/gfsm/gfsm/src/libgfsm/tests/compre2test.c
deleted file mode 100644
index 07d2b07..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/compre2test.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <gfsmRegexCompiler.h>
-#include <gfsmAutomatonIO.h>
-
-
-/*======================================================================
- * User C Code
- */
-
-int main (int argc, char **argv) {
- gfsmRegexCompiler *rec = gfsm_regex_compiler_new();
- gfsmAutomaton *fsm = NULL;
-
- //-- initialization
- rec->abet = gfsm_string_alphabet_new();
- if (!gfsm_alphabet_load_filename(rec->abet, "test.lab", &(rec->scanner.err))) {
- g_printerr("%s: load failed for labels file '%s': %s\n",
- *argv, "test.lab", (rec->scanner.err ? rec->scanner.err->message : "?"));
- exit(2);
- }
-
- //-- debug: lexer
- rec->scanner.emit_warnings = TRUE;
-
- //-- parse
- fsm = gfsm_regex_compiler_parse(rec);
-
- //-- sanity check
- if (rec->scanner.err) {
- fprintf(stderr, "%s: %s\n", *argv, rec->scanner.err->message);
- }
-
- if (fsm) {
- gfsm_automaton_save_bin_file(fsm, stdout, NULL);
- } else {
- fprintf(stderr, "%s: Error: no fsm!\n", *argv);
- }
-
- gfsm_regex_compiler_free(rec,TRUE,TRUE);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/comprelex.l b/gfsm/gfsm/src/libgfsm/tests/comprelex.l
deleted file mode 100644
index b82178d..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/comprelex.l
+++ /dev/null
@@ -1,297 +0,0 @@
-/*======================================================================
- * Flex Options
- */
-%option outfile="comprelex.lex.c"
-%option header-file="comprelex.lex.h"
-%option prefix="compretest_yy"
-%option reentrant
-%option 8bit
-%option yylineno
-
-%{
-/*======================================================================
- * User C Header
- */
-
-#include <gfsmRegexCompiler.h>
-//#include "compretest.tab.h"
-
-#define my_compiler ((gfsmRegexCompiler*)yyextra)
-#define my_gstr (my_compiler->gstr)
-#define my_abet (my_compiler->abet)
-
-typedef enum {
- TOK_UNKNOWN =256,
- TOK_CHAR =257,
- TOK_STRING =258,
- TOK_WEIGHT =259,
- TOK_UINT =260,
- TOK_BRACKETED =261,
- TOK_EOF =262
-} TokenType;
-
-%}
-
-/*======================================================================
- * Flex Definitions
- */
-
-DIGIT [0-9]
-SPACE [[:space:]]
-WCHAR [^\<\[\\ \t\n\r\#]
-BCHAR [^\\\]\ \t\n\r\=]
-UTF8PREFIX "Ã"
-
-%x STATE_ESCAPE
-%x STATE_BRACKETED
-%x STATE_BRACKETED_SEP
-%x STATE_BRACKETED_ESCAPE
-%x STATE_COMMENT
-%x STATE_WEIGHT
-%x STATE_UINT
-
-/*======================================================================
- * Rules
- */
-%%
-
-{UTF8PREFIX}+. {
- g_string_truncate(my_gstr,0);
- g_string_append_len(my_gstr,yytext,yyleng);
- return TOK_STRING;
-}
-
-"\\" { BEGIN(STATE_ESCAPE); }
-
-"#" { BEGIN(STATE_COMMENT); }
-
-"[" {
- BEGIN(STATE_BRACKETED);
- return '[';
-}
-
-"<" { BEGIN(STATE_WEIGHT); return '<'; }
-
-"(" { return '('; }
-")" { return ')'; }
-
-"*" { return '*'; }
-"+" { return '+'; }
-"^" { BEGIN(STATE_UINT); return '|'; }
-"?" { return '?'; }
-"!" { return '!'; }
-"|" { return '|'; }
-"&" { return '&'; }
-":" { return ':'; }
-"@" { return '@'; }
-"-" { return '-'; /*"/1"{return PROJ1;}*/ /*"/2"{return PROJ2;}*/ }
-
-"$" { return '$'; /* non-AT&T: determinize */ }
-"%" { return '%'; /* non-AT&T: rmepsilon */ }
-"~" { return '~'; /* non-AT&T: connect */ }
-
-{SPACE} { /* ignore */ }
-
-{WCHAR} {
- //yylval->u = gfsm_alphabet_find_label(my_abet, yytext);
- return TOK_CHAR;
-}
-
-
-
-<STATE_WEIGHT>([\+\-])?({DIGIT}*\.)?({DIGIT}+)([Ee]([\+\-]?){DIGIT}+)? {
- //yylval->w = strtod(yytext,NULL);
- return TOK_WEIGHT;
-}
-
-<STATE_WEIGHT>\> {
- BEGIN(INITIAL);
- return '>';
-}
-
-
-
-<STATE_UINT>{DIGIT}+ {
- BEGIN(INITIAL);
- //yylval->u = strtol(yytext,NULL,0);
- return TOK_UINT;
-}
-
-
-<STATE_COMMENT>[^\n]*\n { BEGIN(INITIAL); /* ignore comments */ }
-
-
-
-
-<STATE_ESCAPE>. {
- BEGIN(INITIAL);
- return TOK_CHAR;
-}
-
-
-
-<STATE_BRACKETED>{UTF8PREFIX}+. {
- g_string_append_len(my_gstr,yytext,yyleng);
-}
-<STATE_BRACKETED>{SPACE}*"]" {
- unput(']');
- BEGIN(STATE_BRACKETED_SEP);
- if (my_gstr->len) return TOK_STRING;
-}
-<STATE_BRACKETED>{BCHAR}+ {
- g_string_append(my_gstr, yytext);
- //return TOK_STRING;
-}
-<STATE_BRACKETED>({SPACE}*)"="({SPACE}*) {
- unput('=');
- BEGIN(STATE_BRACKETED_SEP);
- if (my_gstr->len) return TOK_STRING;
-}
-<STATE_BRACKETED>{SPACE}+ {
- unput(' ');
- BEGIN(STATE_BRACKETED_SEP);
- if (my_gstr->len) return TOK_STRING;
-}
-<STATE_BRACKETED>\\ {
- BEGIN(STATE_BRACKETED_ESCAPE);
-}
-
-
-<STATE_BRACKETED_SEP>"]" {
- BEGIN(INITIAL);
- if (my_gstr->len) {
- g_string_truncate(my_gstr,0);
- return ']';
- }
-}
-<STATE_BRACKETED_SEP>"=" {
- BEGIN(STATE_BRACKETED);
- g_string_truncate(my_gstr,0);
- return '=';
-}
-<STATE_BRACKETED_SEP>" " {
- BEGIN(STATE_BRACKETED);
- if (my_gstr->len) {
- g_string_truncate(my_gstr,0);
- return ' ';
- }
-}
-
-
-
-<STATE_BRACKETED_ESCAPE>. {
- BEGIN(STATE_BRACKETED);
- g_string_append_c(my_gstr, yytext[0]);
- //return TOK_STRING;
-}
-
-
-
-<*>. {
- gfsm_scanner_carp(yyextra, "bad character '%s'", yytext);
- return TOK_UNKNOWN;
-}
-
-<<EOF>> { return TOK_EOF; }
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-void testme(gfsmScanner *scanner) {
- TokenType tok;
- double weight;
- unsigned int uint;
-
- while ((tok=compretest_yylex(scanner->yyscanner)) != TOK_EOF) {
- switch (tok) {
- case TOK_CHAR:
- printf("(char) '%s'\n", compretest_yyget_text(scanner->yyscanner));
- break;
-
- case TOK_BRACKETED:
- printf("(bracketed) text=\"%s\" gstr=\"%s\"\n",
- compretest_yyget_text(scanner->yyscanner),
- ((gfsmRegexCompiler*)scanner)->gstr->str);
- break;
-
- case TOK_STRING:
- printf("(string) gstr=\"%s\"\n",
- //compretest_yyget_text(scanner->yyscanner),
- ((gfsmRegexCompiler*)scanner)->gstr->str
- );
- break;
-
- case '[':
- printf("(left-bracket) text=\"%s\"\n", compretest_yyget_text(scanner->yyscanner));
- break;
-
- case ']':
- printf("(right-bracket) text=\"%s\"\n", compretest_yyget_text(scanner->yyscanner));
- break;
-
- case ' ':
- printf("(space) text=\"%s\"\n", compretest_yyget_text(scanner->yyscanner));
- break;
-
- case '=':
- printf("(equal) text=\"%s\"\n", compretest_yyget_text(scanner->yyscanner));
- break;
-
- case TOK_WEIGHT:
- weight = strtod(compretest_yyget_text(scanner->yyscanner),NULL);
- printf("(weight) =%g\n", weight);
- break;
-
- case TOK_UINT:
- uint = strtol(compretest_yyget_text(scanner->yyscanner),NULL,0);
- printf("(uint) =%d\n", uint);
- break;
-
- default:
- printf("(other=%d~'%c'): (%s)\n", tok, tok, compretest_yyget_text(scanner->yyscanner));
- break;
- }
-
- if (scanner->err) {
- fprintf(stderr, "Error: %s\n", scanner->err->message);
- g_clear_error(&(scanner->err));
- break;
- }
- }
-}
-
-int main(int argc,char **argv) {
- gfsmRegexCompiler *reparser = g_new0(gfsmRegexCompiler,1);
- gfsm_scanner_init((gfsmScanner*)reparser, "gfsmRegexCompiler", compretest_yy);
-
- //-- initialization
- reparser->srtype = gfsmSRTTropical;
- reparser->gstr = g_string_new("");
- reparser->abet = gfsm_string_alphabet_new();
- if (!gfsm_alphabet_load_filename(reparser->abet, "test.lab", &(reparser->scanner.err))) {
- g_printerr("%s: load failed for labels file '%s': %s\n",
- *argv, "test.lab", (reparser->scanner.err ? reparser->scanner.err->message : "?"));
- exit(2);
- }
-
- //-- debug: lexer
- reparser->scanner.emit_warnings = TRUE;
-
- //-- lex
- testme((gfsmScanner*)reparser);
-
- //-- sanity check
- if (reparser->scanner.err) {
- fprintf(stderr, "Error: %s\n", reparser->scanner.err->message);
- }
-
- gfsm_scanner_free((gfsmScanner*)reparser);
-
- return 0;
-}
-
-
-GFSM_SCANNER_YYWRAP(compretest_yy)
diff --git a/gfsm/gfsm/src/libgfsm/tests/compretest.l b/gfsm/gfsm/src/libgfsm/tests/compretest.l
deleted file mode 100644
index 731655c..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/compretest.l
+++ /dev/null
@@ -1,199 +0,0 @@
-/*======================================================================
- * Flex Options
- */
-%option outfile="compretest.lex.c"
-%option header-file="compretest.lex.h"
-%option prefix="compretest_yy"
-%option reentrant
-%option 8bit
-%option yylineno
-
-%option bison-bridge
-
-%{
-/*======================================================================
- * User C Header
- */
-
-#include <gfsmMem.h>
-#include <gfsmRegexCompiler.h>
-#include "compretest.tab.h"
-
-#define my_compiler ((gfsmRegexCompiler*)yyextra)
-#define my_gstr (my_compiler->gstr)
-#define my_abet (my_compiler->abet)
-
-%}
-
-/*======================================================================
- * Flex Definitions
- */
-
-DIGIT [0-9]
-SPACE [[:space:]]
-WCHAR [^\<\[\\ \t\n\r\#]
-BCHAR [^\\\]\ \t\n\r\=]
-UTF8PREFIX "Ã"
-
-%x STATE_ESCAPE
-%x STATE_BRACKETED
-%x STATE_BRACKETED_SEP
-%x STATE_BRACKETED_ESCAPE
-%x STATE_COMMENT
-%x STATE_WEIGHT
-%x STATE_UINT
-
-/*======================================================================
- * Rules
- */
-%%
-
-{UTF8PREFIX}+. {
- yylval->gs = gfsm_gstring_new_bytes(yytext,yyleng);
- return TOK_STRING;
-}
-
-"\\" { BEGIN(STATE_ESCAPE); }
-
-"#" { BEGIN(STATE_COMMENT); }
-
-"[" {
- BEGIN(STATE_BRACKETED);
- return '[';
-}
-
-"<" { BEGIN(STATE_WEIGHT); return '<'; }
-
-"(" { return '('; }
-")" { return ')'; }
-
-"*" { return '*'; }
-"+" { return '+'; }
-"^" { BEGIN(STATE_UINT); return '|'; }
-"?" { return '?'; }
-"!" { return '!'; }
-"|" { return '|'; }
-"&" { return '&'; }
-":" { return ':'; }
-"@" { return '@'; }
-"-" { return '-'; /*"/1"{return PROJ1;}*/ /*"/2"{return PROJ2;}*/ }
-
-"$" { return '$'; /* non-AT&T: determinize */ }
-"%" { return '%'; /* non-AT&T: rmepsilon */ }
-"~" { return '~'; /* non-AT&T: connect */ }
-
-{SPACE} { /* ignore */ }
-
-{WCHAR} {
- yylval->c = yytext[0];
- return TOK_CHAR;
-}
-
-
-
-<STATE_WEIGHT>([\+\-])?({DIGIT}*\.)?({DIGIT}+)([Ee]([\+\-]?){DIGIT}+)? {
- yylval->w = strtod(yytext,NULL);
- return TOK_WEIGHT;
-}
-
-<STATE_WEIGHT>\> {
- BEGIN(INITIAL);
- return '>';
-}
-
-
-
-<STATE_UINT>{DIGIT}+ {
- BEGIN(INITIAL);
- yylval->u = strtol(yytext,NULL,0);
- return TOK_UINT;
-}
-
-
-<STATE_COMMENT>[^\n]*\n { BEGIN(INITIAL); /* ignore comments */ }
-
-
-
-
-<STATE_ESCAPE>. {
- BEGIN(INITIAL);
- yylval->c = yytext[0];
- return TOK_CHAR;
-}
-
-
-<STATE_BRACKETED>{UTF8PREFIX}+. {
- g_string_append_len(my_gstr,yytext,yyleng);
-}
-<STATE_BRACKETED>{SPACE}*"]" {
- unput(']');
- BEGIN(STATE_BRACKETED_SEP);
- if (my_gstr->len) {
- yylval->gs = gfsm_gstring_dup(my_gstr);
- return TOK_STRING;
- }
-}
-<STATE_BRACKETED>{BCHAR}+ {
- g_string_append(my_gstr, yytext);
-}
-<STATE_BRACKETED>({SPACE}*)"="({SPACE}*) {
- unput('=');
- BEGIN(STATE_BRACKETED_SEP);
- if (my_gstr->len) {
- yylval->gs = gfsm_gstring_dup(my_gstr);
- return TOK_STRING;
- }
-}
-<STATE_BRACKETED>{SPACE}+ {
- unput(' ');
- BEGIN(STATE_BRACKETED_SEP);
- if (my_gstr->len) {
- yylval->gs = gfsm_gstring_dup(my_gstr);
- return TOK_STRING;
- }
-}
-<STATE_BRACKETED>\\ {
- BEGIN(STATE_BRACKETED_ESCAPE);
-}
-
-
-<STATE_BRACKETED_SEP>"]" {
- BEGIN(INITIAL);
- if (my_gstr->len) {
- g_string_truncate(my_gstr,0);
- return ']';
- }
-}
-<STATE_BRACKETED_SEP>"=" {
- BEGIN(STATE_BRACKETED);
- g_string_truncate(my_gstr,0);
- return '=';
-}
-<STATE_BRACKETED_SEP>" " {
- BEGIN(STATE_BRACKETED);
- if (my_gstr->len) {
- g_string_truncate(my_gstr,0);
- return ' ';
- }
-}
-
-
-<STATE_BRACKETED_ESCAPE>. {
- BEGIN(STATE_BRACKETED);
- g_string_append_c(my_gstr, yytext[0]);
-}
-
-
-
-<*>. {
- gfsm_scanner_carp(yyextra, "bad character '%s'", yytext);
- return TOK_UNKNOWN;
-}
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-GFSM_SCANNER_YYWRAP(compretest_yy)
diff --git a/gfsm/gfsm/src/libgfsm/tests/compretest.y b/gfsm/gfsm/src/libgfsm/tests/compretest.y
deleted file mode 100644
index d55f488..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/compretest.y
+++ /dev/null
@@ -1,185 +0,0 @@
-/*======================================================================
- * Bison Options
- */
-%pure_parser
-
-%{
-/*======================================================================
- * Bison C Header
- */
-#include <gfsmRegexCompiler.h>
-#include <gfsmAutomatonIO.h>
-
-#include "compretest.tab.h"
-#include "compretest.lex.h"
-
-#define my_compiler ((gfsmRegexCompiler*)reparser)
-
-#define YYLEX_PARAM ((gfsmRegexCompiler*)reparser)->scanner.yyscanner
-#define YYPARSE_PARAM reparser
-
-#define YYERROR_VERBOSE 1
-#define compretest_yyerror(msg) \
- gfsm_scanner_carp((gfsmScanner*)reparser, (msg));
-
-%}
-
-/*======================================================================
- * Bison Definitions
- */
-%union {
- gfsmAutomaton *fsm; //-- automaton
- GString *gs; //-- needs to be freed by hand
- gchar c;
- guint32 u;
- gfsmWeight w;
-}
-
-%token <c> TOK_UNKNOWN TOK_CHAR
-%token <u> TOK_UINT
-%token <gs> TOK_STRING
-%token <w> TOK_WEIGHT
-
-%type <u> label
-%type <w> weight
-%type <fsm> regex
-
-/*
-empty { $$=gfsm_regex_automaton_epsilon(my_compiler); }
-*/
-
-/*
- | gfsmRETChar %prec LAB
- { $$=gfsm_regex_automaton_lab(my_compiler, $1); }
-*/
-
-// -- Operator precedence and associativity
-%left CONCAT
-%left LABCONCAT
-%left WEIGHT
-%right '%' //-- non-AT&T: rmepsilon: % REGEX
-%right '$' //-- non-AT&T: determinize: $ REGEX
-%right '~' //-- non-AT&T: connect: ~ REGEX
-%left '*' '+' '?' '^'
-%right '!'
-%left '@'
-%left ':'
-%left '-'
-%left '&'
-%left '|'
-
-/*======================================================================
- * Bison Rules
- */
-%%
-
-regex: '('regex ')'
- { $$=$2; }
-
- | label
- { $$=gfsm_regex_compiler_label_fsm(my_compiler, $1); }
-
- | label regex %prec LABCONCAT
- { $$=gfsm_regex_compiler_prepend_lab(my_compiler, $1, $2); }
-
- | regex regex %prec CONCAT
- { $$=gfsm_regex_compiler_concat(my_compiler, $1, $2); }
-
- | '%' regex
- { $$=gfsm_regex_compiler_rmepsilon(my_compiler, $2); /* non-ATT */ }
-
- | '$' regex
- { $$=gfsm_regex_compiler_determinize(my_compiler, $2); /* non-ATT */ }
-
- | '~' regex
- { $$=gfsm_regex_compiler_connect(my_compiler, $2); /* non-ATT */ }
-
- | regex '*'
- { $$=gfsm_regex_compiler_closure(my_compiler,$1,FALSE); }
-
- | regex '+'
- { $$=gfsm_regex_compiler_closure(my_compiler,$1,TRUE); }
-
- | regex '^' TOK_UINT
- { $$=gfsm_regex_compiler_power(my_compiler,$1,$3); }
-
- | regex '?'
- { $$=gfsm_regex_compiler_optional(my_compiler,$1); }
-
- | '!' regex
- { $$=gfsm_regex_compiler_complement(my_compiler,$2); }
-
- | regex '|' regex
- { $$=gfsm_regex_compiler_union(my_compiler,$1,$3); }
-
- | regex '&' regex
- { $$=gfsm_regex_compiler_intersect(my_compiler,$1,$3); }
-
- | regex ':' regex
- { $$=gfsm_regex_compiler_product(my_compiler,$1,$3); }
-
- | regex '@' regex
- { $$=gfsm_regex_compiler_compose(my_compiler,$1,$3); }
-
- | regex '-' regex
- { $$=gfsm_regex_compiler_difference(my_compiler,$1,$3); }
-
- | regex weight %prec WEIGHT
- { $$=gfsm_regex_compiler_weight(my_compiler,$1,$2); }
- ;
-
-label: TOK_CHAR
- { $$=gfsm_regex_compiler_char2label(my_compiler, $1); }
-
- | TOK_STRING
- { $$=gfsm_regex_compiler_gstring2label(my_compiler, $1); }
-
- | '[' TOK_STRING ']'
- { $$=gfsm_regex_compiler_gstring2label(my_compiler, $2); }
- ;
-
-weight: '<' TOK_WEIGHT '>' { $$=$2; }
- ;
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-int main (int argc, char **argv) {
- gfsmRegexCompiler *reparser = g_new0(gfsmRegexCompiler,1);
- gfsm_scanner_init((gfsmScanner*)reparser, "gfsmRegexCompiler", compretest_yy);
-
-
- //-- initialization
- reparser->srtype = gfsmSRTTropical;
- reparser->gstr = g_string_new("");
- reparser->abet = gfsm_string_alphabet_new();
- if (!gfsm_alphabet_load_filename(reparser->abet, "test.lab", &(reparser->scanner.err))) {
- g_printerr("%s: load failed for labels file '%s': %s\n",
- *argv, "test.lab", (reparser->scanner.err ? reparser->scanner.err->message : "?"));
- exit(2);
- }
-
- //-- debug: lexer
- reparser->scanner.emit_warnings = TRUE;
-
- //-- parse
- compretest_yyparse(reparser);
-
- //-- sanity check
- if (reparser->scanner.err) {
- fprintf(stderr, "%s: %s\n", *argv, reparser->scanner.err->message);
- }
-
- if (reparser->fsm) {
- gfsm_automaton_save_bin_file(reparser->fsm, stdout, NULL);
- } else {
- fprintf(stderr, "%s: Error: no fsm!\n", *argv);
- }
-
- gfsm_scanner_free((gfsmScanner*)reparser);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/ctest.c b/gfsm/gfsm/src/libgfsm/tests/ctest.c
deleted file mode 100644
index 78d9002..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/ctest.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-
-typedef struct testme_s {
- int i : 1;
- int j : 1;
- int k : 1;
-} testme_t;
-
-int main (void) {
- int x,y,z;
- float f = +inf;
- printf("sizeof(testme_t)=%u\n", sizeof(testme_t));
-
- z = (x=42,y=24,17);
- printf ("z = (x=42,y=24) = %d\n", z);
- printf("f = %g\n", f);
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/dettest.c b/gfsm/gfsm/src/libgfsm/tests/dettest.c
deleted file mode 100644
index 278535c..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/dettest.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <gfsm.h>
-#include <stdio.h>
-
-int main (void) {
- gfsmAutomaton *fsm = gfsm_automaton_new();
-
- printf("##-- determinize()-1...\n");
- gfsm_automaton_determinize(fsm);
- gfsm_automaton_print_file(fsm,stdout,NULL);
-
- printf("##-- determinize()-2...\n");
- gfsm_automaton_determinize(fsm);
- gfsm_automaton_print_file(fsm,stdout,NULL);
-
- printf("##-- determinize()-3...\n");
- gfsm_automaton_determinize(fsm);
- gfsm_automaton_print_file(fsm,stdout,NULL);
-
- printf("done.\n");
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/flex2test.l b/gfsm/gfsm/src/libgfsm/tests/flex2test.l
deleted file mode 100644
index b81e7f7..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/flex2test.l
+++ /dev/null
@@ -1,174 +0,0 @@
-/*======================================================================
- * Flex Options
- */
-%option outfile="flex2test.lex.c"
-%option header-file="flex2test.lex.h"
-%option prefix="testme_yy"
-%option reentrant
-%option 8bit
-%option yylineno
-
-%{
-/*======================================================================
- * User C Header
- */
-
-#include <gfsm.h>
-
-typedef enum {
- T_EOF,
- T_CHAR,
- T_STRING,
- T_WEIGHT,
-
- T_OP_PROJ_1,
- T_OP_PROJ_2,
- T_OP_STAR,
- T_OP_PLUS,
- T_OP_POWER, //-- "^n"
- T_OP_MINUS,
- T_OP_OPTIONAL,
- T_OP_UNION,
- T_OP_COMPLEMENT,
- T_OP_INTERSECT,
- T_OP_PRODUCT,
- T_OP_COMPOSE,
-
- T_LPAREN,
- T_RPAREN,
- T_LBRACKET,
- T_RBRACKET,
-
- T_EQUAL,
- T_SEMICOLON, //-- semicolon
-
- T_OTHER
-} TokenType;
-
-#define GSTR_BUF ((GString*)((gfsmScanner*)yyextra)->data)
-
-%}
-
-/*======================================================================
- * Flex Definitions
- */
-
-DIGIT [0-9]
-SPACE [[:space:]]
-WCHAR [^\\\[ \t\n\r\#\<]
-SCHAR [^\\\]]
-
-%x ESCAPE STRING SESCAPE COMMENT WEIGHT
-
-/*======================================================================
- * Rules
- */
-%%
-
-<INITIAL>{WCHAR} { return T_CHAR; }
-
-<INITIAL>{SPACE} { /* ignore */ }
-
-<INITIAL># { BEGIN(COMMENT); }
-
-<INITIAL>\\ { BEGIN(ESCAPE); }
-
-<INITIAL>\[ { BEGIN(STRING); GSTR_BUF->len = 0; }
-
-<INITIAL>\< { BEGIN(WEIGHT); }
-
-
-
-<WEIGHT>[^\>]+ { return WEIGHT; /* hack */ }
-
-<WEIGHT>\> { BEGIN(INITIAL); }
-
-
-
-<COMMENT>[^\n]*\n { BEGIN(INITIAL); }
-
-
-
-
-<ESCAPE>. { BEGIN(INITIAL); return T_CHAR; }
-
-
-
-
-<STRING>\] { BEGIN(INITIAL); return T_STRING; }
-
-<STRING>{SCHAR} { g_string_append_c(GSTR_BUF, yytext[0]); }
-
-<STRING>\\ { BEGIN(SESCAPE); }
-
-
-
-<SESCAPE>. { BEGIN(STRING); g_string_append_c(GSTR_BUF, yytext[0]); }
-
-
-
-<<EOF>> { return T_EOF; }
-
-
-<*>. {
- gfsm_scanner_carp(yyextra, "bad character '%s'", yytext);
- return T_OTHER;
-}
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-void testme(gfsmScanner *scanner) {
- TokenType tok;
- double weight;
-
- while ((tok=testme_yylex(scanner->yyscanner)) != T_EOF) {
- switch (tok) {
- case T_CHAR:
- printf("(char) '%s'\n", testme_yyget_text(scanner->yyscanner));
- break;
- case STRING:
- printf("(string) \"%s\"\n", ((GString*)scanner->data)->str);
- break;
- case WEIGHT:
- weight = strtod(testme_yyget_text(scanner->yyscanner),NULL);
- printf("(weight) %g\n", weight);
- break;
- default:
- printf("(other=%d): (%s)\n", tok, testme_yyget_text(scanner->yyscanner));
- break;
- }
-
- if (scanner->err) {
- fprintf(stderr, "Error: %s\n", scanner->err->message);
- g_clear_error(&(scanner->err));
- break;
- }
- }
-}
-
-int main(void) {
- gfsmScanner *scanner = gfsm_scanner_new("myScanner",testme_yy);
- scanner->data = g_string_new("");
-
- //-- first, scan a string
- /*
- gfsm_scanner_scan_string(scanner, "line 1\nline 2\nline 3.");
- scanner->filename = g_strdup("string");
- testme(scanner);
- */
-
- //-- now scan stdin
- gfsm_scanner_scan_filename(scanner, "-");
- testme(scanner);
-
- gfsm_scanner_free(scanner);
-
- return 0;
-}
-
-//int testme_yywrap(yyscan_t yyscanner) { return 1; }
-GFSM_SCANNER_YYWRAP(testme_yy)
diff --git a/gfsm/gfsm/src/libgfsm/tests/flex3test.l b/gfsm/gfsm/src/libgfsm/tests/flex3test.l
deleted file mode 100644
index 27c1cc1..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/flex3test.l
+++ /dev/null
@@ -1,232 +0,0 @@
-/*======================================================================
- * Flex Options
- */
-%option outfile="flex3test.lex.c"
-%option header-file="flex3test.lex.h"
-%option prefix="testme_yy"
-%option reentrant
-%option 8bit
-%option yylineno
-
-%{
-/*======================================================================
- * User C Header
- */
-
-#include <gfsm.h>
-
-typedef enum {
- T_EOF = 256,
- T_CHAR = 257,
- T_BRACKETED = 258,
- T_BSPACE = 259,
- T_WEIGHT = 260,
- T_UINT = 261,
- T_UTF8 = 262,
-
- T_LPAREN = '(',
- T_RPAREN = ')',
- T_LBRACKET = '[',
- T_RBRACKET = ']',
- T_LANGLE = '<',
- T_RANGLE = '>',
-
- T_BEQUAL = '=',
-
- T_OTHER = 65535
-} TokenType;
-
-#define GSTR_BUF ((GString*)((gfsmScanner*)yyextra)->data)
-
-%}
-
-/*======================================================================
- * Flex Definitions
- */
-
-DIGIT [0-9]
-SPACE [[:space:]]
-WCHAR [^\<\>\[\]\\ \t\n\r\#]
-BCHAR [^\\\]\ \t\n\r\=]
-UTF8PREFIX "Ã"
-
-%x ESCAPE BRACKETED BESCAPE COMMENT WEIGHT UINT UTF8 BUTF8
-
-/*======================================================================
- * Rules
- */
-%%
-
-{UTF8PREFIX} { BEGIN(UTF8); g_string_set_size(GSTR_BUF,1); GSTR_BUF->str[0] = yytext[0]; }
-
-"\\" { BEGIN(ESCAPE); }
-
-"#" { BEGIN(COMMENT); }
-
-"[" { BEGIN(BRACKETED); g_string_truncate(GSTR_BUF,0); return T_LBRACKET; }
-
-"<" { BEGIN(WEIGHT); return T_LANGLE; }
-
-
-"(" { return '('; }
-")" { return ')'; }
-
-"*" { return '*'; }
-"+" { return '+'; }
-"^" { BEGIN(UINT); return '|'; }
-"?" { return '?'; }
-"!" { return '!'; }
-"|" { return '|'; }
-"&" { return '&'; }
-":" { return ':'; }
-"@" { return '@'; }
-"-" { return '-'; }
-
-{SPACE} { /* ignore */ }
-
-{WCHAR} { return T_CHAR; }
-
-
-
-<UTF8>{UTF8PREFIX}+ { g_string_append(GSTR_BUF, yytext); }
-
-<UTF8>. { BEGIN(INITIAL); g_string_append_c(GSTR_BUF, yytext[0]); return T_UTF8; }
-
-
-<WEIGHT>([\+\-])?({DIGIT}*\.)?({DIGIT}+)([Ee]([\+\-]?){DIGIT}+)? { return T_WEIGHT; /* hack */ }
-
-<WEIGHT>\> { BEGIN(INITIAL); return T_RANGLE; }
-
-
-
-<UINT>{DIGIT}+ { BEGIN(INITIAL); return T_UINT; }
-
-
-<COMMENT>[^\n]*\n { BEGIN(INITIAL); /* ignore comments */ }
-
-
-
-
-<ESCAPE>. { BEGIN(INITIAL); return T_CHAR; }
-
-
-
-<BRACKETED>{UTF8PREFIX} { BEGIN(BUTF8); g_string_append_c(GSTR_BUF, yytext[0]); }
-
-<BRACKETED>\] { BEGIN(INITIAL); return T_RBRACKET; }
-
-<BRACKETED>{BCHAR} { g_string_append_c(GSTR_BUF, yytext[0]); }
-
-<BRACKETED>{SPACE} { return T_BSPACE; }
-
-<BRACKETED>"=" { return T_BEQUAL; }
-
-<BRACKETED>\\ { BEGIN(BESCAPE); }
-
-
-<BUTF8>{UTF8PREFIX}+ { g_string_append(GSTR_BUF, yytext); }
-
-<BUTF8>. { BEGIN(BRACKETED); g_string_append_c(GSTR_BUF, yytext[0]); }
-
-
-<BESCAPE>. { BEGIN(BRACKETED); g_string_append_c(GSTR_BUF, yytext[0]); }
-
-
-
-<<EOF>> { return T_EOF; }
-
-
-<*>. {
- gfsm_scanner_carp(yyextra, "bad character '%s'", yytext);
- return T_OTHER;
-}
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-void testme(gfsmScanner *scanner) {
- TokenType tok;
- double weight;
- unsigned int uint;
-
- while ((tok=testme_yylex(scanner->yyscanner)) != T_EOF) {
- switch (tok) {
- case T_CHAR:
- printf("(char) '%s'\n", testme_yyget_text(scanner->yyscanner));
- break;
-
- case T_UTF8:
- printf("(utf8) '%s'\n", ((GString*)scanner->data)->str);
- break;
-
- case T_LBRACKET:
- printf("(lbracket)\n");
- break;
-
- case T_RBRACKET:
- printf("(rbracket) gstr=\"%s\"\n", ((GString*)scanner->data)->str);
- g_string_truncate(((GString*)scanner->data),0);
- break;
- case T_BSPACE:
- printf("(bspace) gstr=\"%s\"\n", ((GString*)scanner->data)->str);
- g_string_truncate(((GString*)scanner->data),0);
- break;
- case T_BEQUAL:
- printf("(bequal) gstr=\"%s\"\n", ((GString*)scanner->data)->str);
- g_string_truncate(((GString*)scanner->data),0);
- break;
-
- case T_LANGLE:
- printf("(langle)\n");
- break;
- case T_RANGLE:
- printf("(rangle)\n");
- break;
- case T_WEIGHT:
- weight = strtod(testme_yyget_text(scanner->yyscanner),NULL);
- printf("(weight) =%g\n", weight);
- break;
-
- case T_UINT:
- uint = strtol(testme_yyget_text(scanner->yyscanner),NULL,0);
- printf("(uint) =%d\n", uint);
- break;
-
- default:
- printf("(other=%d~'%c'): (%s)\n", tok, tok, testme_yyget_text(scanner->yyscanner));
- break;
- }
-
- if (scanner->err) {
- fprintf(stderr, "Error: %s\n", scanner->err->message);
- g_clear_error(&(scanner->err));
- break;
- }
- }
-}
-
-int main(void) {
- gfsmScanner *scanner = gfsm_scanner_new("myScanner",testme_yy);
- scanner->data = g_string_new("");
-
- //-- first, scan a string
- /*
- gfsm_scanner_scan_string(scanner, "line 1\nline 2\nline 3.");
- scanner->filename = g_strdup("string");
- testme(scanner);
- */
-
- //-- now scan stdin
- gfsm_scanner_scan_filename(scanner, "-");
- testme(scanner);
-
- gfsm_scanner_free(scanner);
-
- return 0;
-}
-
-//int testme_yywrap(yyscan_t yyscanner) { return 1; }
-GFSM_SCANNER_YYWRAP(testme_yy)
diff --git a/gfsm/gfsm/src/libgfsm/tests/flextest.l b/gfsm/gfsm/src/libgfsm/tests/flextest.l
deleted file mode 100644
index c0d103d..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/flextest.l
+++ /dev/null
@@ -1,59 +0,0 @@
-/*======================================================================
- * Flex Options
- */
-%option outfile="flextest.c"
-%option header-file="flextest.h"
-%option prefix="testme_yy"
-%option reentrant
-%option 8bit
-
-%{
-/*======================================================================
- * User C Header
- */
-
-int nlines=0;
-
-%}
-
-/*======================================================================
- * Flex Definitions
- */
-
-
-/*======================================================================
- * Rules
- */
-%%
-
-\n { return 1; }
-
-<<EOF>> { return 0; }
-
-. { /* do nothing */; }
-
-%%
-
-/*======================================================================
- * User C Code
- */
-
-int main(void) {
- yyscan_t scanner;
- int nlines=0;
- int tok;
-
- testme_yylex_init(&scanner); //-- initialize reentrant flex scanner
-
- while ((tok=testme_yylex(scanner))) {
- //printf("tok=%d\n", tok);
- nlines++;
- }
-
- testme_yylex_destroy(scanner); //-- cleanup reentrant flex scanner
-
- printf("%d\n", nlines);
- return 0;
-}
-
-int testme_yywrap(yyscan_t yyscanner) { return 1; }
diff --git a/gfsm/gfsm/src/libgfsm/tests/ftest.c b/gfsm/gfsm/src/libgfsm/tests/ftest.c
deleted file mode 100644
index e571f31..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/ftest.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <stdio.h>
-#include <glib.h>
-
-int main (int argc, char **argv) {
- float f, f2;
- gpointer p;
- int i;
-
- for (i=1; i<argc; i++) {
- sscanf(argv[i], "%f", &f);
- p = (gpointer)(*((int*)(&f)));
- f2 = *((float*)(&p));
- printf("argv[i=%d]='%s' ; f=%g ; f->p=%p ; p->f=%g\n", i, argv[i], f, p, f2);
- }
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/gbtest.c b/gfsm/gfsm/src/libgfsm/tests/gbtest.c
deleted file mode 100644
index e0e406d..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/gbtest.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <glib.h>
-#include <stdio.h>
-
-GArray *ary1;
-GArray *ary2;
-GArray *ary3;
-guint esize = 8;
-guint nelts = 128;
-
-int main (void) {
- int i;
-
- ary1 = g_array_sized_new(FALSE, TRUE, esize, nelts);
- ary2 = g_array_sized_new(FALSE, TRUE, esize, nelts);
- ary3 = g_array_sized_new(FALSE, TRUE, esize, nelts);
-
- for (i=0; i < 128; i++) {
- g_array_free(ary2,TRUE);
- ary2 = g_array_sized_new(FALSE,TRUE,esize,nelts*i);
- }
-
- g_array_free(ary1,TRUE);
- g_array_free(ary2,TRUE);
- g_array_free(ary3,TRUE);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/gfsm-chop.perl b/gfsm/gfsm/src/libgfsm/tests/gfsm-chop.perl
deleted file mode 100755
index 7f81bd8..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/gfsm-chop.perl
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/perl -w
-
-use Gfsm;
-
-our @want_states =
- (
- 5,
- 4,
- 11,
- 98,
- 5257,
- 45623,
- 290132,
- 0
- );
-
-push(@ARGV,'-') if (!@ARGV);
-
-$fsmfile = shift(@ARGV);
-our $fsm = Gfsm::Automaton->new();
-$fsm->load($fsmfile) or die("$0: load failed for fsm file '$fsmfile': $!");
-
-##-- chop it
-my %q2i = map { $want_states[$_]=>$_ } (0..$#want_states);
-my $qid_dummy = scalar(@want_states);
-$fsm2 = $fsm->shadow;
-$ai=Gfsm::ArcIter->new;
-
-foreach $qid_dst (0..$#want_states) {
- $fsm2->ensure_state($qid_dst);
- $qid_src = $want_states[$qid_dst];
- for ($ai->open($fsm,$qid_src); $ai->ok; $ai->next) {
- $fsm2->add_arc($qid_dst, $qid_dummy, $ai->lower, $ai->upper, $ai->weight);
- }
- $fsm2->add_arc($qid_dummy,$qid_dst,0,0,0);
-}
-$fsm2->root($qid_dummy);
-$fsm2->final_weight($qid_dummy,0);
-
-$fsm2->save('-');
diff --git a/gfsm/gfsm/src/libgfsm/tests/gfsm-out-degrees.perl b/gfsm/gfsm/src/libgfsm/tests/gfsm-out-degrees.perl
deleted file mode 100755
index 38caf2d..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/gfsm-out-degrees.perl
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/perl -w
-
-use Gfsm;
-
-$fsmfile = @ARGV ? shift : '-';
-$fsm = Gfsm::Automaton->new();
-die("$0: load failed for '$fsmfile': $!") if (!$fsm->load($fsmfile));
-
-foreach $qid (0..($fsm->n_states-1)) {
- print $qid, "\t", $fsm->out_degree($qid), "\n";
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.c b/gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.c
deleted file mode 100644
index 12495fa..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.c
+++ /dev/null
@@ -1,210 +0,0 @@
-#include <gfsmRegexCompiler.h>
-#include <gfsmArith.h>
-#include <gfsmUtils.h>
-
-#define RETURN(rec,_rea) (rec)->rea=(_rea); return (_rea);
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_epsilon(gfsmRegexCompiler *rec)
-{
- rec->rea.typ = gfsmREATEmpty;
- rec->rea.val.lab = 0;
- return rec->rea;
-}
-
-//--------------------------------------------------------------
-gfsmAutomaton *gfsm_regex_automaton_new_fsm(gfsmRegexCompiler *rec)
-{
- gfsmAutomaton *fsm = gfsm_automaton_new_full(gfsmAutomatonDefaultFlags,
- rec->srtype,
- gfsmAutomatonDefaultSize);
- fsm->flags.is_transducer = FALSE;
- return fsm;
-}
-
-//--------------------------------------------------------------
-gfsmAutomaton *gfsm_regex_automaton_epsilon_fsm(gfsmRegexCompiler *rec)
-{
- gfsmAutomaton *fsm = gfsm_regex_automaton_new_fsm(rec);
- fsm->root_id = gfsm_automaton_add_state(fsm);
- gfsm_automaton_set_final_state(fsm,fsm->root_id,TRUE);
- return fsm;
-}
-
-//--------------------------------------------------------------
-gfsmAutomaton *gfsm_regex_automaton_label_fsm(gfsmRegexCompiler *rec, gfsmLabelVal lab)
-{
- gfsmAutomaton *fsm = gfsm_regex_automaton_new_fsm(rec);
- gfsmStateId labid;
- fsm->root_id = gfsm_automaton_add_state(fsm);
- labid = gfsm_automaton_add_state(fsm);
- gfsm_automaton_add_arc(fsm, fsm->root_id, labid, lab, lab, fsm->sr->one);
- gfsm_automaton_set_final_state(fsm,labid,TRUE);
- return fsm;
-}
-
-//--------------------------------------------------------------
-gfsmAutomaton *gfsm_regex_automaton_fsm(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea)
-{
- switch (rea.typ) {
- case gfsmREATEmpty:
- return gfsm_regex_automaton_epsilon_fsm(rec);
- break;
- case gfsmREATLabel:
- return gfsm_regex_automaton_label_fsm(rec, rea.val.lab);
- break;
- case gfsmREATFull:
- default:
- return rea.val.fsm;
- break;
- }
-}
-
-//--------------------------------------------------------------
-gfsmAutomaton *gfsm_regex_automaton_expand(gfsmRegexCompiler *rec, gfsmRegexAutomaton *rea)
-{
- rea->val.fsm = gfsm_regex_automaton_fsm(rec,*rea);
- rea->typ = gfsmREATFull;
- return rea->val.fsm;
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_label(gfsmRegexCompiler *rec, gfsmLabelVal lab)
-{
- rec->rea.typ = gfsmREATLabel;
- rec->rea.val.lab = lab;
- return rec->rea;
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_concat(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmRegexAutomaton rea2)
-{
- switch (rea2.typ) {
- case gfsmREATEmpty:
- break;
- case gfsmREATLabel:
- gfsm_regex_automaton_append_lab(rec, gfsm_regex_automaton_expand(rec,&rea1), rea2.val.lab);
- break;
- case gfsmREATFull:
- default:
- gfsm_automaton_concat(gfsm_regex_automaton_expand(rec,&rea1), rea2.val.fsm);
- gfsm_automaton_free(rea2.val.fsm);
- break;
- }
-
- RETURN(rec,rea1);
-}
-
-
-//--------------------------------------------------------------
-struct _gfsm_regex_append_lab_data {
- gfsmAutomaton *fsm;
- gfsmLabelVal lab;
- gfsmStateId newid;
-};
-
-gboolean _gfsm_regex_append_lab_foreach_func(gfsmStateId qid, gpointer pw,
- struct _gfsm_regex_append_lab_data *data)
-{
- gfsm_automaton_get_state(data->fsm,qid)->is_final = FALSE;
- gfsm_automaton_add_arc(data->fsm, qid, data->newid, data->lab, data->lab, gfsm_ptr2weight(pw));
- return FALSE;
-}
-
-gfsmAutomaton *gfsm_regex_automaton_append_lab(gfsmRegexCompiler *rec, gfsmAutomaton *fsm, gfsmLabelVal lab)
-{
- struct _gfsm_regex_append_lab_data data = { fsm, lab, gfsm_automaton_add_state(fsm) };
- gfsm_weightmap_foreach(fsm->finals,
- (GTraverseFunc)_gfsm_regex_append_lab_foreach_func,
- &data);
- gfsm_weightmap_clear(fsm->finals);
- gfsm_automaton_set_final_state(fsm, data.newid, TRUE);
- return fsm;
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_closure(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea, gboolean is_plus)
-{
- gfsm_automaton_closure(gfsm_regex_automaton_expand(rec,&rea),is_plus);
- RETURN(rec,rea);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_power(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea, guint32 n)
-{
- gfsm_automaton_n_closure(gfsm_regex_automaton_expand(rec,&rea),n);
- RETURN(rec,rea);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_project(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea,
- gfsmLabelSide which)
-{
- gfsm_automaton_project(gfsm_regex_automaton_expand(rec,&rea),which);
- RETURN(rec,rea);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_optional(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea)
-{
- gfsm_automaton_optional(gfsm_regex_automaton_expand(rec,&rea));
- RETURN(rec,rea);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_complement(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea)
-{
- gfsm_automaton_complement_full(gfsm_regex_automaton_expand(rec,&rea),rec->abet);
- RETURN(rec,rea);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_union(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea1, gfsmRegexAutomaton rea2)
-{
- gfsm_automaton_union(gfsm_regex_automaton_expand(rec,&rea1),gfsm_regex_automaton_expand(rec,&rea2));
- gfsm_automaton_free(gfsm_regex_automaton_expand(rec,&rea2));
- RETURN(rec,rea1);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_intersect(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea1, gfsmRegexAutomaton rea2)
-{
- gfsm_automaton_intersect(gfsm_regex_automaton_expand(rec,&rea1),gfsm_regex_automaton_expand(rec,&rea2));
- gfsm_automaton_free(gfsm_regex_automaton_expand(rec,&rea2));
- RETURN(rec,rea1);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_product(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea1, gfsmRegexAutomaton rea2)
-{
- _gfsm_automaton_product(gfsm_regex_automaton_expand(rec,&rea1),gfsm_regex_automaton_expand(rec,&rea2));
- gfsm_automaton_free(gfsm_regex_automaton_expand(rec,&rea2));
- RETURN(rec,rea1);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_compose(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea1, gfsmRegexAutomaton rea2)
-{
- gfsm_automaton_compose(gfsm_regex_automaton_expand(rec,&rea1),gfsm_regex_automaton_expand(rec,&rea2));
- gfsm_automaton_free(gfsm_regex_automaton_expand(rec,&rea2));
- RETURN(rec,rea1);
-}
-
-//--------------------------------------------------------------
-gfsmRegexAutomaton gfsm_regex_automaton_difference(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea1, gfsmRegexAutomaton rea2)
-{
- gfsm_automaton_difference(gfsm_regex_automaton_expand(rec,&rea1),gfsm_regex_automaton_expand(rec,&rea2));
- gfsm_automaton_free(gfsm_regex_automaton_expand(rec,&rea2));
- RETURN(rec,rea1);
-}
-
-//--------------------------------------------------------------
-/** Weight */
-gfsmRegexAutomaton gfsm_regex_automaton_weight(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea, gfsmWeight w)
-{
- gfsm_automaton_arith_final(gfsm_regex_automaton_expand(rec,&rea), gfsmAOSRTimes, w, FALSE);
- RETURN(rec,rea);
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.h b/gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.h
deleted file mode 100644
index aefc1cc..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/gfsmRegexCompiler-v1.h
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef _GFSM_REGEX_COMPILER_H
-#define _GFSM_REGEX_COMPILER_H
-
-#include <gfsmScanner.h>
-#include <gfsmAutomaton.h>
-#include <gfsmAlphabet.h>
-#include <gfsmAlgebra.h>
-
-/** Regex automaton type */
-typedef enum {
- gfsmREATEmpty, ///< empty acceptor
- gfsmREATLabel, ///< single label
- gfsmREATFull ///< full automaton
-} gfsmRegexAutomatonType;
-
-/** Regex automaton value */
-typedef union {
- gfsmLabelVal lab; ///< single label
- gfsmAutomaton *fsm; ///< full automaton
-} gfsmRegexAutomatonValue;
-
-/** Regex automaton */
-typedef struct {
- gfsmRegexAutomatonType typ; ///< regex type
- gfsmRegexAutomatonValue val; ///< regex value
-} gfsmRegexAutomaton;
-
-/** Data structure for regex compiler */
-typedef struct {
- gfsmScanner scanner; ///< scanner
- gfsmSRType srtype; ///< semiring type
- gfsmRegexAutomaton rea; ///< regex automaton under construction
- gfsmAlphabet *abet; ///< alphabet
- GString *gstr; ///< buffer
- gboolean is_label : 1; ///< is this a singleton fsm? (if so, *fsm is a gfsmLabelVal)
-} gfsmRegexCompiler;
-
-/** New full-fleded automaton */
-gfsmAutomaton *gfsm_regex_automaton_new_fsm(gfsmRegexCompiler *rec);
-
-/** Get full-fledged automaton */
-gfsmAutomaton *gfsm_regex_automaton_fsm(gfsmRegexCompiler *rec, gfsmRegexAutomaton rea);
-
-/** Full Epsilon recognizer */
-gfsmAutomaton *gfsm_regex_automaton_epsilon_fsm(gfsmRegexCompiler *rec);
-
-/** Full single-character recognizer */
-gfsmAutomaton *gfsm_regex_automaton_label_fsm(gfsmRegexCompiler *rec, gfsmLabelVal lab);
-
-
-/** Single-label recognizer */
-gfsmRegexAutomaton gfsm_regex_automaton_label(gfsmRegexCompiler *rec, gfsmLabelVal lab);
-
-/** Single-label concatenation (low-level) */
-gfsmAutomaton *gfsm_regex_automaton_append_lab(gfsmRegexCompiler *rec,
- gfsmAutomaton *fsm,
- gfsmLabelVal lab);
-
-/** General concatenation */
-gfsmRegexAutomaton gfsm_regex_automaton_concat(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmRegexAutomaton rea2);
-
-/** Closure */
-gfsmRegexAutomaton gfsm_regex_automaton_closure(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea,
- gboolean is_plus);
-
-/** Power (n-ary closure) */
-gfsmRegexAutomaton gfsm_regex_automaton_power(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea,
- guint32 n);
-
-/** Projection */
-gfsmRegexAutomaton gfsm_regex_automaton_project(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea,
- gfsmLabelSide which);
-
-
-/** Optionality */
-gfsmRegexAutomaton gfsm_regex_automaton_optional(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea);
-
-/** Complement */
-gfsmRegexAutomaton gfsm_regex_automaton_complement(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea);
-
-/** Union */
-gfsmRegexAutomaton gfsm_regex_automaton_union(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmRegexAutomaton rea2);
-
-/** Intersection */
-gfsmRegexAutomaton gfsm_regex_automaton_intersect(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmRegexAutomaton rea2);
-
-/** Product */
-gfsmRegexAutomaton gfsm_regex_automaton_product(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmRegexAutomaton rea2);
-
-/** Composition */
-gfsmRegexAutomaton gfsm_regex_automaton_compose(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmRegexAutomaton rea2);
-
-/** Difference */
-gfsmRegexAutomaton gfsm_regex_automaton_difference(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmRegexAutomaton rea2);
-
-/** Weight */
-gfsmRegexAutomaton gfsm_regex_automaton_weight(gfsmRegexCompiler *rec,
- gfsmRegexAutomaton rea1,
- gfsmWeight w);
-
-
-
-
-#endif /* _GFSM_REGEX_COMPILER_H */
diff --git a/gfsm/gfsm/src/libgfsm/tests/gfsmlabdump.c b/gfsm/gfsm/src/libgfsm/tests/gfsmlabdump.c
deleted file mode 100644
index 05916ac..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/gfsmlabdump.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <gfsm.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main (int argc, char **argv) {
- gfsmStringAlphabet *sa = (gfsmStringAlphabet*)gfsm_string_alphabet_new();
- gfsmAlphabet *a = (gfsmAlphabet*)sa;
- gfsmError *err = NULL;
- char *filename= NULL;
- gfsmLabelVal lv1,lv2;
- char *key;
-
- /*-- test: insert --*/
- printf("testing insert: ");
- lv1 = gfsm_alphabet_insert(a,"foo",gfsmNoLabel);
- printf("%s\n", lv1 != gfsmNoLabel ? "ok" : "FAILED");
-
- /*-- test: find --*/
- printf("testing find_label: ");
- lv2 = gfsm_alphabet_find_label(a,"foo");
- printf("%s\n", lv1==lv2 ? "ok" : "FAILED");
-
- /*-- test: find key --*/
- printf("testing find_key: ");
- key = gfsm_alphabet_find_key(a,lv1);
- printf("%s\n", key != NULL && strcmp(key,"foo")==0 ? "ok" : "FAILED");
-
- /*-- clear test --*/
- printf("testing clear: ");
- gfsm_alphabet_clear(a);
- printf("%s\n", gfsm_alphabet_size(a)==0 ? "ok" : "FAILED");
-
- /*-- load labels file --*/
- if (argc > 0) { filename=argv[1]; }
- else { filename="-"; }
- printf("\nLoading alphabet from file %s: ", argc==0 ? "(stdin)" : filename);
- if (!a || !gfsm_alphabet_load_filename(a, filename, &err)) {
- g_printerr("couldn't load labels from stdin: %s\n", err->message);
- exit(1);
- }
- printf("loaded.\n\n");
-
- /*-- get some basic information --*/
- printf("Basic Information:\n");
- printf(" + gfsmAlphabet:\n");
- printf(" type : %u (%s)\n", a->type,
- (a->type==gfsmATString ? "string keys" : "weird type: tell moocow"));
- printf(" lab_min: %u\n", a->lab_min);
- printf(" lab_max: %u\n", a->lab_max);
- printf(" + gfsmPointerAlphabet:\n");
- printf(" labels2keys: %p [size=%u]\n",
- sa->labels2keys, sa->labels2keys->len);
- printf(" keys2labels: %p [size=%u]\n",
- sa->keys2labels, g_hash_table_size(sa->keys2labels));
- printf(" keydupfunc : %p (%s)\n",
- sa->key_dup_func, (sa->key_dup_func == NULL
- ? "no key copying: tell moocow"
- : ((void*)sa->key_dup_func == (void*)gfsm_alphabet_strdup
- ? "keys are copied: ok"
- : "strangeness: tell moocow")));
-
-
- /*-- dump it --*/
- printf("\n--BEGIN dump--\n");
- if (!gfsm_alphabet_save_file(a,stdout,&err)) {
- g_printerr("couldn't save labels to stdout: %s\n", err->message);
- exit(1);
- }
- printf("--END dump--\n\n");
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/gscantest.c b/gfsm/gfsm/src/libgfsm/tests/gscantest.c
deleted file mode 100644
index 199c414..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/gscantest.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <gfsm.h>
-#include <glib.h>
-#include <stdlib.h>
-
-#undef VERBOSE
-
-int main (int argc, char **argv) {
- GScanner *scanner = g_scanner_new(&gfsm_automaton_scanner_config);
- GTokenType typ;
-
- scanner->input_name = *argv;
- g_scanner_input_file(scanner, fileno(stdin));
- while ((typ = g_scanner_get_next_token(scanner)) != G_TOKEN_EOF) {
-#ifdef VERBOSE
- switch (typ) {
- case G_TOKEN_INT:
- printf("INT %ld\n", scanner->value.v_int);
- break;
- case G_TOKEN_FLOAT:
- printf("FLOAT %g\n", scanner->value.v_float);
- break;
- case G_TOKEN_CHAR:
- if (scanner->value.v_char == '\n') printf ("CHAR '\\n'\n");
- else printf("CHAR '%c'\n", scanner->value.v_char);
- break;
- default:
- printf("? (typ=%d)\n", typ);
- break;
- }
-#else // !VERBOSE
- switch (typ) {
- case G_TOKEN_INT:
- printf("%ld\t", scanner->value.v_int);
- break;
- case G_TOKEN_FLOAT:
- printf("%g\t", scanner->value.v_float);
- break;
- case G_TOKEN_CHAR:
- if (scanner->value.v_char == '\n') fputc('\n',stdout);
- else exit(1);
- break;
- default:
- exit(1);
- break;
- }
-#endif // VERBOSE
- }
- g_scanner_destroy(scanner);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/intfloat.c b/gfsm/gfsm/src/libgfsm/tests/intfloat.c
deleted file mode 100644
index 098b860..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/intfloat.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <stdio.h>
-
-#define ptr2int(p) ((int)(p))
-#define int2ptr(i) ((void*)(i))
-#define ptr2float(p) (*((float*)(&(p))))
-#define int2float(i) (*((float*)(&(i))))
-
-#define float2int(f) (*((int*)(&(f))))
-#define float2ptr(f) (*((void**)(&(f))))
-
-int main(void) {
- float f = 42.24;
- int fi;
- void *fp;
- float fif, fpf;
-
- printf("f=%f\n", f);
- fi = float2int(f);
- printf("->fi=%d\n", fi);
-
- fif = int2float(fi);
- printf("-->fif=%f\n", fif);
-
- fp = float2ptr(f);
- printf("->fp=%p\n", fp);
-
- fpf=ptr2float(fp);
- printf("-->fpf=%f\n", fpf);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/iotest.c b/gfsm/gfsm/src/libgfsm/tests/iotest.c
deleted file mode 100644
index c218627..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/iotest.c
+++ /dev/null
@@ -1,180 +0,0 @@
-#include <glib.h>
-#include <gfsmIO.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/*---------------------------------------------------
- * generic test: output
- */
-void test_output_generic(gfsmIOHandle *io, const char *label)
-{
- gboolean rc;
- fprintf(stderr, "\n-------- I/O: %s: output\n", label);
-
- fprintf(stderr, "+ write(\"foo\\n\",4):\n");
- rc = gfsmio_write(io, "foo\n", 4);
- gfsmio_flush(io);
- fprintf(stderr, " --> %d\n", rc);
-
- fprintf(stderr, "+ puts(\"bar\\n\"):\n");
- rc = gfsmio_puts(io, "bar\n");
- gfsmio_flush(io);
- fprintf(stderr, " --> %d\n", rc);
-
- fprintf(stderr, "+ putc('x'); putc('\\n'):\n");
- rc = gfsmio_putc(io, 'x') && gfsmio_putc(io, '\n');
- gfsmio_flush(io);
- fprintf(stderr, " --> %d\n", rc);
-
- fprintf(stderr, "+ printf(\"%%s%%s\\n\",\"foo\",\"bar\"):\n");
- rc = gfsmio_printf(io, "%s%s\n", "foo", "bar");
- gfsmio_flush(io);
- fprintf(stderr, " --> %d\n", rc);
-}
-
-/*---------------------------------------------------
- * generic test: input
- */
-void test_input_generic(gfsmIOHandle *io, const char *label)
-{
- char buf[2];
- char *linebuf=NULL;
- size_t n=0;
- ssize_t nread=0;
- gboolean rc;
-
- fprintf(stderr, "\n-------- I/O: %s: input\n", label);
-
- fprintf(stderr, "+ read(2)\n");
- rc = gfsmio_read(io, buf, 2);
- fprintf(stderr, " --> %d ; buf=\"%c%c\"\n", rc, buf[0], buf[1]);
-
- fprintf(stderr, "+ getline()\n");
- while ( (nread=gfsmio_getline(io, &linebuf, &n)) > 0) {
- fprintf(stderr, " --> %d ; linebuf=\"%s\"\n", nread, linebuf);
- fprintf(stderr, "+ getline()\n");
- }
- fprintf(stderr, " --> %d ; linebuf=\"%s\"\n", nread, linebuf);
-
- if (linebuf) free(linebuf);
-}
-
-
-/*---------------------------------------------------
- * test: FILE*
- */
-void test_io_cfile(void) {
- gfsmIOHandle *ioh=NULL;
-
- //-- I/O to file: output
- ioh = gfsmio_new_file(stdout);
- test_output_generic(ioh, "FILE* (stdout)");
- gfsmio_handle_free(ioh);
-
- //-- I/O from file: input
- ioh = gfsmio_new_file(stdin);
- test_input_generic(ioh, "FILE* (stdin)");
- gfsmio_handle_free(ioh);
-}
-
-/*---------------------------------------------------
- * test: GString*
- */
-void test_io_gstring(void) {
- GString *gs = g_string_new("");
- gfsmPosGString pgs = { gs, 0 };
- gfsmIOHandle *ioh = NULL;
-
- //-- I/O to GString*: output
- ioh = gfsmio_new_gstring(&pgs);
- test_output_generic(ioh, "GString*");
- fprintf(stderr, "+ OUTPUT=\"%s\"\n", gs->str);
-
- //-- I/O from GString*: input
- pgs.pos = 0;
- /*
- g_string_assign(gs, "ab\ncde");
- test_input_generic(ioh, "GString* \"ab\\nc\")");
- */
- /*
- g_string_assign(gs, "a b c\nd e f");
- test_input_generic(ioh, "GString* \"a b c\\nd e f\")");
- */
- /*
- g_string_assign(gs, "abcde\nfghij\nklmnopqrstuvwxyz");
- test_input_generic(ioh, "GString* \"...\")");
- */
- g_string_assign(gs, "abc\n\ndef\n");
- test_input_generic(ioh, "GString* \"...\")");
-
-
- gfsmio_handle_free(ioh);
- g_string_free(gs,TRUE);
-}
-
-/*---------------------------------------------------
- * test: gzFile
- */
-void test_io_zfile(void) {
- gfsmIOHandle *ioh=NULL;
- gfsmError *err=NULL;
-
- //-- I/O to gzGile: output
- ioh = gfsmio_new_filename("iotest-out.gz", "wb", 0, &err);
- test_output_generic(ioh, "gzFile (iotest-out.gz)");
- gfsmio_close(ioh);
- gfsmio_handle_free(ioh);
-
- //-- I/O from gzFile: input
- ioh = gfsmio_new_filename("iotest-in.gz", "rb", -1, &err);
- test_input_generic(ioh, "gzFile (iotest-in.gz)");
- gfsmio_close(ioh);
- gfsmio_handle_free(ioh);
-}
-
-/*---------------------------------------------------
- * test: gzFile from FILE*
- */
-void test_io_zcfile(void) {
- gfsmIOHandle *ioh=NULL;
- int zlevel = -1;
-
- //-- I/O to gzGile: output
- ioh = gfsmio_new_zfile(stdout, "wb", zlevel);
- test_output_generic(ioh, "gzFile(fileno(stdout))");
- gfsmio_close(ioh);
- gfsmio_handle_free(ioh);
-
- //-- I/O from gzFile: input
- ioh = gfsmio_new_zfile(stdin, "rb", zlevel);
- test_input_generic(ioh, "gzFile(fileno(stdin))");
- gfsmio_close(ioh);
- gfsmio_handle_free(ioh);
-}
-
-
-/*---------------------------------------------------
- * MAIN
- */
-int main (void) {
- /*
- fprintf(stderr, "\n=================================\n");
- test_io_cfile();
- */
-
- /*
- fprintf(stderr, "\n=================================\n");
- test_io_gstring();
- */
-
- /*
- fprintf(stderr, "\n=================================\n");
- test_io_zfile();
- */
-
- fprintf(stderr, "\n=================================\n");
- test_io_zcfile();
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/lab2ary.c b/gfsm/gfsm/src/libgfsm/tests/lab2ary.c
deleted file mode 100644
index e6dbee9..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/lab2ary.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <gfsm.h>
-#include <stdlib.h>
-
-
-gfsmAutomaton *fsm;
-gfsmAlphabet *ialph;
-const char *tfstname = "lab2ary.tfst";
-gfsmError *err = NULL;
-
-
-int main (int argc, char **argv) {
- guint i;
- ialph = gfsm_identity_alphabet_new();
- //GArray *ary;
- GPtrArray *ary;
-
- fsm = gfsm_automaton_new();
- if (!gfsm_automaton_compile_filename(fsm,tfstname,&err)) {
- g_printerr("%s: compile failed for '%s': %s\n", *argv, tfstname, err->message);
- exit(255);
- }
- printf("%s: compiled test automaton from '%s'\n", *argv, tfstname);
-
- ialph = gfsm_automaton_get_alphabet(fsm, gfsmLSLower, ialph);
-
- printf("--\n");
- printf("alphabet size=%u ; min=%u ; max=%u\n",
- gfsm_alphabet_size(ialph), ialph->lab_min, ialph->lab_max);
-
- printf("--\n");
- printf("alphabet array={");
- /*-- ok
- ary = g_array_new(FALSE,FALSE,sizeof(gfsmLabelVal));
- gfsm_alphabet_labels_to_array(ialph,ary);
- */
- /*-- ok
- ary = g_array_sized_new(FALSE,FALSE,sizeof(gfsmLabelVal),gfsm_alphabet_size(ialph));
- gfsm_alphabet_labels_to_array(ialph,ary);
- */
- /*-- ok */
- //ary = gfsm_alphabet_labels_to_array(ialph,NULL);
-
- /*-- ptr_array */
- ary = g_ptr_array_sized_new(gfsm_alphabet_size(ialph));
- gfsm_alphabet_labels_to_array(ialph,ary);
-
- for (i=0; i < ary->len; i++) {
- //printf(" %u", g_array_index(ary,gfsmLabelVal,i));
- printf(" %u", (gfsmLabelVal)g_ptr_array_index(ary,i));
- }
- printf(" }\n");
-
- //-- cleanup
- //g_array_free(ary,TRUE);
- g_ptr_array_free(ary,TRUE);
-
- gfsm_automaton_free(fsm);
- gfsm_alphabet_free(ialph);
-
- return 0;
-}
-
diff --git a/gfsm/gfsm/src/libgfsm/tests/labchurn.c b/gfsm/gfsm/src/libgfsm/tests/labchurn.c
deleted file mode 100644
index b8f0a99..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/labchurn.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <gfsm.h>
-
-gfsmAlphabet *alph;
-
-int main (int argc, char **argv)
-{
- char *infilename = (argc > 1 ? argv[1] : "-");
-
- g_mem_set_vtable(glib_mem_profiler_table);
-
- alph = gfsm_string_alphabet_new();
- //g_mem_profile();
-
- gfsm_alphabet_load_filename(alph,infilename,NULL);
- //gfsm_alphabet_save_file(alph,stdout,NULL);
-
-
- gfsm_alphabet_free(alph);
-
- g_blow_chunks();
- g_mem_profile();
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/labcount.perl b/gfsm/gfsm/src/libgfsm/tests/labcount.perl
deleted file mode 100755
index 4086797..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/labcount.perl
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl -w
-
-use Gfsm;
-
-if (!@ARGV) {
- print STDERR "Usage: $0 LABFILE [DATA_FILE(s)...]\n";
- exit 1;
-}
-
-$labfile = shift;
-$labs = Gfsm::Alphabet->new();
-$labs->load($labfile) or die("$0: load failed for labels file '$labfile': $!");
-$sym2id = $labs->asHash;
-
-##-- read data
-%labf = qw();
-$ftotal = 0;
-while (defined($line=<>)) {
- chomp($line);
- @labs = grep {defined($_)} @$sym2id{split(//,$line)};
- $ftotal += scalar(@labs);
- foreach (@labs) { ++$labf{$_}; }
-}
-
-##-- write data vector
-#print map { pack('d', (defined($_) ? $_ : 0)/$ftotal) } @labf;
-
-print map {pack('Sd',$_,$labf{$_}/$ftotal)} sort(keys(%labf));
diff --git a/gfsm/gfsm/src/libgfsm/tests/labprobs.h b/gfsm/gfsm/src/libgfsm/tests/labprobs.h
deleted file mode 100644
index d8589d0..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/labprobs.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <gfsm.h>
-
-guint32 grand_seed = 42;
-const char *probfile = "tagh-probs.bin";
-
-extern gulong count_test;
-GArray *seekus = NULL; /*-- lab = g_array_index(seekus,i); 1<=i<=count_test --*/
-
-typedef struct {
- gfsmLabelId lab;
- double prob;
-} seekProb;
-GArray *labp=NULL; /*-- g_array_index(probs,seekProb,i) = (lab,p(lab)) --*/
-
-GRand *grand=NULL;
-
-/*======================================================================
- * load_label_probs()
- */
-void load_label_probs(void) {
- seekProb sp;
- double total=0, tmp;
- FILE *f = fopen(probfile,"r");
- if (!f) {
- fprintf(stderr, "error: open failed for probability file '%s'\n", probfile);
- exit(1);
- }
- labp = g_array_sized_new(FALSE,TRUE,sizeof(seekProb),256);
- labp->len = 0;
- while ( !feof(f) ) {
- if (fread(&(sp.lab), sizeof(gfsmLabelId), 1, f) != 1
- || fread(&(sp.prob), sizeof(double), 1, f) != 1)
- {
- break;
- }
- tmp = sp.prob;
- sp.prob += total;
- total += tmp;
- g_array_append_val(labp,sp);
-
- }
- fclose(f);
- fprintf(stderr, "[info]: read probability distribution over %d labels from '%s'\n",
- labp->len, probfile);
-}
-
-/*======================================================================
- * random_label()
- */
-gfsmLabelId random_label(void) {
- double w;
- int i;
- if (!grand) { grand = g_rand_new_with_seed(grand_seed); }
- w = g_rand_double(grand);
- for (i=0; i < labp->len && w > g_array_index(labp,seekProb,i).prob; i++) { ; }
- if (i==labp->len) { --i; }
- return g_array_index(labp,seekProb,i).lab;
-}
-
-/*======================================================================
- * populate_seek_labels()
- */
-void populate_seek_labels(void) {
- int i;
- gfsmLabelId lab;
- seekus = g_array_sized_new(FALSE,TRUE,sizeof(gfsmLabelId),count_test);
- for (i=0; i < count_test; i++) {
- lab = random_label();
- g_array_append_val(seekus,lab);
- }
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/lkptest.tfst b/gfsm/gfsm/src/libgfsm/tests/lkptest.tfst
deleted file mode 100644
index 11f371e..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/lkptest.tfst
+++ /dev/null
@@ -1,8 +0,0 @@
-0 0 1 2 1
-0 0 2 3 1
-0 0 3 1 1
-0 1 2 2 1
-0 0
-1 2 2 2 1
-2 3 3 3 1
-3 0
diff --git a/gfsm/gfsm/src/libgfsm/tests/macrotest.i b/gfsm/gfsm/src/libgfsm/tests/macrotest.i
deleted file mode 100644
index e540e43..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/macrotest.i
+++ /dev/null
@@ -1,11 +0,0 @@
-#define _gfsm_bitvector_bits2bytes(nbits) ((nbits)>0 ? ((((nbits)-1)/8)+1) : 1)
-
-#define gfsm_bitvector_set(bv,i,v) \
- ( (i >= gfsm_bitvector_size(bv) ? gfsm_bitvector_resize(bv,i) : 0), \
- (v ? ( (bv)->data[ _gfsm_bitvector_bits2bytes(i)-1 ] |= (1<<((i)%8)) ) \
- : ( (bv)->data[ _gfsm_bitvector_bits2bytes(i)-1 ] &= ~(1<<((i)%8)) ) ) )
-
-bits2bytes: _gfsm_bitvector_bits2bytes(MyBit)
-
-set: gfsm_bitvector_set(MyVector,MyBit,MyValue)
-
diff --git a/gfsm/gfsm/src/libgfsm/tests/memtest-alphabet.c b/gfsm/gfsm/src/libgfsm/tests/memtest-alphabet.c
deleted file mode 100644
index edb1492..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/memtest-alphabet.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <glib.h>
-#include <gfsmAlphabet.h>
-
-void dofree (gpointer p) { g_free(p); }
-
-int main (void) {
- gfsmAlphabet *a;
- g_mem_set_vtable(glib_mem_profiler_table);
-
- //a = (gfsmAlphabet*)g_new0(gfsmPointerAlphabet,1);
- a = gfsm_string_alphabet_new();
-
- gfsm_alphabet_insert(a,"foo",42);
-
- gfsm_alphabet_free(a);
-
- printf("<CHUNKS:1>--------\n");
- //g_mem_chunk_info();
-
-
-
- printf("<PROF:1>--------\n");
- g_mem_profile();
- g_blow_chunks();
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/memtest-automaton.c b/gfsm/gfsm/src/libgfsm/tests/memtest-automaton.c
deleted file mode 100644
index ace1fbd..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/memtest-automaton.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <glib.h>
-#include <gfsm.h>
-
-void dofree (gpointer p) { g_free(p); }
-
-int main (void) {
- gfsmAutomaton *fsm;
- g_mem_set_vtable(glib_mem_profiler_table);
-
- fsm = gfsm_automaton_new();
- gfsm_automaton_free(fsm);
-
- //printf("<CHUNKS:1>--------\n");
- //g_mem_chunk_info();
-
- printf("<PROF:1>--------\n");
- g_blow_chunks();
- g_mem_profile();
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/memtest-general.c b/gfsm/gfsm/src/libgfsm/tests/memtest-general.c
deleted file mode 100644
index 50fe42f..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/memtest-general.c
+++ /dev/null
@@ -1,168 +0,0 @@
-#include <gfsm.h>
-#include <glib.h>
-
-#define VTABLE_PROFILE 1
-//#define VTABLE_LOCAL 1
-
-
-//#define USE_ALLOCATORS 1
-//#define DELAY_ALLOCATOR_FREE 1
-
-
-//#define NITEMS 0
-//#define NITEMS 1
-//#define NITEMS 10
-#define NITEMS 128
-//#define NITEMS 256
-//#define NITEMS 1024
-//#define NITEMS 65536
-//#define NITEMS 131072
-//#define NITEMS 262144
-//#define NITEMS 524288
-//#define NITEMS 1048576
-
-
-//#define NITERS
-//#define NITERS 1
-//#define NITERS 10
-#define NITERS 128
-//#define NITERS 1024
-//#define NITERS 65536
-//#define NITERS 131072
-//#define NITERS 262144
-//#define NITERS 524288
-//#define NITERS 1048576
-
-//#define PRINT_CHUNK_INFO 1
-//#define DO_PROFILE 1
-
-#define DO_GMALLOC 1
-#define GMALLOC_SIZE 45
-
-#define DO_GNEW 1
-#define GNEW_SIZE 70
-
-#define DO_SLIST 1
-
-#define DO_PTRARRAY 1
-#define PTRARRAY_SIZE 128
-
-
-/*--------------------------------------------------------------------
- * mem table
- */
-gpointer my_malloc(gsize n_bytes)
-{ return (gpointer)malloc(n_bytes); }
-
-gpointer my_realloc(gpointer mem, gsize n_bytes)
-{ return (gpointer)realloc(mem, n_bytes); }
-
-void my_free(gpointer mem)
-{ free(mem); }
-
-GMemVTable my_vtable =
- {
- my_malloc,
- my_realloc,
- my_free,
- NULL,
- NULL,
- NULL
- };
-
-/*--------------------------------------------------------------------
- * operation macro
- */
-#define MEMOP(code) \
- printf("%s\n", #code); \
- code;
-
-#define ITEMOP(code) \
- for (i=0; i<NITEMS; i++) { code; }
-
-/*--------------------------------------------------------------------
- * variables
- */
-gpointer mallocp[NITERS];
-gpointer newp[NITERS];
-GSList *slist[NITERS];
-GPtrArray *ptrarray[NITERS];
-
-/*--------------------------------------------------------------------
- * MAIN
- */
-int main(int argc, char **argv) {
- int i,j;
-
-
- //-- memory debugging
-#if defined(VTABLE_PROFILE)
- g_mem_set_vtable(glib_mem_profiler_table);
-#elif defined(VTABLE_LOCAL)
- g_mem_set_vtable(&my_vtable);
-#endif
-
- //-- setup gfsm allocators
-#if defined(USE_ALLOCATORS)
- MEMOP(gfsm_allocators_enable());
-#endif
-
-
- //--------------- iteration
- for (j=0; j < NITERS; j++) {
- //-- alloc
-# ifdef DO_GMALLOC
- ITEMOP(mallocp[i]=g_malloc(GMALLOC_SIZE));
-# endif
-# ifdef DO_GNEW
- ITEMOP(newp[i]=g_new(char,GNEW_SIZE));
-# endif
-# ifdef DO_SLIST
- ITEMOP(slist[i]=g_slist_prepend(NULL,NULL));
-# endif
-# ifdef DO_PTRARRAY
- ITEMOP(ptrarray[i]=g_ptr_array_sized_new(PTRARRAY_SIZE));
-# endif
-
- //-- free
-# ifdef DO_GMALLOC
- ITEMOP(g_free(mallocp[i]));
-# endif
-# ifdef DO_GNEW
- ITEMOP(g_free(newp[i]));
-# endif
-# ifdef DO_SLIST
- ITEMOP(g_slist_free(slist[i]));
-# endif
-# ifdef DO_PTRARRAY
- ITEMOP(g_ptr_array_free(ptrarray[i],TRUE));
-# endif
- }
-
-
- //-- pop gfsm allocators
-#if defined(USE_ALLOCATORS) && !defined(DELAY_ALLOCATOR_FREE)
- MEMOP(gfsm_allocators_free());
-#endif
-
- //-- memory debugging
-#if defined(PRINT_CHUNK_INFO) && defined(VTABLE_PROFILE)
- printf("\n<CHUNKS:1>--------\n");
- g_blow_chunks();
- g_mem_chunk_info();
-#endif
- //
-#ifdef VTABLE_PROFILE
- printf("\n<PROF:1>--------\n");
- g_blow_chunks();
- g_mem_profile();
-#endif
-
- g_blow_chunks();
-
-#if defined(USE_ALLOCATORS) && defined(DELAY_ALLOCATOR_FREE)
- MEMOP(gfsm_allocators_free());
-#endif
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/memtest.c b/gfsm/gfsm/src/libgfsm/tests/memtest.c
deleted file mode 100644
index edb1492..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/memtest.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <glib.h>
-#include <gfsmAlphabet.h>
-
-void dofree (gpointer p) { g_free(p); }
-
-int main (void) {
- gfsmAlphabet *a;
- g_mem_set_vtable(glib_mem_profiler_table);
-
- //a = (gfsmAlphabet*)g_new0(gfsmPointerAlphabet,1);
- a = gfsm_string_alphabet_new();
-
- gfsm_alphabet_insert(a,"foo",42);
-
- gfsm_alphabet_free(a);
-
- printf("<CHUNKS:1>--------\n");
- //g_mem_chunk_info();
-
-
-
- printf("<PROF:1>--------\n");
- g_mem_profile();
- g_blow_chunks();
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/module/.cvsignore b/gfsm/gfsm/src/libgfsm/tests/module/.cvsignore
deleted file mode 100644
index 58d248b..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/module/.cvsignore
+++ /dev/null
@@ -1,18 +0,0 @@
-*~
-.*~
-
-*.gfst
-*.output
-*.lex.c
-*.lex.h
-*.tab.c
-*.tab.h
-*.gz
-*.so
-*.o
-
-tagh*
-*.dat
-negra*
-
-mod1test
diff --git a/gfsm/gfsm/src/libgfsm/tests/module/Makefile b/gfsm/gfsm/src/libgfsm/tests/module/Makefile
deleted file mode 100644
index c310837..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/module/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-TARGETS = mod1test libmod1a.so libmod1b.so
-KNOWN_TARGETS = mod1test libmod1a.so libmod1b.so
-
-CC = gcc
-#CC = ccmalloc --no-wrapper gcc
-LD = $(CC)
-
-CPPFLAGS = $(shell pkg-config --cflags-only-I gmodule-2.0)
-#CFLAGS ?= -O2 -pipe
-#CFLAGS ?= -Wall -g
-#CFLAGS += -Wall -g
-CFLAGS ?= -g
-CFLAGS += -Wall -fPIC -DPIC
-
-LDFLAGS = $(shell pkg-config --libs-only-L gmodule-2.0)
-LIBS = $(shell pkg-config --libs-only-l gmodule-2.0) -lm
-
-LDFLAGS_MODULE = -shared $(LDFLAGS)
-
-all: $(TARGETS)
-
-##-- keep intermediate files
-.SECONDARY:
-
-##-- PATTERN: .c -> .o
-%.o: %.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
-
-##-- clean
-clean:
- rm -f *.o *.lo *.tab.[ch] *.lex.[ch] $(KNOWN_TARGETS)
-
-##-- modules
-lib%.so: %.o
- $(LD) $(LDFLAGS_MODULE) -o $@ $^ $(LIBS)
-
-##-- Executables
-%test: %test.o
- $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
diff --git a/gfsm/gfsm/src/libgfsm/tests/module/mod1a.c b/gfsm/gfsm/src/libgfsm/tests/module/mod1a.c
deleted file mode 100644
index 69674c5..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/module/mod1a.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdio.h>
-
-void foo(void) {
- printf("mod1a:foo() called.\n");
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/module/mod1b.c b/gfsm/gfsm/src/libgfsm/tests/module/mod1b.c
deleted file mode 100644
index 4705f7c..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/module/mod1b.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdio.h>
-
-void foo(void) {
- printf("mod1b:foo() called.\n");
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/module/mod1test.c b/gfsm/gfsm/src/libgfsm/tests/module/mod1test.c
deleted file mode 100644
index 6389972..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/module/mod1test.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdio.h>
-#include <glib.h>
-#include <gmodule.h>
-
-typedef void (*fooFunc) (void);
-
-int main(int argc, char **argv) {
- int i;
- const gchar *prog = argv[0];
- //const gchar *moddir = g_getenv("PWD"); //-- get module directory (hack)
- const gchar *moddir = ".";
- gchar *modpath;
- GModule *mod;
- fooFunc foofunc;
-
- g_assert(g_module_supported());
-
- for (i=1; i < argc; i++) {
- //-- build full module pathname
- modpath = g_module_build_path(moddir,argv[i]);
- printf("%s: argv[%d]='%s': moddir='%s', modpath='%s'\n", prog, i, moddir, argv[i], modpath);
- //--
- //modpath = argv[i];
- //printf("%s: argv[%d]='%s': modfile='%s'\n", prog, i, argv[i], modpath);
-
- //-- open module
- if ( !(mod = g_module_open(modpath,G_MODULE_BIND_LOCAL)) ) {
- g_printerr("%s: could not load module '%s': %s - skipping\n", prog, modpath, g_module_error());
- if (modpath != argv[i]) g_free(modpath);
- continue;
- }
- printf("-> open(): %p\n", mod);
-
- //-- get symbol 'foo' from module
- if (!g_module_symbol(mod,"foo",(gpointer *)&foofunc)) {
- g_printerr("%s: could not load symbol 'foo' from module '%s': %s\n", prog, modpath, g_module_error());
- g_module_close(mod);
- if (modpath != argv[i]) g_free(modpath);
- continue;
- }
- printf("-> symbol('foo'): %p\n", foofunc);
-
- //-- call 'foo' as a foofunc
- printf("-> calling foo(): ");
- foofunc();
-
- //-- cleanup
- if (modpath != argv[i]) g_free(modpath);
- g_module_close(mod);
- }
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/nofinal.tfst b/gfsm/gfsm/src/libgfsm/tests/nofinal.tfst
deleted file mode 100644
index ab866fa..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/nofinal.tfst
+++ /dev/null
@@ -1 +0,0 @@
-0 0 1 1
diff --git a/gfsm/gfsm/src/libgfsm/tests/offsettest.c b/gfsm/gfsm/src/libgfsm/tests/offsettest.c
deleted file mode 100644
index bec8e8f..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/offsettest.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include <gfsm.h>
-#include <glib.h>
-#include <stdio.h>
-
-static const gulong count_test
-//= 1048576UL //== 2^20
-//= 16777216UL //== 2^24
-//= 33554432UL //==2^25
-= 268435456UL //==2^28
-//= 4294967295UL //== 2^32-1
-;
-
-//======================================================================
-// Basic bench subs
-
-inline gfsmLabelId get_lower(gfsmArc *a) { return a->lower; }
-inline gfsmLabelId get_upper(gfsmArc *a) { return a->upper; }
-inline gfsmLabelId get_label_offset(gfsmArc *a, gint offset) {
- return *((gfsmLabelId*)G_STRUCT_MEMBER_P(&a,offset));
-}
-
-//======================================================================
-// Bench: literal: lower
-
-double bench_literal_lower(gfsmArc *a) {
- gfsmLabelId l;
- GTimer *timer = g_timer_new();
- gulong i;
- double elapsed;
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- l = get_lower(a);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
- g_timer_destroy(timer);
- return elapsed;
-}
-
-//======================================================================
-// Bench: offset
-
-double bench_offset(gfsmArc *a, gint lab_offset) {
- gfsmLabelId l;
- GTimer *timer = g_timer_new();
- gulong i;
- double elapsed;
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- l = get_label_offset(a,lab_offset);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
- g_timer_destroy(timer);
- return elapsed;
-}
-
-//======================================================================
-// Bench: offset: lower
-
-#define bench_offset_lower(a) bench_offset((a),G_STRUCT_OFFSET(gfsmArc, lower))
-
-
-//======================================================================
-// MAIN
-int main(int argc, char **argv) {
- gfsmArc a = {0,1,2,3,4.5};
- double elapsed_literal, elapsed_offset, count_dbl=count_test;
-
- printf("G_STRUCT_OFFSET(gfsmArc, lower)=%d: *()=%d\n",
- G_STRUCT_OFFSET(gfsmArc, lower),
- *((gfsmLabelId*)G_STRUCT_MEMBER_P(&a,G_STRUCT_OFFSET(gfsmArc, lower)))
- );
-
- printf("G_STRUCT_OFFSET(gfsmArc, upper)=%d: *()=%d\n",
- G_STRUCT_OFFSET(gfsmArc, upper),
- *((gfsmLabelId*)G_STRUCT_MEMBER_P(&a,G_STRUCT_OFFSET(gfsmArc, upper)))
- );
-
- printf("G_STRUCT_OFFSET(gfsmArc, weight)=%d: *()=%g\n",
- G_STRUCT_OFFSET(gfsmArc, weight),
- *((gfsmWeight*)G_STRUCT_MEMBER_P(&a,G_STRUCT_OFFSET(gfsmArc, weight)))
- );
-
- //-- bench
- elapsed_literal = bench_literal_lower(&a);
- elapsed_literal = bench_literal_lower(&a);
- //
- elapsed_offset = bench_offset_lower(&a);
- elapsed_offset = bench_offset_lower(&a);
- //
- //
- fprintf(stderr, "%16s: %.2f sec, %ld iters, %.2e iter/sec\n",
- "literal", elapsed_literal, count_test, count_dbl/elapsed_literal);
- fprintf(stderr, "%16s: %.2f sec, %ld iters, %.2e iter/sec\n",
- "offset", elapsed_offset, count_test, count_dbl/elapsed_offset);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/ortest.c b/gfsm/gfsm/src/libgfsm/tests/ortest.c
deleted file mode 100644
index 8327e0b..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/ortest.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-int main(void) {
- int x=0, y=-1;
- int z = x||y;
- printf("x||y=%d\n", z);
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/pathtest.c b/gfsm/gfsm/src/libgfsm/tests/pathtest.c
deleted file mode 100644
index 86a3ad3..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/pathtest.c
+++ /dev/null
@@ -1,289 +0,0 @@
-#include <gfsm.h>
-
-
-//#define USE_VTABLE 1
-//#define USE_ALLOCATORS 1
-//#define DELAY_ALLOCATOR_FREE 1
-
-#define NEW_FST 1
-
-//#define MAKE_SLIST 1
-//#define MAKE_LIST 1
-//#define MAKE_FST 1
-//#define COMPILE_FST 1
-#define LOAD_FST 1
-//#define LOAD_EMPTY
-//#define LOAD_NOFINAL
-
-#define LOAD_NITERS 1
-//#define LOAD_NITERS 10
-//#define LOAD_NITERS 32768
-//#define LOAD_NITERS 65535
-//#define LOAD_NITERS 131072
-//#define LOAD_NITERS 262144
-//#define LOAD_NITERS 524288
-//#define LOAD_NITERS 1048576
-
-
-#define NEW_ABET 1
-#define LOAD_ABET 1
-
-//#define DO_INPUT 1
-//#define DO_LOOKUP 1
-//#define DO_PATHS 1
-//#define DO_STRINGS 1
-//#define DO_PTRARRAY 1
-
-#define NITERS 0
-//#define NITERS 1
-//#define NITERS 10
-//#define NITERS 1024
-//#define NITERS 65536
-//#define NITERS 131072
-//#define NITERS 262144
-//#define NITERS 524288
-//#define NITERS 1048576
-
-//#define PRINT_CHUNK_INFO 1
-//#define DO_PROFILE 1
-
-const char *progname = "pathtest";
-const char *labfile = "test.lab";
-
-#if defined(LOAD_EMPTY)
-const char *fstfile = "empty.gfst";
-const char *tfstfile = "empty.tfst";
-#elif defined(LOAD_NOFINAL)
-const char *fstfile = "nofinal.gfst";
-const char *tfstfile = "nofinal.tfst";
-#else
-const char *fstfile = "lkptest.gfst";
-const char *tfstfile = "lkptest.tfst";
-#endif
-
-
-gfsmLabelVector *input = NULL;
-gfsmAlphabet *abet = NULL;
-gfsmAutomaton *fst = NULL;
-gfsmAutomaton *result = NULL;
-gfsmSet *paths = NULL;
-GSList *strings = NULL;
-GPtrArray *ptrarray = NULL;
-gfsmError *err = NULL;
-GSList *sltmp = NULL;
-gfsmState *st = NULL;
-gfsmArc *arc=NULL;
-gfsmArcList *al=NULL;
-char line[256];
-
-
-gpointer my_malloc(gsize n_bytes)
-{
- return (gpointer)malloc(n_bytes);
-}
-
-gpointer my_realloc(gpointer mem, gsize n_bytes)
-{
- return (gpointer)realloc(mem, n_bytes);
-}
-
-void my_free(gpointer mem)
-{
- free(mem);
-}
-
-GMemVTable my_vtable =
- {
- my_malloc,
- my_realloc,
- my_free,
- NULL,
- NULL,
- NULL
- };
-
-#define MEMOP(code) \
- fprintf(stderr,"%s\n", #code); \
- code;
-
-int main(int argc, char **argv) {
- int i;
-
- //-- memory debugging
-#if defined(DO_PROFILE)
- g_mem_set_vtable(glib_mem_profiler_table);
-#elif defined(USE_VTABLE)
- g_mem_set_vtable(&my_vtable);
-#endif
-
- //-- setup gfsm allocators
-#if defined(USE_ALLOCATORS)
- MEMOP(gfsm_allocators_enable());
-#endif
-
- //-- load or make fst
-#ifdef NEW_FST
- MEMOP(fst = gfsm_automaton_new(););
-
-#if defined(MAKE_SLIST)
- //-- this is the culprit!
- MEMOP(al = g_slist_prepend(NULL,NULL));
- MEMOP(g_slist_free(al));
-#elif defined(MAKE_LIST)
- {
- GList *l=NULL;
- MEMOP(l=g_list_prepend(NULL,NULL));
- MEMOP(g_list_free(l));
- }
-#elif defined(MAKE_FST)
- MEMOP(st = gfsm_automaton_get_state(fst,0)); //-- ok
- MEMOP(gfsm_automaton_set_final_state(fst, 0, TRUE)); //-- ok
-
- MEMOP(gfsm_automaton_add_arc(fst,0,0,1,1,0)); //-- NOT ok!
-
- //-- alloc
- //MEMOP(arc=gfsm_arc_new_full(0,1,1,0)); //--ok
- //MEMOP(st->arcs = g_slist_prepend((gpointer)arc,st->arcs)); //-- ok w/ allocator
-
- //-- free
- //MEMOP(g_slist_free(st->arcs); st->arcs=NULL;); //-- ok w/ allocator
- //MEMOP(gfsm_arc_free(arc)); //-- /ok
-
-#elif defined(COMPILE_FST)
- fprintf(stderr,"gfsm_automaton_compile_filename(\"%s\");\n", tfstfile);
- if (!gfsm_automaton_compile_filename(fst,tfstfile,&err)) {
- fprintf(stderr,"%s: compile failed for '%s': %s\n", progname, tfstfile, (err ? err->message : "?"));
- exit(3);
- }
- //g_mem_profile();
-#elif defined(LOAD_FST)
- fprintf(stderr,"gfsm_automaton_load_bin_filename(\"%s\"); //---[x %d]---\n", fstfile, LOAD_NITERS);
- for (i=0; i < LOAD_NITERS; i++) {
- if (fst) gfsm_automaton_free(fst);
- fst = gfsm_automaton_new();
- if (!gfsm_automaton_load_bin_filename(fst,fstfile,&err)) {
- fprintf(stderr,"%s: load failed for '%s': %s\n", progname, fstfile, (err ? err->message : "?"));
- exit(3);
- }
- g_blow_chunks();
- }
- //g_mem_profile();
-#endif // make or load FST
-#endif // NEW_FST
-
- //-- load labels
-#ifdef NEW_ABET
- MEMOP(abet = gfsm_string_alphabet_new(););
-#ifdef LOAD_ABET
- fprintf(stderr,"gfsm_alphabet_load_filename(\"%s\");\n", labfile);
- if (!gfsm_alphabet_load_filename(abet,labfile,&err)) {
- fprintf(stderr,"%s: load failed for labels file '%s': %s\n",
- progname, labfile, (err ? err->message : "?"));
- exit(2);
- }
- //g_mem_profile();
-#endif //-- LOAD_ABET
-#endif //-- NEW_ABET
-
- //-- setup input vector
-#ifdef DO_INPUT
- MEMOP(input = g_ptr_array_new());
- MEMOP(g_ptr_array_add(input,(gpointer)2));
- MEMOP(g_ptr_array_add(input,(gpointer)2));
- MEMOP(g_ptr_array_add(input,(gpointer)3));
-#endif //-- DEFINE_INPUT
-
- //-- guts
- fprintf(stderr, "\n--bench[%d] :lookup=%d, paths=%d, strings=%d, ptrarray=%d--\n\n",
- NITERS,
-#ifdef DO_LOOKUP
- 1
-#else
- 0
-#endif
- ,
-#ifdef DO_PATHS
- 1
-#else
- 0
-#endif
- ,
-#ifdef DO_STRINGS
- 1
-#else
- 0
-#endif
- ,
-#ifdef DO_PTRARRAY
- 1
-#else
- 0
-#endif
- );
-
- for (i=0; i < NITERS; i++) {
-#ifdef DO_LOOKUP
- result = gfsm_automaton_lookup(fst, input, result);
-#endif
-#ifdef DO_PATHS
- paths = gfsm_automaton_paths(result,paths);
-#endif
-#ifdef DO_STRINGS
- strings = gfsm_paths_to_strings(paths, abet, NULL, fst->sr, TRUE, TRUE, strings);
-#endif
-#ifdef DO_PTRARRAY
- ptrarray=g_ptr_array_sized_new(gfsm_set_size(paths));
- gfsm_set_to_ptr_array(paths, ptrarray);
-#endif
-
- //-- cleanup
- for (sltmp=strings; sltmp; sltmp=sltmp->next) { g_free(sltmp->data); }
- if (ptrarray) g_ptr_array_free(ptrarray,TRUE);
- if (strings) g_slist_free(strings);
- if (paths) gfsm_set_clear(paths);
- g_blow_chunks();
- }
-
- //-- pop gfsm allocators (too early: segfaults)
- /*
-#if defined(USE_ALLOCATORS) && !defined(DELAY_ALLOCATOR_FREE)
- MEMOP(gfsm_allocators_disable());
-#endif
- */
-
- //-- cleanup
- if (result) { MEMOP(gfsm_automaton_free(result)); }
- if (paths) { MEMOP(gfsm_set_free(paths)); }
- if (input) { MEMOP(g_ptr_array_free(input,TRUE)); }
- if (fst) { MEMOP(gfsm_automaton_free(fst)); }
- if (abet) { MEMOP(gfsm_alphabet_free(abet);); }
-
- //-- pop gfsm allocators
-#if defined(USE_ALLOCATORS) && !defined(DELAY_ALLOCATOR_FREE)
- MEMOP(gfsm_allocators_free());
-#endif
-
- //-- memory debugging
-#ifdef PRINT_CHUNK_INFO
- printf("\n<CHUNKS:1>--------\n");
- g_blow_chunks();
- g_mem_chunk_info();
-#endif
- //
-#ifdef DO_PROFILE
- printf("\n<PROF:1>--------\n");
- g_blow_chunks();
- g_mem_profile();
-#endif
-
-#if defined(USE_ALLOCATORS) && defined(DELAY_ALLOCATOR_FREE)
- MEMOP(gfsm_allocators_free());
-#endif
-
- {
- printf("OK to exit? ");
- scanf("%s", &line);
- }
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/pathtest.tfst b/gfsm/gfsm/src/libgfsm/tests/pathtest.tfst
deleted file mode 100644
index fd189c5..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/pathtest.tfst
+++ /dev/null
@@ -1,9 +0,0 @@
-0 2 3 3 1
-0 1 2 2 1
-1 6 2 2 1
-2 4 3 3 1
-2 3 2 2 1
-4 5 1 1 1
-5 0
-6 7 3 3 1
-7 0
diff --git a/gfsm/gfsm/src/libgfsm/tests/priotest.c b/gfsm/gfsm/src/libgfsm/tests/priotest.c
deleted file mode 100644
index c56a39e..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/priotest.c
+++ /dev/null
@@ -1,171 +0,0 @@
-#include <glib.h>
-#include <stdio.h>
-#include <string.h>
-
-const char *prog=NULL;
-
-//======================================================================
-// typedefs
-typedef enum {
- gfsmAFNone = 0x0, /**< no sort field */
- gfsmAFLower = 0x1, /**< sort by lower label */
- gfsmAFUpper = 0x2, /**< sort by upper label */
- gfsmAFWeight = 0x3, /**< sort by weight (refers to semiring) */
- gfsmAFSource = 0x4, /**< sort by arc source (if supported and meaningful) */
- gfsmAFTarget = 0x5, /**< sort by arc target (if supported and meaningful) */
- gfsmAFUser = 0x6, /**< user-defined sort function */
- gfsmAFAll = 0x7, /**< not really a sort field: mask of all valid sort fields */
- gfsmAFReverse = 0x8, /**< not really a sort field: if set, indicates that arc comparisons should be reversed */
- gfsmAFMask = 0xf /**< not really a sort field: mask of valid sort fields & reverse flag */
-} gfsmArcField;
-
-typedef enum {
- gfsmAFNone = 0x0, /**< '_': no sort field */
- gfsmAFLower = 0x1, /**< 'l': sort by lower label */
- gfsmAFUpper = 0x2, /**< 'u': sort by upper label */
- gfsmAFWeight = 0x3, /**< 'w': sort by weight (refers to semiring) */
- gfsmAFSource = 0x4, /**< 's': sort by arc source (if supported and meaningful) */
- gfsmAFTarget = 0x5, /**< 't': sort by arc target (if supported and meaningful) */
- gfsmAFLowerR = 0x6, /**< 'L': reverse sort by lower label */
- gfsmAFUpperR = 0x7, /**< 'U': reverse sort by upper label */
- gfsmAFWeightR = 0x8, /**< 'W': reverse sort semiring weight */
- gfsmAFSourceR = 0x9, /**< 'S': reverse sort source state (if supported and meaningful) */
- gfsmAFTargetR = 0xa, /**< 'T': reverse sort target state (if supported and meaningful) */
- gfsmAFUser = 0xf /**< 'x': pseudo-field for user-defined comparisons */
-} gfsmArcFieldId;
-
-#define gfsmArcFieldShift 4 //-- number of bits in a single logical ::gfsmArcField element
-const guint32 gfsmNArcFields = 5; //-- maximum 'nth' paramter supported by ::gfsmArcFieldMask
-
-typedef guint32 gfsmArcFieldMask; //-- mask of ::gfsmArcField values, left-shifted by ::gfsmArcFieldShift
-
-
-const guint32 gfsmAFM_L = gfsmAFLower;
-const guint32 gfsmAFM_LU = gfsmAFLower|(gfsmAFUpper<<gfsmArcFieldShift);
-const guint32 gfsmAFM_LUW = gfsmAFLower|(gfsmAFUpper<<gfsmArcFieldShift)|(gfsmAFWeight<<(2*gfsmArcFieldShift));
-
-gfsmArcFieldMask gfsm_arc_field_mask_new(guint nth, gfsmArcField field, gboolean reverse)
-{
- gfsmArcFieldMask m = field;
- if (reverse) m |= gfsmAFReverse;
- return m << (nth*gfsmArcFieldShift);
-}
-
-gfsmArcFieldMask gfsm_arc_field_mask_add(gfsmArcFieldMask m, guint nth, gfsmArcField field, gboolean reverse)
-{ return (m | gfsm_arc_field_mask_new(nth,field,reverse)); }
-
-gfsmArcFieldMask gfsm_arc_field_mask_clear(gfsmArcFieldMask m, guint nth)
-{ return m & ((~gfsmAFMask)<<(nth*gfsmArcFieldShift)); }
-
-gfsmArcField gfsm_arc_field_mask_get_field(gfsmArcFieldMask m, guint nth)
-{ return (m>>(nth*gfsmArcFieldShift))&gfsmAFAll; }
-
-gboolean gfsm_arc_field_mask_get_reverse(gfsmArcFieldMask m, guint nth)
-{ return ((m>>(nth*gfsmArcFieldShift))&gfsmAFReverse) ? TRUE : FALSE; }
-
-
-//======================================================================
-// parse
-gfsmArcFieldMask parse_mask(const char *str)
-{
- gfsmArcFieldMask m = 0;
- gint i;
- guint nth=0;
- /*
- gint max_tokens = 32;
- gchar **toks = g_strsplit(str,",; \n\t",max_tokens);
-
- //-- parse
- for (i=0; toks[i] != NULL; i++) {
- gchar *tok = toks[i];
- g_strstrip(tok);
- }
- */
- for (i=0; str[i] && nth < gfsmNArcFields; i++) {
- switch (str[i]) {
- case 'l' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFLower,0); break;
- case 'L' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFLower,1); break;
-
- case 'u' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFUpper,0); break;
- case 'U' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFUpper,1); break;
-
- case 'w' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFWeight,0); break;
- case 'W' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFWeight,1); break;
-
- case 's' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFSource,0); break;
- case 'S' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFSource,1); break;
-
- case 't' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFTarget,0); break;
- case 'T' : m |= gfsm_arc_field_mask_new(nth++,gfsmAFTarget,1); break;
-
- //-- silently ignore these
- case 'x':
- case 'X':
- case '-':
- case ',':
- case ' ':
- case '\t':
- case '\n':
- break;
-
- default:
- g_printerr("%s: character '%c' is not in [sStTlLuUwW] in field string '%s' - skipping\n", prog, str[i], str);
- break;
- }
- }
- if (str[i] && nth==gfsmNArcFields) {
- g_printerr("%s: ignoring trailing characters '%s' in field string '%s'\n", prog, (str+i), str);
- }
-
- //-- cleanup
- //g_strfreev(toks);
-
- return m;
-}
-
-//======================================================================
-// dump
-
-const char *mask_field_str(gfsmArcFieldMask afm, guint nth)
-{
- switch (gfsm_arc_field_mask_get_field(afm, nth)) {
- case gfsmAFNone: return "none";
- case gfsmAFLower: return "lower";
- case gfsmAFUpper: return "upper";
- case gfsmAFWeight: return "weight";
- case gfsmAFSource: return "source";
- case gfsmAFTarget: return "target";
- default: return "?";
- }
- return "?";
-}
-const char *mask_reverse_str(gfsmArcFieldMask afm, guint nth)
-{
- return gfsm_arc_field_mask_get_reverse(afm, nth) ? ">" : "<";
-}
-
-void dump_mask(gfsmArcFieldMask afm, const char *str)
-{
- printf("%s: str='%s': priorities = %u = %#0.6x = { %s%s, %s%s, %s%s, %s%s, %s%s }\n",
- prog, str, afm, afm,
- mask_field_str(afm,0), mask_reverse_str(afm,0),
- mask_field_str(afm,1), mask_reverse_str(afm,1),
- mask_field_str(afm,2), mask_reverse_str(afm,2),
- mask_field_str(afm,3), mask_reverse_str(afm,3),
- mask_field_str(afm,4), mask_reverse_str(afm,4)
- );
-}
-
-//======================================================================
-// MAIN
-int main(int argc, char **argv) {
- int i;
- gfsmArcFieldMask afm = 0;
-
- prog = argv[0];
- for (i=1; i < argc; i++) {
- afm = parse_mask(argv[i]);
- dump_mask(afm, argv[i]);
- }
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/prtest.c b/gfsm/gfsm/src/libgfsm/tests/prtest.c
deleted file mode 100644
index d93f207..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/prtest.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <gfsm.h>
-#include <stdlib.h>
-
-//char *fsmfile = "prtest.tfst";
-char *fsmfile = "prtest.gfst";
-gfsmError *errp = NULL;
-
-int main (int argc, char **argv) {
- gfsmAutomaton *fsm=NULL;
-
- if (argc > 1) fsmfile = argv[1];
-
- fsm = gfsm_automaton_new();
-
- //gfsm_automaton_compile_filename(fsm,fsmfile,&errp);
- gfsm_automaton_load_bin_filename(fsm,fsmfile,&errp);
- if (errp) { g_printerr("error: %s\n", errp->message); exit(1); }
-
- gfsm_automaton_prune(fsm);
- gfsm_automaton_renumber_states(fsm);
-
- gfsm_automaton_print_file(fsm,stdout,&errp);
- if (errp) { g_printerr("error: %s\n", errp->message); exit(1); }
-
- if (fsm) gfsm_automaton_free(fsm);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/prtest.tfst b/gfsm/gfsm/src/libgfsm/tests/prtest.tfst
deleted file mode 100644
index f3ebd16..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/prtest.tfst
+++ /dev/null
@@ -1,8 +0,0 @@
-0 1 1 1 0
-0 0
-1 0
-2 0
-3 0
-4 0
-5 0
-6 0
diff --git a/gfsm/gfsm/src/libgfsm/tests/ptest.c b/gfsm/gfsm/src/libgfsm/tests/ptest.c
deleted file mode 100644
index 44911cd..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/ptest.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <glib.h>
-#include <stdio.h>
-
-typedef struct _xstruc {
- int x;
- int y;
-} xstruc;
-
-int main (void) {
- xstruc xs = {42,24};
- xstruc *xsp = &xs;
- void *vp = xsp;
- char *s = NULL;
- char *s2;
-
- printf ("&xs =%p ; xsp =%p ; vp =%p\n", &xs, xsp, vp);
- printf ("&xs.x =%p ; &xs.y =%p\n", &xs.x, &xs.y);
- printf ("&xsp->x=%p ; &xsp->y=%p\n", &xsp->x, &xsp->y);
- printf ("(vp)->x=%p ; (vp)->y=%p\n", &((xstruc*)vp)->x, &((xstruc*)vp)->y);
-
- printf("\n");
- printf("s=%p ; s2=%p\n", s, g_strdup(s));
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/rudtest.c b/gfsm/gfsm/src/libgfsm/tests/rudtest.c
deleted file mode 100644
index 7329b70..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/rudtest.c
+++ /dev/null
@@ -1,100 +0,0 @@
-#include <gfsm.h>
-#include <gfsmDebug.h>
-#include <stdlib.h>
-
-//char *fsm1file = "rudtest.gfst";
-char *fsm1file = "rudtest2.gfst";
-char *fsm2file = "rudtest.gfst";
-
-gfsmError *errp = NULL;
-
-void hackme(gfsmAutomaton *fsm1, gfsmAutomaton *fsm2, char *label)
-{
- printf("<%s>.a : reverse(fsm1)\n", label);
- gfsm_automaton_reverse(fsm1);
-
- printf("<%s>.b : union(fsm1,fsm2)\n", label);
- gfsm_automaton_union(fsm1, fsm2);
-
- printf("<%s>.c : determinize(fsm1)\n", label);
- gfsm_automaton_determinize(fsm1);
-
- printf("<%s> : done.\n", label);
-}
-
-void print_sizes(void)
-{
- //-- show some memory sizes:
- fprintf(stderr, "%-32s | %6s\n", "TYPE", "SIZE");
-#define PRINTSIZE(type) fprintf(stderr, "%-32s | %u\n", #type, sizeof(type))
- PRINTSIZE(gfsmAlphabet);
- PRINTSIZE(gfsmIdentityAlphabet);
- PRINTSIZE(gfsmRangeAlphabet);
-
- PRINTSIZE(gfsmArc);
- PRINTSIZE(gfsmArcIter);
- PRINTSIZE(gfsmArcList);
- PRINTSIZE(gfsmAutomaton);
- PRINTSIZE(gfsmAutomatonFlags);
- PRINTSIZE(gfsmAutomatonHeader);
- PRINTSIZE(gfsmSemiring);
- //PRINTSIZE(gfsmSet);
- //PRINTSIZE(gfsmSetUnionData);
- PRINTSIZE(gfsmWeightedStateSet);
- PRINTSIZE(gfsmState);
- PRINTSIZE(gfsmStatePair);
- PRINTSIZE(gfsmStateSet);
- PRINTSIZE(gfsmStateSetIter);
- PRINTSIZE(gfsmStoredState);
- PRINTSIZE(gfsmStoredArc);
- PRINTSIZE(gfsmVersionInfo);
-#undef PRINTSIZE
-}
-
-void rudtest_construct(gfsmAutomaton *fsm)
-{
- gfsm_automaton_clear(fsm);
- fsm->root_id = 0;
- gfsm_automaton_add_state_full(fsm,0);
- gfsm_automaton_add_state_full(fsm,1);
- gfsm_automaton_add_state_full(fsm,2);
- gfsm_automaton_set_final_state(fsm,2,TRUE);
- gfsm_automaton_add_arc(fsm,0,1,1,1,0);
-}
-
-int main (int argc, char **argv) {
- gfsmAutomaton *fsm1=NULL, *fsm2=NULL;
-
- //g_thread_init(NULL);
- GFSM_DEBUG_INIT();
-
- //print_sizes();
-
- if (argc > 1) fsm1file = argv[1];
- if (argc > 2) fsm2file = argv[2];
-
- fsm1 = gfsm_automaton_new();
- fsm2 = gfsm_automaton_new();
-
- gfsm_automaton_load_bin_filename(fsm1,fsm1file,&errp);
- //rudtest_construct(fsm1);
- if (errp) { g_printerr("error: %s\n", errp->message); exit(1); }
-
- if (fsm2) gfsm_automaton_load_bin_filename(fsm2,fsm1file,&errp);
- if (errp) { g_printerr("error: %s\n", errp->message); exit(1); }
-
- hackme(fsm1,fsm2,"1");
- hackme(fsm1,fsm2,"2");
- hackme(fsm1,fsm2,"3");
- hackme(fsm1,fsm2,"4");
- /* */
-
- if (fsm1) gfsm_automaton_free(fsm1);
- if (fsm2) gfsm_automaton_free(fsm2);
-
-
- GFSM_DEBUG_FINISH();
- GFSM_DEBUG_PRINT();
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/rudtest.tfst b/gfsm/gfsm/src/libgfsm/tests/rudtest.tfst
deleted file mode 100644
index ac8c248..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/rudtest.tfst
+++ /dev/null
@@ -1,3 +0,0 @@
-0 1 1 1 0
-1 2 2 2 0
-2 0
diff --git a/gfsm/gfsm/src/libgfsm/tests/rudtest2.tfst b/gfsm/gfsm/src/libgfsm/tests/rudtest2.tfst
deleted file mode 100644
index 65261c9..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/rudtest2.tfst
+++ /dev/null
@@ -1,5 +0,0 @@
-0 1 1 1 0
-1 2 2 2 0
-2 3 3 3 0
-3 4 4 4 0
-4 0
diff --git a/gfsm/gfsm/src/libgfsm/tests/seek2test.c b/gfsm/gfsm/src/libgfsm/tests/seek2test.c
deleted file mode 100644
index cf12ac8..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/seek2test.c
+++ /dev/null
@@ -1,259 +0,0 @@
-#include <gfsm.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "labprobs.h"
-
-/*======================================================================
- * Globals
- */
-const char *prog = "seek2test";
-
-const char *fsmfile = "tagh-chopped.gfst";
-//const char *xfsmfile = "tagh-lo.gfstx";
-
-gfsmStateId qid_test = 0;
-guint out_degree_test = 0;
-gulong count_test =
-//1024
-//1048576
-4194304
-//16777216
-;
-
-//#define BENCH_SORTED 1
-#undef BENCH_SORTED
-
-/*======================================================================
- * bench_seek_vanilla()
- */
-double bench_seek_vanilla(gfsmAutomaton *fsm) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(gfsm_automaton_out_degree(fsm,qid_test));
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = qid_test;
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcIter ai;
- ary->len=0;
- for (gfsm_arciter_open(&ai,fsm,qid), gfsm_arciter_seek_lower(&ai,lab);
- gfsm_arciter_ok(&ai);
- gfsm_arciter_next(&ai), gfsm_arciter_seek_lower(&ai,lab))
- {
- gfsmArc *a = gfsm_arciter_arc(&ai);
- if (fsm->flags.sort_mode==gfsmASMLower && a->lower!=lab) break;
- g_ptr_array_add(ary, a);
- }
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_labx()
- */
-#ifndef SEEK_LABX_BINSEARCH_CUTOFF
-#define SEEK_LABX_BINSEARCH_CUTOFF 0
-//#define SEEK_LABX_BINSEARCH_CUTOFF 4
-//#define SEEK_LABX_BINSEARCH_CUTOFF 8
-//#define SEEK_LABX_BINSEARCH_CUTOFF 16
-//#define SEEK_LABX_BINSEARCH_CUTOFF 32
-//#define SEEK_LABX_BINSEARCH_CUTOFF 64
-//#define SEEK_LABX_BINSEARCH_CUTOFF 128
-//#define SEEK_LABX_BINSEARCH_CUTOFF 256
-#endif
-
-double bench_seek_labx(gfsmArcLabelIndex *labx) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(gfsm_arc_label_index_out_degree(labx,qid_test));
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = qid_test;
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcRange range;
- gfsmArc *a;
- ary->len=0;
- gfsm_arcrange_open_label_index(&range,labx,qid);
- if ((range.max - range.min) <= SEEK_LABX_BINSEARCH_CUTOFF) {
- for ( ; gfsm_arcrange_ok(&range); gfsm_arcrange_next(&range) ) {
- a = gfsm_arcrange_arc(&range);
- if (a->lower<lab) continue;
- if (a->lower>lab) break;
- g_ptr_array_add(ary, a);
- }
- } else {
- for (gfsm_arcrange_seek_lower(&range,lab); gfsm_arcrange_ok(&range); gfsm_arcrange_next(&range)) {
- a = gfsm_arcrange_arc(&range);
- if (a->lower!=lab) break;
- g_ptr_array_add(ary, a);
- }
- }
- //gfsm_arcrange_close(&range);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-
-
-/*======================================================================
- * Report
- */
-GString *dat_header=NULL;
-GString *dat_data=NULL;
-gint dat_row=0;
-gint dat_col=0;
-
-void report_new_row(void) {
- fprintf(stderr, "%s: qid=%u, out_degree=%u\n", prog, qid_test, out_degree_test);
- //
- //-- save data for gnuplot output
- dat_col=0;
- if (!dat_header) dat_header = g_string_new("");
- if (!dat_data) dat_data = g_string_new("");
- if (dat_row==0) {
- g_string_append(dat_header,"#1:out_deg");
- }
- g_string_append_printf(dat_data, "%u", out_degree_test);
-}
-
-void report_column(char *label, double elapsed) {
- double iters_per_sec = ((double)count_test)/elapsed;
- //
- //-- to stderr
- fprintf(stderr, "BENCH[%16s]: %ld iters in %.2g sec: %.2g iters/sec\n",
- label, count_test, elapsed, iters_per_sec);
- fflush(stderr);
- //
- //-- to data strings
- if (dat_row==0) {
- g_string_append_printf(dat_header, "\t%d:%s_secs\t%d:%s_ips", (2*dat_col+2),label, (2*dat_col+3),label);
- }
- g_string_append_c(dat_data,'\t');
- g_string_append_printf(dat_data,"\t%g\t%g", elapsed,iters_per_sec);
- ++dat_col;
-}
-
-void report_end_row(void) {
- ++dat_row;
- g_string_append(dat_data,"\n");
-}
-
-void report_gnuplot(void) {
- fflush(stderr);
- printf("%s\n%s", dat_header->str, dat_data->str);
-}
-
-
-/*======================================================================
- * Main
- */
-int main(int argc, char **argv)
-{
- char *qid_str="0";
- gfsmError *err=NULL;
- int argi;
- //
- gfsmAutomaton *fsm=NULL;
- double elapsed_vanilla;
-#ifdef BENCH_SORTED
- gfsmAutomaton *fsm_sorted=NULL;
- double elapsed_sorted;
-#endif
- gfsmArcLabelIndex *labx=NULL;
- double elapsed_labx;
-
- //-- sanity check
- if (argc < 2) {
- fprintf(stderr, "Usage: %s [QID(s)...]\n", prog);
- exit(1);
- }
-
- //-- load probabilities & initialize
- load_label_probs();
- populate_seek_labels();
-
- //-- report
- fprintf(stderr, "%s: count=%lu\n", prog, count_test);
- fflush(stderr);
-
- //-- load/create: vanilla
- fprintf(stderr, "%s: loading vanilla automaton '%s'... ", prog, fsmfile); fflush(stderr);
- fsm = gfsm_automaton_new();
- if (!gfsm_automaton_load_bin_filename(fsm,fsmfile,&err)) {
- fprintf(stderr,"%s: load failed for '%s': %s\n", prog, fsmfile, (err ? err->message : "?"));
- exit(3);
- }
- fsm->flags.sort_mode = gfsmASMNone;
- fprintf(stderr, "loaded.\n"); fflush(stderr);
-
-#ifdef BENCH_SORTED
- //-- load/create: sorted
- fprintf(stderr, "%s: sorting... ", prog); fflush(stderr);
- fsm_sorted = gfsm_automaton_clone(fsm);
- gfsm_automaton_arcsort(fsm_sorted,gfsmASMLower);
- fprintf(stderr, "sorted.\n"); fflush(stderr);
-#endif
-
- //-- load/create: labx
- fprintf(stderr, "%s: indexing to gfsmArcLabelIndex... ", prog); fflush(stderr);
- labx = gfsm_automaton_to_arc_label_index_lower(fsm,NULL);
- fprintf(stderr, "indexed.\n"); fflush(stderr);
-
- //-- main loop
- for (argi=1; argi < argc; argi++) {
- qid_str = argv[argi];
- qid_test = strtol(qid_str,NULL,0);
- out_degree_test = gfsm_automaton_out_degree(fsm,qid_test);
-
- report_new_row();
-
- //-- benchmark: vanilla
- elapsed_vanilla = bench_seek_vanilla(fsm);
- report_column("vanilla", elapsed_vanilla);
-
-#ifdef BENCH_SORTED
- //-- benchmark: vanilla+sorted
- gfsm_automaton_arcsort(fsm,gfsmASMLower);
- elapsed_sorted = bench_seek_vanilla(fsm);
- report_column("sorted", elapsed_sorted);
-#endif
-
- //-- benchmark: indexed
- elapsed_labx = bench_seek_labx(labx);
- report_column("labx", elapsed_labx);
-
- report_end_row();
- }
-
- //-- gnuplot output
- report_gnuplot();
-
- //-- cleanup
- if (fsm) gfsm_automaton_free(fsm);
-#ifdef BENCH_SORTED
- if (fsm_sorted) gfsm_automaton_free(fsm_sorted);
-#endif
- if (labx) gfsm_arc_label_index_free(labx);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/seek3test.c b/gfsm/gfsm/src/libgfsm/tests/seek3test.c
deleted file mode 100644
index 8c3e8af..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/seek3test.c
+++ /dev/null
@@ -1,611 +0,0 @@
-#include <gfsm.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/*======================================================================
- * Globals
- */
-const char *prog = "seek2test";
-
-gfsmStateId qid_test = 0;
-guint out_degree_test;
-gulong count_test_max =
-//1024UL //==2^10
-//1048576UL //==2^20
-2097152UL //==2^21
-//4194304UL //==2^22
-//16777216UL //==2^24
-//67108864UL //==2^26
-//268435456UL //==2^28
-;
-gulong count_test=0; //-- count_test_max/out_degree
-
-/*======================================================================
- * Label population
- */
-
-//--------------------------------------------------------------
-// globals
-GRand *grand = NULL;
-const guint32 grand_seed = 42;
-#define GRAND_USE_SEED 1
-//#undef GRAND_USE_SEED
-
-const guint32 n_labels = 128;
-const guint32 n_states = 8192;
-
-GArray *seekus = NULL; /*-- lab = g_array_index(seekus,i); 1<=i<=count_test --*/
-GArray *seekfrom = NULL; /*-- qid = g_array_index(seekus,i); 1<=i<=count_test --*/
-
-//--------------------------------------------------------------
-// random_label()
-gfsmLabelId random_label(void) {
- if (!grand) {
- grand = g_rand_new();
-#ifdef GRAND_USE_SEED
- g_rand_set_seed(grand,grand_seed);
-#endif
- }
- return g_rand_int_range(grand,0,n_labels);
-}
-
-//--------------------------------------------------------------
-// populate_seek_labels()
-void populate_seek_labels(void) {
- int i;
- gfsmLabelId lab;
- seekus = g_array_sized_new(FALSE,TRUE,sizeof(gfsmLabelId),count_test_max);
- for (i=0; i < count_test_max; i++) {
- lab = random_label();
- g_array_append_val(seekus,lab);
- }
-}
-
-//--------------------------------------------------------------
-// random_state()
-gfsmStateId random_state(void) {
- if (!grand) { grand = g_rand_new_with_seed(grand_seed); }
- return g_rand_int_range(grand,0,n_states);
-}
-
-//--------------------------------------------------------------
-// populate_seek_states()
-void populate_seek_states(void) {
- int i;
- seekfrom = g_array_sized_new(FALSE,TRUE,sizeof(gfsmStateId),count_test_max);
- for (i=0; i < count_test_max; i++) {
- gfsmStateId qid = random_state();
- g_array_append_val(seekfrom,qid);
- }
-}
-
-
-/*======================================================================
- * bench_seek_vanilla()
- */
-double bench_seek_vanilla(gfsmAutomaton *fsm) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId, i);
- gfsmLabelId lab = g_array_index(seekus, gfsmLabelId, i);
- gfsmArcIter ai;
- ary->len=0;
- for (gfsm_arciter_open(&ai,fsm,qid); gfsm_arciter_ok(&ai); gfsm_arciter_next(&ai)) {
- gfsmArc *a = gfsm_arciter_arc(&ai);
- if (a->lower != lab) continue;
- g_ptr_array_add(ary, a);
- }
- gfsm_arciter_close(&ai);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_sorted()
- */
-double bench_seek_sorted(gfsmAutomaton *fsm) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId,i);
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcIter ai;
- ary->len=0;
- for (gfsm_arciter_open(&ai,fsm,qid); gfsm_arciter_ok(&ai); gfsm_arciter_next(&ai)) {
- gfsmArc *a = gfsm_arciter_arc(&ai);
- if (a->lower < lab) continue;
- if (a->lower > lab) break;
- g_ptr_array_add(ary, a);
- }
- gfsm_arciter_close(&ai);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_tabx_vanilla()
- */
-double bench_seek_tabx_vanilla(gfsmArcTableIndex *tabx) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId,i);
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcRange range;
- ary->len=0;
- for (gfsm_arcrange_open_table_index(&range,tabx,qid); gfsm_arcrange_ok(&range); gfsm_arcrange_next(&range)) {
- gfsmArc *a = gfsm_arcrange_arc(&range);
- if (a->lower != lab) continue;
- g_ptr_array_add(ary, a);
- }
- gfsm_arcrange_close(&range);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_tabx_sorted() : linear search
- */
-double bench_seek_tabx_sorted(gfsmArcTableIndex *tabx) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId,i);
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcRange range;
- ary->len=0;
- for (gfsm_arcrange_open_table_index(&range,tabx,qid); gfsm_arcrange_ok(&range); gfsm_arcrange_next(&range)) {
- gfsmArc *a = gfsm_arcrange_arc(&range);
- if (a->lower < lab) continue;
- if (a->lower > lab) break;
- g_ptr_array_add(ary, a);
- }
- gfsm_arcrange_close(&range);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_tabx_sorted_2() : linear search (v2) [identical to v1]
- */
-double bench_seek_tabx_sorted_2(gfsmArcTableIndex *tabx) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId,i);
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcRange range;
- ary->len=0;
- for (gfsm_arcrange_open_table_index(&range,tabx,qid); range.min<range.max; ++range.min) {
- if (range.min->lower < lab) continue;
- if (range.min->lower > lab) break;
- g_ptr_array_add(ary, range.min);
- }
- gfsm_arcrange_close(&range);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_tabx_seek_lib() : binary search: library function
- */
-inline void gfsm_arcrange_seek_lower(gfsmArcRange *range, gfsmLabelId find)
-{
- g_assert(range != NULL);
- while (gfsm_arcrange_ok(range) && gfsm_arcrange_arc(range)->lower < find)
- gfsm_arcrange_next(range);
-}
-
-double bench_seek_tabx_seek_lib(gfsmArcTableIndex *tabx) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId,i);
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcRange range;
- ary->len=0;
- for (gfsm_arcrange_open_table_index(&range,tabx,qid), gfsm_arcrange_seek_lower(&range,lab);
- gfsm_arcrange_ok(&range);
- gfsm_arcrange_next(&range))
- {
- gfsmArc *a = gfsm_arcrange_arc(&range);
- if (a->lower > lab) break;
- g_ptr_array_add(ary, a);
- }
- gfsm_arcrange_close(&range);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_tabx_bsearch_inl() : binary search: inline function
- */
-#define BSEARCH_CUTOFF 16
-static inline gfsmArc *bsearch_lower(gfsmArc *min, gfsmArc *max, gfsmLabelId find)
-{
- while (min < max) {
- gint diff = max-min;
- if (diff < BSEARCH_CUTOFF) {
- do {
- if (min->lower >= find) break;
- min++;
- } while (min < max);
- return min;
- }
- else {
- gfsmArc *mid = min + diff/2;
- if (mid->lower < find) min = mid+1;
- else max = mid;
- }
- }
- return min;
-}
-
-double bench_seek_tabx_bsearch_inl(gfsmArcTableIndex *tabx) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId,i);
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcRange range;
- ary->len=0;
- for (gfsm_arcrange_open_table_index(&range,tabx,qid), range.min=bsearch_lower(range.min,range.max,lab);
- gfsm_arcrange_ok(&range);
- gfsm_arcrange_next(&range))
- {
- gfsmArc *a = gfsm_arcrange_arc(&range);
- if (a->lower > lab) break;
- g_ptr_array_add(ary, a);
- }
- gfsm_arcrange_close(&range);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * bench_seek_tabx_bsearch_func() : binary search: inline function
- */
-static void bsearch_range_func(gfsmArcRange *range, gfsmLabelId find)
-{
- gfsmArc *min=range->min, *max=range->max;
- while (min < max) {
- gfsmArc *mid = min + (max-min)/2;
- if (mid->lower < find) min = mid+1;
- else max = mid;
- }
- range->min = min;
-}
-
-double bench_seek_tabx_bsearch_func(gfsmArcTableIndex *tabx) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(out_degree_test);
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = g_array_index(seekfrom,gfsmStateId,i);
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcRange range;
- ary->len=0;
- for (gfsm_arcrange_open_table_index(&range,tabx,qid), bsearch_range_func(&range,lab);
- gfsm_arcrange_ok(&range);
- gfsm_arcrange_next(&range))
- {
- gfsmArc *a = gfsm_arcrange_arc(&range);
- if (a->lower > lab) break;
- g_ptr_array_add(ary, a);
- }
- gfsm_arcrange_close(&range);
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-
-/*======================================================================
- * Report
- */
-GString *dat_header=NULL;
-GString *dat_data=NULL;
-gint dat_row=0;
-gint dat_col=0;
-
-void report_new_row(void) {
- fprintf(stderr, "%s: n_states=%u, n_labels=%u, out_degree=%u\n", prog, n_states, n_labels, out_degree_test);
- //
- //-- save data for gnuplot output
- dat_col=0;
- if (!dat_header) dat_header = g_string_new("");
- if (!dat_data) dat_data = g_string_new("");
- if (dat_row==0) {
- g_string_append(dat_header,"#1:out_deg");
- }
- g_string_append_printf(dat_data, "%u", out_degree_test);
-}
-
-void report_column(char *label, double elapsed) {
- double iters_per_sec = ((double)count_test)/elapsed;
- //
- //-- to stderr
- fprintf(stderr, "BENCH[%24s]: %ld iters in %5.3f sec: %7.2e iters/sec\n",
- label, count_test, elapsed, iters_per_sec);
- fflush(stderr);
- //
- //-- to data strings
- if (dat_row==0) {
- g_string_append_printf(dat_header, "\t%d:%s_secs\t%d:%s_ips", (2*dat_col+2),label, (2*dat_col+3),label);
- }
- g_string_append_c(dat_data,'\t');
- g_string_append_printf(dat_data,"\t%g\t%g", elapsed,iters_per_sec);
- ++dat_col;
-}
-
-void report_end_row(void) {
- ++dat_row;
- g_string_append(dat_data,"\n");
-}
-
-void report_gnuplot(void) {
- fflush(stderr);
- printf("%s\n%s", dat_header->str, dat_data->str);
-}
-
-
-/*======================================================================
- * Main
- */
-//#define BENCH_VANILLA 1
-//#define BENCH_SORTED 1
-//#define BENCH_TABX_VANILLA 1
-#define BENCH_TABX_SORTED 1
-//#define BENCH_TABX_SORTED_2 1
-//#define BENCH_TABX_SEEK_LIB 1
-#define BENCH_TABX_BSEARCH_FUNC 1
-//#define BENCH_TABX_BSEARCH_INL 1
-int main(int argc, char **argv)
-{
- char *out_degree_str="32";
- int argi, arci, qi;
- //
- gfsmAutomaton *fsm=NULL;
- double elapsed_vanilla=0;
- //
- gfsmAutomaton *fsm_sorted=NULL;
- double elapsed_sorted=0;
- //
- gfsmArcTableIndex *tabx=NULL;
- double elapsed_tabx_vanilla=0;
- //
- gfsmArcTableIndex *tabx_sorted=NULL;
- double elapsed_tabx_sorted=0;
- //
- gfsmArcTableIndex *tabx_sorted_2=NULL;
- double elapsed_tabx_sorted_2=0;
- //
- gfsmArcTableIndex *tabx_seek_lib=NULL;
- double elapsed_tabx_seek_lib=0;
- //
- gfsmArcTableIndex *tabx_bsearch_func=NULL;
- double elapsed_tabx_bsearch_func=0;
- //
- gfsmArcTableIndex *tabx_bsearch_inl=NULL;
- double elapsed_tabx_bsearch_inl=0;
-
- //-- sanity check
- if (argc < 2) {
- fprintf(stderr, "Usage: %s [OUT_DEGREE(s)...]\n", prog);
- exit(1);
- }
-
- //-- initialize labels to seek
- populate_seek_labels();
- populate_seek_states();
-
- //-- report
- fprintf(stderr, "%s: count_test_max=%lu\n", prog, count_test_max);
- fflush(stderr);
-
- //-- create: vanilla
- fsm = gfsm_automaton_new();
-
- //-- main loop
- for (argi=1; argi < argc; argi++) {
- out_degree_str = argv[argi];
- out_degree_test = strtol(out_degree_str,NULL,0);
- //count_test = count_test_max / out_degree_test;
- count_test = count_test_max;
-
- //-- populate: vanilla
- gfsm_automaton_clear(fsm);
- gfsm_automaton_set_root(fsm,gfsm_automaton_ensure_state(fsm,0));
- gfsm_automaton_set_final_state_full(fsm,0,TRUE,fsm->sr->one);
- for (qi=1; qi < n_states; qi++) {
- gfsm_automaton_ensure_state(fsm,qi);
- for (arci=0; arci < out_degree_test; arci++) {
- gfsmLabelId lo = random_label();
- gfsmLabelId hi = random_label();
- gfsmWeight w = arci + 1.0;
- gfsm_automaton_add_arc(fsm,qi,qi, lo,hi, w);
- }
- }
-
- //-------- bench
- report_new_row();
-
- //-- benchmark: vanilla (twice for cache optimization)
-#ifdef BENCH_VANILLA
- elapsed_vanilla = bench_seek_vanilla(fsm);
- elapsed_vanilla = bench_seek_vanilla(fsm);
- report_column("vanilla", elapsed_vanilla);
-#endif
-
-#ifdef BENCH_SORTED
- //-- benchmark: vanilla+sorted
- fsm_sorted = gfsm_automaton_clone(fsm);
- gfsm_automaton_arcsort(fsm_sorted,gfsmASMLower);
- elapsed_sorted = bench_seek_sorted(fsm_sorted);
- elapsed_sorted = bench_seek_sorted(fsm_sorted);
- report_column("sorted", elapsed_sorted);
-#endif
-
-#ifdef BENCH_TABX_VANILLA
- //-- benchmark: table: vanilla
- tabx = gfsm_automaton_to_arc_table_index(fsm,tabx);
- elapsed_tabx_vanilla = bench_seek_tabx_vanilla(tabx);
- elapsed_tabx_vanilla = bench_seek_tabx_vanilla(tabx);
- report_column("tabx_vanilla", elapsed_tabx_vanilla);
-#endif
-
-#ifdef BENCH_TABX_SORTED
- //-- benchmark: table: sorted linear
- tabx_sorted = gfsm_automaton_to_arc_table_index(fsm,tabx_sorted);
- gfsm_arc_table_index_priority_sort(tabx_sorted, gfsmASP_LU, fsm->sr);
- elapsed_tabx_sorted = bench_seek_tabx_sorted(tabx_sorted);
- elapsed_tabx_sorted = bench_seek_tabx_sorted(tabx_sorted);
- report_column("tabx_sorted", elapsed_tabx_sorted);
-#endif
-
-#ifdef BENCH_TABX_SORTED_2
- //-- benchmark: table: sorted linear (v2)
- tabx_sorted_2 = gfsm_automaton_to_arc_table_index(fsm,tabx_sorted_2);
- gfsm_arc_table_index_priority_sort(tabx_sorted_2, gfsmASP_LU, fsm->sr);
- elapsed_tabx_sorted_2 = bench_seek_tabx_sorted_2(tabx_sorted_2);
- elapsed_tabx_sorted_2 = bench_seek_tabx_sorted_2(tabx_sorted_2);
- report_column("tabx_sorted_2", elapsed_tabx_sorted_2);
-#endif
-
-#ifdef BENCH_TABX_SEEK_LIB
- //-- benchmark: table: binary search: lib
- tabx_seek_lib = gfsm_automaton_to_arc_table_index(fsm,tabx_seek_lib);
- gfsm_arc_table_index_priority_sort(tabx_seek_lib, gfsmASP_LU, fsm->sr);
- elapsed_tabx_seek_lib = bench_seek_tabx_seek_lib(tabx_seek_lib);
- elapsed_tabx_seek_lib = bench_seek_tabx_seek_lib(tabx_seek_lib);
- report_column("tabx_seek_lib", elapsed_tabx_seek_lib);
-#endif
-
-#ifdef BENCH_TABX_BSEARCH_FUNC
- //-- benchmark: table: binary search: func
- tabx_bsearch_func = gfsm_automaton_to_arc_table_index(fsm,tabx_bsearch_func);
- gfsm_arc_table_index_priority_sort(tabx_bsearch_func, gfsmASP_LU, fsm->sr);
- elapsed_tabx_bsearch_func = bench_seek_tabx_bsearch_func(tabx_bsearch_func);
- elapsed_tabx_bsearch_func = bench_seek_tabx_bsearch_func(tabx_bsearch_func);
- report_column("tabx_bsearch_func", elapsed_tabx_bsearch_func);
-#endif
-
-#ifdef BENCH_TABX_BSEARCH_INL
- //-- benchmark: table: binary search: inline
- tabx_bsearch_inl = gfsm_automaton_to_arc_table_index(fsm,tabx_bsearch_inl);
- gfsm_arc_table_index_priority_sort(tabx_bsearch_inl, gfsmASP_LU, fsm->sr);
- elapsed_tabx_bsearch_inl = bench_seek_tabx_bsearch_inl(tabx_bsearch_inl);
- elapsed_tabx_bsearch_inl = bench_seek_tabx_bsearch_inl(tabx_bsearch_inl);
- report_column("tabx_bsearch_inl", elapsed_tabx_bsearch_inl);
-#endif
-
- report_end_row();
- }
-
- //-- gnuplot output
- report_gnuplot();
-
- //-- cleanup
- if (fsm) gfsm_automaton_free(fsm);
- if (fsm_sorted) gfsm_automaton_free(fsm_sorted);
- if (tabx) gfsm_arc_table_index_free(tabx);
- if (tabx_sorted) gfsm_arc_table_index_free(tabx_sorted);
- if (tabx_sorted_2) gfsm_arc_table_index_free(tabx_sorted_2);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/seektest.c b/gfsm/gfsm/src/libgfsm/tests/seektest.c
deleted file mode 100644
index cc59874..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/seektest.c
+++ /dev/null
@@ -1,365 +0,0 @@
-#include <gfsm.h>
-#include <gfsmIndexed2.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "labprobs.h"
-
-/*======================================================================
- * Globals
- */
-const char *prog = "seektest";
-
-const char *fsmfile = "tagh-chopped.gfst";
-//const char *xfsmfile = "tagh-lo.gfstx";
-
-gfsmStateId qid_test = 0;
-guint out_degree_test = 0;
-gulong count_test =
-//1024
-//1048576
-4194304
-//16777216
-;
-
-//#define BENCH_SORTED 1
-#undef BENCH_SORTED
-
-/*======================================================================
- * bench_seek_vanilla()
- */
-double bench_seek_vanilla(gfsmAutomaton *fsm) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(gfsm_automaton_out_degree(fsm,qid_test));
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = qid_test;
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcIter ai;
- ary->len=0;
- for (gfsm_arciter_open(&ai,fsm,qid), gfsm_arciter_seek_lower(&ai,lab);
- gfsm_arciter_ok(&ai);
- gfsm_arciter_next(&ai), gfsm_arciter_seek_lower(&ai,lab))
- {
- gfsmArc *a = gfsm_arciter_arc(&ai);
- if (fsm->flags.sort_mode==gfsmASMLower && a->lower!=lab) break;
- g_ptr_array_add(ary, a);
- }
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-/*======================================================================
- * indexed_lower_lb()
- */
-gfsmArcId indexed_lower_lb(gfsmIndexedAutomaton *fsm,
- gfsmLabelId lab,
- gfsmArcId aid_lo,
- gfsmArcId aid_hi)
-
-{
- /*
- gfsmArcId aid_mid;
- gfsmArc *a;
- */
-
- //if (!gfsm_indexed_automaton_has_state(fsm,qid)) return gfsmNoArc;
- /*
- aid_lo = g_array_index(fsm->state_first_arc, gfsmArcId, qid);
- aid_hi = g_array_index(fsm->state_first_arc, gfsmArcId, qid+1);
- */
-
- while (aid_lo < aid_hi) {
- gfsmArcId aid_mid = (aid_lo+aid_hi)/2;
- gfsmArc *a = &g_array_index(fsm->arcs, gfsmArc, g_array_index(fsm->arcix_lower, gfsmArcId, aid_mid));
- if (a->lower < lab) { aid_lo = aid_mid+1; }
- else { aid_hi = aid_mid; }
- }
- //return aid_lo <= aid_hi ? aid_lo : gfsmNoArc;
- return aid_lo;
-}
-
-
-/*======================================================================
- * bench_seek_indexed()
- */
-#ifndef SEEK_INDEXED_BINSEARCH_CUTOFF
-//#define SEEK_INDEXED_BINSEARCH_CUTOFF 0
-//#define SEEK_INDEXED_BINSEARCH_CUTOFF 4
-//#define SEEK_INDEXED_BINSEARCH_CUTOFF 8
-//#define SEEK_INDEXED_BINSEARCH_CUTOFF 16
-//#define SEEK_INDEXED_BINSEARCH_CUTOFF 32
-#define SEEK_INDEXED_BINSEARCH_CUTOFF 64
-#endif
-double bench_seek_indexed(gfsmIndexedAutomaton *fsm) {
-#if 1
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(gfsm_indexed_automaton_out_degree(fsm,qid_test));
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = qid_test;
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcId aid_lo = g_array_index(fsm->state_first_arc, gfsmArcId, qid);
- gfsmArcId aid_hi = g_array_index(fsm->state_first_arc, gfsmArcId, qid+1);
- gfsmArcId aid;
- gfsmArc *a;
- ary->len=0;
- if (aid_hi-aid_lo >= SEEK_INDEXED_BINSEARCH_CUTOFF) {
- for (aid=indexed_lower_lb(fsm,lab,aid_lo,aid_hi); aid<aid_hi; aid++) {
- a = &g_array_index(fsm->arcs, gfsmArc, g_array_index(fsm->arcix_lower, gfsmArcId, aid));
- if (a->lower!=lab) break;
- g_ptr_array_add(ary, a);
- }
- } else {
- for (a=((gfsmArc*)fsm->arcs->data)+aid_lo; a < ((gfsmArc*)fsm->arcs->data)+aid_hi; a++) {
- if (a->lower==lab) g_ptr_array_add(ary,a);
- }
- }
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-#else
- return 1e38; //-- dummy
-#endif
-}
-
-
-/*======================================================================
- * indexed2_lower_lb()
- */
-gfsmArcId indexed2_lower_lb(gfsmIndexedAutomaton2 *fsm,
- gfsmLabelId lab,
- gfsmArcId aid_lo,
- gfsmArcId aid_hi)
-
-{
- while (aid_lo < aid_hi) {
- gfsmArcId aid_mid = (aid_lo+aid_hi)/2;
- gfsmArc *a = g_ptr_array_index(fsm->arcix_lower, aid_mid);
- if (a->lower < lab) { aid_lo = aid_mid+1; }
- else { aid_hi = aid_mid; }
- }
- //return aid_lo <= aid_hi ? aid_lo : gfsmNoArc;
- return aid_lo;
-}
-
-
-/*======================================================================
- * bench_seek_indexed2()
- */
-double bench_seek_indexed2(gfsmIndexedAutomaton2 *fsm) {
- guint i;
- double elapsed;
- GPtrArray *ary = g_ptr_array_sized_new(gfsm_indexed_automaton2_out_degree(fsm,qid_test));
- GTimer *timer = g_timer_new();
-
- g_timer_start(timer);
- for (i=0; i < count_test; i++) {
- //-- BEGIN TEST CODE
- gfsmStateId qid = qid_test;
- gfsmLabelId lab = g_array_index(seekus,gfsmLabelId,i);
- gfsmArcId aid_lo = g_array_index(fsm->state_first_arc, gfsmArcId, qid);
- gfsmArcId aid_hi = g_array_index(fsm->state_first_arc, gfsmArcId, qid+1);
- gfsmArcId aid;
- gfsmArc **app;
- ary->len=0;
- if (aid_hi-aid_lo >= SEEK_INDEXED_BINSEARCH_CUTOFF) {
- for (app = ((gfsmArc**)(fsm->arcix_lower->pdata)) + indexed2_lower_lb(fsm,lab,aid_lo,aid_hi);
- app < ((gfsmArc**)(fsm->arcix_lower->pdata)) + aid_hi && (*app)->lower==lab;
- app++)
- {
- g_ptr_array_add(ary, (*app));
- }
- } else {
- for (app = ((gfsmArc**)(fsm->arcix_lower->pdata)) + aid_lo;
- app < ((gfsmArc**)(fsm->arcix_lower->pdata)) + aid_hi;
- app++)
- {
- if ((*app)->lower==lab) g_ptr_array_add(ary,(*app));
- }
- }
- //-- END TEST CODE
- }
- elapsed = g_timer_elapsed(timer,NULL);
-
- //-- cleanup
- g_ptr_array_free(ary,TRUE);
- g_timer_destroy(timer);
-
- return elapsed;
-}
-
-
-/*======================================================================
- * Report
- */
-GString *dat_header=NULL;
-GString *dat_data=NULL;
-gint dat_row=0;
-gint dat_col=0;
-
-void report_new_row(void) {
- fprintf(stderr, "%s: qid=%u, out_degree=%u\n", prog, qid_test, out_degree_test);
- //
- //-- save data for gnuplot output
- dat_col=0;
- if (!dat_header) dat_header = g_string_new("");
- if (!dat_data) dat_data = g_string_new("");
- if (dat_row==0) {
- g_string_append(dat_header,"#1:out_deg");
- }
- g_string_append_printf(dat_data, "%u", out_degree_test);
-}
-
-void report_column(char *label, double elapsed) {
- double iters_per_sec = ((double)count_test)/elapsed;
- //
- //-- to stderr
- fprintf(stderr, "BENCH[%16s]: %ld iters in %.2g sec: %.2g iters/sec\n",
- label, count_test, elapsed, iters_per_sec);
- fflush(stderr);
- //
- //-- to data strings
- if (dat_row==0) {
- g_string_append_printf(dat_header, "\t%d:%s_secs\t%d:%s_ips", (2*dat_col+2),label, (2*dat_col+3),label);
- }
- g_string_append_c(dat_data,'\t');
- g_string_append_printf(dat_data,"\t%g\t%g", elapsed,iters_per_sec);
- ++dat_col;
-}
-
-void report_end_row(void) {
- ++dat_row;
- g_string_append(dat_data,"\n");
-}
-
-void report_gnuplot(void) {
- fflush(stderr);
- printf("%s\n%s", dat_header->str, dat_data->str);
-}
-
-
-/*======================================================================
- * Main
- */
-int main(int argc, char **argv)
-{
- char *qid_str="0";
- gfsmError *err=NULL;
- int argi;
- //
- gfsmAutomaton *fsm=NULL;
- double elapsed_vanilla;
-#ifdef BENCH_SORTED
- gfsmAutomaton *fsm_sorted=NULL;
- double elapsed_sorted;
-#endif
- gfsmIndexedAutomaton *xfsm=NULL;
- double elapsed_indexed;
- gfsmIndexedAutomaton2 *xfsm2=NULL;
- double elapsed_indexed2;
-
- //-- sanity check
- if (argc < 2) {
- fprintf(stderr, "Usage: %s [QID(s)...]\n", prog);
- exit(1);
- }
-
- //-- load probabilities & initialize
- load_label_probs();
- populate_seek_labels();
-
- //-- report
- fprintf(stderr, "%s: count=%lu\n", prog, count_test);
- fflush(stderr);
-
- //-- load/create: vanilla
- fprintf(stderr, "%s: loading vanilla automaton '%s'... ", prog, fsmfile); fflush(stderr);
- fsm = gfsm_automaton_new();
- if (!gfsm_automaton_load_bin_filename(fsm,fsmfile,&err)) {
- fprintf(stderr,"%s: load failed for '%s': %s\n", prog, fsmfile, (err ? err->message : "?"));
- exit(3);
- }
- fsm->flags.sort_mode = gfsmASMNone;
- fprintf(stderr, "loaded.\n"); fflush(stderr);
-
-#ifdef BENCH_SORTED
- //-- load/create: sorted
- fprintf(stderr, "%s: sorting... ", prog); fflush(stderr);
- fsm_sorted = gfsm_automaton_clone(fsm);
- gfsm_automaton_arcsort(fsm_sorted,gfsmASMLower);
- fprintf(stderr, "sorted.\n"); fflush(stderr);
-#endif
-
- //-- load/create: indexed
- fprintf(stderr, "%s: indexing... ", prog); fflush(stderr);
- xfsm = gfsm_automaton_to_indexed(fsm,NULL);
- fprintf(stderr, "indexed.\n"); fflush(stderr);
-
- //-- load/create: indexed2
- fprintf(stderr, "%s: indexing(2)... ", prog); fflush(stderr);
- xfsm2 = gfsm_automaton_to_indexed2(fsm,NULL);
- fprintf(stderr, "indexed.\n"); fflush(stderr);
-
- //-- main loop
- for (argi=1; argi < argc; argi++) {
- qid_str = argv[argi];
- qid_test = strtol(qid_str,NULL,0);
- out_degree_test = gfsm_automaton_out_degree(fsm,qid_test);
-
- report_new_row();
-
- //-- benchmark: vanilla
- elapsed_vanilla = bench_seek_vanilla(fsm);
- report_column("vanilla", elapsed_vanilla);
-
-#ifdef BENCH_SORTED
- //-- benchmark: vanilla+sorted
- gfsm_automaton_arcsort(fsm,gfsmASMLower);
- elapsed_sorted = bench_seek_vanilla(fsm);
- report_column("sorted", elapsed_sorted);
-#endif
-
- //-- benchmark: indexed
- elapsed_indexed = bench_seek_indexed(xfsm);
- report_column("indexed", elapsed_indexed);
-
- //-- benchmark: indexed2
- elapsed_indexed2 = bench_seek_indexed2(xfsm2);
- report_column("indexed2", elapsed_indexed2);
-
- report_end_row();
- }
-
- //-- gnuplot output
- report_gnuplot();
-
- //-- cleanup
- if (fsm) gfsm_automaton_free(fsm);
-#ifdef BENCH_SORTED
- if (fsm_sorted) gfsm_automaton_free(fsm_sorted);
-#endif
- if (xfsm) gfsm_indexed_automaton_free(xfsm);
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/seektest.dat b/gfsm/gfsm/src/libgfsm/tests/seektest.dat
deleted file mode 100644
index 2f05a4b..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/seektest.dat
+++ /dev/null
@@ -1,9 +0,0 @@
-#1:out_deg 2:vanilla_secs 3:vanilla_ips 4:indexed_secs 5:indexed_ips
-1 0.100445 4.17572e+07 0.057384 7.30919e+07
-2 0.108812 3.85463e+07 0.139554 3.00551e+07
-4 0.141588 2.96233e+07 0.148173 2.83068e+07
-8 0.195003 2.15089e+07 0.147859 2.83669e+07
-16 0.292195 1.43545e+07 0.21333 1.96611e+07
-32 0.539624 7.77264e+06 0.328515 1.27675e+07
-64 0.889506 4.71532e+06 0.394453 1.06332e+07
-148 1.79711 2.33392e+06 0.544203 7.70724e+06
diff --git a/gfsm/gfsm/src/libgfsm/tests/settest.c b/gfsm/gfsm/src/libgfsm/tests/settest.c
deleted file mode 100644
index 443f4d1..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/settest.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <glib.h>
-#include <gfsm.h>
-
-int main (void)
-{
- gfsmSet *set;
- GSList *setl;
- GPtrArray *setary;
- g_mem_set_vtable(glib_mem_profiler_table);
-
- set = gfsm_set_new(gfsm_uint_compare);
- gfsm_set_insert(set,(gpointer)2);
-
- //gfsm_set_clear(set);
-
- /*
- fprintf(stderr,"**** set=");
- gfsm_set_print_uint(set,stderr);
- fprintf(stderr,"\n");
- */
- //setl = gfsm_set_to_slist(set);
- //g_slist_free(setl);
- /*
- setl = g_slist_prepend(NULL,(gpointer)2);
- g_slist_free(setl);
- */
- setary = g_ptr_array_sized_new(gfsm_set_size(set));
- gfsm_set_to_ptr_array(set,setary);
- g_ptr_array_free(setary,TRUE);
-
- gfsm_set_free(set);
-
- g_blow_chunks();
- g_mem_profile();
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/sizes.bc b/gfsm/gfsm/src/libgfsm/tests/sizes.bc
deleted file mode 100644
index 28632e4..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/sizes.bc
+++ /dev/null
@@ -1,70 +0,0 @@
-##-*- Mode: Shell-Script -*-
-
-##-- tagh size (carrot)
-tagh_carrot_n_states = 5345565;
-tagh_carrot_n_finals = 1;
-tagh_carrot_n_arcs = 9407741;
-
-##-- test constants (tagh, carrot)
-n_states = tagh_carrot_n_states;
-n_finals = tagh_carrot_n_finals;
-n_arcs = tagh_carrot_n_arcs;
-
-##-- basic type sizes
-size_ptr = 4;
-size_int32 = 4;
-size_float = 4;
-size_arc = 12;
-size_arc_src = 16;
-size_weight = size_float;
-
-##-- vanilla automaton sizes
-define size_vanilla_arcs(n_arcs) { return n_arcs*(size_arc+size_ptr); }
-define size_vanilla_states(n_states,n_finals) {
- return (n_states*(size_int32+size_ptr)) + (n_finals*(size_float+size_int32));
-}
-define size_vanilla_full(n_states,n_finals,n_arcs) {
- return size_vanilla_states(n_states,n_finals) + size_vanilla_arcs(n_arcs);
-}
-size_vanilla = size_vanilla_full(n_states,n_finals,n_arcs) / 2^20; ##== 184MB
-
-##-- basic index type sizes
-define size_arctab_ptr(n_arcs) { return (n_arcs*size_ptr); }
-define size_arctab(n_arcs) { return (n_arcs*size_arc); }
-define size_arcfirst(n_states) { return (n_states*size_ptr); }
-define size_finaltab(n_states) { return (n_states*size_weight); }
-define size_bitvec(n_bits) { return (n_bits/8); }
-
-##-- arcindex_ptr: auxilliary index: { arc*[] arc_ptrs_sorted; arc** first; }
-define size_arcindex_ptr_full(n_states,n_finals,n_arcs) {
- return size_arctab_ptr(n_arcs) + size_arcfirst(n_states);
-}
-size_arcindex_ptr = size_arcindex_ptr_full(n_states,n_finals,n_arcs)/2^20; ##== 56MB
-
-##-- arcindex_tab: copy index: { arc[] arcs_sorted; arc* first; }
-define size_arcindex_tab_full(n_states,n_finals,n_arcs) {
- return size_arctab(n_arcs) + size_arcfirst(n_states);
-}
-size_arcindex_tab = size_arcindex_tab_full(n_states,n_finals,n_arcs) / 2^20;
-
-##-- fsmtab: copy index: { arc[] arcs_sorted; arc* first; weight[] finals; }
-## --> SMALLEST, likely also MOST EFFICIENT!
-## + w/ finals: 149MB (vs. vanilla 184MB)
-## + w/o finals: 129MB
-define size_fsmtab_full(n_states,n_finals,n_arcs) {
- return size_arctab(n_arcs) + size_arcfirst(n_states) + size_finaltab(n_states) + size_bitvec(n_states);
-}
-size_fsmtab = size_fsmtab_full(n_states,n_finals,n_arcs) / 2^20; ##== 149MB
-
-##-- fsmbitab: bi-indexed: { arc[] arcs; int32~arc*[] first; weight[] finals; int32[] ix_lo; int32[] ix_hi; }
-define size_ixtab(n_arcs) { return n_arcs*size_int32; }
-define size_fsmbitab_full(n_states,n_finals,n_arcs) {
- return size_fsmtab_full(n_states,n_finals,n_arcs) + 2*size_ixtab(n_arcs);
-}
-size_fsmbitab = size_fsmbitab_full(n_states,n_finals,n_arcs) / 2^20; ##== 220MB
-
-##-- fsmbitab2: bi-indexed: { arc[] arcs~ix_lo; int32~arc*[] first; weight[] finals; int32[] ix_hi; }
-define size_fsmbitab2_full(n_states,n_finals,n_arcs) {
- return size_fsmtab_full(n_states,n_finals,n_arcs) + size_ixtab(n_arcs);
-}
-size_fsmbitab2 = size_fsmbitab2_full(n_states,n_finals,n_arcs) / 2^20; ##== 185MB
diff --git a/gfsm/gfsm/src/libgfsm/tests/sizetest.c b/gfsm/gfsm/src/libgfsm/tests/sizetest.c
deleted file mode 100644
index 5e09070..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/sizetest.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <stdio.h>
-
-typedef struct {
- int x1 : 1;
- int x2 : 1;
- int x3 : 30;
-} tstruc;
-
-int main (void) {
- int i;
- tstruc ts;
-
- printf("sizeof(int)=%ld ; sizeof(tstruc)=%ld\n", sizeof(int), sizeof(tstruc));
- printf("sizeof(float)=%ld, sizeof(void*)=%ld\n", sizeof(float), sizeof(void*));
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/sltest.c b/gfsm/gfsm/src/libgfsm/tests/sltest.c
deleted file mode 100644
index 8567e6a..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/sltest.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <glib.h>
-#include <stdio.h>
-
-int main (void) {
- GSList *sl=NULL;
- GAllocator *myalloc=NULL;
-
- g_mem_set_vtable(glib_mem_profiler_table);
-
- //-- allocator hack
- myalloc = g_allocator_new("myAllocator", 128);
- g_slist_push_allocator(myalloc);
-
- sl = g_slist_prepend(NULL,(gpointer)2);
- g_slist_free(sl);
-
- //-- allocator hack
- g_slist_pop_allocator();
- g_allocator_free(myalloc);
-
- g_blow_chunks();
- g_mem_profile();
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/statetest.tfst b/gfsm/gfsm/src/libgfsm/tests/statetest.tfst
deleted file mode 100644
index 175575f..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/statetest.tfst
+++ /dev/null
@@ -1,8 +0,0 @@
-0 1 0 0 0
-0 2 0 0 0
-0 3 0 0 0
-3 4 0 0 0
-0 99 99 99 0
-1
-2
-3
diff --git a/gfsm/gfsm/src/libgfsm/tests/structtest.c b/gfsm/gfsm/src/libgfsm/tests/structtest.c
deleted file mode 100644
index 6bb0558..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/structtest.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <glib.h>
-#include <stdio.h>
-
-typedef struct {
- guint32 i1 : 1;
- guint32 i2 : 31;
-} testme;
-
-int main (void) {
-
- printf("guint32:%u ; testme=%u\n", sizeof(guint32), sizeof(testme));
-
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/tagh-lo.testus b/gfsm/gfsm/src/libgfsm/tests/tagh-lo.testus
deleted file mode 100644
index b8eeec7..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/tagh-lo.testus
+++ /dev/null
@@ -1,8 +0,0 @@
-5 out_deg=1
-4 out_deg=2
-11 out_deg=4
-98 out_deg=8
-5257 out_deg=16
-45623 out_deg=32
-290132 out_deg=64
-0 out_deg=148
diff --git a/gfsm/gfsm/src/libgfsm/tests/test-255.lab b/gfsm/gfsm/src/libgfsm/tests/test-255.lab
deleted file mode 100644
index d2ad9fa..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/test-255.lab
+++ /dev/null
@@ -1,3 +0,0 @@
-a 1
-ÿ 2
-b 3
diff --git a/gfsm/gfsm/src/libgfsm/tests/test-stateset.c b/gfsm/gfsm/src/libgfsm/tests/test-stateset.c
deleted file mode 100644
index 4e56112..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/test-stateset.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <gfsm.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-const char *progname = "test-stateset";
-const char *infilename = "statetest.tfst";
-
-gfsmAutomaton *fsm;
-gfsmError *err = NULL;
-
-gboolean stateset_print_func(gfsmStateId id, gpointer data)
-{
- printf(" %u", id);
- return FALSE;
-}
-
-void stateset_print(const char *label, gfsmStateSet *sset)
-{
- gfsmStateSetIter ssi;
- gfsmStateId ssid;
-
- printf("%s: {", label);
-
- //gfsm_stateset_foreach(sset, stateset_print_func, NULL);
- for (ssi = gfsm_stateset_iter_begin(sset);
- (ssid=gfsm_stateset_iter_id(ssi)) != gfsmNoState;
- ssi = gfsm_stateset_iter_next(sset,ssi))
- {
- printf(" %u", ssid);
- }
-
- printf(" }\n");
-}
-
-int main (int argc, char **argv) {
- int i;
- gfsmStateId id;
- gfsmStateSet *sset;
-
- fsm = gfsm_automaton_new();
- sset = gfsm_stateset_new();
-
- if (!gfsm_automaton_compile_filename(fsm,infilename,&err)) {
- g_printerr("%s: compile failed for '%s': %s\n", progname, infilename, err->message);
- exit(255);
- }
- printf("%s: compiled test automaton from '%s'\n", *argv, infilename);
-
- for (i=0; i < argc; i++) {
- id = strtol(argv[i],NULL,10);
- gfsm_stateset_clear(sset);
- gfsm_stateset_populate(sset,fsm,id, gfsmEpsilon, gfsmEpsilon);
-
- printf("--\nseed=%u\n", id);
- stateset_print("equiv", sset);
- }
-
- gfsm_stateset_free(sset);
- gfsm_automaton_free(fsm);
- return 0;
-}
diff --git a/gfsm/gfsm/src/libgfsm/tests/test.lab b/gfsm/gfsm/src/libgfsm/tests/test.lab
deleted file mode 100644
index ff5af08..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/test.lab
+++ /dev/null
@@ -1,10 +0,0 @@
-<epsilon> 0
-a 1
-b 2
-c 3
-d 4
-e 5
-f 6
-foo 42
-bar 43
-baz 44
diff --git a/gfsm/gfsm/src/libgfsm/tests/test.txt b/gfsm/gfsm/src/libgfsm/tests/test.txt
deleted file mode 100644
index c89f586..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/test.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-This is a test.
-This is ONLY a test.
diff --git a/gfsm/gfsm/src/libgfsm/tests/test2.lab b/gfsm/gfsm/src/libgfsm/tests/test2.lab
deleted file mode 100644
index 2398dad..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/test2.lab
+++ /dev/null
@@ -1,2 +0,0 @@
-a 1
-b 2
diff --git a/gfsm/gfsm/src/libgfsm/tests/test2.txt b/gfsm/gfsm/src/libgfsm/tests/test2.txt
deleted file mode 100644
index ed2c580..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/test2.txt
+++ /dev/null
@@ -1 +0,0 @@
-a b c \ No newline at end of file
diff --git a/gfsm/gfsm/src/libgfsm/tests/testme.lab b/gfsm/gfsm/src/libgfsm/tests/testme.lab
deleted file mode 100644
index 78226ef..0000000
--- a/gfsm/gfsm/src/libgfsm/tests/testme.lab
+++ /dev/null
@@ -1,5 +0,0 @@
-<eps> 0
-a 1
-b 2
-c 3
-answer 42