Small cleanup of the original PR:
* moved the target-specific `make test` implementation out of Makefile and into bluepill_makefile.inc * removed some special handling of spaces etc. * added 'build' as a dependency for 'test' to ensure we can `make test` directly after a `make clean`.
This commit is contained in:
parent
2d1c2e63b7
commit
c433887131
@ -13,12 +13,20 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
#
|
||||
#
|
||||
# Parameters:
|
||||
# ${1} - path to a binary to test or directory (all *_test will be run).
|
||||
|
||||
set -e
|
||||
|
||||
TARGET=bluepill
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
TFLM_ROOT_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The renode script for the board being emulated.
|
||||
RESC_PATH=${TFLM_ROOT_DIR}/testing/bluepill.resc
|
||||
RESC_PATH=${TFLM_ROOT_DIR}/testing/${TARGET}.resc
|
||||
|
||||
# Robot file with definition of custom keywords used in test suite.
|
||||
ROBOT_RESOURCE=${TFLM_ROOT_DIR}/testing/robot.resource.txt
|
||||
@ -41,8 +49,6 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit_code=0
|
||||
|
||||
# Files generated by this script will go in the RESULTS_DIRECTORY. These include:
|
||||
# 1. UART_LOG: Output log from the renode uart.
|
||||
# 2. html and xml files generated by the Robot Framework.
|
||||
@ -52,12 +58,12 @@ exit_code=0
|
||||
# binaries are run in a the same test suite and UART_LOG only has logs from the last test
|
||||
# binary since it is deleted prior to running each test binary. If some test fails
|
||||
# the UART_LOG will be printed to console log before being deleted.
|
||||
RESULTS_DIRECTORY=/tmp/renode_bluepill_logs
|
||||
RESULTS_DIRECTORY=/tmp/renode_${TARGET}_logs
|
||||
mkdir -p ${RESULTS_DIRECTORY}
|
||||
|
||||
UART_LOG=${RESULTS_DIRECTORY}/uart_log.txt
|
||||
|
||||
ROBOT_SCRIPT=${RESULTS_DIRECTORY}/Bluepill.robot
|
||||
ROBOT_SCRIPT=${RESULTS_DIRECTORY}/${TARGET}.robot
|
||||
|
||||
echo -e "*** Settings ***\n" \
|
||||
"Suite Setup Setup\n" \
|
||||
@ -66,7 +72,7 @@ echo -e "*** Settings ***\n" \
|
||||
"Test Teardown Teardown With Custom Message\n" \
|
||||
"Resource \${RENODEKEYWORDS}\n" \
|
||||
"Resource ${ROBOT_RESOURCE}\n" \
|
||||
"Default Tags bluepill uart tensorflow arm\n" \
|
||||
"Default Tags tensorflow\n" \
|
||||
"\n" \
|
||||
"*** Variables ***\n" \
|
||||
"\${RESC} undefined_RESC\n" \
|
||||
@ -78,34 +84,24 @@ echo -e "*** Settings ***\n" \
|
||||
"Should Create Platform\n" \
|
||||
" Create Platform\n" > $ROBOT_SCRIPT
|
||||
|
||||
# Prepare test binaries list using binaries directory path or single binary path
|
||||
# Internal field separator needs to be temporarely set to newline to handle paths with spaces
|
||||
IFS=$'\n'
|
||||
declare -a FILES
|
||||
if [[ -d $1 ]]; then
|
||||
FILES=($(ls -1 $1/*_test));
|
||||
if [[ -d ${1} ]]; then
|
||||
FILES=`ls -1 ${1}/*_test`
|
||||
else
|
||||
FILES=("$1");
|
||||
FILES=${1}
|
||||
fi
|
||||
|
||||
for binary in "${FILES[@]}";
|
||||
for binary in ${FILES}
|
||||
do
|
||||
echo -e "Should Run $(basename ${binary})\n"\
|
||||
" Test Binary @$(realpath ${binary})\n" >> $ROBOT_SCRIPT
|
||||
" Test Binary @$(realpath ${binary})\n" >> ${ROBOT_SCRIPT}
|
||||
done
|
||||
|
||||
IFS=$' \n\t'
|
||||
ROBOT_COMMAND="${RENODE_TEST_SCRIPT} ${ROBOT_SCRIPT} \
|
||||
-r ${RESULTS_DIRECTORY} \
|
||||
--variable RESC:${RESC_PATH} \
|
||||
--variable UART_LOG:${UART_LOG}"
|
||||
|
||||
echo "${ROBOT_COMMAND}"
|
||||
echo " "
|
||||
|
||||
if ! ${ROBOT_COMMAND}
|
||||
then
|
||||
exit_code=1
|
||||
fi
|
||||
|
||||
exit $exit_code
|
||||
echo ""
|
||||
${ROBOT_COMMAND}
|
||||
|
@ -39,6 +39,4 @@ readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARG
|
||||
# Next, build w/o release so that we can run the tests and get additional
|
||||
# debugging info on failures.
|
||||
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
|
||||
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} build
|
||||
|
||||
readable_run make -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} test
|
||||
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} test
|
||||
|
@ -525,6 +525,10 @@ $(HOST_OS) \
|
||||
arduino \
|
||||
chre
|
||||
|
||||
# ${TARGET}_makefile.inc can set this to true to allow it to defined a custom
|
||||
# implementation for `make test`. See bluepill_makefile as an example.
|
||||
TARGET_SPECIFIC_MAKE_TEST:=0
|
||||
|
||||
ifeq ($(findstring $(TARGET),$(TARGETS_WITHOUT_MAKEFILES)),)
|
||||
include $(MAKEFILE_DIR)/targets/$(TARGET)_makefile.inc
|
||||
endif
|
||||
@ -644,11 +648,7 @@ $(eval $(call microlite_test,$(notdir $(basename $(TEST_TARGET))),$(TEST_TARGET)
|
||||
$(foreach TEST_TARGET,$(filter tensorflow/lite/micro/kernels/%,$(MICROLITE_TEST_SRCS)),\
|
||||
$(eval $(call microlite_test,kernel_$(notdir $(basename $(TEST_TARGET))),$(TEST_TARGET))))
|
||||
|
||||
ifeq ($(OVERRIDE_TEST_ALL_TARGET),1)
|
||||
test:
|
||||
@test -f $$(TEST_SCRIPT) || (echo 'Unable to find the test script. Is the software emulation available in $$(TARGET)?'; exit 1)
|
||||
$(TEST_SCRIPT) $(BINDIR)
|
||||
else
|
||||
ifeq ($(TARGET_SPECIFIC_MAKE_TEST),0)
|
||||
test: $(MICROLITE_TEST_TARGETS)
|
||||
endif
|
||||
|
||||
|
@ -58,4 +58,11 @@ EXCLUDED_EXAMPLE_TESTS := \
|
||||
MICRO_LITE_EXAMPLE_TESTS := $(filter-out $(EXCLUDED_EXAMPLE_TESTS), $(MICRO_LITE_EXAMPLE_TESTS))
|
||||
|
||||
TEST_SCRIPT := tensorflow/lite/micro/testing/test_bluepill_binary.sh
|
||||
OVERRIDE_TEST_ALL_TARGET := 1
|
||||
|
||||
# We are setting this variable to non-zero to allow us to have a custom
|
||||
# implementation of `make test` for bluepill
|
||||
TARGET_SPECIFIC_MAKE_TEST := 1
|
||||
test: build
|
||||
$(TEST_SCRIPT) $(BINDIR)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user