Merge pull request #45222 from antmicro:renode_makefile

PiperOrigin-RevId: 348099358
Change-Id: If07c7cac5d3d6f6d250875bff02eb40330053528
This commit is contained in:
TensorFlower Gardener 2020-12-17 15:03:56 -08:00
commit d0ed3b210c
4 changed files with 37 additions and 22 deletions

View File

@ -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,11 +84,17 @@ echo -e "*** Settings ***\n" \
"Should Create Platform\n" \
" Create Platform\n" > $ROBOT_SCRIPT
BIN_DIR=$1
for binary in `ls $BIN_DIR/*_test`;
declare -a FILES
if [[ -d ${1} ]]; then
FILES=`ls -1 ${1}/*_test`
else
FILES=${1}
fi
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
ROBOT_COMMAND="${RENODE_TEST_SCRIPT} ${ROBOT_SCRIPT} \
@ -91,10 +103,5 @@ ROBOT_COMMAND="${RENODE_TEST_SCRIPT} ${ROBOT_SCRIPT} \
--variable UART_LOG:${UART_LOG}"
echo "${ROBOT_COMMAND}"
if ! ${ROBOT_COMMAND}
then
exit_code=1
fi
exit $exit_code
echo ""
${ROBOT_COMMAND}

View File

@ -39,9 +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
# TODO(b/172939049): Using renode to run the tests is not currently integrated
# with the Makefile. So, we manually run the test script with the correct path
# to the bluepill generated files.
tensorflow/lite/micro/testing/test_bluepill_binary.sh tensorflow/lite/micro/tools/make/gen/bluepill_cortex-m3/bin/
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} test

View File

@ -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,7 +648,9 @@ $(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 ($(TARGET_SPECIFIC_MAKE_TEST),0)
test: $(MICROLITE_TEST_TARGETS)
endif
# Just build the test targets
build: $(MICROLITE_BUILD_TARGETS)

View File

@ -59,3 +59,10 @@ MICRO_LITE_EXAMPLE_TESTS := $(filter-out $(EXCLUDED_EXAMPLE_TESTS), $(MICRO_LITE
TEST_SCRIPT := tensorflow/lite/micro/testing/test_bluepill_binary.sh
# 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)