65 lines
1.3 KiB
Bash
Executable File
65 lines
1.3 KiB
Bash
Executable File
#! /bin/sh -ex
|
|
|
|
fail () {
|
|
echo "$@"
|
|
exit 1
|
|
}
|
|
|
|
test -n "$VMDIR" || fail "must pass --with-vm to configure to run unit tests"
|
|
|
|
rm -rf tmp
|
|
mkdir tmp
|
|
cd tmp
|
|
|
|
ln -s $KSRC/arch/i386/boot/bzImage kernel.bin
|
|
ln -s $VMDIR/hda.dsk hda.dsk
|
|
|
|
cat > unit.conf <<EOF
|
|
MEM=128 # Avoids kmalloc failures that clutter output.
|
|
SWITCHES=
|
|
VMS="unit"
|
|
unit_NETS=""
|
|
EOF
|
|
|
|
unit_tests="table_t crc_t forward_t"
|
|
unit_tests_comma=`echo $unit_tests | sed 's/ /,/g'`
|
|
if test "$KVERSION" = 2.6; then
|
|
prereq_modules="openflow_mod.ko"
|
|
unit_mod="unit_mod.ko"
|
|
elif test "$KVERSION" = 2.4; then
|
|
prereq_modules="compat24_mod.o openflow_mod.o"
|
|
unit_mod="unit_mod.o"
|
|
else
|
|
fail "\$KVERSION not set"
|
|
fi
|
|
|
|
load_prereqs=
|
|
for d in $prereq_modules; do
|
|
load_prereqs="$load_prereqs
|
|
insmod $d"
|
|
done
|
|
|
|
mkdir unit.cd
|
|
ln -s $KSRC/System.map $KSRC/vmlinux unit.cd
|
|
for d in $prereq_modules $unit_mod; do
|
|
ln -s $builddir/$d unit.cd
|
|
done
|
|
cat > unit.cd/runme <<EOF
|
|
#! /bin/sh -x
|
|
$load_prereqs
|
|
insmod $unit_mod 'run="$unit_tests_comma"' || true
|
|
poweroff
|
|
EOF
|
|
chmod a+x unit.cd/runme
|
|
|
|
$top_srcdir/switch/utilities/start-test-vm -f unit unit.conf
|
|
|
|
grep -3 FAIL unit.log && fail "Unit test failed (see tmp/unit.log)"
|
|
for d in $unit_tests; do
|
|
grep -F -q "$d: PASS" unit.log || fail "$d didn't pass (see tmp/unit.log)"
|
|
done
|
|
|
|
rm -rf tmp
|
|
|
|
echo "Unit tests passed"
|