3 # Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # NOTE: Supposed that this script would be executed with an artifact path.
19 # The artifact path has tests/(test suite) and Product/
20 # Reference this PR(https://github.sec.samsung.net/STAR/nnfw/pull/375).
24 echo "Usage: ./$0 --artifactpath=. # run all tests"
25 echo "Usage: ./$0 --artifactpath=/home/dragon/nnfw --frameworktest --verification --benchmark # run fw test & verfication and benchmark"
27 echo "--artifactpath - (default={test-driver.sh's path}/../../) it should contain tests/ and Product/"
29 echo "Following options are needed when you want to tests of specific types. If you don't pass any one, unittest and verification will be run"
30 echo "--frameworktest - (default=off) run framework test"
31 echo "--verification - (default=on) run verification"
32 echo "--frameworktest_list_file - filepath of model list for test"
34 echo "Following option is only needed when you want to test benchmark."
35 echo "--benchmark_onert_op - (default=off) run benchmark per operation on onert"
38 echo "--framework_driverbin - (default=../../Product/out/bin/tflite_run) runner for runnning framework tests"
39 echo "--verification_driverbin - (default=../../Product/out/bin/nnapi_test) runner for runnning verification tests"
41 echo "--reportdir - (default=\$ARTIFACT_PATH/report) directory to save report"
45 TEST_DRIVER_DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
46 ARTIFACT_PATH="$TEST_DRIVER_DIR/../../"
47 FRAMEWORK_DRIVER_BIN=""
48 VERIFICATION_DRIVER_BIN=""
50 FRAMEWORKTEST_ON="false"
51 VERIFICATION_ON="false"
52 BENCHMARK_ONERT_OP_ON="false"
65 --framework_driverbin=*)
66 FRAMEWORK_DRIVER_BIN=${i#*=}
68 --verification_driverbin=*)
69 VERIFICATION_DRIVER_BIN=${i#*=}
73 FRAMEWORKTEST_ON="true"
75 --frameworktest_list_file=*)
76 FRAMEWORKTEST_LIST_FILE=$PWD/${i#*=}
77 if [ ! -e "$FRAMEWORKTEST_LIST_FILE" ]; then
78 echo "Pass on with proper frameworktest_list_file"
84 VERIFICATION_ON="true"
88 BENCHMARK_ONERT_OP_ON="true"
94 # Be careful that others params are handled as $ARTIFACT_PATH
101 ARTIFACT_PATH="$(readlink -f $ARTIFACT_PATH)"
103 if [ -z "$UNIT_TEST_DIR" ]; then
104 UNIT_TEST_DIR=$ARTIFACT_PATH/Product/out/unittest
107 if [ -z "$REPORT_DIR" ]; then
108 REPORT_DIR=$ARTIFACT_PATH/report
111 source $TEST_DRIVER_DIR/common.sh
113 # Run tflite_run with various tflite models
114 if [ "$FRAMEWORKTEST_ON" == "true" ]; then
115 if [ -z "$FRAMEWORK_DRIVER_BIN" ]; then
116 FRAMEWORK_DRIVER_BIN=$ARTIFACT_PATH/Product/out/bin/tflite_run
119 $TEST_DRIVER_DIR/test_framework.sh \
120 --driverbin=$FRAMEWORK_DRIVER_BIN \
121 --reportdir=$REPORT_DIR \
122 --tapname=framework_test.tap \
123 --logname=framework_test.log \
124 --testname="Frameworktest" \
125 --frameworktest_list_file=${FRAMEWORKTEST_LIST_FILE:-}
128 # Run nnapi_test with various tflite models
129 if [ "$ALLTEST_ON" == "true" ] || [ "$VERIFICATION_ON" == "true" ]; then
130 if [ -z "$VERIFICATION_DRIVER_BIN" ]; then
131 VERIFICATION_DRIVER_BIN=$ARTIFACT_PATH/Product/out/bin/nnapi_test
134 # verification uses the same script as frameworktest does
135 $TEST_DRIVER_DIR/test_framework.sh \
136 --driverbin=$VERIFICATION_DRIVER_BIN \
137 --reportdir=$REPORT_DIR \
138 --tapname=verification_test.tap \
139 --logname=verification_test.log \
140 --testname="Verification" \
141 --frameworktest_list_file=${FRAMEWORKTEST_LIST_FILE:-}
144 if [ "$BENCHMARK_ONERT_OP_ON" == "true" ]; then
145 DRIVER_BIN=$ARTIFACT_PATH/Product/out/bin/tflite_run
147 $TEST_DRIVER_DIR/benchmark_nnapi.sh \
149 --driverbin=$DRIVER_BIN \
150 --reportdir=$REPORT_DIR/benchmark_op \
151 --modelfilepath=$ARTIFACT_PATH/tests/scripts/models
154 # Make json file. Actually, this process is only needed on CI. That's why it is in test-driver.sh.
155 if [ "$BENCHMARK_ONERT_OP_ON" == "true" ]; then
156 # functions to fill json with benchmark results
157 source $ARTIFACT_PATH/tests/scripts/print_to_json.sh
158 if [ "$BENCHMARK_ONERT_OP_ON" == "true" ]; then
159 print_to_json $REPORT_DIR/benchmark_op $REPORT_DIR "benchmark_op_result.json"
161 print_to_json $REPORT_DIR/benchmark $REPORT_DIR "benchmark_result.json"