Home | History | Annotate | Download | only in specs
      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 
     18 NNAPI_VERSION="
     19 V1_0
     20 V1_1
     21 "
     22 
     23 VTS_PATH=`realpath ../`
     24 function generate_one_testcase {
     25   # Generate one testcase
     26   BASENAME=`basename -s .mod.py $1`
     27   $VTS_PATH/../../tools/test_generator/vts_generator.py ./`basename $1`\
     28     -m $VTS_PATH/generated/vts_models/$BASENAME.model.cpp \
     29     -e $VTS_PATH/generated/examples/$BASENAME.example.cpp
     30   # Paste these lines into TestGenerated.cpp
     31   echo
     32   echo namespace $BASENAME {
     33   echo std::vector\<MixedTypedExample\> examples \= {
     34   echo // Generated $BASENAME test
     35   echo \#include \"examples/$BASENAME.example.cpp\"
     36   echo }\;
     37   echo // Generated model constructor
     38   echo \#include \"vts_models/$BASENAME.model.cpp\"
     39   echo }  // namespace $BASENAME
     40   echo TEST_F\(NeuralnetworksHidlTest\, $BASENAME\) {
     41   echo '    generated_tests::Execute'\(device,
     42   echo '                             '$BASENAME\:\:createTestModel\,
     43   echo '                             '$BASENAME\:\:is_ignored\,
     44   echo '                             '$BASENAME\:\:examples\)\;
     45   echo }
     46 }
     47 
     48 for ver in $NNAPI_VERSION;
     49 do
     50   cd $ANDROID_BUILD_TOP/frameworks/ml/nn/runtime/test/specs/$ver
     51   OUTFILE=$VTS_PATH/generated/all_generated_${ver}_vts_tests.cpp
     52   echo "// DO NOT EDIT;" > $OUTFILE
     53   echo "// Generated by ml/nn/runtime/test/specs/generate_vts_test.sh" >> $OUTFILE
     54 
     55   if [ $# -eq 0 ]; then
     56     FILES=*.mod.py
     57   else
     58     FILES="$@"
     59   fi
     60 
     61   for f in $FILES;
     62   do
     63     echo "Processing $f"
     64     generate_one_testcase $f >> $OUTFILE
     65   done
     66   echo "Generated file in $VTS_PATH/generated/"`basename $OUTFILE`
     67 done
     68 
     69