Makefile revision 1.2
1# $OpenBSD: Makefile,v 1.2 2017/06/22 16:10:34 bluhm Exp $ 2 3# Copyright (c) 2008 Marco Pfatschbacher <mpf@openbsd.org> 4# Copyright (c) 2017 Alexander Bluhm <bluhm@openbsd.org> 5# 6# Permission to use, copy, modify, and distribute this software for any 7# purpose with or without fee is hereby granted, provided that the above 8# copyright notice and this permission notice appear in all copies. 9# 10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 18CLEANFILES= *.gz rc rcmotd multi owner perm 19 20# Test if gzip(1) detects truncated or corrupted files 21 22REGRESS_TARGETS+= run-regress-integrity 23run-regress-integrity: 24 @echo "\n==== $@ ====" 25 # create gz 26 gzip -v </etc/rc >rc.gz 27 # check that everything is ok 28 gzip -vt rc.gz 29 30REGRESS_TARGETS+= run-regress-truncate-2k 31run-regress-truncate-2k: 32 @echo "\n==== $@ ====" 33 # truncate at 2k 34 gzip </etc/rc >rc.gz 35 dd if=rc.gz bs=1k count=2 of=2k.gz 36 # check that truncation is detected 37 ! gzip -vt 2k.gz 38 39REGRESS_TARGETS+= run-regress-truncate-1k 40run-regress-truncate-1k: 41 @echo "\n==== $@ ====" 42 # truncate at 1k 43 gzip </etc/rc >rc.gz 44 dd if=rc.gz bs=1k count=1 of=1k.gz 45 # check that truncation is detected 46 ! gzip -vt 1k.gz 47 48REGRESS_TARGETS+= run-regress-skip 49run-regress-skip: 50 @echo "\n==== $@ ====" 51 # skip some data in the middle 52 gzip </etc/rc >rc.gz 53 dd if=rc.gz bs=1k count=1 of=skip.gz 54 dd if=rc.gz bs=1k seek=2 skip=2 conv=notrunc of=skip.gz 55 # check that corruption is detected 56 ! gzip -vt skip.gz 57 58JOT100!= jot 100 59REGRESS_TARGETS+= run-regress-fuzz 60run-regress-fuzz: 61 @echo "\n==== $@ ====" 62 # simple fuzzer that modifies one random byte at a random offset 63 gzip </etc/rc >rc.gz 64.for i in ${JOT100} 65 dd if=rc.gz bs=1k of=fuzz.gz status=none 66 RANDOM=$i;\ 67 where=$$((RANDOM % 2048 + 256)); fuzz=$$((RANDOM % 256));\ 68 orig=`dd if=rc.gz bs=1 skip=$$where count=1 status=none |\ 69 hexdump -e '"%d"'`;\ 70 echo "$i/100: fuzzing byte @$$where: $$orig -> $$fuzz";\ 71 echo -n \\0`printf "%o" $$fuzz` |\ 72 dd bs=1 seek=$$where conv=notrunc of=fuzz.gz status=none 73 cmp -s rc.gz fuzz.gz || ! gzip -vt fuzz.gz 74.endfor 75 76# test basic gzip functionality 77 78REGRESS_TARGETS+= run-regress-gunzip 79run-regress-gunzip: 80 @echo "\n==== $@ ====" 81 # gzip and gunzip 82 gzip -v </etc/rc >rc.gz 83 gunzip -f rc.gz 84 # check that uncompressed file does match 85 diff -up /etc/rc rc 86 87REGRESS_TARGETS+= run-regress-multi 88run-regress-multi: 89 @echo "\n==== $@ ====" 90 # compress multiple files 91 gzip -c /etc/rc /etc/motd >multi.gz 92 # check multiple gzip file 93 gzip -vt multi.gz 94 gunzip -f multi.gz 95 # check that gunzipped files do match 96 cat /etc/rc /etc/motd >rcmotd 97 diff -up rcmotd multi 98 99# Test permissions 100 101REGRESS_TARGETS+= run-regress-perm-zip 102run-regress-perm-zip: 103 @echo "\n==== $@ ====" 104 # compress file with special permissions 105 cat /etc/rc >perm 106 chmod 614 perm 107 rm -f perm.gz 108 gzip perm 109 ls -l perm.gz | grep '^-rw---xr-- ' 110 111REGRESS_TARGETS+= run-regress-perm-unzip 112run-regress-perm-unzip: 113 @echo "\n==== $@ ====" 114 # uncompress file with special permissions 115 gzip </etc/rc >perm.gz 116 chmod 614 perm.gz 117 rm -f perm 118 gunzip perm.gz 119 ls -l perm | grep '^-rw---xr-- ' 120 121REGRESS_TARGETS+= run-regress-owner-zip 122run-regress-owner-zip: 123 @echo "\n==== $@ ====" 124 # compress file as root with user and group nobody 125 rm -f owner 126 cat /etc/rc >owner 127 ${SUDO} chown nobody:nobody owner 128 rm -f owner.gz 129 ${SUDO} gzip owner 130 ls -l owner.gz | grep ' nobody *nobody ' 131 132REGRESS_TARGETS+= run-regress-owner-unzip 133run-regress-owner-unzip: 134 @echo "\n==== $@ ====" 135 # uncompress file with special permissions 136 rm -f owner.gz 137 gzip </etc/rc >owner.gz 138 ${SUDO} chown nobody:nobody owner.gz 139 rm -f owner 140 ${SUDO} gunzip owner.gz 141 ls -l owner | grep ' nobody *nobody ' 142 143.include <bsd.regress.mk> 144