Makefile revision 1.11 1 PROG= vndcompress
2 SRCS= main.c offtab.c utils.c vndcompress.c vnduncompress.c
3
4 LINKS= ${BINDIR}/vndcompress ${BINDIR}/vnduncompress
5 MLINKS= vndcompress.1 vnduncompress.1
6
7 DPADD+= ${LIBZ}
8 LDADD+= -lz
9
10 WARNS= 5
11
12 .include <bsd.prog.mk>
13
14 TESTFILES+= oneblock
15 XFAIL+= oneblock.in-outx
16 XFAIL+= oneblock.cl2-cl2x
17 oneblock.in:
18 head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \
19 && mv -f ${.TARGET}.tmp ${.TARGET}
20
21 TESTFILES+= tenblock
22 XFAIL+= tenblock.in-outx
23 XFAIL+= tenblock.cl2-cl2x
24 tenblock.in:
25 head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \
26 && mv -f ${.TARGET}.tmp ${.TARGET}
27
28 TESTFILES+= smallfile
29 XFAIL+= smallfile.in-outx
30 XFAIL+= smallfile.cl2-cl2x
31 smallfile.in:
32 head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \
33 && mv -f ${.TARGET}.tmp ${.TARGET}
34
35 CHECKS+= check-pipe
36 CLEANFILES+= smallfile.cl2pipe
37 check-pipe: .PHONY smallfile.cl2 smallfile.cl2pipe
38 cmp ${.ALLSRC}
39 smallfile.cl2pipe: smallfile.in vndcompress
40 head -c 54321 < /usr/share/dict/words \
41 | ./vndcompress -l 12345 /dev/stdin ${.TARGET}.tmp \
42 && mv -f ${.TARGET}.tmp ${.TARGET}
43
44 TESTFILES+= onechunk
45 onechunk.in:
46 head -c 65536 < /usr/share/dict/words > ${.TARGET}.tmp \
47 && mv -f ${.TARGET}.tmp ${.TARGET}
48
49 TESTFILES+= tenchunk
50 tenchunk.in:
51 head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
52 && mv -f ${.TARGET}.tmp ${.TARGET}
53
54 TESTFILES+= extrablock
55 XFAIL+= extrablock.in-outx
56 XFAIL+= extrablock.cl2-cl2x
57 extrablock.in:
58 head -c $$((65536 + 512)) < /usr/share/dict/words > ${.TARGET}.tmp \
59 && mv -f ${.TARGET}.tmp ${.TARGET}
60
61 TESTFILES+= medfile
62 XFAIL+= medfile.in-outx
63 XFAIL+= medfile.cl2-cl2x
64 medfile.in:
65 head -c 123456 < /usr/share/dict/words > ${.TARGET}.tmp \
66 && mv -f ${.TARGET}.tmp ${.TARGET}
67
68 TESTFILES+= onetinyblock
69 BLOCKSIZE.onetinyblock= 512
70 onetinyblock.in:
71 head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \
72 && mv -f ${.TARGET}.tmp ${.TARGET}
73
74 TESTFILES+= tentinyblock
75 BLOCKSIZE.tentinyblock= 512
76 tentinyblock.in:
77 head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \
78 && mv -f ${.TARGET}.tmp ${.TARGET}
79
80 CHECKS+= check-pipe-restart
81 CLEANFILES+= piperestart.in piperestart.in.tmp
82 CLEANFILES+= piperestart.cl2 piperestart.cl2.tmp
83 CLEANFILES+= piperestart.cl2restart piperestart.cl2restart.tmp
84 CLEANFILES+= piperestart.cl2part piperestart.cl2part.tmp
85 check-pipe-restart: .PHONY piperestart.cl2 piperestart.cl2restart
86 cmp ${.ALLSRC}
87 piperestart.cl2restart: piperestart.cl2part vndcompress
88 cp piperestart.cl2part ${.TARGET}.tmp \
89 && head -c 700000 < /usr/share/dict/words \
90 | ./vndcompress -l 655360 -k 1 -rR /dev/stdin ${.TARGET}.tmp \
91 && mv -f ${.TARGET}.tmp ${.TARGET}
92 # The following rule uses ; and not && on purpose: vndcompress is
93 # supposed to fail (and it is even OK to interrupt!) so we can restart
94 # and fill in the rest.
95 piperestart.cl2part: vndcompress
96 head -c 600000 < /usr/share/dict/words \
97 | ./vndcompress -l 655360 -k 1 /dev/stdin ${.TARGET}.tmp; \
98 mv -f ${.TARGET}.tmp ${.TARGET}
99 piperestart.in:
100 head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
101 && mv -f ${.TARGET}.tmp ${.TARGET}
102
103 CHECKS+= check-part
104 CLEANFILES+= part.orig part.cl2part part.cl2 part.out
105 check-part: .PHONY part.orig part.out
106 cmp part.orig part.out
107 part.cl2: part.orig part.cl2part vndcompress
108 cp part.cl2part ${.TARGET}.tmp \
109 && ./vndcompress -s 512 -rR part.orig ${.TARGET}.tmp \
110 && mv -f ${.TARGET}.tmp ${.TARGET}
111 part.cl2part: part.orig vndcompress
112 ./vndcompress -s 512 -p 10 part.orig ${.TARGET}.tmp \
113 && mv -f ${.TARGET}.tmp ${.TARGET}
114 part.orig:
115 head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \
116 && mv -f ${.TARGET}.tmp ${.TARGET}
117
118 TESTFILES+= smallwindow
119 smallwindow.in:
120 head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
121 && mv -f ${.TARGET}.tmp ${.TARGET}
122 smallwindow.cl2: smallwindow.in
123 ./vndcompress -w 1 ${.IMPSRC} ${.TARGET}.tmp \
124 && mv -f ${.TARGET}.tmp ${.TARGET}
125 smallwindow.out: smallwindow.cl2
126 ./vndcompress -w 1 -d ${.IMPSRC} ${.TARGET}.tmp \
127 && mv -f ${.TARGET}.tmp ${.TARGET}
128
129 CHECKS+= check-pipewindow
130 check-pipewindow: smallwindow.cl2
131 @echo '# expecting failure...'
132 if cat smallwindow.cl2 | ./vndcompress -w 1 -d /dev/stdin /dev/null; \
133 then \
134 echo 'unexpected pass!' && exit 1; \
135 fi
136
137 # The following two tests try to ensure a limited window size means
138 # limited memory allocation. They don't work very well. The virtual
139 # address space rlimit (ulimit -v, RLIMIT_AS) must cover the stack size
140 # that is allocated automatically for the process, which varies from
141 # machine architecture to machine architecture (the kernel's MAXSSIZ
142 # parameter), as well as any shared libraries that get loaded in and
143 # other auxiliary crud the loader or libc might allocate.
144 #
145 # In principle, the overhead from that and the program image should be
146 # constant, and the only substantial memory allocation performed by
147 # vndcompress should be w*8 bytes or (n/b)*8, where w is the window
148 # size if specified, n is the size of the input, and b is the block
149 # size.
150 #
151 # We could perhaps do an exponential growth and then binary search on
152 # the virtual address space limit to determine the overhead, but that's
153 # more trouble than I care to do in a makefile right now. Currently
154 # this is calibrated for NetBSD/amd64 6, where 128 MB of virtual
155 # address space is allocated for the stack. (Note `ulimit -v' takes a
156 # number of kilobytes, not a number of bytes.) Since this is not
157 # reliable, however, these are commented out.
158
159 #CHECKS+= check-ulimit
160 #check-ulimit:
161 # @echo '# expecting failure...'
162 # if head -c $$((64 * 1024 * 1024)) < /dev/zero \
163 # | (ulimit -v $$((139 * 1024)) && \
164 # ./vndcompress -l 64m -s 512 /dev/stdin /dev/null); then \
165 # echo 'unexpected pass!' && exit 1; \
166 # fi
167 #
168 #CHECKS+= check-ulimit-window
169 #check-ulimit-window:
170 # head -c $$((64 * 1024 * 1024)) < /dev/zero \
171 # | (ulimit -v $$((139 * 1024)) && \
172 # ./vndcompress -w 8192 -l 64m -s 512 /dev/stdin /dev/null)
173
174 TESTSUFFIXES+= in cl2 cl2x out outx
175
176 TESTFORMS+= cl2 cl2x
177 TESTFORMS+= in out
178 TESTFORMS+= in outx
179
180 .for testfile in ${TESTFILES}
181 . for suffix in ${TESTSUFFIXES}
182 CLEANFILES+= ${testfile}.${suffix}
183 CLEANFILES+= ${testfile}.${suffix}.tmp
184 . endfor
185 . for left right in ${TESTFORMS}
186 CHECKS.${testfile}+= check-${testfile}.${left}-${right}
187 check-${testfile}.${left}-${right}: .PHONY \
188 ${testfile}.${left} ${testfile}.${right}
189 . if empty(XFAIL:M${testfile}.${left}-${right})
190 cmp ${testfile}.${left} ${testfile}.${right}
191 . else
192 @echo '# expecting failure...' \
193 && echo 'cmp ${testfile}.${left} ${testfile}.${right}' \
194 && if cmp ${testfile}.${left} ${testfile}.${right}; then \
195 echo 'unexpected pass!' \
196 && exit 1; \
197 fi
198 . endif
199 . endfor
200 check-${testfile}: ${CHECKS.${testfile}}
201 CHECKS+= check-${testfile}
202 .endfor
203
204 check: .PHONY ${CHECKS}
205
206 .SUFFIXES: .cl2 .cl2x .in .out .outx
207
208 # XXX These tests should automatically try different window sizes, but
209 # that is tricky to express in make.
210
211 .in.cl2: vndcompress
212 ./vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \
213 && mv -f ${.TARGET}.tmp ${.TARGET}
214
215 .in.cl2x:
216 vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \
217 && mv -f ${.TARGET}.tmp ${.TARGET}
218
219 .cl2.out: vndcompress
220 ./vndcompress -d ${.IMPSRC} ${.TARGET}.tmp \
221 && mv -f ${.TARGET}.tmp ${.TARGET}
222
223 .cl2.outx:
224 vnduncompress ${.IMPSRC} ${.TARGET}.tmp \
225 && mv -f ${.TARGET}.tmp ${.TARGET}
226