Skip to content

Commit

Permalink
generating code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
parvathika committed Nov 13, 2024
1 parent ce1ce8b commit b14dbb1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 247 deletions.
62 changes: 18 additions & 44 deletions .github/workflows/gnome_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@ jobs:
unit-tests:
name: Build and run unit tests
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [ gcc, clang ]
coverage: [ with-coverage, without-coverage ]
exclude:
- compiler: clang
coverage: with-coverage
- compiler: clang
coverage: without-coverage
- compiler: gcc
coverage: without-coverage


steps:
- name: Configure cache
if: ${{ !env.ACT }}
Expand Down Expand Up @@ -102,14 +91,6 @@ jobs:
with:
path: networkmanager

- name: Set clang toolchain
if: ${{ matrix.compiler == 'clang' }}
run: echo "TOOLCHAIN_FILE=${{github.workspace}}/networkmanager/Tests/clang.cmake" >> $GITHUB_ENV

- name: Set gcc/with-coverage toolchain
if: ${{ matrix.compiler == 'gcc' && matrix.coverage == 'with-coverage' && !env.ACT }}
run: echo "TOOLCHAIN_FILE=${{github.workspace}}/networkmanager/Tests/gcc-with-coverage.cmake" >> $GITHUB_ENV

- name: Build networkmanager with Gnome Proxy
run: >
cmake
Expand All @@ -129,28 +110,21 @@ jobs:
run: >
PATH=${{github.workspace}}/install/usr/bin:${PATH}
LD_LIBRARY_PATH=${{github.workspace}}/install/usr/lib:${{github.workspace}}/install/usr/lib/wpeframework/plugins:${LD_LIBRARY_PATH}
wifiTest
tests
- name: Generate coverage
if: ${{ matrix.coverage == 'with-coverage' && !env.ACT }}
run: >
cp ${{github.workspace}}/networkmanager/Tests/WiFi/.lcovrc_l1 ~/.lcovrc
&&
lcov -c
-o coverage.info
-d build/GnomeNetworkmanager
&&
lcov
-r coverage.info
'/usr/include/*'
'*/build/GnomeNetworkmanager/_deps/*'
'*/install/usr/include/*'
'*/Tests/headers/*'
'*/Tests/mocks/*'
'*/Tests/WiFi/*'
-o filtered_coverage.info
&&
genhtml
-o coverage
-t "wifisignalstrengthmonitor coverage"
filtered_coverage.info
run: |
lcov -c -o coverage.info -d build/GnomeNetworkmanager
lcov -r coverage.info '/usr/include/*' '*/build/GnomeNetworkmanager/*' \
'*/install/usr/include/*' '*/Tests/*' 'googlemock/*' 'googletest/*' \
-o filtered_coverage.info
- name: Generate the html report
run: |
genhtml filtered_coverage.info --output-directory /tmp/coverage_report
- name: Upload the coverage report to Pull request using actions
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: /tmp/coverage_report

181 changes: 0 additions & 181 deletions Tests/WiFi/.lcovrc_l1

This file was deleted.

12 changes: 0 additions & 12 deletions Tests/clang.cmake

This file was deleted.

1 change: 0 additions & 1 deletion Tests/gcc-with-coverage.cmake

This file was deleted.

19 changes: 10 additions & 9 deletions Tests/WiFi/wifiTest.cmake → Tests/unit_test/tests.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
set(WIFI_TEST "wifiTest")
set(UNIT_TEST "tests")

find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)
Expand All @@ -13,19 +13,20 @@ FetchContent_Declare(
)

FetchContent_MakeAvailable(googletest)
add_executable(${WIFI_TEST}
Tests/WiFi/test_WiFiSignalStrengthMonitor.cpp
add_executable(${UNIT_TEST}
Tests/unittest/test_WiFiSignalStrengthMonitor.cpp
WiFiSignalStrengthMonitor.cpp
NetworkManagerLogger.cpp
NetworkManagerConnectivity.cpp
)
set_target_properties(${WIFI_TEST} PROPERTIES
set_target_properties(${UNIT_TEST} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
)
target_compile_options(${WIFI_TEST} PRIVATE -Wall -include ${CMAKE_SOURCE_DIR}/INetworkManager.h)
target_compile_options(${UNIT_TEST} PRIVATE -Wall -include ${CMAKE_SOURCE_DIR}/INetworkManager.h)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")

target_include_directories(${WIFI_TEST} PRIVATE
target_include_directories(${UNIT_TEST} PRIVATE
${GLIB_INCLUDE_DIRS}
${LIBNM_INCLUDE_DIRS}
${GIO_INCLUDE_DIRS}
Expand All @@ -36,7 +37,7 @@ target_include_directories(${WIFI_TEST} PRIVATE
${gtest_SOURCE_DIR}/../googlemock/include
)

target_link_libraries(${WIFI_TEST} PRIVATE gmock_main ${NAMESPACE}Core::${NAMESPACE}Core ${GLIB_LIBRARIES} ${GIO_LIBRARIES} ${LIBNM_LIBRARIES} ${CURL_LIBRARIES})
target_include_directories(${WIFI_TEST} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS ${WIFI_TEST} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
target_link_libraries(${UNIT_TEST} PRIVATE gmock_main ${NAMESPACE}Core::${NAMESPACE}Core ${GLIB_LIBRARIES} ${GIO_LIBRARIES} ${LIBNM_LIBRARIES} ${CURL_LIBRARIES})
target_include_directories(${UNIT_TEST} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS ${UNIT_TEST} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

0 comments on commit b14dbb1

Please sign in to comment.