diff --git a/.gitignore b/.gitignore index 4d24ed3d3..790392b22 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +initCoverage.info +testCoverage.info +coverageReport/ .vscode/ - +ut_build/ sdk_build/ diff --git a/.travis.yml b/.travis.yml index b77cda4d8..95591eea5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,14 @@ +dist: xenial sudo: require language: cpp compiler: gcc -before_install: - - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - - sudo apt-get update -qq - install: - - sudo apt-get install -qq g++-5 - - sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-5 90 + - sudo apt-get install lcov libcurl4-openssl-dev libssl-dev uuid-dev libjsoncpp-dev script: - - cmake . - - ./build.sh - - ./travis_qmake_gcc_cpp11_gcov - - ./get_code_cov.sh + - ./unit_test.sh + - ./generate_code_cov.sh after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/generate_code_cov.sh b/generate_code_cov.sh new file mode 100755 index 000000000..5c7d2f32d --- /dev/null +++ b/generate_code_cov.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +cd `dirname $0` + +UT_BUILD_DIR=ut_build + +echo '--------- generate initial info ---------------- ' +lcov -d $UT_BUILD_DIR -z +lcov -d $UT_BUILD_DIR -b . --no-external --initial -c -o initCoverage.info + +echo '--------- run test ---------------- ' +cd $UT_BUILD_DIR +ctest --verbose +cd .. + +echo '--------- generate post info ---------------- ' +lcov -d $UT_BUILD_DIR -b . --no-external -c -o testCoverage.info + +echo '--------- generate html report ---------------- ' +genhtml -o coverageReport --prefix=`pwd` initCoverage.info testCoverage.info + +echo 'check report: ' `pwd`/coverageReport/index.html + +echo ' ------remove tmp file ------' + +rm initCoverage.info +rm testCoverage.info + diff --git a/unit_test.sh b/unit_test.sh new file mode 100755 index 000000000..f541f01db --- /dev/null +++ b/unit_test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +cd `dirname $0` +echo '-------build unit test----------' + +UT_BUILD_DIR=ut_build +rm -rf $UT_BUILD_DIR +mkdir $UT_BUILD_DIR +cd $UT_BUILD_DIR +cmake .. +make core_ut +make httpserver_for_ut + +echo '------- run unit test -----------' + +ctest --verbose +