run 1.1 KB

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