run 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2009-2016 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. is_test() {
  8. test -d $test_path
  9. }
  10. do_run() {
  11. variant=$1
  12. s=".$1"
  13. strip=0
  14. if [ "$variant" = "strip" ]; then
  15. # This test should not be stripped
  16. [ -f $test_path/nostrip ] && return
  17. strip=1
  18. fi
  19. STRIP=$strip $json_process --env \
  20. <$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s
  21. valgrind_check $test_log/stderr$s || return 1
  22. ref=error
  23. [ -f $test_path/error$s ] && ref=error$s
  24. if ! cmp -s $test_path/$ref $test_log/stderr$s; then
  25. echo $variant > $test_log/variant
  26. return 1
  27. fi
  28. }
  29. run_test() {
  30. do_run normal && do_run strip
  31. }
  32. show_error() {
  33. valgrind_show_error && return
  34. read variant < $test_log/variant
  35. s=".$variant"
  36. echo "VARIANT: $variant"
  37. echo "EXPECTED ERROR:"
  38. ref=error
  39. [ -f $test_path/error$s ] && ref=error$s
  40. nl -bn $test_path/$ref
  41. echo "ACTUAL ERROR:"
  42. nl -bn $test_log/stderr$s
  43. }
  44. . $top_srcdir/test/scripts/run-tests.sh