From 9dd104fce57a0681dc31f2d286b8effb46689479 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=EC=B6=98=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 3 May 2018 20:55:38 +0900 Subject: [PATCH] Add xu4 tizen test script (#1038) * Add xu4 tizen test script For example, if you'd like to build & test for tizen xu4, do as follows: 1. cross build and test `$ ./run docker_build_tizen_cross.sh ; ./run tizen_xu4_test.sh --test-suite-path=Product/out/test-suite.tar.gz --unittest --verification` 2. gbs build and test `$ ./run docker_gbs_build.sh ; ./run tizen_xu4_test.sh --rpm-dir=Product/out/rpm --verification --unittest` Signed-off-by: Chunseok Lee --- scripts/command/tizen_xu4_test.sh | 135 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100755 scripts/command/tizen_xu4_test.sh diff --git a/scripts/command/tizen_xu4_test.sh b/scripts/command/tizen_xu4_test.sh new file mode 100755 index 0000000..bfebc35 --- /dev/null +++ b/scripts/command/tizen_xu4_test.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +NNFW_ROOT=$SCRIPT_ROOT/../.. +if [ -z "$TEST_ROOT" ]; then + TEST_ROOT=/opt/usr/nnfw-test +fi + +function Usage() +{ + echo "Usage: ./tizen_xu4_test.sh --rpm-dir=path/to/rpm-dir --unittest --verification" + echo "Usage: ./tizen_xu4_test.sh --test-suite-path=path/to/test-suite.tar.gz --unittest --verification" + echo "--rpm-dir : directory containing nnfw.rpm and nnfw-test.rpm" + echo "--test-suite-path : filepath to test-suite.tar.gz" + echo "--unittest : run unittest" + echo "--verification : run verification" + echo "--framework : run framework" +} + + +function prepare_rpm_test() +{ + echo "======= Test with rpm packages(gbs build) =======" + # install nnfw nnfw-test rpms + for file in $RPM_DIR/* + do + $SDB_CMD push $file $TEST_ROOT + $SDB_CMD shell rpm -Uvh $TEST_ROOT/$(basename $file) --force --nodeps + done + + # download tflite model files + pushd $NNFW_ROOT + tests/framework/run_test.sh --download=on + tar -zcf cache.tar.gz tests/framework/cache + $SDB_CMD push cache.tar.gz $TEST_ROOT/. + rm -rf cache.tar.gz + $SDB_CMD shell tar -zxf $TEST_ROOT/cache.tar.gz -C $TEST_ROOT +} + +function prepare_suite_test() +{ + echo "======= Test with test-suite(cross build) =======" + # install test-suite + $SDB_CMD push $TEST_SUITE_PATH $TEST_ROOT/$(basename $TEST_SUITE_PATH) + $SDB_CMD shell tar -zxf $TEST_ROOT/$(basename $TEST_SUITE_PATH) -C $TEST_ROOT + + # download tflite model files + pushd $NNFW_ROOT + tests/framework/run_test.sh --download=on + tar -zcf cache.tar.gz tests/framework/cache + $SDB_CMD push cache.tar.gz $TEST_ROOT/. + rm -rf cache.tar.gz + $SDB_CMD shell tar -zxf $TEST_ROOT/cache.tar.gz -C $TEST_ROOT +} + + +# Parse command argv +for i in "$@" +do + case $i in + -h|--help|help) + Usage + exit 1 + ;; + --rpm-dir=*) + RPM_DIR=${i#*=} + ;; + --test-suite-path=*) + TEST_SUITE_PATH=${i#*=} + ;; + --unittest) + UNITTEST=on + ;; + --verification) + VERIFICATION=on + ;; + --framework) + FRAMEWORK=on + ;; + esac + shift +done + + +N=`sdb devices 2>/dev/null | wc -l` + +# exit if no device found +if [[ $N -le 1 ]]; then + echo "No device found." + exit 1; +fi + +NUM_DEV=$(($N-1)) +echo "device list" +DEVICE_LIST=`sdb devices 2>/dev/null` +echo "$DEVICE_LIST" | tail -n"$NUM_DEV" + +if [ -z "$SERIAL" ]; then + SERIAL=`echo "$DEVICE_LIST" | tail -n1 | awk '{print $1}'` +fi +SDB_CMD="sdb -s $SERIAL " + +# root on, remount as rw +$SDB_CMD root on +$SDB_CMD shell mount -o rw,remount / + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT=$SCRIPT_ROOT/../ + +if [ -z "$RPM_DIR" ] && [ -z "$TEST_SUITE_PATH" ]; then + echo "Please provide --rpm-dir or --test-suite-path" + exit 255 +fi + +if [ ! -z "$RPM_DIR" ]; then + prepare_rpm_test +else + prepare_suite_test +fi + +# run unittest +if [ "$UNITTEST" == "on" ]; then + $SDB_CMD shell $TEST_ROOT/tools/test_driver/test_driver.sh --unittest --artifactpath=$TEST_ROOT +fi + +# run framework test +if [ "$FRAMEWORK" == "on" ]; then + $SDB_CMD shell $TEST_ROOT/tools/test_driver/test_driver.sh --frameworktest --artifactpath=$TEST_ROOT +fi + +# run verification +if [ "$VERIFICATION" == "on" ]; then + $SDB_CMD shell $TEST_ROOT/tools/test_driver/test_driver.sh --verification --artifactpath=$TEST_ROOT +fi + -- 2.7.4