From 961988eb5e1a2214ed917fa8afafe906d0e17fff Mon Sep 17 00:00:00 2001 From: trupthi1403 Date: Wed, 3 Dec 2025 10:43:15 +0530 Subject: [PATCH 1/3] RDKEMW-9172: L2testcase for rdkNativeScript Reason for change: Changes to run L2 test cases Test Procedure: Able to build and run test cases in CI Risks: low Priority: P2 --- CMakeLists.txt | 20 ++++++++++++++++++++ include/NativeJSRenderer.h | 1 + src/NativeJSRenderer.cpp | 7 ++++++- src/jsruntime.cpp | 21 +++++++++++++++++++-- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f888133..df6acc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ option(BUILD_JSRUNTIME_APP "BUILD_JSRUNTIME_APP" ON) option(ENABLE_JSRUNTIME_SERVER "ENABLE_JSRUNTIME_SERVER" OFF) option(BUILD_JSRUNTIME_CLIENT "BUILD_JSRUNTIME_CLIENT" OFF) option(NATIVEJS_DEVELOPER_MODE "NATIVEJS_DEVELOPER_MODE" OFF) +option(NATIVEJS_L2_BUILD "NATIVEJS_L2_BUILD" OFF) #can be jsc or node or v8 or quickjs option(JSRUNTIME_ENGINE_NAME "JSRUNTIME_ENGINE_NAME" "jsc") @@ -39,6 +40,7 @@ option(ENABLE_JSRUNTIME_PLAYER "ENABLE_JSRUNTIME_PLAYER" OFF) option(ENABLE_JSRUNTIME_THUNDER_SECURITYAGENT "ENABLE_JSRUNTIME_THUNDER_SECURITYAGENT" OFF) option(BUILD_JSRUNTIME_DESKTOP "BUILD_JSRUNTIME_DESKTOP" ON) option(USE_ETHANLOG "USE_ETHANLOG" OFF) +option(ENABLE_COVERAGE "ENABLE_COVERAGE" OFF) option(PKG_CONFIG_SYSROOT_DIR "PKG_CONFIG_SYSROOT_DIR" "${CMAKE_CURRENT_SOURCE_DIR}/externals/extlibs") if(JSRUNTIME_ENGINE_NAME STREQUAL "jsc") @@ -101,6 +103,14 @@ if (ENABLE_JSRUNTIME_THUNDER_SECURITYAGENT) add_definitions("-DENABLE_JSRUNTIME_THUNDER_SECURITYAGENT") endif (ENABLE_JSRUNTIME_THUNDER_SECURITYAGENT) +if (NATIVEJS_DEVELOPER_MODE) + add_definitions("-DNATIVEJS_DEVELOPER_MODE") +endif (NATIVEJS_DEVELOPER_MODE) + +if (NATIVEJS_L2_BUILD) + add_definitions("-DNATIVEJS_L2_BUILD") +endif (NATIVEJS_L2_BUILD) + include (${JSRUNTIME_SOURCE_DIRECTORY}/include.cmake) set(JSRUNTIME_APP_FILES ${JSRUNTIME_COMMON_SOURCE_DIRECTORY}/jsruntime.cpp @@ -188,6 +198,16 @@ if (APPLE) endif (APPLE) add_definitions("-std=c++17 -DUSE_LIBUV") + +# Coverage support +if (ENABLE_COVERAGE) + message("Enabling code coverage support") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") +endif (ENABLE_COVERAGE) + set_target_properties(${JSRUNTIME_LIBRARY_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES) diff --git a/include/NativeJSRenderer.h b/include/NativeJSRenderer.h index 51fde0f..796594a 100644 --- a/include/NativeJSRenderer.h +++ b/include/NativeJSRenderer.h @@ -31,6 +31,7 @@ #include #include #include +#include namespace JsRuntime { diff --git a/src/NativeJSRenderer.cpp b/src/NativeJSRenderer.cpp index a7b71e6..4657e4b 100644 --- a/src/NativeJSRenderer.cpp +++ b/src/NativeJSRenderer.cpp @@ -571,7 +571,12 @@ void NativeJSRenderer::runDeveloperConsole(ModuleSettings moduleSettings) // Short-cirtuit: in case consoleLoop was altered by signal handler we shouldn't execute lines below if (!consoleLoop || input == "exit") { delete mConsoleState->consoleContext; - break; + + #ifdef NATIVEJS_L2_BUILD + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + terminate(); + #endif + break; } mConsoleState->inputMutex.lock(); diff --git a/src/jsruntime.cpp b/src/jsruntime.cpp index 0f6390c..2859880 100644 --- a/src/jsruntime.cpp +++ b/src/jsruntime.cpp @@ -140,8 +140,25 @@ int main(int argc, char* argv[]) #if defined(NATIVEJS_DEVELOPER_MODE) std::this_thread::sleep_for(std::chrono::milliseconds(500)); renderer->getApplications(); - sleep(10); - renderer->terminateApplication(id); + + #ifdef NATIVEJS_L2_BUILD + int waitTime = 10; + if (moduleSettings.enableWebSocket || moduleSettings.enableWebSocketEnhanced) { + waitTime = 30; + NativeJSLogger::log(INFO, "WebSocket enabled - using extended wait time: %d seconds\n", waitTime); + } + sleep(waitTime); + #else + sleep(10) ; + #endif + + renderer->terminateApplication(id); + + #ifdef NATIVEJS_L2_BUILD + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + renderer->terminate(); + #endif + #endif }); } From fddbc2110fd35c6a05eb9b802382a47ac6f78d1d Mon Sep 17 00:00:00 2001 From: Vinod Jain <98183059+vjain008@users.noreply.github.com> Date: Tue, 9 Dec 2025 01:52:21 -0600 Subject: [PATCH 2/3] Update src/NativeJSRenderer.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/NativeJSRenderer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NativeJSRenderer.cpp b/src/NativeJSRenderer.cpp index 4657e4b..5a5d740 100644 --- a/src/NativeJSRenderer.cpp +++ b/src/NativeJSRenderer.cpp @@ -573,10 +573,10 @@ void NativeJSRenderer::runDeveloperConsole(ModuleSettings moduleSettings) delete mConsoleState->consoleContext; #ifdef NATIVEJS_L2_BUILD - std::this_thread::sleep_for(std::chrono::milliseconds(200)); - terminate(); - #endif - break; + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + terminate(); + #endif + break; } mConsoleState->inputMutex.lock(); From 896f2dbd6a393d2966dc15eba05041b4e2316e21 Mon Sep 17 00:00:00 2001 From: Vinod Jain <98183059+vjain008@users.noreply.github.com> Date: Tue, 9 Dec 2025 01:52:34 -0600 Subject: [PATCH 3/3] Update src/jsruntime.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/jsruntime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsruntime.cpp b/src/jsruntime.cpp index 2859880..2198a53 100644 --- a/src/jsruntime.cpp +++ b/src/jsruntime.cpp @@ -149,7 +149,7 @@ int main(int argc, char* argv[]) } sleep(waitTime); #else - sleep(10) ; + sleep(10); #endif renderer->terminateApplication(id);