2015-02-06 17:34:50 +08:00
|
|
|
#!/bin/bash
|
2014-01-29 16:01:06 +08:00
|
|
|
|
2015-02-09 20:23:34 +08:00
|
|
|
# Usage info
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat << EOF
|
|
|
|
usage: $0 [options]
|
|
|
|
|
|
|
|
This script runs the OpenCV tests on linux device.
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-h Show this message
|
|
|
|
-c Color output
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
# Parse options
|
|
|
|
|
|
|
|
COLOR_OUTPUT=0
|
|
|
|
while getopts “hc” OPTION
|
|
|
|
do
|
|
|
|
case $OPTION in
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
COLOR_OUTPUT=1
|
|
|
|
;;
|
|
|
|
?)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2015-02-04 17:38:51 +08:00
|
|
|
# Text style
|
|
|
|
|
2015-02-09 20:23:34 +08:00
|
|
|
if [ $COLOR_OUTPUT -eq 1 ]; then
|
|
|
|
TEXT_RED="$(tput setaf 1)"
|
|
|
|
TEXT_GREEN="$(tput setaf 2)"
|
|
|
|
TEXT_CYAN="$(tput setaf 6)"
|
|
|
|
TEXT_RESET="$(tput sgr0)"
|
|
|
|
else
|
|
|
|
TEXT_RED=""
|
|
|
|
TEXT_GREEN=""
|
|
|
|
TEXT_CYAN=""
|
|
|
|
TEXT_RESET=""
|
|
|
|
fi
|
2015-02-04 17:38:51 +08:00
|
|
|
|
|
|
|
# Test binaries and data paths
|
|
|
|
|
2014-02-06 16:35:14 +08:00
|
|
|
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
|
2014-09-08 22:11:12 +08:00
|
|
|
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@
|
2014-01-29 16:01:06 +08:00
|
|
|
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
|
|
|
|
2015-05-19 23:17:28 +08:00
|
|
|
CUR_DIR=`pwd`
|
|
|
|
if [ -d "$CUR_DIR" -a -w "$CUR_DIR" ]; then
|
|
|
|
echo "${TEXT_CYAN}CUR_DIR : $CUR_DIR${TEXT_RESET}"
|
|
|
|
else
|
|
|
|
echo "${TEXT_RED}Error: Do not have permissions to write to $CUR_DIR${TEXT_RESET}"
|
|
|
|
echo "${TEXT_RED}Please run the script from directory with write access${TEXT_RESET}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-02-04 17:38:51 +08:00
|
|
|
# Run tests
|
|
|
|
|
2014-01-29 16:01:06 +08:00
|
|
|
SUMMARY_STATUS=0
|
2015-02-04 17:38:51 +08:00
|
|
|
FAILED_TESTS=""
|
|
|
|
PASSED_TESTS=""
|
|
|
|
|
2014-01-29 16:01:06 +08:00
|
|
|
for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*;
|
|
|
|
do
|
2015-02-04 17:38:51 +08:00
|
|
|
test_name=`basename "$t"`
|
|
|
|
report="$test_name-`date --rfc-3339=date`.xml"
|
|
|
|
|
|
|
|
cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:\"$report\""
|
|
|
|
|
2015-02-09 20:23:34 +08:00
|
|
|
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
|
|
|
|
if [ $COLOR_OUTPUT -eq 1 ]; then
|
|
|
|
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 ]
|
|
|
|
fi
|
2015-02-04 17:38:51 +08:00
|
|
|
|
|
|
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
2015-05-19 23:22:30 +08:00
|
|
|
eval "$cmd" | tee "$test_name.log" | sed -r "$seg_reg"
|
2015-02-04 17:38:51 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
echo ""
|
2014-01-29 16:01:06 +08:00
|
|
|
done
|
|
|
|
|
2014-09-08 22:11:12 +08:00
|
|
|
for t in $OPENCV_PYTHON_TESTS;
|
|
|
|
do
|
2015-02-04 17:38:51 +08:00
|
|
|
test_name=`basename "$t"`
|
|
|
|
report="$test_name-`date --rfc-3339=date`.xml"
|
|
|
|
|
|
|
|
cmd="py.test --junitxml $report \"$OPENCV_TEST_PATH\"/$t"
|
|
|
|
|
|
|
|
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
|
|
|
|
|
|
|
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
2015-05-19 23:22:30 +08:00
|
|
|
eval "$cmd" | tee "$test_name.log" | sed -r "$seg_reg"
|
2015-02-04 17:38:51 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
echo ""
|
2014-09-08 22:11:12 +08:00
|
|
|
done
|
|
|
|
|
2015-02-04 17:38:51 +08:00
|
|
|
# Remove temporary test files
|
|
|
|
|
2014-01-29 16:01:06 +08:00
|
|
|
rm -f /tmp/__opencv_temp.*
|
|
|
|
|
2015-02-04 17:38:51 +08:00
|
|
|
# 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}"
|
2014-01-29 16:01:06 +08:00
|
|
|
if [ $SUMMARY_STATUS -eq 0 ]; then
|
2015-02-04 17:38:51 +08:00
|
|
|
echo "${TEXT_GREEN}STATUS : OK${TEXT_RESET}"
|
|
|
|
echo "${TEXT_GREEN}STATUS : All OpenCV tests finished successfully${TEXT_RESET}"
|
2014-01-29 16:01:06 +08:00
|
|
|
else
|
2015-02-04 17:38:51 +08:00
|
|
|
echo "${TEXT_RED}STATUS : FAIL${TEXT_RESET}"
|
|
|
|
echo "${TEXT_RED}STATUS : OpenCV tests finished with status $SUMMARY_STATUS${TEXT_RESET}"
|
2014-01-29 16:01:06 +08:00
|
|
|
fi
|
|
|
|
|
2015-02-04 17:38:51 +08:00
|
|
|
exit $SUMMARY_STATUS
|