1# $OpenBSD: Makefile,v 1.6 2020/12/17 00:51:12 bluhm Exp $ 2# 3# Copyright (c) 2010 Theo de Raadt <deraadt@openbsd.org> 4# Copyright (c) 2018 Kenneth R Westerback <krw@openbsd.org> 5# Copyright (c) 2018 Alexander Bluhm <bluhm@openbsd.org> 6# 7# Permission to use, copy, modify, and distribute this software for any 8# purpose with or without fee is hereby granted, provided that the above 9# copyright notice and this permission notice appear in all copies. 10# 11# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18# 19# Regress tests for disklabel auto layout 20 21DISK_SIZES = 18000 \ 22 256 \ 23 400 \ 24 800 \ 25 1000 \ 26 1024 \ 27 2000 \ 28 2200 \ 29 2300 \ 30 3000 \ 31 3500 \ 32 4000 \ 33 4100 \ 34 5000 \ 35 6000 \ 36 7000 \ 37 8000 \ 38 9000 \ 39 90000 \ 40 12000 \ 41 20000 \ 42 40000 \ 43 300000 \ 44 900000 45 46DISKLABEL ?= ${.OBJDIR}/disklabel 47 48CLEANFILES += *.tmp *.out *.dl *.fstab diskimage disklabel.c manual.c 49 50.PATH: ${.CURDIR}/../../../sbin/disklabel 51PROG = disklabel 52SRCS = disklabel.c dkcksum.c editor.c manual.c 53CPPFLAGS = -I ${.CURDIR}/../../../sbin/disklabel 54LDADD = -lutil 55 56# The disk layout depends on physical ram. Fake it to a fixed value. 57# Recompile disklabel program. 58disklabel.c: ../../../sbin/disklabel/disklabel.c Makefile 59 sed '/^getphysmem/,/^}/s/^[ ].*/ physmem = 16844521472ULL;/' \ 60 ${.CURDIR}/../../../sbin/disklabel/disklabel.c >$@.tmp 61 mv $@.tmp $@ 62 63manual.c: 64 (echo 'const unsigned char manpage[] = {'; \ 65 echo 'no manual' | gzip -9c | hexdump -ve '"0x" 1/1 "%02x,"'; \ 66 echo '};'; echo 'const int manpage_sz = sizeof(manpage);') > manual.c 67 68.for s in ${DISK_SIZES} 69 70REGRESS_TARGETS += run-disklabel-$s 71run-disklabel-$s: $s.out 72 diff -up ${.CURDIR}/$s.ok $s.out 73 74$s.out: ${DISKLABEL} 75 rm -f $s.tmp $s.out 76 ${SUDO} vnconfig -u vnd0 || true 77 rm -f diskimage 78 echo "=== Start ${s}MB disk ===" >$s.tmp 79 dd if=/dev/zero of=diskimage bs=1m count=1 seek=$s status=none 80 ${SUDO} vnconfig vnd0 diskimage 81 ${SUDO} fdisk -iy vnd0 >>$s.tmp 82 echo >>$s.tmp 83 ${SUDO} ${DISKLABEL} -A -p g vnd0 >$s.dl 84 ${SUDO} ${DISKLABEL} -Aw -f $s.fstab vnd0 >>$s.dl 85 ${SUDO} ${DISKLABEL} vnd0 >>$s.dl 86 grep '^ [a-p]: ' $s.dl | egrep -v "unused" | sort >>$s.tmp 87 echo >>$s.tmp 88 cat $s.fstab >>$s.tmp 89 echo "=== End ${s}MB disk ===" >>$s.tmp 90 mv $s.tmp $s.out 91 92$s-update: $s.out 93 cp $s.out ${.CURDIR}/$s.ok 94 95# replace all .ok files with the new generated .out files 96update: $s-update 97 98.endfor 99 100REGRESS_CLEANUP += cleanup 101cleanup: 102 -${SUDO} vnconfig -u vnd0 103 rm -f diskimage 104 105.include <bsd.regress.mk> 106