Skip to content

Commit 7dfd2dd

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 7dfd2dd

12 files changed

Lines changed: 154 additions & 4 deletions
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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: Configure and Build L1
56+
run: |
57+
mkdir -p ../build_l1
58+
cd ../build_l1
59+
cmake -DCMAKE_BUILD_TYPE=Debug \
60+
-DRUN_L1=ON \
61+
-DRUN_L2=OFF \
62+
-DENABLE_JSRUNTIME_ESSOS=ON \
63+
-DENABLE_JSRUNTIME_PLAYER=ON \
64+
-DENABLE_AAMP_JSBINDINGS=ON \
65+
-DENABLE_AAMP_JSBINDINGS_DYNAMIC=ON \
66+
-DENABLE_AAMP_JSBINDINGS_STATIC=OFF \
67+
-DJSRUNTIME_ENGINE_NAME=jsc \
68+
-Djsruntime_source=../rdkNativeScript ../rdkNativeScript/rdkNativeScript_tests
69+
make -j$(nproc)
70+
71+
- name: Run L1 Tests and Generate JUnit Results
72+
run: |
73+
set -e
74+
cd ../build_l1
75+
ctest -R RunL1Tests --output-on-failure --no-compress-output -T Test || true
76+
# Convert CTest results to JUnit XML for reporting
77+
if [ -f Testing/*/Test.xml ]; then cp Testing/*/Test.xml ctest-results.xml; fi
78+
79+
- name: Publish L1 test results
80+
uses: dorny/test-reporter@v1
81+
with:
82+
name: Unit Test Results
83+
path: ../build_l1/ctest-results.xml
84+
reporter: java-junit
85+
86+
- name: Generate coverage report
87+
run: |
88+
cd ../build_l1
89+
lcov --capture --directory . --output-file coverage.info
90+
genhtml coverage.info --output-directory html_coverage_report
91+
92+
- name: Upload test result file (JUnit XML)
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: ctest-results-l1-${{ github.run_id }}
96+
path: ../build_l1/ctest-results.xml
97+
98+
- name: Upload coverage report
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: l1-html-coverage-report
102+
path: ../build_l1/html_coverage_report
103+
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>

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>

src/jsc/PlayerWrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void PlayerWrapper::clearCallbackForAllAdIds()
141141
for (std::map<std::string, JSObjectRef>::iterator it = mPromiseCallbacks.begin(); it != mPromiseCallbacks.end(); )
142142
{
143143
JSValueUnprotect(ctx, it->second);
144-
mPromiseCallbacks.erase(it);
144+
it = mPromiseCallbacks.erase(it);
145145
}
146146
}
147147
}
@@ -344,7 +344,7 @@ JSValueRef AAMPMediaPlayerJS_initConfig (JSContextRef ctx, JSObjectRef function,
344344
}
345345
if (!success)
346346
{
347-
NativeJSLogger::log(ERROR, "Failed to parse JSON string [%s]\n", configData.c_str());
347+
NativeJSLogger::log(ERROR, "Failed to parse JSON string [%s]\n", configData);
348348
fflush(stdout);
349349
}
350350
if (configData)

0 commit comments

Comments
 (0)