Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / infra / nnfw / command / count-unittest
1 #!/bin/bash
2 #
3 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 #
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
8 #
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 Usage()
18 {
19     echo "Usage: ./$0 [--install-path=Product/out]"
20 }
21
22 INSTALL_PATH=Product/out
23
24 for i in "$@"
25 do
26     case $i in
27         -h|--help|help)
28             Usage
29             exit 1
30             ;;
31         --install-path=*)
32             INSTALL_PATH=${i#*=}
33             ;;
34         *)
35             Usage
36             exit 1
37             ;;
38     esac
39     shift
40 done
41
42 # List of gtest binaries
43 GTEST_BINS=(
44     unittest_standalone/nnfw_api_gtest
45     unittest_standalone/test_compute
46     unittest_standalone/test_onert
47     unittest_standalone/test_onert_backend_cpu_common
48     unittest_standalone/test_onert_frontend_nnapi
49     unittest_standalone/tflite_test
50 )
51
52 # Collect test cases
53 echo "Install Path : '$INSTALL_PATH'"
54 TEST_LIST=
55 for GTEST_BIN in ${GTEST_BINS[@]}; do
56     GTEST_PATH=$INSTALL_PATH/$GTEST_BIN
57     echo "Collecting test cases from '$GTEST_PATH'"
58     TESTS=$($GTEST_PATH --gtest_list_tests | grep '^  ')
59     if [ "$?" -ne 0 ]; then
60         echo "Error collecting test cases from '$GTEST_PATH'"
61         exit 1;
62     fi
63     TEST_LIST=$TEST_LIST$TESTS
64 done
65
66 # Count stats
67 TOTAL_TCS=$(echo "$TEST_LIST" | wc -l)
68 TOTAL_NEG_TCS=$(echo "$TEST_LIST" | grep '^  neg_' | wc -l)
69 TOTAL_POS_TCS=$(echo "$TEST_LIST" | grep '^  neg_' -v | wc -l)
70
71 # Report stats
72 echo "TOTAL NUMBER OF TEST CASES          : $TOTAL_TCS"
73 echo "TOTAL NUMBER OF POSTIVE TEST CASES  : $TOTAL_NEG_TCS"
74 echo "TOTAL NUMBER OF NEGATIVE TEST CASES : $TOTAL_POS_TCS"