regression.sh.in 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2010-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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. #
  17. WORKDIR=`mktemp -d`
  18. SRCDIR=@STARPU_SRC_DIR@
  19. MAKE="${MAKE:-make -j3}"
  20. ##################################################
  21. # arg: returned status from the previous command
  22. check_exec()
  23. {
  24. PROFILE=$PROFILE_NUM
  25. if [ $SUBPROFILE_NUM -ne 0 ] ; then
  26. PROFILE="${PROFILE}.${SUBPROFILE_NUM}"
  27. fi
  28. if [ $1 -eq 0 ]; then
  29. echo "PASS: Profile $PROFILE"
  30. else
  31. echo "FAIL: Profile $PROFILE"
  32. if [ ${ABORT_ON_ERROR} -eq 1 ]; then
  33. echo "Aborting ..."
  34. exit 1;
  35. fi
  36. fi
  37. }
  38. do_build()
  39. {
  40. PROFILE_NUM=`expr ${PROFILE_NUM} + 1`
  41. echo ">>> Build configuration ${PROFILE_NUM}: <$@>"
  42. rm -rf ${WORKDIR}/build/*
  43. cd ${WORKDIR}/build
  44. ${SRCDIR}/configure "$@" > $WORKDIR/logs/profile.${PROFILE_NUM} 2>&1
  45. cd -
  46. code_build=$?
  47. if [ $code_build -ne 0 ]; then
  48. check_exec $code_build
  49. else
  50. ${MAKE} -C ${WORKDIR}/build >> $WORKDIR/logs/profile.${PROFILE_NUM} 2>&1
  51. code_build=$?
  52. check_exec $code_build
  53. fi
  54. }
  55. do_test()
  56. {
  57. SUBPROFILE_NUM=`expr ${SUBPROFILE_NUM} + 1`
  58. echo ">>>> Execution configuration ${PROFILE_NUM}.${SUBPROFILE_NUM} : <$@>"
  59. (
  60. export $* ;
  61. ${MAKE} -C ${WORKDIR}/build check
  62. ) > $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM} 2>&1
  63. code_check=$?
  64. check_exec $code_check
  65. if [ $code_check -ne 0 ] ; then
  66. grep FAIL: $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM}
  67. fi
  68. coverage=$(find ${WORKDIR}/build -name "*.gcda" 2>/dev/null)
  69. if [ -n "$coverage" ] ; then
  70. lcov -c -d ${WORKDIR}/build -o ${WORKDIR}/cov/profile_${PROFILE_NUM}.${SUBPROFILE_NUM}.lcov >> $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM} 2>&1
  71. fi
  72. }
  73. ##################################################
  74. ABORT_ON_ERROR=0
  75. while [ $# -ne 0 ]; do
  76. case $1 in
  77. --abort-on-error)
  78. ABORT_ON_ERROR=1
  79. shift ;;
  80. --help)
  81. echo
  82. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  83. echo
  84. exit 0 ;;
  85. *)
  86. break ;;
  87. esac
  88. done
  89. if [ -z "$1" ] ; then
  90. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  91. exit 0
  92. fi
  93. #################################################
  94. ## Create and jump to the workdir
  95. mkdir ${WORKDIR}/build ; mkdir ${WORKDIR}/cov ; mkdir ${WORKDIR}/html ; mkdir ${WORKDIR}/logs
  96. PROFILE_NUM=0
  97. code_build=1
  98. for file in $* ; do
  99. (
  100. while read line ; do
  101. if [ "$line" == "# Build configuration" ] ; then
  102. read line
  103. SUBPROFILE_NUM=0
  104. do_build $line
  105. elif [ "$line" == "# Execution configuration" ] ; then
  106. read line
  107. if [ $code_build -eq 0 ] ; then
  108. do_test $line
  109. fi
  110. fi
  111. done
  112. ) < $file
  113. done
  114. echo $WORKDIR
  115. ### End of script
  116. coverage=$(ls ${WORKDIR}/cov/*.lcov 2>/dev/null)
  117. if [ -n "${coverage}" ] ; then
  118. genhtml --function-coverage --legend ${WORKDIR}/cov/*.lcov -o ${WORKDIR}/html -t "StarPU coverage test results" > ${WORKDIR}/logs/genhtml.log
  119. echo "The coverage report is located at : ${WORKDIR}/html"
  120. fi
  121. echo "Tests done"