]> Dogcows Code - chaz/yoink/blob - yajl/test/run_tests.sh
174932f491c78a54c6c4d0e2533a53e16b1cd4a3
[chaz/yoink] / yajl / test / run_tests.sh
1 #!/usr/bin/env bash
2
3 DIFF_FLAGS="-u"
4 if [[ `uname` == *W32* ]] ; then
5 DIFF_FLAGS="-wu"
6 fi
7
8 # find test binary on both platforms. allow the caller to force a
9 # particular test binary (useful for non-cmake build systems).
10 if [ -z "$testBin" ]; then
11 testBin="../build/test/Debug/yajl_test.exe"
12 if [[ ! -x $testBin ]] ; then
13 testBin="../build/test/yajl_test"
14 if [[ ! -x $testBin ]] ; then
15 echo "cannot execute test binary: '$testBin'"
16 exit 1;
17 fi
18 fi
19 fi
20
21 echo "using test binary: $testBin"
22
23 let testsSucceeded=0
24 let testsTotal=0
25
26 for file in cases/*.json ; do
27 allowComments="-c"
28
29 # if the filename starts with dc_, we disallow comments for this test
30 if [[ $(basename $file) == dc_* ]] ; then
31 allowComments=""
32 fi
33 echo -n " test case: '$file': "
34 let iter=1
35 success="success"
36
37 # parse with a read buffer size ranging from 1-31 to stress stream parsing
38 while (( $iter < 32 )) && [ $success == "success" ] ; do
39 $testBin $allowComments -b $iter < $file > ${file}.test 2>&1
40 diff ${DIFF_FLAGS} ${file}.gold ${file}.test
41 if [[ $? == 0 ]] ; then
42 if (( $iter == 31 )) ; then let testsSucceeded+=1 ; fi
43 else
44 success="FAILURE"
45 let iter=32
46 fi
47 let iter+=1
48 rm ${file}.test
49 done
50
51 echo $success
52 let testsTotal+=1
53 done
54
55 echo $testsSucceeded/$testsTotal tests successful
56
57 if [[ $testsSucceeded != $testsTotal ]] ; then
58 exit 1
59 fi
60
61 exit 0
This page took 0.031773 seconds and 3 git commands to generate.