Refactor decoder input stream
[jansson.git] / test / suites / valid / run
1 #!/bin/sh
2 #
3 # Copyright (c) 2009-2011 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 export JSON_SORT_KEYS=1
9
10 is_test() {
11     test -d $test_path
12 }
13
14 do_run() {
15     variant=$1
16     s=".$1"
17
18     strip=0
19     [ "$variant" = "strip" ] && strip=1
20
21     STRIP=$strip $json_process \
22         <$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s
23     valgrind_check $test_log/stderr$s || return 1
24
25     ref=output
26     [ -f $test_path/output$s ] && ref=output$s
27
28     if ! cmp -s $test_path/$ref $test_log/stdout$s; then
29         echo $variant > $test_log/variant
30         return 1
31     fi
32 }
33
34 run_test() {
35     do_run normal && do_run strip
36 }
37
38 show_error() {
39     valgrind_show_error && return
40
41     read variant < $test_log/variant
42     s=".$variant"
43
44     echo "VARIANT: $variant"
45
46     echo "EXPECTED OUTPUT:"
47     ref=output
48     [ -f $test_path/output$s ] && ref=output$s
49     nl -bn $test_path/$ref
50
51     echo "ACTUAL OUTPUT:"
52     nl -bn $test_log/stdout$s
53 }
54
55 . $top_srcdir/test/scripts/run-tests.sh