parent
0ab4bbf771
commit
2b303f38a8
1 changed files with 78 additions and 15 deletions
@ -1,36 +1,99 @@ |
|||||||
#!/bin/sh |
#!/bin/sh |
||||||
|
|
||||||
|
# Text style |
||||||
|
|
||||||
|
TEXT_RED="$(tput setaf 1)" |
||||||
|
TEXT_GREEN="$(tput setaf 2)" |
||||||
|
TEXT_CYAN="$(tput setaf 6)" |
||||||
|
TEXT_RESET="$(tput sgr0)" |
||||||
|
|
||||||
|
# Test binaries and data paths |
||||||
|
|
||||||
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@ |
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@ |
||||||
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@ |
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@ |
||||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata |
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata |
||||||
|
|
||||||
|
# Run tests |
||||||
|
|
||||||
SUMMARY_STATUS=0 |
SUMMARY_STATUS=0 |
||||||
|
FAILED_TESTS="" |
||||||
|
PASSED_TESTS="" |
||||||
|
|
||||||
for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*; |
for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*; |
||||||
do |
do |
||||||
report="`basename "$t"`-`date --rfc-3339=date`.xml" |
test_name=`basename "$t"` |
||||||
"$t" --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:"$report" |
report="$test_name-`date --rfc-3339=date`.xml" |
||||||
TEST_STATUS=$? |
|
||||||
if [ $TEST_STATUS -ne 0 ]; then |
cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:\"$report\"" |
||||||
SUMMARY_STATUS=$TEST_STATUS |
|
||||||
|
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name |
||||||
|
seg_reg="${seg_reg};s/\[==========\]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [==========] |
||||||
|
seg_reg="${seg_reg};s/\[----------\]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [----------] |
||||||
|
seg_reg="${seg_reg};s/\[ RUN \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ RUN ] |
||||||
|
seg_reg="${seg_reg};s/\[ OK \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ OK ] |
||||||
|
seg_reg="${seg_reg};s/\[ FAILED \]/${TEXT_RED}&${TEXT_RESET}/g" # red for [ FAILED ] |
||||||
|
seg_reg="${seg_reg};s/\[ PASSED \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ PASSED ] |
||||||
|
|
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd" |
||||||
|
eval "$cmd" | sed -r "$seg_reg" |
||||||
|
|
||||||
|
ret=${PIPESTATUS[0]} |
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret" |
||||||
|
|
||||||
|
if [ $ret -ne 0 ]; then |
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_RED}FAILED${TEXT_RESET}" |
||||||
|
SUMMARY_STATUS=1 |
||||||
|
FAILED_TESTS="$FAILED_TESTS $test_name" |
||||||
|
else |
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_GREEN}OK${TEXT_RESET}" |
||||||
|
PASSED_TESTS="$PASSED_TESTS $test_name" |
||||||
fi |
fi |
||||||
|
|
||||||
|
echo "" |
||||||
done |
done |
||||||
|
|
||||||
for t in $OPENCV_PYTHON_TESTS; |
for t in $OPENCV_PYTHON_TESTS; |
||||||
do |
do |
||||||
report="`basename "$t"`-`date --rfc-3339=date`.xml" |
test_name=`basename "$t"` |
||||||
py.test --junitxml $report "$OPENCV_TEST_PATH"/$t |
report="$test_name-`date --rfc-3339=date`.xml" |
||||||
TEST_STATUS=$? |
|
||||||
if [ $TEST_STATUS -ne 0 ]; then |
cmd="py.test --junitxml $report \"$OPENCV_TEST_PATH\"/$t" |
||||||
SUMMARY_STATUS=$TEST_STATUS |
|
||||||
|
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name |
||||||
|
|
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd" |
||||||
|
eval "$cmd" | sed -r "$seg_reg" |
||||||
|
|
||||||
|
ret=${PIPESTATUS[0]} |
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret" |
||||||
|
|
||||||
|
if [ $ret -ne 0 ]; then |
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_RED}FAILED${TEXT_RESET}" |
||||||
|
SUMMARY_STATUS=1 |
||||||
|
FAILED_TESTS="$FAILED_TESTS $test_name" |
||||||
|
else |
||||||
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_GREEN}OK${TEXT_RESET}" |
||||||
|
PASSED_TESTS="$PASSED_TESTS $test_name" |
||||||
fi |
fi |
||||||
|
|
||||||
|
echo "" |
||||||
done |
done |
||||||
|
|
||||||
|
# Remove temporary test files |
||||||
|
|
||||||
rm -f /tmp/__opencv_temp.* |
rm -f /tmp/__opencv_temp.* |
||||||
|
|
||||||
|
# Report final status |
||||||
|
|
||||||
|
echo "${TEXT_CYAN}===============================================================${TEXT_RESET}" |
||||||
|
echo "${TEXT_CYAN}PASSED TESTS : $PASSED_TESTS${TEXT_RESET}" |
||||||
|
echo "${TEXT_CYAN}FAILED TESTS : $FAILED_TESTS${TEXT_RESET}" |
||||||
if [ $SUMMARY_STATUS -eq 0 ]; then |
if [ $SUMMARY_STATUS -eq 0 ]; then |
||||||
echo "All OpenCV tests finished successfully" |
echo "${TEXT_GREEN}STATUS : OK${TEXT_RESET}" |
||||||
|
echo "${TEXT_GREEN}STATUS : All OpenCV tests finished successfully${TEXT_RESET}" |
||||||
else |
else |
||||||
echo "OpenCV tests finished with status $SUMMARY_STATUS" |
echo "${TEXT_RED}STATUS : FAIL${TEXT_RESET}" |
||||||
|
echo "${TEXT_RED}STATUS : OpenCV tests finished with status $SUMMARY_STATUS${TEXT_RESET}" |
||||||
fi |
fi |
||||||
|
|
||||||
return $SUMMARY_STATUS |
exit $SUMMARY_STATUS |
||||||
|
Loading…
Reference in new issue