Update copyright notices for 2012
[jansson.git] / test / suites / valid / run
1 #!/bin/sh
2 #
3 # Copyright (c) 2009-2012 Petri Lehtinen <petri@digip.org>
4 #
5 # Jansson is free software; you can redistribute it and/or modify
6 # it under the terms of the MIT license. See LICENSE for details.
7
8 JSON_SORT_KEYS=1
9 export JSON_SORT_KEYS
10
11 is_test() {
12     test -d $test_path
13 }
14
15 do_run() {
16     variant=$1
17     s=".$1"
18
19     strip=0
20     [ "$variant" = "strip" ] && strip=1
21
22     STRIP=$strip $json_process \
23         <$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s
24     valgrind_check $test_log/stderr$s || return 1
25
26     ref=output
27     [ -f $test_path/output$s ] && ref=output$s
28
29     if ! cmp -s $test_path/$ref $test_log/stdout$s; then
30         echo $variant > $test_log/variant
31         return 1
32     fi
33 }
34
35 run_test() {
36     do_run normal && do_run strip
37 }
38
39 show_error() {
40     valgrind_show_error && return
41
42     read variant < $test_log/variant
43     s=".$variant"
44
45     echo "VARIANT: $variant"
46
47     echo "EXPECTED OUTPUT:"
48     ref=output
49     [ -f $test_path/output$s ] && ref=output$s
50     nl -bn $test_path/$ref
51
52     echo "ACTUAL OUTPUT:"
53     nl -bn $test_log/stdout$s
54 }
55
56 . $top_srcdir/test/scripts/run-tests.sh