mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
make color output in run_test script optional
This commit is contained in:
parent
05e404c2ff
commit
6a3f33090d
@ -1,11 +1,53 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
# Text style
|
# Text style
|
||||||
|
|
||||||
TEXT_RED="$(tput setaf 1)"
|
if [ $COLOR_OUTPUT -eq 1 ]; then
|
||||||
TEXT_GREEN="$(tput setaf 2)"
|
TEXT_RED="$(tput setaf 1)"
|
||||||
TEXT_CYAN="$(tput setaf 6)"
|
TEXT_GREEN="$(tput setaf 2)"
|
||||||
TEXT_RESET="$(tput sgr0)"
|
TEXT_CYAN="$(tput setaf 6)"
|
||||||
|
TEXT_RESET="$(tput sgr0)"
|
||||||
|
else
|
||||||
|
TEXT_RED=""
|
||||||
|
TEXT_GREEN=""
|
||||||
|
TEXT_CYAN=""
|
||||||
|
TEXT_RESET=""
|
||||||
|
fi
|
||||||
|
|
||||||
# Test binaries and data paths
|
# Test binaries and data paths
|
||||||
|
|
||||||
@ -27,16 +69,17 @@ do
|
|||||||
cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:\"$report\""
|
cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:\"$report\""
|
||||||
|
|
||||||
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
|
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/\[----------\]/${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/\[ 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/\[ 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/\[ FAILED \]/${TEXT_RED}&${TEXT_RESET}/g" # red for [ FAILED ]
|
||||||
seg_reg="${seg_reg};s/\[ PASSED \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ PASSED ]
|
seg_reg="${seg_reg};s/\[ PASSED \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ PASSED ]
|
||||||
|
fi
|
||||||
|
|
||||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
||||||
eval "$cmd" | sed -r "$seg_reg"
|
$cmd | sed -r "$seg_reg"
|
||||||
|
|
||||||
ret=${PIPESTATUS[0]}
|
ret=${PIPESTATUS[0]}
|
||||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
|
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user