Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/jsruntime_L1tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: L1 Unit Tests for rdkNativeScript
permissions:
contents: read
checks: write

on:
push:
branches: [develop]
pull_request:
branches: [develop]
workflow_dispatch:

env:
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
AUTOMATICS_PASSCODE: ${{ secrets.AUTOMATICS_PASSCODE }}

jobs:
build-and-test-l1:
runs-on: ubuntu-latest

steps:
- name: Checkout source repository
uses: actions/checkout@v3

- name: Checkout rdkNativeScript_tests repository
uses: actions/checkout@v3
with:
repository: rdk-e/rdkNativeScript_tests
ref: topic/RDKEMW-5610
path: rdkNativeScript_tests
token: ${{ secrets.GH_PAT }}

- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y \
g++ \
cmake \
build-essential \
libcurl4-openssl-dev \
libcjson-dev \
libgtest-dev \
libssl-dev \
zlib1g-dev \
libuv1-dev \
lcov \
libglib2.0-dev

- name: Build Google Test and Google Mock
run: |
cd /usr/src/googletest
sudo cmake -S . -B build
sudo cmake --build build
sudo cp build/lib/libgmock.a /usr/lib
sudo cp build/lib/libgmock_main.a /usr/lib
sudo cp build/lib/libgtest.a /usr/lib
sudo cp build/lib/libgtest_main.a /usr/lib

- name: Configure and Build L1
run: |
mkdir -p build_l1
cd build_l1
cmake -DCMAKE_BUILD_TYPE=Debug \
-DRUN_L1=ON \
-DRUN_L2=OFF \
-DENABLE_JSRUNTIME_ESSOS=ON \
-DENABLE_JSRUNTIME_PLAYER=ON \
-DENABLE_AAMP_JSBINDINGS=ON \
-DENABLE_AAMP_JSBINDINGS_DYNAMIC=ON \
-DENABLE_AAMP_JSBINDINGS_STATIC=OFF \
-DJSRUNTIME_ENGINE_NAME=jsc \
-Djsruntime_source=.. ../rdkNativeScript_tests
make -j$(nproc)

- name: Run L1 Tests and Generate JUnit Results
run: |
cd build_l1
#ctest -R RunL1Tests --output-on-failure --no-compress-output --output-junit ctest-results.xml
./L1_tests --gtest_output=xml:ctest-results.xml

- name: Publish L1 test results
uses: dorny/test-reporter@v1
with:
name: Unit Test Results
path: build_l1/ctest-results.xml
reporter: java-junit

- name: Generate coverage report
run: |
cd build_l1
lcov --capture --directory . --output-file coverage.info --ignore-errors mismatch --rc geninfo_unexecuted_blocks=1
lcov --remove coverage.info '/usr/*' '*/test/*' '*/tests/*' '*/L1/*' '*/mocks/*' '*/gtest/*' '*/gmock/*' '*/googletest/*' '*/include/*' --output-file coverage.cleaned.info --ignore-errors unused
lcov --extract coverage.cleaned.info '*/src/*' --output-file coverage.final.info
genhtml coverage.final.info --output-directory html_coverage_report

- name: Upload test result file (JUnit XML)
uses: actions/upload-artifact@v4
with:
name: ctest-results-l1-${{ github.run_id }}
path: build_l1/ctest-results.xml

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: l1-html-coverage-report
path: build_l1/html_coverage_report
if-no-files-found: warn
5 changes: 5 additions & 0 deletions include/EssosInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
#ifndef NativeJS_ESSOS_INSTANCE_H
#define NativeJS_ESSOS_INSTANCE_H

#ifdef USE_ESSOS_MOCK
#include "essos_mock.h"
#else
#include <essos.h>
#endif

#include <KeyListener.h>

class EssosInstance
Expand Down
5 changes: 5 additions & 0 deletions include/JSRuntimeClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
**/

#pragma once

#ifdef USE_WEBSOCKET_MOCK
#include "websocketpp.hpp"
#else
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/common/thread.hpp>
#include <websocketpp/client.hpp>
#endif

#include <string>
#include <condition_variable>
Expand Down
5 changes: 5 additions & 0 deletions include/JSRuntimeServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

#pragma once
#include <NativeJSRenderer.h>

#ifdef USE_WEBSOCKET_MOCK
#include "websocketpp.hpp"
#else
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
#endif

#include <memory>
#include <mutex>
Expand Down
1 change: 1 addition & 0 deletions include/jsc/JavaScriptEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <unistd.h>
#include <errno.h>
#include <cstdint>

//#include <algorithm>
#include <string>
Expand Down
8 changes: 8 additions & 0 deletions src/JSRuntimeClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
**/
#include <JSRuntimeClient.h>
#include <NativeJSLogger.h>

#ifdef USE_JSCLIB_MOCK
#include "jsc_lib_mock.h"
#else
#include "jsc_lib.h"
#endif

#include <iostream>
#include <sstream>
#include <thread>
Expand Down Expand Up @@ -143,6 +149,7 @@ void JSRuntimeClient::onClose(websocketpp::connection_hdl hdl)
setState("close");
}

#ifndef UNIT_TEST_BUILD
int main(int argc, char **argv)
{
std::string command;
Expand Down Expand Up @@ -178,3 +185,4 @@ int main(int argc, char **argv)

return 0;
}
#endif
5 changes: 5 additions & 0 deletions src/JSRuntimeServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* limitations under the License.
**/

#ifdef USE_JSCLIB_MOCK
#include "jsc_lib_mock.h"
#else
#include "jsc_lib.h"
#endif

#include <JSRuntimeServer.h>
#include <NativeJSLogger.h>
#include <iostream>
Expand Down
4 changes: 2 additions & 2 deletions src/jsc/JavaScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ void JavaScriptContext::loadAAMPJSBindingsLib()
gAAMPJSBindings->PlayerLibHandle = aampJSBindingsLibHandle;

gAAMPJSBindings->fnLoadJS =
reinterpret_cast<typeof AAMPJSBindings::fnLoadJS>(
reinterpret_cast<decltype(AAMPJSBindings::fnLoadJS)>(
dlsym(aampJSBindingsLibHandle, "_Z17AAMPPlayer_LoadJSPv"));
gAAMPJSBindings->fnUnloadJS =
reinterpret_cast<typeof AAMPJSBindings::fnUnloadJS>(
reinterpret_cast<decltype(AAMPJSBindings::fnUnloadJS)>(
dlsym(aampJSBindingsLibHandle, "_Z19AAMPPlayer_UnloadJSPv"));
}
else
Expand Down
6 changes: 6 additions & 0 deletions src/jsc/JavaScriptUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
#include "JavaScriptUtils.h"
#include "JavaScriptWrapper.h"
#include "rtLog.h"

#ifdef USE_JSCLIB_MOCK
#include "jsc_lib_mock.h"
#else
#include "jsc_lib.h"
#endif

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
Expand Down
5 changes: 5 additions & 0 deletions src/jsc/JavaScriptWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* limitations under the License.
**/

#ifdef USE_JSCLIB_MOCK
#include "jsc_lib_mock.h"
#else
#include "jsc_lib.h"
#endif

#include "JavaScriptEngine.h"
#include "JavaScriptWrapper.h"
#include <NativeJSLogger.h>
Expand Down
4 changes: 2 additions & 2 deletions src/jsc/PlayerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void PlayerWrapper::clearCallbackForAllAdIds()
for (std::map<std::string, JSObjectRef>::iterator it = mPromiseCallbacks.begin(); it != mPromiseCallbacks.end(); )
{
JSValueUnprotect(ctx, it->second);
mPromiseCallbacks.erase(it);
it = mPromiseCallbacks.erase(it);
}
}
}
Expand Down Expand Up @@ -344,7 +344,7 @@ JSValueRef AAMPMediaPlayerJS_initConfig (JSContextRef ctx, JSObjectRef function,
}
if (!success)
{
NativeJSLogger::log(ERROR, "Failed to parse JSON string [%s]\n", configData.c_str());
NativeJSLogger::log(ERROR, "Failed to parse JSON string [%s]\n", configData);
fflush(stdout);
}
if (configData)
Expand Down
5 changes: 5 additions & 0 deletions src/jsc/jsc_lib/jsc_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifdef USE_JSCLIB_MOCK
#include "jsc_lib_mock.h"
#else
#include "jsc_lib.h"
#endif

#include "NativeJSLogger.h"

using namespace JSC;
Expand Down
1 change: 1 addition & 0 deletions src/jsc/rtScriptJSCPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <map>
#include <memory>
#include <cassert>
#include <utility>

#ifdef __cplusplus
extern "C" {
Expand Down
3 changes: 3 additions & 0 deletions src/jsruntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using namespace std;
using namespace JsRuntime;

#ifndef UNIT_TEST_BUILD
int main(int argc, char* argv[])
{
if (argc < 2)
Expand Down Expand Up @@ -155,3 +156,5 @@ int main(int argc, char* argv[])

return 0;
}

#endif