Skip to content

Commit fe8e3d1

Browse files
nkader321nkader321
nkader321
authored and
nkader321
committed
RDK-53592 L1/L2 run_ut.sh script for OCDM client repository
Reason for change : L1/L2 test framework for ocdm and run scripts added Test procedure: Run run.sh and check tests are executed and reports generated Risks: Low Signed-off-by: nkader321 <[email protected]>
1 parent 6c58da0 commit fe8e3d1

13 files changed

+559
-0
lines changed

.github/workflows/run_tests.yml

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Unit tests
2+
3+
on:
4+
pull_request:
5+
branches: [ develop, main ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
12+
- name: Install dependencies
13+
run: |
14+
sudo apt -y install build-essential pkg-config cmake ninja-build libusb-1.0-0-dev zlib1g-dev libssl-dev
15+
sudo apt -y install nodejs npm
16+
17+
- name: Install GStreamer
18+
run: |
19+
sudo apt update
20+
sudo apt install -y libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.x'
26+
- run: pip install jsonref
27+
28+
- name: Checkout ThunderTools
29+
uses: actions/checkout@v3
30+
with:
31+
repository: rdkcentral/ThunderTools
32+
ref: R5_1
33+
path: ThunderTools
34+
35+
- name: Build ThunderTools
36+
run: >
37+
cmake -G Ninja -S ThunderTools -B build/ThunderTools -DCMAKE_INSTALL_PREFIX="install"
38+
cmake --build build/ThunderTools --target install
39+
40+
- name: Checkout Thunder
41+
uses: actions/checkout@v3
42+
with:
43+
repository: rdkcentral/Thunder
44+
ref: R5_1
45+
path: Thunder
46+
47+
- name: Build Thunder
48+
run: >
49+
cmake -G Ninja -S Thunder -B build/Thunder \
50+
-DBINDING="127.0.0.1" \
51+
-DCMAKE_BUILD_TYPE="Debug" \
52+
-DCMAKE_INSTALL_PREFIX="install" \
53+
-DPORT="55555" \
54+
-DTOOLS_SYSROOT="${PWD}" \
55+
-DINITV_SCRIPT=OFF
56+
cmake --build build/Thunder --target install
57+
58+
- name: Checkout ThunderInterfaces
59+
uses: actions/checkout@v3
60+
with:
61+
repository: rdkcentral/ThunderInterfaces
62+
ref: R5_1
63+
path: ThunderInterfaces
64+
65+
- name: Build ThunderInterfaces
66+
run: >
67+
cmake -G Ninja -S ThunderInterfaces -B build/ThunderInterfaces \
68+
-DCMAKE_INSTALL_PREFIX="install"
69+
cmake --build build/ThunderInterfaces --target install
70+
71+
- name: Checkout ThunderNanoServices
72+
uses: actions/checkout@v3
73+
with:
74+
repository: rdkcentral/ThunderNanoServices
75+
ref: R5_1
76+
path: ThunderNanoServices
77+
78+
- name: Build ThunderNanoServices
79+
run: >
80+
cmake -G Ninja -S ThunderNanoServices -B build/ThunderNanoServices \
81+
-DCMAKE_INSTALL_PREFIX="install" \
82+
-DPLUGIN_COMMANDER=ON \
83+
-DPLUGIN_DIALSERVER=ON \
84+
-DPLUGIN_DICTIONARY=ON \
85+
-DPLUGIN_FILETRANSFER=ON \
86+
-DPLUGIN_INPUTSWITCH=ON \
87+
-DPLUGIN_PROCESSMONITOR=ON \
88+
-DPLUGIN_RESOURCEMONITOR=ON \
89+
-DPLUGIN_SYSTEMCOMMANDS=ON \
90+
-DPLUGIN_SWITCHBOARD=ON \
91+
-DPLUGIN_WEBPROXY=ON \
92+
-DPLUGIN_WEBSHELL=ON
93+
cmake --build build/ThunderNanoServices --target install
94+
95+
- name: Checkout ThunderNanoServicesRDK
96+
uses: actions/checkout@v3
97+
with:
98+
repository: rdkcentral/ThunderNanoServicesRDK
99+
ref: R5_1
100+
path: ThunderNanoServicesRDK
101+
102+
- name: Build ThunderNanoServicesRDK
103+
run: >
104+
cmake -G Ninja -S ThunderNanoServicesRDK -B build/ThunderNanoServicesRDK \
105+
-DCMAKE_INSTALL_PREFIX="install" \
106+
-DPLUGIN_DEVICEINFO=ON \
107+
-DPLUGIN_MESSAGECONTROL=ON \
108+
-DPLUGIN_MESSENGER=ON \
109+
-DPLUGIN_MONITOR=ON \
110+
-DPLUGIN_OPENCDMI=ON \
111+
-DPLUGIN_PERFORMANCEMETRICS=ON
112+
cmake --build build/ThunderNanoServicesRDK --target install
113+
114+
- name: Checkout ThunderClientLibraries
115+
uses: actions/checkout@v3
116+
with:
117+
repository: rdkcentral/ThunderClientLibraries
118+
ref: R5_1
119+
path: ThunderClientLibraries
120+
121+
- name: Build ThunderClientLibraries
122+
run: >
123+
cmake -G Ninja -S ThunderClientLibraries -B build/ThunderClientLibraries \
124+
-DCMAKE_INSTALL_PREFIX="install" \
125+
-DBLUETOOTHAUDIOSINK=ON \
126+
-DDEVICEINFO=ON \
127+
-DDISPLAYINFO=ON \
128+
-DSECURITYAGENT=ON \
129+
-DPLAYERINFO=ON \
130+
-DPROTOCOLS=ON \
131+
-DVIRTUALINPUT=ON \
132+
-DCDMI=ON \
133+
-DL1_TESTS=ON \
134+
-DL2_TESTS=ON
135+
cmake --build build/ThunderClientLibraries --target install
136+
137+
- name: Export path
138+
run: >
139+
export LD_LIBRARY_PATH=${PWD}/install/lib:${LD_LIBRARY_PATH}
140+
export PATH=${PWD}/install/bin:${PATH}
141+
142+
- name: Run unit tests
143+
run: /bin/bash ThunderClientLibraries/run.sh -c
144+
145+
- name: Upload test results to automatic test result management system
146+
run: >
147+
gtest-json-result-push.py ${{github.workspace}}/ThunderClientLibraries/TestReport.json https://rdkeorchestrationservice.as-g8.cf.comcast.net/rdke_orchestration_api/push_unit_test_results `pwd`
148+

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ option(CRYPTOGRAPHY
4848

4949
option(INSTALL_TESTS "Install the test applications" OFF)
5050

51+
option(L1_TESTS "Install the test applications" OFF)
52+
53+
option(L2_TESTS "Install the test applications" OFF)
54+
5155
if (BUILD_REFERENCE)
5256
add_definitions (-DBUILD_REFERENCE=${BUILD_REFERENCE})
5357
endif()

Tests/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ if(CDMI)
1919
add_subdirectory(ocdmtest)
2020
endif()
2121

22+
if(L1_TESTS)
23+
add_subdirectory(L1Tests)
24+
endif()
25+
26+
if(L2_TESTS)
27+
add_subdirectory(L2Tests)
28+
endif()
29+
2230

Tests/L1Tests/CMakeLists.txt

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# If not stated otherwise in this file or this component's LICENSE file the
2+
# following copyright and licenses apply:
3+
#
4+
# Copyright 2024 RDK Management
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
cmake_minimum_required(VERSION 3.8)
19+
project(L1Test)
20+
21+
set(CMAKE_CXX_STANDARD 11)
22+
23+
find_package(Thunder)
24+
find_package(ClientOCDM REQUIRED)
25+
find_package(${NAMESPACE}Core REQUIRED)
26+
find_package(${NAMESPACE}COM REQUIRED)
27+
find_package(${NAMESPACE}Messaging REQUIRED)
28+
find_package(CompileSettingsDebug CONFIG REQUIRED)
29+
find_package(GTest REQUIRED)
30+
include(CTest)
31+
32+
file(GLOB TESTS tests/*.cpp)
33+
34+
add_executable(${PROJECT_NAME}
35+
gtest_main.cpp
36+
${TESTS}
37+
)
38+
39+
include_directories(../../Source/ocdm)
40+
link_directories(../../Source/ocdm)
41+
42+
target_link_libraries(${PROJECT_NAME}
43+
${NAMESPACE}Core::${NAMESPACE}Core
44+
${NAMESPACE}COM::${NAMESPACE}COM
45+
${NAMESPACE}Messaging::${NAMESPACE}Messaging
46+
CompileSettingsDebug::CompileSettingsDebug
47+
ClientOCDM::ClientOCDM
48+
GTest::GTest
49+
)
50+
51+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
52+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
53+
54+
gtest_add_tests(TARGET ${PROJECT_NAME})
55+
56+
install(TARGETS ${PROJECT_NAME} DESTINATION bin)

Tests/L1Tests/gtest_main.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* If not stated otherwise in this file or this component's license file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2024 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#include <gtest/gtest.h>
21+
22+
int main(int argc, char** argv)
23+
{
24+
testing::InitGoogleTest(&argc, argv);
25+
return RUN_ALL_TESTS();
26+
}

Tests/L1Tests/run.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# This script will build and run the L1 tests
3+
4+
rm -rf build
5+
6+
mkdir build
7+
8+
cd build
9+
10+
export GTEST_OUTPUT="json"
11+
12+
cmake ..
13+
14+
make
15+
16+
./L1Test
17+
18+
#Generate coverage report
19+
if [ "$1" != "" ] && [ $1 = "-c" ]; then
20+
lcov --capture --directory . --output-file coverage.info
21+
lcov --remove coverage.info '/usr/*' --output-file coverage.info
22+
lcov --list coverage.info
23+
genhtml coverage.info --output-directory coverage_report
24+
fi
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* If not stated otherwise in this file or this component's license file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2024 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#include "open_cdm_impl.h"
21+
#include "open_cdm_ext.h"
22+
#include <gtest/gtest.h>
23+
using namespace testing;
24+
25+
class OpenCDMExtTest : public ::testing::Test {
26+
protected:
27+
28+
void SetUp() override {
29+
}
30+
31+
void TearDown() override {
32+
}
33+
};
34+
35+
TEST_F(OpenCDMExtTest, opencdmCreateSystem)
36+
{
37+
int status = 0;
38+
const char keySystem[] = "playready";
39+
struct OpenCDMSystem* result;
40+
result = opencdm_create_system(keySystem);
41+
EXPECT_EQ(result, nullptr);
42+
}
43+
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* If not stated otherwise in this file or this component's license file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2024 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#include "open_cdm.h"
21+
#include <gtest/gtest.h>
22+
using namespace testing;
23+
24+
class OpenCDMTest : public ::testing::Test {
25+
protected:
26+
27+
void SetUp() override {
28+
}
29+
30+
void TearDown() override {
31+
}
32+
};
33+
34+
TEST_F(OpenCDMTest, status)
35+
{
36+
int status = 1;
37+
EXPECT_EQ(status, 1);
38+
}
39+

0 commit comments

Comments
 (0)