summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author이춘석/동작제어Lab(SR)/Senior Engineer/삼성전자 <chunseok.lee@samsung.com>2018-04-17 17:51:22 +0900
committer김정현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh0822.kim@samsung.com>2018-04-17 17:51:22 +0900
commit516bd7b204177ff5963e7ad20915b676e4bbc2dc (patch)
tree24401c5186306ab6b1b143d1e8ffc14006754481
parent409f6871499d187bce40ec6b061f6412b31e6a31 (diff)
downloadnnfw-516bd7b204177ff5963e7ad20915b676e4bbc2dc.tar.gz
nnfw-516bd7b204177ff5963e7ad20915b676e4bbc2dc.tar.bz2
nnfw-516bd7b204177ff5963e7ad20915b676e4bbc2dc.zip
Add test coverage build (#744)
* Add test coverage build 1. add flags for test coverage build 2. add script to enable on CI * Add OPTION init Signed-off-by: Chunseok Lee <chunseok.lee@samsung.com>
-rw-r--r--CMakeLists.txt9
-rw-r--r--Makefile19
-rwxr-xr-xci/docker_cross_test_coverage_build.sh68
3 files changed, 95 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index feca7e8a7..67a580f0c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,6 +50,15 @@ set(TARGET_PLATFORM "${TARGET_ARCH}-${TARGET_OS}")
# platform specific options
include("cmake/option/option_${TARGET_PLATFORM}.cmake")
+# test-coverage build flag
+if(${COVERAGE_BUILD} STREQUAL "1")
+ set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE ON)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+ set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+ set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
+endif()
+
# add common flags
foreach(FLAG ${FLAGS_COMMON})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
diff --git a/Makefile b/Makefile
index 94b348303..d8f38b4f6 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,8 @@ CROSS_BUILD?=0
HOST_OS?=linux
NPROCS:=1
OBS_BUILD?=0
+COVERAGE_BUILD?=0
+OPTIONS?=
# make TARGET and TYPE to lowercase
TARGET_ARCH_LC=$(shell echo $(TARGET_ARCH) | tr A-Z a-z)
@@ -26,6 +28,12 @@ else
OPTION_TOOLCHAIN=
endif
+ifeq ($(COVERAGE_BUILD),1)
+ OPTIONS+= -DCOVERAGE_BUILD=1
+else
+ OPTIONS+= -DCOVERAGE_BUILD=0
+endif
+
# Get number of processors (linux only for now)
ifeq ($(HOST_OS),linux)
NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
@@ -87,7 +95,8 @@ endif
-DCMAKE_INSTALL_PREFIX=$(INSTALL_PATH) \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE_LC) -DTARGET_ARCH=$(TARGET_ARCH_LC) \
-DHOST_OS=$(HOST_OS) \
- $(OPTION_TOOLCHAIN)
+ $(OPTION_TOOLCHAIN) \
+ $(OPTIONS)
touch $(TIMESTAMP_CONFIGURE)
build_internal: $(BUILD_ROOT)
@@ -136,6 +145,14 @@ build_test_suite: install_internal
@tar -zcf test-suite.tar.gz tests/ tools/test_driver $(INSTALL_ALIAS) --dereference
@mv test-suite.tar.gz $(INSTALL_ROOT)/.
+build_coverage_suite: install_internal
+ @echo "packaging test-coverage suite"
+ @rm -rf $(INSTALL_ROOT)/coverage-suite.tar.gz
+ @find Product -name "*.gcno" > include_lists.txt
+ @tar -zcf coverage-suite.tar.gz tests/ tools/test_driver $(INSTALL_ALIAS) --dereference -T include_lists.txt
+ @rm -rf include_lists.txt
+ @mv coverage-suite.tar.gz $(INSTALL_ROOT)/.
+
###
### Timestamps
###
diff --git a/ci/docker_cross_test_coverage_build.sh b/ci/docker_cross_test_coverage_build.sh
new file mode 100755
index 000000000..9f8997062
--- /dev/null
+++ b/ci/docker_cross_test_coverage_build.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-nnfw_docker}
+
+SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+HOST_HOME=$SCRIPT_ROOT/../
+DOCKER_HOME=/home
+
+GIT_SSL_NO_VERIFY=1
+
+DOCKER_VOLUMES+=" -v $HOST_HOME:$DOCKER_HOME"
+
+DOCKER_ENV_VARS+=" -e http_proxy"
+DOCKER_ENV_VARS+=" -e no_proxy"
+DOCKER_ENV_VARS+=" -e GIT_SSL_NO_VERIFY"
+
+DOCKER_ENV_VARS+=" -e TARGET_ARCH=armv7l"
+DOCKER_ENV_VARS+=" -e CROSS_BUILD=1"
+DOCKER_ENV_VARS+=" -e ROOTFS_DIR=/opt/rootfs"
+DOCKER_ENV_VARS+=" -e EXT_ACL_FOLDER=/opt/libarmcl"
+DOCKER_ENV_VARS+=" -e COVERAGE_BUILD=1"
+
+DOCKER_RUN_OPTS="--rm"
+DOCKER_RUN_OPTS+=" -w $DOCKER_HOME"
+
+
+TMP_DIR=$HOST_HOME/tmp
+mkdir -p $TMP_DIR/libarmcl
+
+# prepare armcl library
+wget http://npuarchive.mooo.com/archive/nnfw/libarmcl/libarmcl.tar.gz -O $TMP_DIR/libarmcl.tar.gz -nv
+tar -zxvf $TMP_DIR/libarmcl.tar.gz -C $TMP_DIR/libarmcl
+
+# prepare rootfs
+wget http://npuarchive.mooo.com/archive/nnfw/rootfs/rootfs_arm_ubuntu.tar.gz -O $TMP_DIR/rootfs.tar.gz -nv
+tar -zxf $TMP_DIR/rootfs.tar.gz -C $TMP_DIR
+
+DOCKER_VOLUMES+=" -v $TMP_DIR/arm:/opt/rootfs"
+DOCKER_VOLUMES+=" -v $TMP_DIR/libarmcl:/opt/libarmcl"
+
+# Change .gitmodules to work around the permission issue
+CMD_SUBMODULE="docker/change_gitmodule.sh"
+docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME sh -c "$CMD_SUBMODULE"
+
+if [ -n "$DOCKER_INTERACTIVE" ]; then
+ DOCKER_RUN_OPTS+=" -it"
+ CMD="/bin/bash"
+else
+ CMD="make external_acl && make && make install && make build_coverage_suite"
+fi
+
+docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME sh -c "$CMD"
+BUILD_RESULT=$?
+
+# Newly created files during above docker run can have different ownership.
+# This may cause some problems, for example, some jenkins slaves or developers
+# can't remove built files due to lack of permission.
+# To address this issue, let's change owner of all files
+# in NNFW to owner of NNFW.
+NNFW_OWNER_UID=$(stat -c "%u" $HOST_HOME)
+NNFW_OWNER_GID=$(stat -c "%g" $HOST_HOME)
+
+CMD="chown -R $NNFW_OWNER_UID:$NNFW_OWNER_GID $DOCKER_HOME"
+docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME $CMD
+
+rm -rf $TMP_DIR
+exit $BUILD_RESULT