2009-12-15 05:01:36 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2012-03-21 02:55:55 +08:00
|
|
|
# Copyright (c) 2009-2012 Petri Lehtinen <petri@digip.org>
|
2009-12-15 05:01:36 +08:00
|
|
|
#
|
|
|
|
# Jansson is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the MIT license. See LICENSE for details.
|
|
|
|
|
2012-03-08 21:01:52 +08:00
|
|
|
JSON_SORT_KEYS=1
|
|
|
|
export JSON_SORT_KEYS
|
2009-12-17 04:05:55 +08:00
|
|
|
|
2009-12-15 05:01:36 +08:00
|
|
|
is_test() {
|
|
|
|
test -d $test_path
|
|
|
|
}
|
|
|
|
|
2011-02-22 16:47:02 +08:00
|
|
|
do_run() {
|
|
|
|
variant=$1
|
|
|
|
s=".$1"
|
|
|
|
|
|
|
|
strip=0
|
|
|
|
[ "$variant" = "strip" ] && strip=1
|
|
|
|
|
|
|
|
STRIP=$strip $json_process \
|
|
|
|
<$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s
|
|
|
|
valgrind_check $test_log/stderr$s || return 1
|
|
|
|
|
|
|
|
ref=output
|
|
|
|
[ -f $test_path/output$s ] && ref=output$s
|
|
|
|
|
|
|
|
if ! cmp -s $test_path/$ref $test_log/stdout$s; then
|
|
|
|
echo $variant > $test_log/variant
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-12-15 05:01:36 +08:00
|
|
|
run_test() {
|
2011-02-22 16:47:02 +08:00
|
|
|
do_run normal && do_run strip
|
2009-12-15 05:01:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
show_error() {
|
|
|
|
valgrind_show_error && return
|
|
|
|
|
2011-02-22 16:47:02 +08:00
|
|
|
read variant < $test_log/variant
|
|
|
|
s=".$variant"
|
|
|
|
|
|
|
|
echo "VARIANT: $variant"
|
|
|
|
|
2009-12-15 05:01:36 +08:00
|
|
|
echo "EXPECTED OUTPUT:"
|
2011-02-22 16:47:02 +08:00
|
|
|
ref=output
|
|
|
|
[ -f $test_path/output$s ] && ref=output$s
|
|
|
|
nl -bn $test_path/$ref
|
|
|
|
|
2009-12-15 05:01:36 +08:00
|
|
|
echo "ACTUAL OUTPUT:"
|
2011-02-22 16:47:02 +08:00
|
|
|
nl -bn $test_log/stdout$s
|
2009-12-15 05:01:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
. $top_srcdir/test/scripts/run-tests.sh
|