1# 2# Copyright (C) 2017 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# usage: generate_vts_test.sh <tests> 17 18VTS_PATH=`realpath ../` 19function generate_one_testcase { 20 # Generate one testcase 21 BASENAME=`basename -s .mod.py $1` 22 ../../../tools/test_generator/test_generator.py ./`basename $1`\ 23 --vts \ 24 -m $VTS_PATH/generated/vts_models/$BASENAME.model.cpp \ 25 -e $VTS_PATH/generated/examples/$BASENAME.example.cpp 26 # Paste these lines into TestGenerated.cpp 27 echo 28 echo namespace $BASENAME { 29 echo std::vector\<MixedTypedExample\> examples \= { 30 echo // Generated $BASENAME test 31 echo \#include \"examples/$BASENAME.example.cpp\" 32 echo }\; 33 echo // Generated model constructor 34 echo \#include \"vts_models/$BASENAME.model.cpp\" 35 echo } // namespace $BASENAME 36 echo TEST_F\(NeuralnetworksHidlTest\, $BASENAME\) { 37 echo ' generated_tests::Execute'\(device, 38 echo ' '$BASENAME\:\:createTestModel\, 39 echo ' '$BASENAME\:\:is_ignored\, 40 echo ' '$BASENAME\:\:examples\)\; 41 echo } 42} 43 44cd $ANDROID_BUILD_TOP/frameworks/ml/nn/runtime/test/specs 45OUTFILE=$VTS_PATH/generated/all_generated_vts_tests.cpp 46echo "// DO NOT EDIT;" > $OUTFILE 47echo "// Generated by ml/nn/runtime/test/specs/generate_vts_test.sh" >> $OUTFILE 48for f in *.mod.py; 49do 50 if [ $f = "mobilenet_quantized.mod.py" ]; then 51 echo "Skipping mobilenet quantized" 52 continue 53 fi 54 echo "Processing $f" 55 generate_one_testcase $f >> $OUTFILE 56done 57echo "Generated file in $VTS_PATH/generated/"`basename $OUTFILE` 58 59