xref: /freebsd/sbin/fdisk/runtest.sh (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1#!/bin/sh
2# $FreeBSD$
3
4set -e
5MD=`mdconfig -a -t malloc -s 4m -x 63 -y 16`
6if [ ! -c /dev/${MD} ] ; then
7	echo "MD device $MD did not materialize" 1>&2
8	exit 2
9fi
10trap "mdconfig -d -u ${MD}" EXIT INT TERM
11
12# Create an empty bootcode file to isolate our checksum from any changes
13# which might happen to the boot code file.
14dd if=/dev/zero of=tmp count=1 > /dev/null 2>&1
15./fdisk -b tmp -I $MD > /dev/null 2>&1
16rm tmp
17
18c=`dd if=/dev/${MD} count=1 2>/dev/null | md5`
19if [ $c != ea4277fcccb6a927a1a497a6b15bfb8c ] ; then
20	echo "FAILED: 'fdisk -I' gives bad checksum ($c)" 1>&2
21	exit 1
22fi
23echo "PASSED: fdisk -I"
24c=`./fdisk $MD | md5`
25if [ $c != 4b126d7ac4c6b2af7ef27ede8ef102ec ] ; then
26	echo "FAILED: 'fdisk' gives bad checksum ($c)" 1>&2
27	exit 1
28fi
29echo "PASSED: fdisk"
30exit 0
31