Skip to content

Commit

Permalink
test: support codecov
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <[email protected]>
  • Loading branch information
pingkai committed Jan 9, 2020
1 parent 1143105 commit 24631bd
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 36 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ before_script:
- cd ../

script:
- cd cmdline/
- mkdir build
- cd build
- cmake ../
- make cicadaPlayer -j8
- cmake -DCODE_COVERAGE=ON -DTRAVIS=ON -DCMAKE_BUILD_TYPE=Debug ../
- cmake --build . --config Debug -- -j8
- cd cmdline/mediaPlayer.out/framework.out/tests/
- ctest -j8 --output-on-failure

after_success:
- bash <(curl -s https://codecov.io/bash) -x "llvm-cov gcov" || echo "Codecov did not collect coverage reports"


addons:
coverity_scan:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![HitCount](http://hits.dwyl.io/aliyun/CicadaPlayer.svg)](http://hits.dwyl.io/aliyun/CicadaPlayer)
[![Build Status](https://api.travis-ci.org/aliyun/CicadaPlayer.svg?branch=develop)](https://travis-ci.org/aliyun/CicadaPlayer)
[![coverity Status](https://scan.coverity.com/projects/20151/badge.svg?flat=1)](https://scan.coverity.com/projects/aliyun-cicadaplayer)
[![codecov](https://codecov.io/gh/aliyun/CicadaPlayer/branch/develop/graph/badge.svg)](https://codecov.io/gh/aliyun/CicadaPlayer/branch/develop)
[![LICENSE](https://img.shields.io/badge/license-MIT-orange.svg)](LICENSE)

<h1 align="center">
Expand Down
13 changes: 9 additions & 4 deletions cmdline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(TARGET_PLATFORM windows)
endif ()

# Code Coverage Configuration
option(CODE_COVERAGE "Enable coverage reporting" OFF)

include(../framework/code_coverage.cmake)
add_subdirectory(../mediaPlayer mediaPlayer.out)

include(../framework/${TARGET_PLATFORM}.cmake)
Expand All @@ -40,7 +44,7 @@ target_link_directories(cicadaPlayer PRIVATE
../external/install/openssl/${CMAKE_SYSTEM_NAME}/x86_64/lib
${COMMON_LIB_DIR})

target_link_libraries(cicadaPlayer
target_link_libraries(cicadaPlayer PRIVATE
media_player
demuxer
data_source
Expand All @@ -63,21 +67,22 @@ target_link_libraries(cicadaPlayer
${FRAMEWORK_LIBS})

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_link_libraries(cicadaPlayer
target_link_libraries(cicadaPlayer PUBLIC
bcrypt
)
else ()
target_link_libraries(cicadaPlayer
target_link_libraries(cicadaPlayer PUBLIC
z
dl
)
endif ()

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(cicadaPlayer
target_link_libraries(cicadaPlayer PUBLIC
bz2
)
endif ()
target_link_libraries(cicadaPlayer PUBLIC coverage_config)

if (USEASAN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope")
Expand Down
4 changes: 4 additions & 0 deletions framework/cacheModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ add_library(cacheModule STATIC
cache/CachePath.h
cache/CacheRet.h
)

if (HAVE_COVERAGE_CONFIG)
target_link_libraries(cacheModule PUBLIC coverage_config)
endif ()
19 changes: 19 additions & 0 deletions framework/code_coverage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

add_library(coverage_config INTERFACE)

if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Add required flags (GCC & LLVM/Clang)
target_compile_options(coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(coverage_config INTERFACE --coverage)
else ()
target_link_libraries(coverage_config INTERFACE --coverage)
endif ()
message("CODE_COVERAGE Enabled")
endif ()

set(HAVE_COVERAGE_CONFIG ON)
4 changes: 4 additions & 0 deletions framework/codec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ link_libraries(${LINNK_LIBRARYS})

add_library(videodec ${TARGET_LIBRARY_TYPE} ${SOURCE_FILES})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")

if (HAVE_COVERAGE_CONFIG)
target_link_libraries(videodec PUBLIC coverage_config)
endif ()
3 changes: 3 additions & 0 deletions framework/data_source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ endif ()
link_libraries(${LINNK_LIBRARYS})

add_library(data_source ${TARGET_LIBRARY_TYPE} ${SOURCE_FILES})
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(data_source PUBLIC coverage_config)
endif ()
5 changes: 4 additions & 1 deletion framework/demuxer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@ endif ()

link_libraries(${LINNK_LIBRARYS})

add_library(demuxer ${TARGET_LIBRARY_TYPE} ${SOURCE_FILES})
add_library(demuxer ${TARGET_LIBRARY_TYPE} ${SOURCE_FILES})
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(demuxer PUBLIC coverage_config)
endif ()
6 changes: 5 additions & 1 deletion framework/filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ set(SOURCE_FILES IAudioFilter.cpp
ffmpegAudioFilter.cpp filterFactory.cpp filterFactory.h)
include_directories(
${COMMON_INC_DIR})
add_library(framework_filter ${TARGET_LIBRARY_TYPE} ${SOURCE_FILES})
add_library(framework_filter ${TARGET_LIBRARY_TYPE} ${SOURCE_FILES})

if (HAVE_COVERAGE_CONFIG)
target_link_libraries(framework_filter PUBLIC coverage_config)
endif ()
5 changes: 4 additions & 1 deletion framework/muxer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ endif ()

link_libraries(${LINNK_LIBRARYS})

add_library(muxer STATIC ${SOURCE_FILES})
add_library(muxer STATIC ${SOURCE_FILES})
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(muxer PUBLIC coverage_config)
endif ()
5 changes: 5 additions & 0 deletions framework/render/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,8 @@ if (ENABLE_GLRENDER)
)

endif ()


if (HAVE_COVERAGE_CONFIG)
target_link_libraries(render PUBLIC coverage_config)
endif ()
20 changes: 13 additions & 7 deletions framework/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
project(frameworkUintTest)
cmake_minimum_required(VERSION 3.15)

if (!HAVE_COVERAGE_CONFIG)
include(../code_coverage.cmake)
endif ()

include(GoogleTest.cmake)
add_subdirectory(dataSource)
add_subdirectory(render)
if (!TRAVIS)
add_subdirectory(render)
endif ()
add_subdirectory(demuxer)
add_subdirectory(decoder)

Expand All @@ -13,12 +19,12 @@ add_test(
NAME dataSourceTest
COMMAND $<TARGET_FILE:dataSourceTest>
)

add_test(
NAME renderTest
COMMAND $<TARGET_FILE:renderTest>
)

if (!TRAVIS)
add_test(
NAME renderTest
COMMAND $<TARGET_FILE:renderTest>
)
endif ()
add_test(
NAME demuxerUnitTest
COMMAND $<TARGET_FILE:demuxerUnitTest>
Expand Down
12 changes: 7 additions & 5 deletions framework/tests/dataSource/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ target_include_directories(
../../../plugin
)

target_link_libraries(
dataSourceTest
target_link_libraries(dataSourceTest PRIVATE
demuxer
videodec
data_source
Expand All @@ -43,16 +42,19 @@ target_link_libraries(
gtest_main)
if (APPLE)
target_link_libraries(
dataSourceTest
dataSourceTest PUBLIC
iconv
bz2
${FRAMEWORK_LIBS}
)
else()
else ()
target_link_libraries(
dataSourceTest
dataSourceTest PUBLIC
dl
pthread
)

endif ()
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(dataSourceTest PUBLIC coverage_config)
endif ()
11 changes: 7 additions & 4 deletions framework/tests/decoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_include_directories(
)

target_link_libraries(
decoderUnitTest
decoderUnitTest PRIVATE
demuxer
videodec
data_source
Expand All @@ -44,16 +44,19 @@ target_link_libraries(

if (APPLE)
target_link_libraries(
decoderUnitTest
decoderUnitTest PUBLIC
iconv
bz2
${FRAMEWORK_LIBS}
)
else()
else ()
target_link_libraries(
decoderUnitTest
decoderUnitTest PUBLIC
dl
pthread
)

endif ()
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(decoderUnitTest PUBLIC coverage_config)
endif ()
4 changes: 3 additions & 1 deletion framework/tests/decoder/decoderUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ int main(int argc, char **argv)
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

#ifdef __APPLE__
TEST(hardCodec, H264)
{

std::string url = "http://player.alicdn.com/video/aliyunmedia.mp4";
test_codec(url, AF_CODEC_ID_H264, DECFLAG_HW);
}
#endif

TEST(softCodec, H264)
{
Expand Down
11 changes: 7 additions & 4 deletions framework/tests/demuxer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ target_include_directories(
)

target_link_libraries(
demuxerUnitTest
demuxerUnitTest PRIVATE
demuxer
videodec
data_source
Expand All @@ -43,16 +43,19 @@ target_link_libraries(

if (APPLE)
target_link_libraries(
demuxerUnitTest
demuxerUnitTest PUBLIC
iconv
bz2
${FRAMEWORK_LIBS}
)
else()
else ()
target_link_libraries(
demuxerUnitTest
demuxerUnitTest PUBLIC
dl
pthread
)

endif ()
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(demuxerUnitTest PUBLIC coverage_config)
endif ()
12 changes: 7 additions & 5 deletions framework/tests/render/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ target_include_directories(
PRIVATE
)

target_link_libraries(
renderTest
target_link_libraries(renderTest PRIVATE
demuxer
videodec
data_source
Expand All @@ -46,17 +45,20 @@ target_link_libraries(

if (APPLE)
target_link_libraries(
renderTest
renderTest PUBLIC
iconv
bz2
${FRAMEWORK_LIBS}
)
else()
else ()
target_link_libraries(
renderTest
renderTest PUBLIC
dl
pthread
)

endif ()
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(renderTest PUBLIC coverage_config)
endif ()

3 changes: 3 additions & 0 deletions mediaPlayer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,7 @@ endif ()

add_library(media_player STATIC ${SOURCE_FILES})
target_include_directories(media_player PUBLIC ../framework)
if (HAVE_COVERAGE_CONFIG)
target_link_libraries(media_player PUBLIC coverage_config)
endif ()

0 comments on commit 24631bd

Please sign in to comment.