From 94b4bc26931abf9cdd99b6a18404e504dcee08ba Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Fri, 30 Oct 2020 09:57:53 +0100 Subject: [PATCH 1/3] Bluepill: generate binary tests in robot --- tensorflow/lite/micro/testing/bluepill.robot | 37 +++++++++++++++---- .../micro/testing/test_bluepill_binary.sh | 10 +---- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tensorflow/lite/micro/testing/bluepill.robot b/tensorflow/lite/micro/testing/bluepill.robot index 8c14e7e9930..5a4c0b21b6e 100644 --- a/tensorflow/lite/micro/testing/bluepill.robot +++ b/tensorflow/lite/micro/testing/bluepill.robot @@ -1,5 +1,5 @@ *** Settings *** -Suite Setup Setup +Suite Setup Prepare Tests Suite Teardown Teardown Test Setup Reset Emulation Test Teardown Test Teardown @@ -8,15 +8,25 @@ Resource ${RENODEKEYWORDS} *** Variables *** ${UART} sysbus.cpu.uartSemihosting -*** Test Cases *** -Should Run Bluepill Test - [Documentation] Runs a Bluepill test and waits for a specific string on the semihosting UART - [Tags] bluepill uart tensorflow arm - ${BIN} = Get Environment Variable BIN +*** Keywords *** +Prepare Tests + Setup ${SCRIPT} = Get Environment Variable SCRIPT ${LOGFILE} = Get Environment Variable LOGFILE ${EXPECTED} = Get Environment Variable EXPECTED - Execute Command $bin = @${BIN} + Set Suite Variable ${SCRIPT} + Set Suite Variable ${EXPECTED} + Set Suite Variable ${LOGFILE} + List All Test Binaries + +List All Test Binaries + Setup + ${BIN_DIR} = Get Environment Variable BIN_DIR + @{binaries} = List Files In Directory ${BIN_DIR} absolute=True + Set Suite Variable @{binaries} + +Test Binary + Remove File ${LOGFILE} Execute Command $logfile = @${LOGFILE} Execute Script ${SCRIPT} @@ -24,3 +34,16 @@ Should Run Bluepill Test Start Emulation Wait For Line On Uart ${EXPECTED} + +*** Test Cases *** +Should Run All Bluepill Tests + [Documentation] Runs Bluepill tests and waits for a specific string on the semihosting UART + [Tags] bluepill uart tensorflow arm + FOR ${BIN} IN @{binaries} + Execute Command $bin = @${BIN} + ${_} ${file} = Split Path ${BIN} + Test Binary + Execute Command Clear + + Log \t${file} - PASSED console=True + END diff --git a/tensorflow/lite/micro/testing/test_bluepill_binary.sh b/tensorflow/lite/micro/testing/test_bluepill_binary.sh index 6353299f4e3..2ff03f53849 100755 --- a/tensorflow/lite/micro/testing/test_bluepill_binary.sh +++ b/tensorflow/lite/micro/testing/test_bluepill_binary.sh @@ -46,17 +46,9 @@ then exit 1 fi - -# This check ensures that we only have a single $MICRO_LOG_FILENAME. Without it, -# renode will do a log rotation and there will be multiple files such as -# $MICRO_LOG_FILENAME.1 $MICRO_LOG_FILENAME.2 etc. -if [ -e $MICRO_LOG_FILENAME ]; then - rm $MICRO_LOG_FILENAME &> /dev/null -fi; - exit_code=0 -if ! BIN=${ROOT_DIR}/$1 \ +if ! BIN_DIR=${ROOT_DIR}/$1 \ SCRIPT=${ROOT_DIR}/tensorflow/lite/micro/testing/bluepill.resc \ LOGFILE=$MICRO_LOG_FILENAME \ EXPECTED="$2" \ From dcc61a4d47d4bb0131efe481dc2e3022d8c9c623 Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Fri, 30 Oct 2020 10:28:09 +0100 Subject: [PATCH 2/3] Bluepill Change output logs --- tensorflow/lite/micro/testing/bluepill.robot | 8 +++++++- tensorflow/lite/micro/testing/test_bluepill_binary.sh | 11 +++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tensorflow/lite/micro/testing/bluepill.robot b/tensorflow/lite/micro/testing/bluepill.robot index 5a4c0b21b6e..56cf74746b2 100644 --- a/tensorflow/lite/micro/testing/bluepill.robot +++ b/tensorflow/lite/micro/testing/bluepill.robot @@ -2,10 +2,11 @@ Suite Setup Prepare Tests Suite Teardown Teardown Test Setup Reset Emulation -Test Teardown Test Teardown +Test Teardown Teardown With Custom Message Resource ${RENODEKEYWORDS} *** Variables *** +${CREATE_SNAPSHOT_ON_FAIL} False ${UART} sysbus.cpu.uartSemihosting *** Keywords *** @@ -19,6 +20,10 @@ Prepare Tests Set Suite Variable ${LOGFILE} List All Test Binaries +Teardown With Custom Message + Set Test Message ${file} - FAILED + Test Teardown + List All Test Binaries Setup ${BIN_DIR} = Get Environment Variable BIN_DIR @@ -42,6 +47,7 @@ Should Run All Bluepill Tests FOR ${BIN} IN @{binaries} Execute Command $bin = @${BIN} ${_} ${file} = Split Path ${BIN} + Set Test Variable ${file} Test Binary Execute Command Clear diff --git a/tensorflow/lite/micro/testing/test_bluepill_binary.sh b/tensorflow/lite/micro/testing/test_bluepill_binary.sh index 2ff03f53849..4a11b7a320f 100755 --- a/tensorflow/lite/micro/testing/test_bluepill_binary.sh +++ b/tensorflow/lite/micro/testing/test_bluepill_binary.sh @@ -54,18 +54,17 @@ if ! BIN_DIR=${ROOT_DIR}/$1 \ EXPECTED="$2" \ ${RENODE_TEST_SCRIPT} \ ${ROOT_DIR}/tensorflow/lite/micro/testing/bluepill.robot \ - -r $TEST_TMPDIR &> ${MICRO_LOG_PATH}robot_logs.txt + -r $TEST_TMPDIR then exit_code=1 fi -echo "LOGS:" -# Extract output from renode log -cat ${MICRO_LOG_FILENAME} |grep 'uartSemihosting' |sed 's/^.*from start] *//g' if [ $exit_code -eq 0 ] then - echo "$1: PASS" + echo "PASS" else - echo "$1: FAIL - '$2' not found in logs." + echo "UART LOGS:" + # Extract output from renode log + cat ${MICRO_LOG_FILENAME} |grep 'uartSemihosting' |sed 's/^.*from start] *//g' fi exit $exit_code From 8c8cd4d3b7ee040768914907e0bf70df52aa9d31 Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Wed, 4 Nov 2020 15:08:17 +0100 Subject: [PATCH 3/3] Add `Documentation` to custom Robot keywords --- tensorflow/lite/micro/testing/bluepill.robot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow/lite/micro/testing/bluepill.robot b/tensorflow/lite/micro/testing/bluepill.robot index 56cf74746b2..c216aa66438 100644 --- a/tensorflow/lite/micro/testing/bluepill.robot +++ b/tensorflow/lite/micro/testing/bluepill.robot @@ -11,6 +11,7 @@ ${UART} sysbus.cpu.uartSemihosting *** Keywords *** Prepare Tests + [Documentation] Make environment variables avaiable in whole test suite and list files in ${BIN_DIR} Setup ${SCRIPT} = Get Environment Variable SCRIPT ${LOGFILE} = Get Environment Variable LOGFILE @@ -21,10 +22,12 @@ Prepare Tests List All Test Binaries Teardown With Custom Message + [Documentation] Replace robot fail message with shorter one to avoid duplicated UART output in log Set Test Message ${file} - FAILED Test Teardown List All Test Binaries + [Documentation] List all files in ${BIN_DIR} and make it available from test cases Setup ${BIN_DIR} = Get Environment Variable BIN_DIR @{binaries} = List Files In Directory ${BIN_DIR} absolute=True