regression.sh.in 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2010 Centre National de la Recherche Scientifique
  5. #
  6. # StarPU is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as published by
  8. # the Free Software Foundation; either version 2.1 of the License, or (at
  9. # your option) any later version.
  10. #
  11. # StarPU is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. WORKDIR=`mktemp -d`
  17. SRCDIR=@STARPU_SRC_DIR@
  18. MAKE="${MAKE:-make -j3}"
  19. ##################################################
  20. # arg: returned status from the previous command
  21. check_exec()
  22. {
  23. PROFILE=$PROFILE_NUM
  24. if [ $SUBPROFILE_NUM -ne 0 ] ; then
  25. PROFILE="${PROFILE}.${SUBPROFILE_NUM}"
  26. fi
  27. if [ $1 -eq 0 ]; then
  28. echo "PASS: Profile $PROFILE"
  29. else
  30. echo "FAIL: Profile $PROFILE"
  31. if [ ${ABORT_ON_ERROR} -eq 1 ]; then
  32. echo "Aborting ..."
  33. exit 1;
  34. fi
  35. fi
  36. }
  37. do_build()
  38. {
  39. PROFILE_NUM=`expr ${PROFILE_NUM} + 1`
  40. echo ">>> Build configuration ${PROFILE_NUM}: <$@>"
  41. rm -rf ${WORKDIR}/build/*
  42. cd ${WORKDIR}/build
  43. ${SRCDIR}/configure "$@" > $WORKDIR/logs/profile.${PROFILE_NUM} 2>&1
  44. cd -
  45. code_build=$?
  46. if [ $code_build -ne 0 ]; then
  47. check_exec $code_build
  48. else
  49. ${MAKE} -C ${WORKDIR}/build >> $WORKDIR/logs/profile.${PROFILE_NUM} 2>&1
  50. code_build=$?
  51. check_exec $code_build
  52. fi
  53. }
  54. do_test()
  55. {
  56. SUBPROFILE_NUM=`expr ${SUBPROFILE_NUM} + 1`
  57. echo ">>>> Execution configuration ${PROFILE_NUM}.${SUBPROFILE_NUM} : <$@>"
  58. (
  59. export $* ;
  60. ${MAKE} -C ${WORKDIR}/build check
  61. ) > $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM} 2>&1
  62. code_check=$?
  63. check_exec $code_check
  64. if [ $code_check -ne 0 ] ; then
  65. grep FAIL: $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM}
  66. fi
  67. coverage=$(find ${WORKDIR}/build -name "*.gcda" 2>/dev/null)
  68. if [ -n "$coverage" ] ; then
  69. lcov -c -d ${WORKDIR}/build -o ${WORKDIR}/cov/profile_${PROFILE_NUM}.${SUBPROFILE_NUM}.lcov >> $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM} 2>&1
  70. fi
  71. }
  72. ##################################################
  73. ABORT_ON_ERROR=0
  74. while [ $# -ne 0 ]; do
  75. case $1 in
  76. --abort-on-error)
  77. ABORT_ON_ERROR=1
  78. shift ;;
  79. --help)
  80. echo
  81. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  82. echo
  83. exit 0 ;;
  84. *)
  85. break ;;
  86. esac
  87. done
  88. if [ -z "$1" ] ; then
  89. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  90. exit 0
  91. fi
  92. #################################################
  93. ## Create and jump to the workdir
  94. mkdir ${WORKDIR}/build ; mkdir ${WORKDIR}/cov ; mkdir ${WORKDIR}/html ; mkdir ${WORKDIR}/logs
  95. PROFILE_NUM=0
  96. code_build=1
  97. for file in $* ; do
  98. (
  99. while read line ; do
  100. if [ "$line" == "# Build configuration" ] ; then
  101. read line
  102. SUBPROFILE_NUM=0
  103. do_build $line
  104. elif [ "$line" == "# Execution configuration" ] ; then
  105. read line
  106. if [ $code_build -eq 0 ] ; then
  107. do_test $line
  108. fi
  109. fi
  110. done
  111. ) < $file
  112. done
  113. echo $WORKDIR
  114. ### End of script
  115. coverage=$(ls ${WORKDIR}/cov/*.lcov 2>/dev/null)
  116. if [ -n "${coverage}" ] ; then
  117. genhtml --function-coverage --legend ${WORKDIR}/cov/*.lcov -o ${WORKDIR}/html -t "StarPU coverage test results" > ${WORKDIR}/logs/genhtml.log
  118. echo "The coverage report is located at : ${WORKDIR}/html"
  119. fi
  120. echo "Tests done"