#!/bin/bash valgrind='' if [ "$1" = "--valgrind" ] then shift valgrind='valgrind --leak-check=full --error-exitcode=1' fi parser="@abs_builddir@/parse-url" testfile=$1 url=$(head -n1 $testfile) tmp=$(mktemp) trap "rm $tmp" EXIT $valgrind $parser $url > $tmp if test $? -ne 0 then echo "Error running $parser on $testfile" exit 2 fi cmp --silent $testfile $tmp result=$? if test $result -ne 0 then echo "FAIL: URL parse results differ:" diff -u $testfile $tmp fi exit $result