#!/bin/sh
TESTSDIR=debian/tests
TMP=${AUTOPKGTEST_TMP:-.}
dd if=/dev/zero of=$TMP/zero.bin bs=1024 count=1 status=none
umockdev-run --device $TESTSDIR/nxt.umockdev \
	--pcap /sys/devices/pci0000:00/0000:00:14.0/usb1/1-2=$TESTSDIR/nxt.pcapng \
	fwexec $TMP/zero.bin > $TMP/nxt-found.output
EXIT_CODE=$?
echo "Exit code: $EXIT_CODE"
cat $TMP/nxt-found.output

if [ $EXIT_CODE -ne 2 ]; then
	echo "Exit code should be 2" >&2
	exit 1
fi

if ! diff -u $TESTSDIR/nxt-found.output-expected $TMP/nxt-found.output; then
	echo "Output mismatch" >&2
	exit 1
fi

echo Success
exit 0
