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