#!/bin/sh

	#-A dead_code \

rustc \
	-A unused_imports \
	-A unused_unsafe \
	-A non_camel_case_types \
	-A unused_variables \
	-o expanded \
	expanded.rs >/dev/null 2>&1
if [ "$?" -ne "0" ]; then
	#echo "failed to compile" 1>&2
	exit 1
fi

root=`dirname $0`

for i in $(seq 1 10); do
	echo $i
	$root/timeout.sh 5 ./expanded --nocapture tcp::test::write_close_ip4 2>&1 | grep "unknown error: Protocol wrong type for socket"
	RET="$?"
	if [ "$RET" -eq "0" ]; then
		echo "found a bad one" 1>&2
		exit 0
	elif [ "$RET" -eq "143" ]; then
		echo "timed out" 1>&2
		exit 1
	fi
done

echo "wasn't supposed to work" 1>&2
exit 1
