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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#!/usr/bin/env bash
pushd $(dirname $0) > /dev/null; script_dir=$PWD; popd > /dev/null
pactester=$script_dir/../src/pactester
pacfile=$script_dir/proxy.pac
testdata=$script_dir/testdata
library_path=$script_dir/../src
export DYLD_LIBRARY_PATH=$library_path:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$library_path:$LD_LIBRARY_PATH
lib=$library_path/libpacparser.so.1
os_arch=$(uname -s | sed /\ /s//_/)
if [ "$os_arch" = "Darwin" ]; then
lib=$library_path/libpacparser.1.dylib
fi
if test ! -f "$lib"; then
echo "Test failed. pacparser library not found."
exit 1
fi
while read line
do
comment="${line#*#}"
line="${line%%#*}"
line=${line%"${line##*[^[:space:]]}"}
test -z "$line" && continue
# If machine is not connected to the internet and a test requires internet
# just skip that test.
test ! -z $NO_INTERNET && \
test "${comment/INTERNET_REQUIRED/}" != "${comment}" && \
continue
params=${line%%|*}
expected_result=${line##*|}
result=$($pactester -p $pacfile $params)
if [ $? != 0 ]; then
echo "pactester execution failed."
echo "Command tried: $pactester -p $pacfile $params"
echo "Running with debug mode on..."
echo "DEBUG=1 $pactester -p $pacfile $params"
DEBUG=1 $pactester -p $pacfile $params
exit 1
fi
[ $DEBUG ] && echo "Test line: $line"
[ $DEBUG ] && echo "Params: $params"
if [ "$result" != "$expected_result" ]; then
echo "Test failed: got \"$result\", expected \"$expected_result\""
echo "Command tried: $pactester -p $pacfile $params"
echo "Running with debug mode on..."
echo "DEBUG=1 $pactester -p $pacfile $params"
DEBUG=1 $pactester -p $pacfile $params
exit 1;
fi
done < $testdata
echo "All tests were successful."
|