Skip to content

Commit cc5b438

Browse files
trupthi1403tboova469_comcast
authored andcommitted
RDKEMW-5610 : L1 test cases for jsruntime
Reason for Change : Added some flags to use mock headers, changes required to build l1 Test Procedure : L1 build must be successful Risk : Low
1 parent afdf341 commit cc5b438

14 files changed

Lines changed: 177 additions & 4 deletions
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: L1 Unit Tests for rdkNativeScript
2+
3+
on:
4+
push:
5+
branches: [topic/RDKEMW-5610]
6+
pull_request:
7+
branches: [topic/RDKEMW-5610]
8+
workflow_dispatch:
9+
10+
env:
11+
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
12+
AUTOMATICS_PASSCODE: ${{ secrets.AUTOMATICS_PASSCODE }}
13+
14+
jobs:
15+
build-and-test-l1:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout source repository
20+
uses: actions/checkout@v3
21+
22+
- name: Checkout rdkNativeScript_tests repository
23+
uses: actions/checkout@v3
24+
with:
25+
repository: rdk-e/rdkNativeScript_tests
26+
ref: topic/RDKEMW-5610
27+
path: rdkNativeScript_tests
28+
token: ${{ secrets.GH_PAT }}
29+
30+
- name: Install dependencies
31+
run: |
32+
sudo apt-get update && sudo apt-get install -y \
33+
g++ \
34+
cmake \
35+
build-essential \
36+
libcurl4-openssl-dev \
37+
libcjson-dev \
38+
libgtest-dev \
39+
libssl-dev \
40+
zlib1g-dev \
41+
libuv1-dev \
42+
lcov \
43+
libglib2.0-dev
44+
45+
- name: Build Google Test and Google Mock
46+
run: |
47+
cd /usr/src/googletest
48+
sudo cmake -S . -B build
49+
sudo cmake --build build
50+
sudo cp build/lib/libgmock.a /usr/lib
51+
sudo cp build/lib/libgmock_main.a /usr/lib
52+
sudo cp build/lib/libgtest.a /usr/lib
53+
sudo cp build/lib/libgtest_main.a /usr/lib
54+
55+
- name: Print working directory
56+
run: pwd
57+
58+
- name: List working directory
59+
run: ls -al
60+
61+
- name: List parent directory
62+
run: ls -al ..
63+
64+
- name: Configure and Build L1
65+
run: |
66+
mkdir -p build_l1
67+
cd build_l1
68+
cmake -DCMAKE_BUILD_TYPE=Debug \
69+
-DRUN_L1=ON \
70+
-DRUN_L2=OFF \
71+
-DENABLE_JSRUNTIME_ESSOS=ON \
72+
-DENABLE_JSRUNTIME_PLAYER=ON \
73+
-DENABLE_AAMP_JSBINDINGS=ON \
74+
-DENABLE_AAMP_JSBINDINGS_DYNAMIC=ON \
75+
-DENABLE_AAMP_JSBINDINGS_STATIC=OFF \
76+
-DJSRUNTIME_ENGINE_NAME=jsc \
77+
-Djsruntime_source=.. ../rdkNativeScript_tests
78+
make -j$(nproc)
79+
80+
- name: Run L1 Tests and Generate JUnit Results
81+
run: |
82+
set -e
83+
cd build_l1
84+
ctest -R RunL1Tests --output-on-failure --no-compress-output -T Test
85+
# Generate JUnit XML (CTest >= 3.17 required)
86+
ctest -T JUnitTest --no-compress-output
87+
if [ -f Testing/UnitTest.xml ]; then cp Testing/UnitTest.xml ctest-results.xml; fi
88+
# Fallback for old CTest: If still missing, copy any Test.xml
89+
if [ ! -f ctest-results.xml ] && [ -f Testing/*/Test.xml ]; then cp Testing/*/Test.xml ctest-results.xml; fi
90+
91+
- name: Show JUnit XML (for debug)
92+
if: always()
93+
run: |
94+
if [ -f build_l1/ctest-results.xml ]; then
95+
head -n 40 build_l1/ctest-results.xml
96+
else
97+
echo "No JUnit XML found!"
98+
fi
99+
100+
- name: Publish L1 test results
101+
uses: dorny/test-reporter@v1
102+
with:
103+
name: Unit Test Results
104+
path: build_l1/ctest-results.xml
105+
reporter: java-junit
106+
107+
- name: Generate coverage report
108+
run: |
109+
cd build_l1
110+
lcov --capture --directory . --output-file coverage.info
111+
genhtml coverage.info --output-directory html_coverage_report
112+
113+
- name: Upload test result file (JUnit XML)
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: ctest-results-l1-${{ github.run_id }}
117+
path: build_l1/ctest-results.xml
118+
119+
- name: Upload coverage report
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: l1-html-coverage-report
123+
path: build_l1/html_coverage_report
124+
if-no-files-found: warn

include/EssosInstance.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
#ifndef NativeJS_ESSOS_INSTANCE_H
2121
#define NativeJS_ESSOS_INSTANCE_H
2222

23+
#ifdef USE_ESSOS_MOCK
24+
#include "essos_mock.h"
25+
#else
2326
#include <essos.h>
27+
#endif
28+
2429
#include <KeyListener.h>
2530

2631
class EssosInstance

include/JSRuntimeClient.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
**/
1919

2020
#pragma once
21+
22+
#ifdef USE_WEBSOCKET_MOCK
23+
#include "websocketpp.hpp"
24+
#else
2125
#include <websocketpp/config/asio_no_tls_client.hpp>
2226
#include <websocketpp/common/thread.hpp>
2327
#include <websocketpp/client.hpp>
28+
#endif
2429

2530
#include <string>
2631
#include <condition_variable>

include/JSRuntimeServer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919

2020
#pragma once
2121
#include <NativeJSRenderer.h>
22+
23+
#ifdef USE_WEBSOCKET_MOCK
24+
#include "websocketpp.hpp"
25+
#else
2226
#include <websocketpp/config/asio_no_tls.hpp>
2327
#include <websocketpp/server.hpp>
28+
#endif
2429

2530
#include <memory>
2631
#include <mutex>

include/jsc/JavaScriptEngine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <unistd.h>
2424
#include <errno.h>
25+
#include <cstdint>
2526

2627
//#include <algorithm>
2728
#include <string>

src/JSRuntimeClient.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
**/
1919
#include <JSRuntimeClient.h>
2020
#include <NativeJSLogger.h>
21+
22+
#ifdef USE_JSCLIB_MOCK
23+
#include "jsc_lib_mock.h"
24+
#else
2125
#include "jsc_lib.h"
26+
#endif
27+
2228
#include <iostream>
2329
#include <sstream>
2430
#include <thread>
@@ -143,6 +149,7 @@ void JSRuntimeClient::onClose(websocketpp::connection_hdl hdl)
143149
setState("close");
144150
}
145151

152+
#ifndef UNIT_TEST_BUILD
146153
int main(int argc, char **argv)
147154
{
148155
std::string command;
@@ -178,3 +185,4 @@ int main(int argc, char **argv)
178185

179186
return 0;
180187
}
188+
#endif

src/JSRuntimeServer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
* limitations under the License.
1818
**/
1919

20+
#ifdef USE_JSCLIB_MOCK
21+
#include "jsc_lib_mock.h"
22+
#else
2023
#include "jsc_lib.h"
24+
#endif
25+
2126
#include <JSRuntimeServer.h>
2227
#include <NativeJSLogger.h>
2328
#include <iostream>

src/jsc/JavaScriptContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ void JavaScriptContext::loadAAMPJSBindingsLib()
146146
gAAMPJSBindings->PlayerLibHandle = aampJSBindingsLibHandle;
147147

148148
gAAMPJSBindings->fnLoadJS =
149-
reinterpret_cast<typeof AAMPJSBindings::fnLoadJS>(
149+
reinterpret_cast<decltype(AAMPJSBindings::fnLoadJS)>(
150150
dlsym(aampJSBindingsLibHandle, "_Z17AAMPPlayer_LoadJSPv"));
151151
gAAMPJSBindings->fnUnloadJS =
152-
reinterpret_cast<typeof AAMPJSBindings::fnUnloadJS>(
152+
reinterpret_cast<decltype(AAMPJSBindings::fnUnloadJS)>(
153153
dlsym(aampJSBindingsLibHandle, "_Z19AAMPPlayer_UnloadJSPv"));
154154
}
155155
else

src/jsc/JavaScriptUtils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
#include "JavaScriptUtils.h"
2121
#include "JavaScriptWrapper.h"
2222
#include "rtLog.h"
23+
24+
#ifdef USE_JSCLIB_MOCK
25+
#include "jsc_lib_mock.h"
26+
#else
2327
#include "jsc_lib.h"
28+
#endif
29+
2430
#include <unistd.h>
2531
#include <stdio.h>
2632
#include <errno.h>

src/jsc/JavaScriptWrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
* limitations under the License.
1818
**/
1919

20+
#ifdef USE_JSCLIB_MOCK
21+
#include "jsc_lib_mock.h"
22+
#else
2023
#include "jsc_lib.h"
24+
#endif
25+
2126
#include "JavaScriptEngine.h"
2227
#include "JavaScriptWrapper.h"
2328
#include <NativeJSLogger.h>

0 commit comments

Comments
 (0)