logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

check-funcs.sh (974B)


  1. #!/bin/false
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. set -o pipefail
  5. tmpdir=
  6. run_test() {
  7. env MALLOC_CHECK_=3 POSIX_ME_HARDER=1 POSIXLY_CORRECT=1 LC_ALL=C.UTF-8 "$1" 2>&1
  8. }
  9. wrap_test() {
  10. runner="$1"
  11. echo "${PS4}${runner}"
  12. if command -v mktemp 2>/dev/null >/dev/null
  13. then
  14. cd "$WD"
  15. tmpdir="$(mktemp -d selfcheck.XXXXXX)"
  16. cd "$tmpdir"
  17. fi
  18. run_test "${WD}/${runner}" | tee -a "${log}" | grep -v '^ok'
  19. ret="$?"
  20. if [ "$ret" != 0 ]
  21. then
  22. printf '## %s exited with code %s\n' "$runner" "$ret"
  23. err=1
  24. fi
  25. remains="$(jobs -l)"
  26. if [ "${remains}" != "" ]; then
  27. printf '## %s: ' 'Some processes remaining'
  28. echo "$remains" | tr '\n' ';'
  29. printf '\n## %s\n' 'Waiting for them to exit'
  30. wait
  31. echo "## Done"
  32. fi
  33. if [ -n "$tmpdir" ]
  34. then
  35. cd "$WD"
  36. if ! rm -d "$tmpdir"
  37. then
  38. printf '## Error: %s left files:\n%s\n' "$runner" "$(ls -R "$tmpdir")"
  39. err=1
  40. fi
  41. fi
  42. }