summaryrefslogtreecommitdiff
path: root/tests/scripts/command/unittest
diff options
context:
space:
mode:
authorChunseok Lee <chunseok.lee@samsung.com>2020-08-14 15:19:19 +0900
committerChunseok Lee <chunseok.lee@samsung.com>2020-08-14 15:19:19 +0900
commit042b262b3633b6c0f577aed6cb4b980ad0c1dcf3 (patch)
treee79fb9ffe65b21bdc5863306db2757ab187a3306 /tests/scripts/command/unittest
parent05e0ec30a632339a8533082476f27bda31ccde16 (diff)
downloadnnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.tar.gz
nnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.tar.bz2
nnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.zip
Imported Upstream version 1.8.0upstream/1.8.0submit/tizen/20200814.062151
Diffstat (limited to 'tests/scripts/command/unittest')
-rw-r--r--tests/scripts/command/unittest108
1 files changed, 108 insertions, 0 deletions
diff --git a/tests/scripts/command/unittest b/tests/scripts/command/unittest
new file mode 100644
index 000000000..135ebea7b
--- /dev/null
+++ b/tests/scripts/command/unittest
@@ -0,0 +1,108 @@
+#!/bin/bash
+#
+# Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+COMMAND_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+INSTALL_DIR="$(dirname $(dirname $COMMAND_DIR))"
+UNITTEST_REPORT_DIR=
+UNITTEST_TEST_DIR=$INSTALL_DIR/unittest
+UNITTEST_RESULT=0
+UNITTEST_RUN_ALL=""
+
+function Usage()
+{
+ # TODO: Fill this
+ echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
+ echo ""
+ echo "Options:"
+ echo " --reportdir=PATH Path to write unittest report"
+ echo " --unittestdir=PATH Path to run unittest (default: $UNITTEST_TEST_DIR"
+}
+
+function get_gtest_option()
+{
+ local UNITTEST_REPORT_FILE=$(basename $TEST_BIN)
+ local output_option
+ local filter_option
+ if [ -n "$UNITTEST_REPORT_DIR" ]; then
+ output_option="--gtest_output=xml:$UNITTEST_REPORT_DIR/$UNITTEST_REPORT_FILE.xml"
+ fi
+ if [ -r "$TEST_BIN.skip" ]; then
+ filter_option="--gtest_filter=-$(grep -v '#' "$TEST_BIN.skip" | tr '\n' ':')"
+ fi
+ echo "$output_option $filter_option"
+}
+
+for i in "$@"
+do
+ case $i in
+ -h|--help|help)
+ Usage
+ exit 1
+ ;;
+ --reportdir=*)
+ UNITTEST_REPORT_DIR=${i#*=}
+ ;;
+ --unittestdir=*)
+ UNITTEST_TEST_DIR=${i#*=}
+ ;;
+ *)
+ echo "Unknown option: $i"
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+if [ -n "$UNITTEST_REPORT_DIR" ] && [ ! -e "$UNITTEST_REPORT_DIR" ]; then
+ mkdir -p $UNITTEST_REPORT_DIR
+fi
+
+echo ""
+echo "============================================"
+echo "Unittest start"
+echo "============================================"
+
+num_unittest=0
+# Run all executables in unit test directory
+for TEST_BIN in `find $UNITTEST_TEST_DIR -maxdepth 1 -type f -executable`; do
+ num_unittest=$((num_unittest+1))
+ echo "============================================"
+ echo "Starting set $num_unittest: $TEST_BIN..."
+ echo "============================================"
+
+ $TEST_BIN $(get_gtest_option)
+ TEMP_UNITTEST_RESULT=$?
+
+ if [[ $TEMP_UNITTEST_RESULT -ne 0 ]]; then
+ UNITTEST_RESULT=$TEMP_UNITTEST_RESULT
+ echo "$TEST_BIN failed... return code: $TEMP_UNITTEST_RESULT"
+ fi
+ echo "============================================"
+ echo "Finishing set $num_unittest: $TEST_BIN..."
+ echo "============================================"
+done
+
+if [[ $UNITTEST_RESULT -ne 0 ]]; then
+ echo "============================================"
+ echo "Failed unit test... exit code: $UNITTEST_RESULT"
+ echo "============================================"
+ exit $UNITTEST_RESULT
+fi
+
+echo "============================================"
+echo "Completed total $num_unittest set of unittest"
+echo "Unittest end"
+echo "============================================"