# Make sure we can restart from a pipe.
CHECKS+= check-pipe-restart
CLEANFILES+= piperestart.in piperestart.in.tmp
CLEANFILES+= piperestart.cl2 piperestart.cl2.tmp
CLEANFILES+= piperestart.cl2restart piperestart.cl2restart.tmp
CLEANFILES+= piperestart.cl2part piperestart.cl2part.tmp
check-pipe-restart: .PHONY piperestart.cl2 piperestart.cl2restart
cmp ${.ALLSRC}
piperestart.cl2restart: piperestart.cl2part vndcompress
cp piperestart.cl2part ${.TARGET}.tmp \
&& head -c 700000 < /usr/share/dict/words \
| ./vndcompress -l 655360 -k 1 -r -R /dev/stdin ${.TARGET}.tmp \
&& mv -f ${.TARGET}.tmp ${.TARGET}
# The following rule uses ; and not && on purpose: vndcompress is
# supposed to fail (and it is even OK to interrupt!) so we can restart
# and fill in the rest.
piperestart.cl2part: vndcompress
head -c 600000 < /usr/share/dict/words \
| ./vndcompress -l 655360 -k 1 /dev/stdin ${.TARGET}.tmp; \
mv -f ${.TARGET}.tmp ${.TARGET}
piperestart.in:
head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
&& mv -f ${.TARGET}.tmp ${.TARGET}
# Make sure we can restart from a pipe even if the original start was
# corrupted, as long as we don't pass -R.
CHECKS+= check-pipe-badstart
CLEANFILES+= pipebadstart.in pipebadstart.in.tmp
CLEANFILES+= pipebadstart.cl2 pipebadstart.cl2.tmp
CLEANFILES+= pipebadstart.cl2restart pipebadstart.cl2restart.tmp
CLEANFILES+= pipebadstart.cl2part pipebadstart.cl2part.tmp
check-pipe-badstart: .PHONY pipebadstart.cl2 pipebadstart.cl2restart
cmp ${.ALLSRC}
pipebadstart.cl2restart: pipebadstart.cl2part vndcompress
cp pipebadstart.cl2part ${.TARGET}.tmp \
&& head -c 700000 < /usr/share/dict/words \
| ./vndcompress -l 655360 -k 1 -r /dev/stdin ${.TARGET}.tmp \
&& mv -f ${.TARGET}.tmp ${.TARGET}
pipebadstart.cl2part:
touch ${.TARGET}
pipebadstart.in:
head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
&& mv -f ${.TARGET}.tmp ${.TARGET}
# Make sure we can `restart' even if there's nothing there.
CHECKS+= check-pipe-falsestart
CLEANFILES+= pipefalsestart.in pipefalsestart.in.tmp
CLEANFILES+= pipefalsestart.cl2 pipefalsestart.cl2.tmp
CLEANFILES+= pipefalsestart.cl2restart pipefalsestart.cl2restart.tmp
check-pipe-falsestart: .PHONY pipefalsestart.cl2 pipefalsestart.cl2restart
cmp ${.ALLSRC}
pipefalsestart.cl2restart: vndcompress
rm -f ${.TARGET}.tmp \
&& head -c 700000 < /usr/share/dict/words \
| ./vndcompress -l 655360 -k 1 -r /dev/stdin ${.TARGET}.tmp \
&& mv -f ${.TARGET}.tmp ${.TARGET}
pipefalsestart.in:
head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
&& mv -f ${.TARGET}.tmp ${.TARGET}
CHECKS+= check-pipewindow
check-pipewindow: smallwindow.cl2
@echo '# expecting failure...'
if cat smallwindow.cl2 | ./vndcompress -w 1 -d /dev/stdin /dev/null; \
then \
echo 'unexpected pass!' && exit 1; \
fi
# The following two tests try to ensure a limited window size means
# limited memory allocation. They don't work very well. The virtual
# address space rlimit (ulimit -v, RLIMIT_AS) must cover the stack size
# that is allocated automatically for the process, which varies from
# machine architecture to machine architecture (the kernel's MAXSSIZ
# parameter), as well as any shared libraries that get loaded in and
# other auxiliary crud the loader or libc might allocate.
#
# In principle, the overhead from that and the program image should be
# constant, and the only substantial memory allocation performed by
# vndcompress should be w*8 bytes or (n/b)*8, where w is the window
# size if specified, n is the size of the input, and b is the block
# size.
#
# We could perhaps do an exponential growth and then binary search on
# the virtual address space limit to determine the overhead, but that's
# more trouble than I care to do in a makefile right now. Currently
# this is calibrated for NetBSD/amd64 6, where 128 MB of virtual
# address space is allocated for the stack. (Note `ulimit -v' takes a
# number of kilobytes, not a number of bytes.) Since this is not
# reliable, however, these are commented out.