runLibTests.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. #
  3. # Script to rebuild libraries and dependencies
  4. # (with or without a sanitizer) and run the tests.
  5. #
  6. # The use case of the script is mainly for development purposes -
  7. # to clean and rebuild a single library, with all of its dependencies,
  8. # and run the tests.
  9. #
  10. # Usage: ./runLibTests.sh library [address | undefined | thread] [<test> | -all | none]
  11. #
  12. # Example: ./runLibTests.sh Data/SQLite address
  13. # (distcleans, rebuilds and runs tests for Data/SQLite with address sanitizer)
  14. #
  15. # Known shortcomings (TODO):
  16. # - the script does not check if the library is a dependency of another library
  17. # workaround: run the script for the dependent libraries first
  18. #
  19. # g++ does not like empty quoted arguments, but
  20. # the shellcheck wants them quoted to remain quiet
  21. # shellcheck disable=SC2086
  22. path=$1
  23. if [ -z "${path}" ]; then
  24. echo "Library not specified"
  25. echo "Usage: $0 path [address | undefined | thread] [<test> | -all | none]"
  26. exit 1
  27. fi
  28. libraries=
  29. IFS='/' read -r -a libraries <<< "$path"
  30. self="${BASH_SOURCE[0]}"
  31. if [ -d "$self" ] ; then
  32. basedir="$(cd "$self" || exit; pwd -P)"
  33. else
  34. basedir="$(cd "$(dirname "$self")" || exit; pwd -P)"
  35. fi
  36. # shellcheck disable=SC1091
  37. . "$basedir"/poco_env.bash
  38. flag=$2
  39. flags=
  40. if [ -n "${flag}" ]; then
  41. flags=SANITIZEFLAGS+=-fsanitize="$flag"
  42. fi
  43. path="$basedir"/"${libraries[0]}"
  44. make distclean -C "$basedir"/Foundation
  45. make distclean -C "$basedir"/CppUnit
  46. make -s -j4 -C "$basedir"/Foundation $flags
  47. make -s -j4 -C "$basedir"/CppUnit $flags
  48. test=$3
  49. if [ -z "${test}" ]; then
  50. test="-all"
  51. fi
  52. # Foundation requested, build/run tests and exit
  53. if [[ "$path" == "$basedir"/"Foundation" ]]; then
  54. cd "$path/testsuite/" || exit
  55. make -s -j4 -C ./ $flags
  56. cd "bin/$OSNAME/$OSARCH/" || exit
  57. if [[ "$test" != "none" ]]; then
  58. ./testrunner "${test}"
  59. ./testrunnerd "${test}"
  60. fi
  61. echo "$path $flags done."
  62. exit 0
  63. fi
  64. for library in "${libraries[@]}"
  65. do
  66. cd "$library" || exit
  67. make distclean
  68. make -s -j4 -C ./ $flags
  69. cd testsuite || exit
  70. make distclean
  71. make -s -j4 -C ./ $flags
  72. cd bin/"$OSNAME"/"$OSARCH"/ || exit
  73. if [[ "$test" != "none" ]]; then
  74. ./testrunner "${test}"
  75. ./testrunnerd "${test}"
  76. fi
  77. echo "$1 $flags done."
  78. cd ../../../../ || exit
  79. done