1 1.3 riastrad PROG= vndcompress 2 1.6 riastrad SRCS= main.c offtab.c utils.c vndcompress.c vnduncompress.c 3 1.3 riastrad 4 1.3 riastrad LINKS= ${BINDIR}/vndcompress ${BINDIR}/vnduncompress 5 1.3 riastrad MLINKS= vndcompress.1 vnduncompress.1 6 1.1 hubertf 7 1.3 riastrad DPADD+= ${LIBZ} 8 1.1 hubertf LDADD+= -lz 9 1.1 hubertf 10 1.8 riastrad WARNS= 5 11 1.8 riastrad 12 1.1 hubertf .include <bsd.prog.mk> 13 1.3 riastrad 14 1.3 riastrad TESTFILES+= oneblock 15 1.3 riastrad XFAIL+= oneblock.in-outx 16 1.3 riastrad XFAIL+= oneblock.cl2-cl2x 17 1.3 riastrad oneblock.in: 18 1.3 riastrad head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \ 19 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 20 1.3 riastrad 21 1.3 riastrad TESTFILES+= tenblock 22 1.3 riastrad XFAIL+= tenblock.in-outx 23 1.3 riastrad XFAIL+= tenblock.cl2-cl2x 24 1.3 riastrad tenblock.in: 25 1.3 riastrad head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \ 26 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 27 1.3 riastrad 28 1.3 riastrad TESTFILES+= smallfile 29 1.3 riastrad XFAIL+= smallfile.in-outx 30 1.3 riastrad XFAIL+= smallfile.cl2-cl2x 31 1.3 riastrad smallfile.in: 32 1.3 riastrad head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \ 33 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 34 1.3 riastrad 35 1.3 riastrad CHECKS+= check-pipe 36 1.3 riastrad CLEANFILES+= smallfile.cl2pipe 37 1.3 riastrad check-pipe: .PHONY smallfile.cl2 smallfile.cl2pipe 38 1.3 riastrad cmp ${.ALLSRC} 39 1.3 riastrad smallfile.cl2pipe: smallfile.in vndcompress 40 1.3 riastrad head -c 54321 < /usr/share/dict/words \ 41 1.3 riastrad | ./vndcompress -l 12345 /dev/stdin ${.TARGET}.tmp \ 42 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 43 1.3 riastrad 44 1.3 riastrad TESTFILES+= onechunk 45 1.3 riastrad onechunk.in: 46 1.3 riastrad head -c 65536 < /usr/share/dict/words > ${.TARGET}.tmp \ 47 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 48 1.3 riastrad 49 1.3 riastrad TESTFILES+= tenchunk 50 1.3 riastrad tenchunk.in: 51 1.3 riastrad head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \ 52 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 53 1.3 riastrad 54 1.3 riastrad TESTFILES+= extrablock 55 1.3 riastrad XFAIL+= extrablock.in-outx 56 1.3 riastrad XFAIL+= extrablock.cl2-cl2x 57 1.3 riastrad extrablock.in: 58 1.3 riastrad head -c $$((65536 + 512)) < /usr/share/dict/words > ${.TARGET}.tmp \ 59 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 60 1.3 riastrad 61 1.3 riastrad TESTFILES+= medfile 62 1.3 riastrad XFAIL+= medfile.in-outx 63 1.3 riastrad XFAIL+= medfile.cl2-cl2x 64 1.3 riastrad medfile.in: 65 1.3 riastrad head -c 123456 < /usr/share/dict/words > ${.TARGET}.tmp \ 66 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 67 1.3 riastrad 68 1.3 riastrad TESTFILES+= onetinyblock 69 1.3 riastrad BLOCKSIZE.onetinyblock= 512 70 1.3 riastrad onetinyblock.in: 71 1.3 riastrad head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \ 72 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 73 1.3 riastrad 74 1.3 riastrad TESTFILES+= tentinyblock 75 1.3 riastrad BLOCKSIZE.tentinyblock= 512 76 1.3 riastrad tentinyblock.in: 77 1.3 riastrad head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \ 78 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 79 1.3 riastrad 80 1.3 riastrad CHECKS+= check-pipe-restart 81 1.3 riastrad CLEANFILES+= piperestart.in piperestart.in.tmp 82 1.3 riastrad CLEANFILES+= piperestart.cl2 piperestart.cl2.tmp 83 1.3 riastrad CLEANFILES+= piperestart.cl2restart piperestart.cl2restart.tmp 84 1.3 riastrad CLEANFILES+= piperestart.cl2part piperestart.cl2part.tmp 85 1.3 riastrad check-pipe-restart: .PHONY piperestart.cl2 piperestart.cl2restart 86 1.3 riastrad cmp ${.ALLSRC} 87 1.3 riastrad piperestart.cl2restart: piperestart.cl2part vndcompress 88 1.3 riastrad cp piperestart.cl2part ${.TARGET}.tmp \ 89 1.3 riastrad && head -c 700000 < /usr/share/dict/words \ 90 1.3 riastrad | ./vndcompress -l 655360 -k 1 -rR /dev/stdin ${.TARGET}.tmp \ 91 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 92 1.9 riastrad # The following rule uses ; and not && on purpose: vndcompress is 93 1.9 riastrad # supposed to fail (and it is even OK to interrupt!) so we can restart 94 1.9 riastrad # and fill in the rest. 95 1.3 riastrad piperestart.cl2part: vndcompress 96 1.3 riastrad head -c 600000 < /usr/share/dict/words \ 97 1.3 riastrad | ./vndcompress -l 655360 -k 1 /dev/stdin ${.TARGET}.tmp; \ 98 1.3 riastrad mv -f ${.TARGET}.tmp ${.TARGET} 99 1.3 riastrad piperestart.in: 100 1.3 riastrad head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \ 101 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 102 1.3 riastrad 103 1.3 riastrad CHECKS+= check-part 104 1.3 riastrad CLEANFILES+= part.orig part.cl2part part.cl2 part.out 105 1.3 riastrad check-part: .PHONY part.orig part.out 106 1.3 riastrad cmp part.orig part.out 107 1.3 riastrad part.cl2: part.orig part.cl2part vndcompress 108 1.3 riastrad cp part.cl2part ${.TARGET}.tmp \ 109 1.3 riastrad && ./vndcompress -s 512 -rR part.orig ${.TARGET}.tmp \ 110 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 111 1.3 riastrad part.cl2part: part.orig vndcompress 112 1.3 riastrad ./vndcompress -s 512 -p 10 part.orig ${.TARGET}.tmp \ 113 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 114 1.3 riastrad part.orig: 115 1.3 riastrad head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \ 116 1.3 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 117 1.3 riastrad 118 1.10 riastrad TESTFILES+= smallwindow 119 1.10 riastrad smallwindow.in: 120 1.10 riastrad head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \ 121 1.10 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 122 1.10 riastrad smallwindow.cl2: smallwindow.in 123 1.10 riastrad ./vndcompress -w 1 ${.IMPSRC} ${.TARGET}.tmp \ 124 1.10 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 125 1.10 riastrad smallwindow.out: smallwindow.cl2 126 1.10 riastrad ./vndcompress -w 1 -d ${.IMPSRC} ${.TARGET}.tmp \ 127 1.10 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 128 1.10 riastrad 129 1.10 riastrad CHECKS+= check-pipewindow 130 1.10 riastrad check-pipewindow: smallwindow.cl2 131 1.10 riastrad @echo '# expecting failure...' 132 1.10 riastrad if cat smallwindow.cl2 | ./vndcompress -w 1 -d /dev/stdin /dev/null; \ 133 1.10 riastrad then \ 134 1.10 riastrad echo 'unexpected pass!' && exit 1; \ 135 1.10 riastrad fi 136 1.10 riastrad 137 1.10 riastrad # These checks don't work unless RLIMIT_AS (i.e., ulimit -v) actually 138 1.10 riastrad # works! Apparently it doesn't... 139 1.10 riastrad 140 1.10 riastrad # CHECKS+= check-ulimit 141 1.10 riastrad # check-ulimit: 142 1.10 riastrad # @echo '# expecting failure...' 143 1.10 riastrad # if head -c 1073741824 < /dev/zero \ 144 1.10 riastrad # | (ulimit -v 20000 && \ 145 1.10 riastrad # ./vndcompress -l 1g -s 512 /dev/stdin /dev/null); then \ 146 1.10 riastrad # echo 'unexpected pass!' && exit 0; \ 147 1.10 riastrad # fi 148 1.10 riastrad 149 1.10 riastrad # CHECKS+= check-ulimit-window 150 1.10 riastrad # check-ulimit-window: 151 1.10 riastrad # head -c 1073741824 < /dev/zero \ 152 1.10 riastrad # | (ulimit -v 20000 && \ 153 1.10 riastrad # ./vndcompress -w 1 -l 1g -s 512 /dev/stdin /dev/null) 154 1.10 riastrad 155 1.3 riastrad TESTSUFFIXES+= in cl2 cl2x out outx 156 1.3 riastrad 157 1.3 riastrad TESTFORMS+= cl2 cl2x 158 1.3 riastrad TESTFORMS+= in out 159 1.3 riastrad TESTFORMS+= in outx 160 1.3 riastrad 161 1.3 riastrad .for testfile in ${TESTFILES} 162 1.3 riastrad . for suffix in ${TESTSUFFIXES} 163 1.3 riastrad CLEANFILES+= ${testfile}.${suffix} 164 1.3 riastrad CLEANFILES+= ${testfile}.${suffix}.tmp 165 1.3 riastrad . endfor 166 1.3 riastrad . for left right in ${TESTFORMS} 167 1.3 riastrad CHECKS.${testfile}+= check-${testfile}.${left}-${right} 168 1.3 riastrad check-${testfile}.${left}-${right}: .PHONY \ 169 1.3 riastrad ${testfile}.${left} ${testfile}.${right} 170 1.3 riastrad . if empty(XFAIL:M${testfile}.${left}-${right}) 171 1.3 riastrad cmp ${testfile}.${left} ${testfile}.${right} 172 1.3 riastrad . else 173 1.3 riastrad @echo '# expecting failure...' \ 174 1.3 riastrad && echo 'cmp ${testfile}.${left} ${testfile}.${right}' \ 175 1.3 riastrad && if cmp ${testfile}.${left} ${testfile}.${right}; then \ 176 1.3 riastrad echo 'unexpected pass!' \ 177 1.3 riastrad && exit 1; \ 178 1.3 riastrad fi 179 1.3 riastrad . endif 180 1.3 riastrad . endfor 181 1.3 riastrad check-${testfile}: ${CHECKS.${testfile}} 182 1.3 riastrad CHECKS+= check-${testfile} 183 1.3 riastrad .endfor 184 1.3 riastrad 185 1.3 riastrad check: .PHONY ${CHECKS} 186 1.3 riastrad 187 1.3 riastrad .SUFFIXES: .cl2 .cl2x .in .out .outx 188 1.3 riastrad 189 1.10 riastrad # XXX These tests should automatically try different window sizes, but 190 1.10 riastrad # that is tricky to express in make. 191 1.10 riastrad 192 1.3 riastrad .in.cl2: vndcompress 193 1.7 riastrad ./vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \ 194 1.7 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 195 1.3 riastrad 196 1.3 riastrad .in.cl2x: 197 1.7 riastrad vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \ 198 1.7 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 199 1.3 riastrad 200 1.3 riastrad .cl2.out: vndcompress 201 1.7 riastrad ./vndcompress -d ${.IMPSRC} ${.TARGET}.tmp \ 202 1.7 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 203 1.3 riastrad 204 1.3 riastrad .cl2.outx: 205 1.7 riastrad vnduncompress ${.IMPSRC} ${.TARGET}.tmp \ 206 1.7 riastrad && mv -f ${.TARGET}.tmp ${.TARGET} 207