Skip to content

Commit

Permalink
Merge branch 'release/testbackup' of https://github.com/parvathika/ne…
Browse files Browse the repository at this point in the history
…tworkmanager into release/testbackup
  • Loading branch information
parvathika committed Nov 19, 2024
2 parents 3f6427e + 1ac8756 commit 7d0e9aa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 47 deletions.
39 changes: 8 additions & 31 deletions .github/workflows/gnome_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ jobs:
unit-tests:
name: Build and run unit tests
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [ gcc ]
coverage: [ with-coverage ]

steps:
- name: Configure cache
Expand Down Expand Up @@ -94,11 +90,7 @@ jobs:
uses: actions/checkout@v3
with:
path: networkmanager

- 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 @@ -107,9 +99,7 @@ jobs:
-DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}"
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr"
-DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake"
-DCMAKE_CXX_FLAGS="
-fprofile-arcs
-ftest-coverage"
-DCMAKE_CXX_FLAGS=" -fprofile-arcs -ftest-coverage "
-DENABLE_GNOME_NETWORKMANAGER=ON
-DENABLE_UNIT_TESTING=ON
&&
Expand All @@ -123,27 +113,14 @@ jobs:
tests
- name: Generate coverage
if: ${{ matrix.coverage == 'with-coverage' && !env.ACT }}
run: >
cp ${{github.workspace}}/networkmanager/Tests/unittest/.lcovrc_l1 ~/.lcovrc
&&
lcov -c
-o coverage.info
-d build/GnomeNetworkmanager
&&
lcov
-r coverage.info
'/usr/include/*'
'*/build/GnomeNetworkmanager/_deps/*'
'*/install/usr/include/*'
'*/Tests*'
'googlemock/*'
'googletest/*'
-o 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 coverage.info --output-directory /tmp/coverage_report
genhtml filtered_coverage.info --output-directory /tmp/coverage_report
- name: Upload the coverage report to Pull request using actions
uses: actions/upload-artifact@v4
Expand Down
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.

10 changes: 7 additions & 3 deletions Tests/unittest/test_connectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ TEST_F(ConnectivityMonitorTest, StartMonitorWithTimeoutLessThanMinimum) {
TEST_F(ConnectivityMonitorTest, MonitorFailsToStart) {
int timeout = 0;
bool result = cm.startContinuousConnectivityMonitor(timeout);
EXPECT_TRUE(result);
}
// Set a timeout less than the minimum allowed (assuming minimum is 5 seconds)
int timeout = 3; // Example timeout that is less than the minimum allowed

// Start the monitor with the invalid timeout
bool result = cm.startContinuousConnectivityMonitor(timeout);

// Assert that the monitor started successfully
EXPECT_TRUE(result);
}

TEST_F(ConnectivityMonitorTest, StopContinuousMonitor_WhenStarted) {
int timeout = 30;
Expand Down Expand Up @@ -100,7 +105,6 @@ TEST_F(ConnectivityMonitorTest, StopContinuousMonitor_LongRunningMonitor) {
EXPECT_TRUE(result); // Monitor should stop successfully, even after running for a long time.
}


TEST_F(ConnectivityMonitorTest, StartMonitor_WithInterfaceStatusTrue) {
bool interfaceStatus = true;
bool result = cm.startConnectivityMonitor(interfaceStatus);
Expand Down
2 changes: 2 additions & 0 deletions Tests/unittest/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ FetchContent_Declare(
FetchContent_MakeAvailable(googletest)
add_executable(${UNIT_TEST}
Tests/unittest/test_WiFiSignalStrengthMonitor.cpp
Tests/unittest/test_connectivity.cpp
WiFiSignalStrengthMonitor.cpp
NetworkManagerLogger.cpp
NetworkManagerConnectivity.cpp
Expand All @@ -24,6 +25,7 @@ set_target_properties(${UNIT_TEST} PROPERTIES
CXX_STANDARD_REQUIRED YES
)
target_compile_options(${UNIT_TEST} PRIVATE -Wall -include ${CMAKE_SOURCE_DIR}/INetworkManager.h)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")

target_include_directories(${UNIT_TEST} PRIVATE
${GLIB_INCLUDE_DIRS}
Expand Down

0 comments on commit 7d0e9aa

Please sign in to comment.