Add spec file
[jansson.git] / test / scripts / run-tests.sh
1 # Copyright (c) 2009-2011 Petri Lehtinen <petri@digip.org>
2 #
3 # Jansson is free software; you can redistribute it and/or modify
4 # it under the terms of the MIT license. See LICENSE for details.
5
6 json_process=$bindir/json_process
7
8 suite_name=$1
9 suite_srcdir=$suites_srcdir/$suite_name
10 suite_builddir=$suites_builddir/$suite_name
11 suite_log=$logdir/$suite_name
12
13
14 [ -z "$VERBOSE" ] && VERBOSE=0
15 [ -z "$STOP" ] && STOP=0
16
17 . $scriptdir/valgrind.sh
18
19 rm -rf $suite_log
20 mkdir -p $suite_log
21
22 for test_path in $suite_srcdir/*; do
23     test_name=$(basename $test_path)
24     test_builddir=$suite_builddir/$test_name
25     test_log=$suite_log/$test_name
26
27     [ "$test_name" = "run" ] && continue
28     is_test || continue
29
30     rm -rf $test_log
31     mkdir -p $test_log
32     if [ $VERBOSE -eq 1 ]; then
33         printf '%s... ' "$test_name"
34     fi
35
36     run_test
37     case $? in
38         0)
39             # Success
40             if [ $VERBOSE -eq 1 ]; then
41                 printf 'ok\n'
42             else
43                 printf '.'
44             fi
45             rm -rf $test_log
46             ;;
47
48         77)
49             # Skip
50             if [ $VERBOSE -eq 1 ]; then
51                 printf 'skipped\n'
52             else
53                 printf 'S'
54             fi
55             rm -rf $test_log
56             ;;
57
58         *)
59             # Failure
60             if [ $VERBOSE -eq 1 ]; then
61                 printf 'FAILED\n'
62             else
63                 printf 'F'
64             fi
65
66             [ $STOP -eq 1 ] && break
67             ;;
68     esac
69 done
70
71 if [ $VERBOSE -eq 0 ]; then
72     printf '\n'
73 fi
74
75 if [ -n "$(ls -A $suite_log)" ]; then
76     for test_log in $suite_log/*; do
77         test_name=$(basename $test_log)
78         test_path=$suite_srcdir/$test_name
79         echo "================================================================="
80         echo "$suite_name/$test_name"
81         echo "================================================================="
82         show_error
83         echo
84     done
85     echo "================================================================="
86     exit 1
87 else
88     rm -rf $suite_log
89 fi