run-tests.sh 2.3 KB

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