run.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2015-2015, Marcus Rohrmoser mobile Software, http://mro.name/me
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without modification, are permitted
  7. # provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of source code must retain the above copyright notice, this list of conditions
  10. # and the following disclaimer.
  11. #
  12. # 2. The software must not be used for military or intelligence or related purposes nor
  13. # anything that's in conflict with human rights as declared in http://www.un.org/en/documents/udhr/ .
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  22. # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. #
  24. cd "$(dirname "$0")"
  25. [ "$CC" != "" ] || { echo "environment \$CC must be set, e.g. $ CC=gcc $0 $@" 1>&2 && exit 1 ; }
  26. TMP=tmp
  27. BUILD=build
  28. # terminal colors (require bash)
  29. # http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
  30. # http://wiki.bash-hackers.org/scripting/terminalcodes
  31. FGC_NONE="\033[0m"
  32. FGC_GRAY="\033[1;30m"
  33. FGC_RED="\033[1;31m"
  34. FGC_GREEN="\033[1;32m"
  35. FGC_YELLOW="\033[1;33m"
  36. FGC_BLUE="\033[1;34m"
  37. FGC_PURPLE="\033[1;35m"
  38. FGC_CYAN="\033[1;36m"
  39. FGC_WHITE="\033[1;37m"
  40. BGC_GRAY="\033[7;30m"
  41. BGC_RED="\033[7;31m"
  42. BGC_GREEN="\033[7;32m"
  43. BGC_YELLOW="\033[7;33m"
  44. BGC_BLUE="\033[7;34m"
  45. BGC_PURPLE="\033[7;35m"
  46. BGC_CYAN="\033[7;36m"
  47. BGC_WHITE="\033[7;37m"
  48. status_code=0
  49. run_c_test() {
  50. test_src="$1"
  51. test_name="$test_src"
  52. echo -n "travis_fold:start:${test_name}\r"
  53. echo -n "Running $test_name "
  54. rm "$TMP"/* "$BUILD"/*
  55. $CC -Wall -Wno-unknown-pragmas -Werror -g3 -O0 -std=c99 -D DEBUG=1 -I "/usr/include/raptor2" -I "/usr/include/rasqal" -c -o "$BUILD/rdf_storage_sqlite_mro.o" "../rdf_storage_sqlite_mro.c" && {
  56. $CC -Wall -Wno-unknown-pragmas -Werror -g3 -O0 -std=c99 -D DEBUG=1 -I "/usr/include/raptor2" -I "/usr/include/rasqal" -c -o "$BUILD/$test_name".o "$test_src" && {
  57. # http://ubuntuforums.org/showthread.php?t=1936253&p=11742200#post11742200
  58. $CC -g3 -O0 -o "$BUILD/a.out" "$BUILD/rdf_storage_sqlite_mro.o" "$BUILD/$test_name".o -lrdf -lraptor2 -lsqlite3 && {
  59. # valgrind --leak-check=full --show-reachable=yes \
  60. "$BUILD/a.out"
  61. }
  62. }
  63. }
  64. code=$?
  65. echo -n "travis_fold:end:${test_name}\r"
  66. if [ "$code" -eq 0 ] ; then
  67. echo -e "${FGC_GREEN}✓${FGC_NONE} ${test_name}"
  68. else
  69. echo -e "${FGC_RED}✗${FGC_NONE} ${test_name} (code: $code)"
  70. status_code=1
  71. fi
  72. }
  73. for tst in test-*.c
  74. do
  75. run_c_test "$tst"
  76. done
  77. exit $status_code