Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DELIA-67605 - RDKServices L1 Test with Valgrind failed dueto Signal 11 crash in Bluetooth plugin #6146

Open
wants to merge 3 commits into
base: sprint/25Q1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/L1-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ jobs:
-DDS_FOUND=ON
-DPLUGIN_TEXTTOSPEECH=ON
-DPLUGIN_MIRACAST=ON
-DPLUGIN_BLUETOOTH=ON
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
&&
cmake --build build/rdkservices -j8
Expand Down
2 changes: 2 additions & 0 deletions Tests/L1Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_executable(${PROJECT_NAME}
../mocks/rdkshell.cpp
../mocks/opkgMock.cpp
../mocks/WpaCtrl.cpp
../mocks/BluetoothMocks.cpp
)

set_source_files_properties(
Expand Down Expand Up @@ -183,6 +184,7 @@ target_link_libraries(${PROJECT_NAME}
${NAMESPACE}TextToSpeech
${NAMESPACE}MiracastService
${NAMESPACE}MiracastPlayer
${NAMESPACE}Bluetooth
)

target_include_directories(${PROJECT_NAME}
Expand Down
45 changes: 36 additions & 9 deletions Tests/L1Tests/tests/test_Bluetooth.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if 0
#include <gtest/gtest.h>
#include "Bluetooth.h"
#include "BluetoothMocks.h"
Expand Down Expand Up @@ -32,7 +31,7 @@ class BluetoothTest : public ::testing::Test {
static void SetUpTestCase() {
std::cout << "Setup once before start test" << std::endl;

if(mockBluetoothManagerInstance == nullptr) {
if(p_iarmBusImplMock == nullptr) {
p_iarmBusImplMock = new NiceMock <IarmBusImplMock>;
IarmBus::setImpl(p_iarmBusImplMock);
}
Expand All @@ -46,16 +45,17 @@ class BluetoothTest : public ::testing::Test {
// Called once after all test cases have run
std::cout << "Tearing down after all tests are run." << std::endl;
// Clean up tasks such as releasing resources or resetting state
if (p_iarmBusImplMock != nullptr) {
delete p_iarmBusImplMock;
p_iarmBusImplMock = nullptr;
IarmBus::setImpl(nullptr);
}

if(mockBluetoothManagerInstance != nullptr) {
delete mockBluetoothManagerInstance;
mockBluetoothManagerInstance = nullptr;
}

IarmBus::setImpl(nullptr);
if (p_iarmBusImplMock != nullptr) {
delete p_iarmBusImplMock;
p_iarmBusImplMock = nullptr;
}

}

void SetUp() override {
Expand Down Expand Up @@ -122,6 +122,15 @@ TEST_F(BluetoothTest, StartScanWrapper_SuccessWithAdapters) {
// Invoke the startScan method and check the response
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startScan"), _T("{\"timeout\":30}"), response));
EXPECT_EQ(response, "{\"status\":\"AVAILABLE\",\"success\":true}");

// Mock successful stop
EXPECT_CALL(*mockBluetoothManagerInstance, BTRMGR_StopDeviceDiscovery(::testing::Eq(0), ::testing::_))
.Times(1)
.WillOnce(::testing::Return(BTRMGR_RESULT_SUCCESS));

// Stop discovery
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopScan"), _T("{}"), response));
EXPECT_EQ(response, "{\"success\":true}");
}

// Test Case: StartScanWrapper when no adapters are available
Expand Down Expand Up @@ -185,6 +194,16 @@ TEST_F(BluetoothTest, StartScanWrapper_DiscoveryFailed) {

// Verify the response matches the actual implementation
EXPECT_EQ(response, "{\"status\":\"AVAILABLE\",\"success\":true}");

// Mock successful stop
EXPECT_CALL(*mockBluetoothManagerInstance, BTRMGR_StopDeviceDiscovery(::testing::Eq(0), ::testing::_))
.Times(1)
.WillOnce(::testing::Return(BTRMGR_RESULT_SUCCESS));

// Stop discovery
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopScan"), _T("{}"), response));
EXPECT_EQ(response, "{\"success\":true}");

}

TEST_F(BluetoothTest, StartScanWrapper_ProfileParsingWithReset) {
Expand Down Expand Up @@ -253,6 +272,15 @@ TEST_F(BluetoothTest, StartScanWrapper_DiscoveryInProgress) {
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startScan"),
_T("{\"timeout\":30, \"profile\":\"HEADPHONES\"}"), response));
EXPECT_EQ(response, "{\"status\":\"AVAILABLE\",\"success\":true}");

// Mock successful stop
EXPECT_CALL(*mockBluetoothManagerInstance, BTRMGR_StopDeviceDiscovery(::testing::Eq(0), ::testing::_))
.Times(1)
.WillOnce(::testing::Return(BTRMGR_RESULT_SUCCESS));

// Stop discovery
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopScan"), _T("{}"), response));
EXPECT_EQ(response, "{\"success\":true}");
}

TEST_F(BluetoothTest, StartScanWrapper_MissingParameters) {
Expand Down Expand Up @@ -2413,4 +2441,3 @@ TEST_F(BluetoothTest, EventCallbackTest) {
ASSERT_EQ(BTRMGR_RESULT_SUCCESS, mockBluetoothManagerInstance->evBluetoothHandler(eventMsg));
}
}
#endif
Loading