summaryrefslogtreecommitdiff
path: root/tests/test-table-opts/Makefile.am
blob: 235e6c8e6d65317f370cb62d7a2efaa556431e34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# This file is part of flex.

# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:

# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.

# Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.

# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.

# ------------------------------------------------
# This test is really a set of tests, one for
# each compression flag. -Ca, -Cem, etc..
# 'test-opt' builds non-serialized scanners with various table options.
# 'test-ver' verifies that the serialized tables match the in-code tables.
# 'test-ser' deserializes the tables at runtime.
# 'test-mul' checks that we can store multiple tables in a single file.
# ------------------------------------------------

FLEX = $(top_builddir)/flex

testname  := test-table-opts
allopts   := -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem

# the test names themselves
opttests :=  $(foreach opt,$(allopts), test-opt-nr$(opt) test-opt-r$(opt))
sertests :=  $(foreach opt,$(allopts), test-ser-nr$(opt) test-ser-r$(opt))
vertests :=  $(foreach opt,$(allopts), test-ver-nr$(opt) test-ver-r$(opt))
alltests  := $(opttests) $(vertests) $(sertests) test-mul

# the executables to build
optexe := $(addsuffix $(EXEEXT),$(opttests))
verexe := $(addsuffix $(EXEEXT),$(vertests))
serexe := $(addsuffix $(EXEEXT),$(sertests))
allexe := $(optexe) $(verexe) $(serexe)

# the .c files
optsrc := $(addsuffix .c,$(opttests))
versrc := $(addsuffix .c,$(vertests))
sersrc := $(addsuffix .c,$(sertests))
allsrc := $(optsrc) $(versrc) $(sersrc)

# the .o files
optobj := $(addsuffix .o,$(opttests))
verobj := $(addsuffix .o,$(vertests))
serobj := $(addsuffix .o,$(sertests))
allobj := $(optobj) $(verobj) $(serobj)

# the .tables files
sertables  := $(addsuffix .tables,$(sertests))
alltables  := $(addsuffix .tables,$(alltests))

EXTRA_DIST = scanner.l test.input
CLEANFILES = scanner.c OUTPUT $(allobj) $(allsrc) $(alltables) \
             all-ser.tables $(allexe)
AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_builddir)

test: test-opt test-ser test-ver test-mul

test-opt-r%.c: $(srcdir)/scanner.l
	$(FLEX) -L -P $(subst -,_,$(basename $(@F))) --reentrant $*  -o $@ $<

test-opt-nr%.c: $(srcdir)/scanner.l
	$(FLEX) -L -P $(subst -,_,$(basename $(@F))) $* -o $@ $<

test-ser-r%.c: $(srcdir)/scanner.l
	$(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ser-r$*.tables" $*  -o $@ $<

test-ser-nr%.c: $(srcdir)/scanner.l
	$(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ser-nr$*.tables"  $* -o $@ $<

test-ver-r%.c: $(srcdir)/scanner.l
	$(FLEX) -L -P $(subst -,_,$(basename $(@F))) -R --tables-file="test-ver-r$*.tables" --tables-verify $*  -o $@ $<

test-ver-nr%.c: $(srcdir)/scanner.l
	$(FLEX) -L -P $(subst -,_,$(basename $(@F))) --tables-file="test-ver-nr$*.tables" --tables-verify $* -o $@ $<

test-opt%$(EXEEXT): test-opt%.o
	$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES)

test-ser%$(EXEEXT): test-ser%.o
	$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES)

test-ver%$(EXEEXT): test-ver%.o
	$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $(LOADLIBES)

test-opt: $(optexe)
	for t in $(optexe) ; do \
		./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
          || { echo $t FAILED ; exit 1 ; } ; \
	done

test-ver: $(verexe)
	for t in $(verexe) ; do \
		./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
          || { echo $t FAILED ; exit 1 ; } ; \
	done

test-ser: $(serexe)
	for t in $(serexe) ; do \
		./$$t `basename $$t $(EXEEXT)`.tables < $(srcdir)/test.input \
          || { echo $t FAILED ; exit 1 ; } ; \
	done

test-mul: $(serexe)
	$(RM) all-ser.tables
	cat $(sertables) > all-ser.tables
	for t in $(serexe) ; do \
		./$$t all-ser.tables < $(srcdir)/test.input || { echo $$t FAILED; exit 1; } ;  \
	done

test-opt-nr-%.o: test-opt-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) $<
test-ser-nr-%.o: test-ser-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL $(CFLAGS) $<
test-ver-nr-%.o: test-ver-nr-%.c ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL $(CFLAGS) $<

test-opt-r-%.o:  test-opt-r-%.c  ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_IS_REENTRANT $(CFLAGS) $<
test-ser-r-%.o:  test-ser-r-%.c  ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT $(CFLAGS) $<
test-ver-r-%.o:  test-ver-r-%.c  ; $(CC) -c -o $@ $(AM_CPPFLAGS) $(CPPFLAGS) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT $(CFLAGS) $<

.PHONY: test test-opt test-ser test-ver test-mul
.SECONDARY: $(allobj) $(allsrc)