Skip to content

Commit

Permalink
Merge pull request rdkcentral#5459 from Prathyushakothuru/sprint/24Q2
Browse files Browse the repository at this point in the history
[RDK-50881] Add L2 Test cases with calling the methods using jsonrpc
  • Loading branch information
anand-ky authored Jun 28, 2024
2 parents 3e52884 + f1e07aa commit 3660398
Show file tree
Hide file tree
Showing 18 changed files with 2,090 additions and 87 deletions.
57 changes: 34 additions & 23 deletions .github/workflows/L2-tests-R4-4-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: >
sudo apt update
&&
sudo apt install -y libsqlite3-dev libcurl4-openssl-dev valgrind lcov clang libsystemd-dev libboost-all-dev libwebsocketpp-dev meson libcunit1 libcunit1-dev
sudo apt install -y libsqlite3-dev libcurl4-openssl-dev valgrind lcov clang libsystemd-dev libboost-all-dev libwebsocketpp-dev meson libcunit1 libcunit1-dev protobuf-compiler protobuf-compiler-grpc libgrpc-dev libgrpc++-dev
- name: Install GStreamer
run: |
Expand Down Expand Up @@ -84,11 +84,24 @@ jobs:
-DEXCEPTIONS_ENABLE=ON
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr"
-DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake"
-DGENERIC_CMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake"
&&
cmake --build build/ThunderTools -j8
&&
cmake --install build/ThunderTools
- name: Checkout rdkservices
uses: actions/checkout@v3
with:
path: rdkservices

- name: Checkout rdkservices
run: |
cd ${{github.workspace}}/rdkservices
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0003-R4.4.1-LocationSync-compilation-error.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0003-R4.4.1-SystemAudioPlayer-compilation-error.patch
cd -
- name: Build Thunder
if: steps.cache.outputs.cache-hit != 'true'
run: >
Expand All @@ -107,18 +120,6 @@ jobs:
&&
cmake --install build/Thunder
- name: Checkout rdkservices
uses: actions/checkout@v3
with:
path: rdkservices

- name: Apply patch Rdkservices
run: |
cd ${{github.workspace}}/rdkservices
patch -p1 < files/0003-R4.4.1-LocationSync-compilation-error.patch
patch -p1 < files/0003-R4.4.1-SystemAudioPlayer-compilation-error.patch
cd -
- name: Checkout ThunderInterfaces
uses: actions/checkout@v3
with:
Expand All @@ -129,14 +130,13 @@ jobs:

- name: Apply patch ThunderInterfaces
run: |
echo "Present working directory is: $(pwd)"
echo "Listing directory is:"
ls -la
cd ThunderInterfaces
echo "Current branch is: $(git branch --show-current)"
git apply "${{github.workspace}}/rdkservices/files/SplitDeviceCapablities.patch"
git apply "${{github.workspace}}/rdkservices/files/0007-RDK-IDeviceInfo-Changes.patch"
git apply "${{github.workspace}}/rdkservices/files/0001-Add-TextToSpeech-Interface.patch"
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/R.4.4.1-0001-Add-TextToSpeech-Interface.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/SplitDeviceCapablities.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0007-RDK-IDeviceInfo-Changes.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0001-RDK-45037-Secure-Storage-Thunder-Plugin.patch
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDKV-48604-User-Settings-Thunder-Plugin.patch
cd ..
- name: Build ThunderInterfaces
Expand Down Expand Up @@ -227,12 +227,13 @@ jobs:
-DTHUNDER_VERSION=4
-DTHUNDER_VERSION_MAJOR=4
-DTHUNDER_VERSION_MINOR=4
-DPLUGIN_PERSISTENTSTORE_PATH="/tmp/secure/persistent/rdkservicestore"
-DPLUGIN_PERSISTENTSTORE_LEGACYPATH="/tmp/persistent/rdkservicestore"
-I ${{github.workspace}}/rdkservices/Tests/headers
-I ${{github.workspace}}/rdkservices/Tests/headers/rdk/ds
-I ${{github.workspace}}/rdkservices/Tests/headers/rdk/iarmbus
-I ${{github.workspace}}/rdkservices/Tests/headers/rdk/iarmmgrs-hal
-I ${{github.workspace}}/rdkservices/Tests/headers/systemservices
-I ${{github.workspace}}/rdkservices/Tests/headers/sampleplugin
-I ${{github.workspace}}/rdkservices/Tests/headers/systemservices/proc
-include ${{github.workspace}}/rdkservices/Tests/mocks/devicesettings.h
-include ${{github.workspace}}/rdkservices/Tests/mocks/Iarm.h
Expand All @@ -242,9 +243,11 @@ jobs:
-include ${{github.workspace}}/rdkservices/Tests/mocks/Wraps.h
-include ${{github.workspace}}/rdkservices/Tests/mocks/maintenanceMGR.h
-include ${{github.workspace}}/rdkservices/Tests/mocks/pkg.h
-Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format=
-Werror -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format=
-DUSE_IARMBUS
-DENABLE_THERMAL_PROTECTION"
-DPLUGIN_PERSISTENTSTORE_PATH="/tmp/secure/persistent/rdkservicestore"
-DPLUGIN_PERSISTENTSTORE_LEGACYPATH="/tmp/persistent/rdkservicestore"
-DCOMCAST_CONFIG=OFF
-DCMAKE_DISABLE_FIND_PACKAGE_DS=ON
-DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON
Expand All @@ -257,7 +260,9 @@ jobs:
-DPLUGIN_HDCPPROFILE=OFF
-DPLUGIN_NETWORK=OFF
-DPLUGIN_TEXTTOSPEECH=OFF
-DPLUGIN_USBACCESS=ON
-DPLUGIN_USBACCESS=OFF
-DPLUGIN_USERSETTINGS=ON
-DPLUGIN_PERSISTENTSTORE=ON
-DUSE_THUNDER_R4=ON
-DPLUGIN_L2Tests=ON
-DRDK_SERVICE_L2_TEST=ON
Expand All @@ -276,6 +281,9 @@ jobs:
/opt/secure/reboot
/opt/secure/persistent
/opt/secure/persistent/System
/tmp/secure/persistent
/tmp/persistent
/tmp/persistent/rdkservicestore
/opt/logs
/lib/rdk
/run/media/sda1/logs/PreviousLogs
Expand Down Expand Up @@ -307,8 +315,9 @@ jobs:
/lib/rdk/getMaintenanceStartTime.sh
/tmp/opkg.conf
/tmp/system_service_temp.conf
/tmp/secure/persistent/rdkservicestore
&&
sudo chmod 777
sudo chmod -R 777
/opt/standbyReason.txt
/opt/tmtryoptout
/opt/fwdnldstatus.txt
Expand All @@ -320,6 +329,8 @@ jobs:
/lib/rdk/getMaintenanceStartTime.sh
/tmp/opkg.conf
/tmp/system_service_temp.conf
/tmp/persistent/rdkservicestore
/tmp/secure/persistent/rdkservicestore
- name: Download pact_verifier_cli
run: >
Expand Down
48 changes: 27 additions & 21 deletions Tests/L2Tests/L2TestsPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,33 @@ set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})
set(THUNDER_PORT 9998)
find_package(${NAMESPACE}Plugins REQUIRED)

# We are not running VerifyContracts,Warehouse_L2Test tests for Thunder R4 as
# this work is not in this scope. In future we will enable these tests for Thunder R4.
if(NOT USE_THUNDER_R4)
add_library(${MODULE_NAME} SHARED
Module.cpp
L2Tests.cpp
L2TestsMock.cpp
tests/SystemService_L2Test.cpp
tests/UsbAccess_L2Test.cpp
tests/Telemetry_L2Test.cpp
tests/Warehouse_L2Test.cpp
tests/VerifyContracts.cpp)
else()
add_library(${MODULE_NAME} SHARED
Module.cpp
L2Tests.cpp
L2TestsMock.cpp
tests/SystemService_L2Test.cpp
tests/UsbAccess_L2Test.cpp
tests/Telemetry_L2Test.cpp)
endif(NOT USE_THUNDER_R4)
set(SRC_FILES Module.cpp L2Tests.cpp L2TestsMock.cpp)

if(PLUGIN_SYSTEMSERVICES)
set(SRC_FILES ${SRC_FILES} tests/SystemService_L2Test.cpp)
endif()

if(PLUGIN_USBACCESS)
set(SRC_FILES ${SRC_FILES} tests/UsbAccess_L2Test.cpp)
endif()

if(PLUGIN_TELEMETRY)
set(SRC_FILES ${SRC_FILES} tests/Telemetry_L2Test.cpp)
endif()

if(PLUGIN_WAREHOUSE)
set(SRC_FILES ${SRC_FILES} tests/Warehouse_L2Test.cpp)
endif()

if(PLUGIN_HDCPPROFILE)
set(SRC_FILES ${SRC_FILES} tests/VerifyContracts.cpp)
endif()

if(PLUGIN_USERSETTINGS)
set(SRC_FILES ${SRC_FILES} tests/UserSettings_L2Test.cpp)
endif()

add_library(${MODULE_NAME} SHARED ${SRC_FILES})

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
Expand Down
50 changes: 50 additions & 0 deletions Tests/L2Tests/L2TestsPlugin/L2TestsMock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,56 @@ uint32_t L2TestMocks::InvokeServiceMethod(const char *callsign, const char *meth
return status;
}

/**
* @brief Invoke a service method
*
* @param[in] callsign Service callsign
* @param[in] method Method name
* @param[out] results Method results
* @return Zero (Core::ERROR_NONE) on succes or another value on error
*/
uint32_t L2TestMocks::InvokeServiceMethod(const char *callsign, const char *method, Core::JSON::Boolean &results)
{

JSONRPC::LinkType<Core::JSON::IElement> jsonrpc(std::string(callsign), TEST_CALLSIGN);
std::string reply;
uint32_t status = Core::ERROR_NONE;

TEST_LOG("Invoking %s.%s \n", callsign, method);

status = jsonrpc.Invoke<void, Core::JSON::Boolean>(INVOKE_TIMEOUT, std::string(method), results);

results.ToString(reply);
TEST_LOG("Status %u, results %s", status, reply.c_str());

return status;
}

/**
* @brief Invoke a service method
*
* @param[in] callsign Service callsign
* @param[in] method Method name
* @param[out] results Method results
* @return Zero (Core::ERROR_NONE) on succes or another value on error
*/
uint32_t L2TestMocks::InvokeServiceMethod(const char *callsign, const char *method, Core::JSON::String &results)
{

JSONRPC::LinkType<Core::JSON::IElement> jsonrpc(std::string(callsign), TEST_CALLSIGN);
std::string reply;
uint32_t status = Core::ERROR_NONE;

TEST_LOG("Invoking %s.%s \n", callsign, method);

status = jsonrpc.Invoke<void, Core::JSON::String>(INVOKE_TIMEOUT, std::string(method), results);

results.ToString(reply);
TEST_LOG("Status %u, results %s", status, reply.c_str());

return status;
}

/**
* @brief Activate a service plugin
*
Expand Down
23 changes: 21 additions & 2 deletions Tests/L2Tests/L2TestsPlugin/L2TestsMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#pragma once

#include <websocket/JSONRPCLink.h>

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "UtilsJsonRpc.h"
Expand Down Expand Up @@ -51,7 +50,6 @@ class L2TestMocks : public ::testing::Test {
VideoOutputPortMock *p_videoOutputPortMock = nullptr;
RBusApiImplMock *p_rBusApiImplMock = nullptr;
TelemetryApiImplMock *p_telemetryApiImplMock = nullptr ;

std::string thunder_address;

L2TestMocks();
Expand All @@ -68,6 +66,27 @@ class L2TestMocks : public ::testing::Test {
*/
uint32_t InvokeServiceMethod(const char *callsign, const char *method, JsonObject &params, JsonObject &results);

/**
* @brief Invoke a service method
*
* @param[in] callsign Service callsign
* @param[in] method Method name
* @param[out] results Method results
* @return Zero (Core::ERROR_NONE) on succes or another value on error
*/
uint32_t InvokeServiceMethod(const char *callsign, const char *method, Core::JSON::Boolean &results);

/**
* @brief Invoke a service method
*
* @param[in] callsign Service callsign
* @param[in] method Method name
* @param[out] results Method results
* @return Zero (Core::ERROR_NONE) on succes or another value on error
*/
uint32_t InvokeServiceMethod(const char *callsign, const char *method, Core::JSON::String &results);


/**
* @brief Activate a service plugin
*
Expand Down
Loading

0 comments on commit 3660398

Please sign in to comment.