Skip to content

Commit 3c2a8a3

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 3c2a8a3

12 files changed

Lines changed: 159 additions & 4 deletions
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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.ACTIONS_DEPLOY_KEY }}
29+
- name: Checkout Thunder repository
30+
uses: actions/checkout@v3
31+
with:
32+
repository: rdkcentral/Thunder
33+
ref: master
34+
path: ../Thunder
35+
36+
- name: Install dependencies
37+
run: |
38+
sudo apt-get update && sudo apt-get install -y \
39+
g++ \
40+
cmake \
41+
build-essential \
42+
libcurl4-openssl-dev \
43+
libcjson-dev \
44+
libgtest-dev \
45+
libssl-dev \
46+
zlib1g-dev \
47+
libuv1-dev \
48+
lcov
49+
50+
- name: Build Google Test and Google Mock
51+
run: |
52+
cd /usr/src/googletest
53+
sudo cmake -S . -B build
54+
sudo cmake --build build
55+
sudo cp build/lib/libgmock.a /usr/lib
56+
sudo cp build/lib/libgmock_main.a /usr/lib
57+
sudo cp build/lib/libgtest.a /usr/lib
58+
sudo cp build/lib/libgtest_main.a /usr/lib
59+
60+
- name: Configure and Build L1
61+
run: |
62+
mkdir -p ../build_l1
63+
cd ../build_l1
64+
cmake -DCMAKE_BUILD_TYPE=Debug \
65+
-DRUN_L1=ON \
66+
-DRUN_L2=OFF \
67+
-DENABLE_JSRUNTIME_ESSOS=ON \
68+
-DENABLE_JSRUNTIME_PLAYER=ON \
69+
-DENABLE_AAMP_JSBINDINGS=ON \
70+
-DENABLE_AAMP_JSBINDINGS_DYNAMIC=ON \
71+
-DENABLE_AAMP_JSBINDINGS_STATIC=OFF \
72+
-DJSRUNTIME_ENGINE_NAME=jsc \
73+
-Djsruntime_source=../rdkNativeScript ../rdkNativeScript_tests
74+
make -j$(nproc)
75+
76+
- name: Run L1 Tests and Generate JUnit Results
77+
run: |
78+
set -e
79+
cd ../build_l1
80+
ctest -R RunL1Tests --output-on-failure --no-compress-output -T Test || true
81+
# Convert CTest results to JUnit XML for reporting
82+
if [ -f Testing/*/Test.xml ]; then cp Testing/*/Test.xml ctest-results.xml; fi
83+
84+
- name: Publish L1 test results
85+
uses: dorny/test-reporter@v1
86+
with:
87+
name: Unit Test Results
88+
path: ../build_l1/ctest-results.xml
89+
reporter: java-junit
90+
91+
- name: Generate coverage report
92+
run: |
93+
cd ../build_l1
94+
lcov --capture --directory . --output-file coverage.info
95+
genhtml coverage.info --output-directory html_coverage_report
96+
97+
- name: Upload test result file (JUnit XML)
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: ctest-results-l1-${{ github.run_id }}
101+
path: ../build_l1/ctest-results.xml
102+
103+
- name: Upload coverage report
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: l1-html-coverage-report
107+
path: ../build_l1/html_coverage_report
108+
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)