1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/bin/sh
RET=0
check_return_code () {
EXPECTED="${1}"
shift 1
echo "Calling nsntrace ${*} ..."
sudo ../src/nsntrace "${@}"
RESULT="${?}"
if [ "${EXPECTED}" != "${RESULT}" ] ; then
echo "Did not return with ${EXPECTED} (saw: ${RESULT})"
RET="1"
fi
}
check_return_code 0 /bin/true
check_return_code 1 /bin/false
check_return_code 1 /bin/does-not-exist
check_return_code 1 -u username-does-not-exist /bin/true
check_return_code 1 -f "broken filter" /bin/true
check_return_code 1 -o /path/does/not/exist /bin/true
check_return_code 1 -d invalid_device /bin/true
rm -rf *.pcap
exit ${RET}
|