1# Copyright (c) 2009-2014 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 6die() { 7 echo "$1" >&2 8 exit 1 9} 10 11[ -n "$1" ] || die "Usage: $0 suite-name" 12[ -n "$bindir" ] || die "Set bindir" 13[ -n "$logdir" ] || die "Set logdir" 14[ -n "$scriptdir" ] || die "Set scriptdir" 15[ -n "$suites_srcdir" ] || die "Set suites_srcdir" 16[ -n "$suites_builddir" ] || die "Set suites_builddir" 17 18json_process=$bindir/json_process 19 20suite_name=$1 21suite_srcdir=$suites_srcdir/$suite_name 22suite_builddir=$suites_builddir/$suite_name 23suite_log=$logdir/$suite_name 24 25[ -z "$VERBOSE" ] && VERBOSE=0 26[ -z "$STOP" ] && STOP=0 27 28. $scriptdir/valgrind.sh 29 30rm -rf $suite_log 31mkdir -p $suite_log 32 33for test_path in $suite_srcdir/*; do 34 test_name=$(basename $test_path) 35 test_builddir=$suite_builddir/$test_name 36 test_log=$suite_log/$test_name 37 38 [ "$test_name" = "run" ] && continue 39 is_test || continue 40 41 rm -rf $test_log 42 mkdir -p $test_log 43 if [ $VERBOSE -eq 1 ]; then 44 printf '%s... ' "$test_name" 45 fi 46 47 run_test 48 case $? in 49 0) 50 # Success 51 if [ $VERBOSE -eq 1 ]; then 52 printf 'ok\n' 53 else 54 printf '.' 55 fi 56 rm -rf $test_log 57 ;; 58 59 77) 60 # Skip 61 if [ $VERBOSE -eq 1 ]; then 62 printf 'skipped\n' 63 else 64 printf 'S' 65 fi 66 rm -rf $test_log 67 ;; 68 69 *) 70 # Failure 71 if [ $VERBOSE -eq 1 ]; then 72 printf 'FAILED\n' 73 else 74 printf 'F' 75 fi 76 77 [ $STOP -eq 1 ] && break 78 ;; 79 esac 80done 81 82if [ $VERBOSE -eq 0 ]; then 83 printf '\n' 84fi 85 86if [ -n "$(ls -A $suite_log)" ]; then 87 for test_log in $suite_log/*; do 88 test_name=$(basename $test_log) 89 test_path=$suite_srcdir/$test_name 90 echo "=================================================================" 91 echo "$suite_name/$test_name" 92 echo "=================================================================" 93 show_error 94 echo 95 done 96 echo "=================================================================" 97 exit 1 98else 99 rm -rf $suite_log 100fi 101