1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-30 12:04:07 +00:00
freebsd/sbin/fdisk/runtest.sh
Poul-Henning Kamp 1a03d6d57a Use symbolic constants from <sys/diskmbr.h> instead of local constants.
Always set the magic sequence when we write, rather than trusting the
previously read boot code to do so.

Use explicit encoding/decoding of little endian disk image.

Remove a comment which was OBE.

Change the test vector for "fdisk -I" to reflect that there is a magic
sequence in the result now.

Add test case for "fdisk" which reads the image back.

At least for the two test-cases this program now gives the same result
on sparc64 as on i386.  The lack of an installed /boot/mbr on sparc64
raises an (un)interesting question.
2003-04-13 21:57:08 +00:00

31 lines
776 B
Bash

#!/bin/sh
# $FreeBSD$
set -e
MD=`mdconfig -a -t malloc -s 4m -x 63 -y 16`
if [ ! -c /dev/${MD} ] ; then
echo "MD device $MD did not materialize" 1>&2
exit 2
fi
trap "mdconfig -d -u ${MD}" EXIT INT TERM
# Create an empty bootcode file to isolate our checksum from any changes
# which might happen to the boot code file.
dd if=/dev/zero of=tmp count=1 > /dev/null 2>&1
./fdisk -b tmp -I $MD > /dev/null 2>&1
rm tmp
c=`dd if=/dev/${MD} count=1 2>/dev/null | md5`
if [ $c != ea4277fcccb6a927a1a497a6b15bfb8c ] ; then
echo "FAILED: 'fdisk -I' gives bad checksum ($c)" 1>&2
exit 1
fi
echo "PASSED: fdisk -I"
c=`./fdisk $MD | md5`
if [ $c != 4b126d7ac4c6b2af7ef27ede8ef102ec ] ; then
echo "FAILED: 'fdisk' gives bad checksum ($c)" 1>&2
exit 1
fi
echo "PASSED: fdisk"
exit 0