From b08ec7466aca7de118995d0521483a69947bec22 Mon Sep 17 00:00:00 2001 From: nxtumUbun Date: Thu, 3 Apr 2025 06:26:38 -0700 Subject: [PATCH 1/3] Initial plugin for verifying JSON-RPC names --- TestPlugin/CMakeLists.txt | 66 +++++++++++ TestPlugin/Module.cpp | 22 ++++ TestPlugin/Module.h | 32 ++++++ TestPlugin/TestPlugin.conf.in | 7 ++ TestPlugin/TestPlugin.cpp | 140 ++++++++++++++++++++++ TestPlugin/TestPlugin.h | 147 ++++++++++++++++++++++++ TestPlugin/TestPluginImplementation.cpp | 76 ++++++++++++ TestPlugin/TestPluginPlugin.json | 16 +++ 8 files changed, 506 insertions(+) create mode 100644 TestPlugin/CMakeLists.txt create mode 100644 TestPlugin/Module.cpp create mode 100644 TestPlugin/Module.h create mode 100644 TestPlugin/TestPlugin.conf.in create mode 100644 TestPlugin/TestPlugin.cpp create mode 100644 TestPlugin/TestPlugin.h create mode 100644 TestPlugin/TestPluginImplementation.cpp create mode 100644 TestPlugin/TestPluginPlugin.json diff --git a/TestPlugin/CMakeLists.txt b/TestPlugin/CMakeLists.txt new file mode 100644 index 000000000..db10c777e --- /dev/null +++ b/TestPlugin/CMakeLists.txt @@ -0,0 +1,66 @@ +# If not stated otherwise in this file or this component's license file the +# following copyright and licenses apply: +# +# Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +project(TestPlugin) + +cmake_minimum_required(VERSION 3.15) + +find_package(Thunder) + +project_version(1.0.0) + +set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME}) + +message("Setup ${MODULE_NAME} v${PROJECT_VERSION}") + +set(PLUGIN_TESTPLUGIN_STARTMODE "Activated" CACHE STRING "Automatically start TestPlugin plugin") +set(PLUGIN_TESTPLUGIN_MODE "Local" CACHE STRING "Controls if the plugin should run in its own process, in process, container or remote.") + +if(BUILD_REFERENCE) + add_definitions(-DBUILD_REFERENCE=${BUILD_REFERENCE}) +endif() + +find_package(${NAMESPACE}Plugins REQUIRED) +find_package(${NAMESPACE}Definitions REQUIRED) +find_package(${NAMESPACE}Messaging REQUIRED) +find_package(CompileSettingsDebug CONFIG REQUIRED) + +add_library(${MODULE_NAME} SHARED + TestPlugin.cpp + TestPluginImplementation.cpp + Module.cpp +) + +set_target_properties(${MODULE_NAME} PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED YES) + +target_link_libraries(${MODULE_NAME} + PRIVATE + CompileSettingsDebug::CompileSettingsDebug + ${NAMESPACE}Plugins::${NAMESPACE}Plugins + ${NAMESPACE}Definitions::${NAMESPACE}Definitions + ${NAMESPACE}Messaging::${NAMESPACE}Messaging) + +target_include_directories(${MODULE_NAME} + PRIVATE + $) + +install(TARGETS ${MODULE_NAME} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${STORAGE_DIRECTORY}/plugins COMPONENT ${NAMESPACE}_Runtime) + +write_config() \ No newline at end of file diff --git a/TestPlugin/Module.cpp b/TestPlugin/Module.cpp new file mode 100644 index 000000000..80af52773 --- /dev/null +++ b/TestPlugin/Module.cpp @@ -0,0 +1,22 @@ +/* +* If not stated otherwise in this file or this component's LICENSE file the +* following copyright and licenses apply: +* +* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "Module.h" + +MODULE_NAME_DECLARATION(BUILD_REFERENCE) \ No newline at end of file diff --git a/TestPlugin/Module.h b/TestPlugin/Module.h new file mode 100644 index 000000000..192fd057b --- /dev/null +++ b/TestPlugin/Module.h @@ -0,0 +1,32 @@ +/* +* If not stated otherwise in this file or this component's LICENSE file the +* following copyright and licenses apply: +* +* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#ifndef MODULE_NAME +#define MODULE_NAME Plugin_TestPlugin +#endif + +#include +#include +#include +#include + +#undef EXTERNAL +#define EXTERNAL \ No newline at end of file diff --git a/TestPlugin/TestPlugin.conf.in b/TestPlugin/TestPlugin.conf.in new file mode 100644 index 000000000..a5b7eeb64 --- /dev/null +++ b/TestPlugin/TestPlugin.conf.in @@ -0,0 +1,7 @@ +startmode = "@PLUGIN_TESTPLUGIN_STARTMODE@" + +configuration = JSON() + +root = JSON() +root.add("mode", "@PLUGIN_TESTPLUGIN_MODE@") +configuration.add("root", root) \ No newline at end of file diff --git a/TestPlugin/TestPlugin.cpp b/TestPlugin/TestPlugin.cpp new file mode 100644 index 000000000..b17a4cc14 --- /dev/null +++ b/TestPlugin/TestPlugin.cpp @@ -0,0 +1,140 @@ +/* +* If not stated otherwise in this file or this component's LICENSE file the +* following copyright and licenses apply: +* +* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "TestPlugin.h" + +namespace Thunder { +namespace Plugin { + + namespace { + + static Metadatametadata( + // Version + 1, 0, 0, + // Preconditions + {}, + // Terminations + {}, + // Controls + {} + ); + } + + const string TestPlugin::Initialize(PluginHost::IShell* service) { + string message; + + ASSERT(_service == nullptr); + ASSERT(service != nullptr); + ASSERT(_implTestTextOptions == nullptr); + ASSERT(_implTestLegacy == nullptr); + ASSERT(_implTestKeep == nullptr); + ASSERT(_implTestCustom == nullptr); + ASSERT(_connectionId == 0); + + _service = service; + _service->AddRef(); + _service->Register(&_notification); + + _implTestTextOptions = service->Root(_connectionId, timeout, _T("TestPluginImplementation")); + if (_implTestTextOptions == nullptr) { + message = _T("Couldn't create instance of implTestTextOptions"); + } else { + QualityAssurance::JTestTextOptions::Register(*this, _implTestTextOptions); + _implTestLegacy = _implTestTextOptions->QueryInterface(); + if (_implTestLegacy == nullptr) { + message = _T("Couldn't create instance of _implITestLegacy"); + } else { + QualityAssurance::TestTextOptions::JTestLegacy::Register(*this, _implTestLegacy); + _implTestKeep = _implTestTextOptions->QueryInterface(); + if (_implTestKeep == nullptr) { + message = _T("Couldn't create instance of _implITestKeep"); + } else { + QualityAssurance::TestTextOptions::JTestKeep::Register(*this, _implTestKeep); + _implTestCustom = _implTestTextOptions->QueryInterface(); + if (_implTestCustom == nullptr) { + message = _T("Couldn't create instance of _implITestCustom"); + } else { + QualityAssurance::TestTextOptions::JTestCustom::Register(*this, _implTestCustom); + } + } + } + } + + return (message); + } + + void TestPlugin::Deinitialize(PluginHost::IShell* service) { + + ASSERT(_service == service); + + _service->Unregister(&_notification); + + if (_implTestTextOptions != nullptr) { + QualityAssurance::JTestTextOptions::Unregister(*this); + + if (_implTestLegacy != nullptr) { + QualityAssurance::TestTextOptions::JTestLegacy::Unregister(*this); + _implTestLegacy->Release(); + _implTestLegacy = nullptr; + } + + if (_implTestKeep != nullptr) { + QualityAssurance::TestTextOptions::JTestKeep::Unregister(*this); + _implTestKeep->Release(); + _implTestKeep = nullptr; + } + + if (_implTestCustom != nullptr) { + QualityAssurance::TestTextOptions::JTestCustom::Unregister(*this); + _implTestCustom->Release(); + _implTestCustom = nullptr; + } + + RPC::IRemoteConnection* connection(service->RemoteConnection(_connectionId)); + VARIABLE_IS_NOT_USED uint32_t result = _implTestTextOptions->Release(); + _implTestTextOptions = nullptr; + + ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED); + + // The process can disappear in the meantime... + if (connection != nullptr) { + // But if it did not disappear in the meantime, forcefully terminate it. Shoot to kill + connection->Terminate(); + connection->Release(); + } + } + _service->Release(); + _service = nullptr; + _connectionId = 0; + } + + string TestPlugin::Information() const { + return (string()); + } + + + void TestPlugin::Deactivated(RPC::IRemoteConnection* connection) { + if (connection->Id() == _connectionId) { + ASSERT(_service != nullptr); + Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE)); + } + } + +} // Plugin +} // Thunder \ No newline at end of file diff --git a/TestPlugin/TestPlugin.h b/TestPlugin/TestPlugin.h new file mode 100644 index 000000000..28987c4d3 --- /dev/null +++ b/TestPlugin/TestPlugin.h @@ -0,0 +1,147 @@ +/* +* If not stated otherwise in this file or this component's LICENSE file the +* following copyright and licenses apply: +* +* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "Module.h" +#include +#include +#include +#include +#include + +namespace Thunder { +namespace Plugin { + + class TestPlugin : public PluginHost::IPlugin, public PluginHost::JSONRPC { + public: + TestPlugin(const TestPlugin&) = delete; + TestPlugin& operator=(const TestPlugin&) = delete; + TestPlugin(TestPlugin&&) = delete; + TestPlugin& operator=(TestPlugin&&) = delete; + + TestPlugin() + : PluginHost::IPlugin() + , PluginHost::JSONRPC() + , _service(nullptr) + , _connectionId(0) + , _implTestTextOptions(nullptr) + , _implTestLegacy(nullptr) + , _implTestKeep(nullptr) + , _implTestCustom(nullptr) + , _notification(*this) + { + } + + ~TestPlugin() override = default; + private: + class Notification : public RPC::IRemoteConnection::INotification, + public QualityAssurance::ITestTextOptions::INotification, + public QualityAssurance::ITestTextOptions::ITestLegacy::INotification, + public QualityAssurance::ITestTextOptions::ITestKeep::INotification, + public QualityAssurance::ITestTextOptions::ITestCustom::INotification { + public: + Notification(const Notification&) = delete; + Notification& operator=(const Notification&) = delete; + Notification(Notification&&) = delete; + Notification& operator=(Notification&&) = delete; + Notification() = delete; + + explicit Notification(TestPlugin& parent) + : RPC::IRemoteConnection::INotification() + , QualityAssurance::ITestTextOptions::INotification() + , QualityAssurance::ITestTextOptions::ITestLegacy::INotification() + , QualityAssurance::ITestTextOptions::ITestKeep::INotification() + , QualityAssurance::ITestTextOptions::ITestCustom::INotification() + , _parent(parent) + { + } + + ~Notification() override = default; + + void Activated(RPC::IRemoteConnection*) override + { + } + + void Deactivated(RPC::IRemoteConnection* connection) override + { + _parent.Deactivated(connection); + } + + // TestEvent for ITestTextOptions::INotification + void TestEvent() override { + QualityAssurance::JTestTextOptions::Event::TestEvent(_parent); + } + + // TestEvent for ITestTextOptions::ITestLegacy::INotification + void TestEvent() override { + QualityAssurance::TestTextOptions::JTestLegacy::Event::TestEvent(_parent); + } + + // TestEvent for ITestTextOptions::ITestKeep::INotification + void TestEvent() override { + QualityAssurance::TestTextOptions::JTestKeep::Event::TestEvent(_parent); + } + + // TestEvent for ITestTextOptions::ITestCustom::INotification + void TestEvent() override { + QualityAssurance::TestTextOptions::JTestCustom::Event::TestEvent(_parent); + } + + BEGIN_INTERFACE_MAP(Notification) + INTERFACE_ENTRY(RPC::IRemoteConnection::INotification) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::INotification) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestLegacy::INotification) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestKeep::INotification) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestCustom::INotification) + END_INTERFACE_MAP + private: + TestPlugin& _parent; + }; + public: + // IPlugin Methods + const string Initialize(PluginHost::IShell* service) override; + void Deinitialize(PluginHost::IShell* service) override; + string Information() const override; + + void Deactivated(RPC::IRemoteConnection* connection); + + BEGIN_INTERFACE_MAP(TestPlugin) + INTERFACE_ENTRY(PluginHost::IPlugin) + INTERFACE_ENTRY(PluginHost::IDispatcher) + INTERFACE_AGGREGATE(QualityAssurance::ITestTextOptions, _implTestTextOptions) + INTERFACE_AGGREGATE(QualityAssurance::ITestTextOptions::ITestLegacy, _implTestLegacy) + INTERFACE_AGGREGATE(QualityAssurance::ITestTextOptions::ITestKeep, _implTestKeep) + INTERFACE_AGGREGATE(QualityAssurance::ITestTextOptions::ITestCustom, _implTestCustom) + END_INTERFACE_MAP + + private: + // Timeout (2000ms) may be changed if necassary, however, it must not exceed RPC::CommunicationTimeOut + static constexpr uint32_t timeout = 2000; + + PluginHost::IShell* _service; + uint32_t _connectionId; + QualityAssurance::ITestTextOptions* _implTestTextOptions; + QualityAssurance::ITestTextOptions::ITestLegacy* _implTestLegacy; + QualityAssurance::ITestTextOptions::ITestKeep* _implTestKeep; + QualityAssurance::ITestTextOptions::ITestCustom* _implTestCustom; + Core::SinkType _notification; + }; +} // Plugin +} // Thunder \ No newline at end of file diff --git a/TestPlugin/TestPluginImplementation.cpp b/TestPlugin/TestPluginImplementation.cpp new file mode 100644 index 000000000..bf1c35a0d --- /dev/null +++ b/TestPlugin/TestPluginImplementation.cpp @@ -0,0 +1,76 @@ +/* +* If not stated otherwise in this file or this component's LICENSE file the +* following copyright and licenses apply: +* +* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "Module.h" +#include + +namespace Thunder { +namespace Plugin { + + class TestPluginImplementation : public QualityAssurance::ITestTextOptions, + public QualityAssurance::ITestTextOptions::ITestLegacy, + public QualityAssurance::ITestTextOptions::ITestKeep, + public QualityAssurance::ITestTextOptions::ITestCustom { + public: + TestPluginImplementation(const TestPluginImplementation&) = delete; + TestPluginImplementation& operator=(const TestPluginImplementation&) = delete; + TestPluginImplementation(TestPluginImplementation&&) = delete; + TestPluginImplementation& operator=(TestPluginImplementation&&) = delete; + + TestPluginImplementation() + : QualityAssurance::ITestTextOptions() + , QualityAssurance::ITestTextOptions::ITestLegacy() + , QualityAssurance::ITestTextOptions::ITestKeep() + , QualityAssurance::ITestTextOptions::ITestCustom() + { + } + ~TestPluginImplementation() override = default; + + public: + + BEGIN_INTERFACE_MAP(TestPluginImplementation) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestLegacy) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestKeep) + INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestCustom) + END_INTERFACE_MAP + + // ITestTextOptions methods + Core::hresult TestStandart(const uint32_t firstTestParam, const uint32_t secondTestParam, const ITestTextOptions::TestDetails& thirdTestParam, const ITestTextOptions::EnumTextOptions fourthTestParam) override { + return Core::ERROR_NONE; + } + + // ITestLegacy methods + Core::hresult TestLegacy(const uint32_t firstTestParam, const uint32_t secondTestParam, const ITestLegacy::TestDetails& thirdTestParam, const ITestLegacy::EnumTextOptions fourthTestParam) override { + return Core::ERROR_NONE; + } + + // ITestKeep methods + Core::hresult TestKeeP(const uint32_t firstTestParaM, const uint32_t secondTestParaM, const ITestKeep::TestDetails& thirdTestParaM, const ITestKeep::EnumTextOptions fourthTestParaM) override { + return Core::ERROR_NONE; + } + // ITestCustom methods + Core::hresult TestCustom(const uint32_t firstTestParam, const uint32_t secondTestParam, const ITestCustom::TestDetails& thirdTestParam, const ITestCustom::EnumTextOptions fourthTestParam) override { + return Core::ERROR_NONE; + } + }; + + SERVICE_REGISTRATION(TestPluginImplementation, 1, 0) +} // Plugin +} // Thunder \ No newline at end of file diff --git a/TestPlugin/TestPluginPlugin.json b/TestPlugin/TestPluginPlugin.json new file mode 100644 index 000000000..3b2aa86ef --- /dev/null +++ b/TestPlugin/TestPluginPlugin.json @@ -0,0 +1,16 @@ +{ + "$schema": "plugin.schema.json", + "info": { + "title": "TestPlugin Plugin", + "callsign": "TestPlugin", + "locator": "libThunderTestPlugin.so", + "status": "development", + "description": [ + "" + ], + "version": "1.0" + }, + "interface": { + "$cppref": "{cppinterfacedir}/TestPluginImplementation.h" + } +} \ No newline at end of file From 710c8eebefd03c5997eecd6baa5f375fc3c27e68 Mon Sep 17 00:00:00 2001 From: nxtumUbun Date: Mon, 5 May 2025 01:17:34 -0700 Subject: [PATCH 2/3] JSONRPC text plugin initial --- TestPlugin/TestPlugin.conf.in | 7 - TestPlugin/TestPluginPlugin.json | 16 -- tests/CMakeLists.txt | 4 + .../TestTextOptions}/CMakeLists.txt | 10 +- .../TestTextOptions}/Module.cpp | 0 .../TestTextOptions}/Module.h | 2 +- tests/TestTextOptions/TestTextOptions.conf.in | 7 + .../TestTextOptions/TestTextOptions.cpp | 17 +-- .../TestTextOptions/TestTextOptions.h | 141 +++++++++++------- .../TestTextOptionsImplementation.cpp | 30 ++-- .../TestTextOptionsPlugin.json | 16 ++ 11 files changed, 148 insertions(+), 102 deletions(-) delete mode 100644 TestPlugin/TestPlugin.conf.in delete mode 100644 TestPlugin/TestPluginPlugin.json rename {TestPlugin => tests/TestTextOptions}/CMakeLists.txt (84%) rename {TestPlugin => tests/TestTextOptions}/Module.cpp (100%) rename {TestPlugin => tests/TestTextOptions}/Module.h (95%) create mode 100644 tests/TestTextOptions/TestTextOptions.conf.in rename TestPlugin/TestPlugin.cpp => tests/TestTextOptions/TestTextOptions.cpp (91%) rename TestPlugin/TestPlugin.h => tests/TestTextOptions/TestTextOptions.h (60%) rename TestPlugin/TestPluginImplementation.cpp => tests/TestTextOptions/TestTextOptionsImplementation.cpp (51%) create mode 100644 tests/TestTextOptions/TestTextOptionsPlugin.json diff --git a/TestPlugin/TestPlugin.conf.in b/TestPlugin/TestPlugin.conf.in deleted file mode 100644 index a5b7eeb64..000000000 --- a/TestPlugin/TestPlugin.conf.in +++ /dev/null @@ -1,7 +0,0 @@ -startmode = "@PLUGIN_TESTPLUGIN_STARTMODE@" - -configuration = JSON() - -root = JSON() -root.add("mode", "@PLUGIN_TESTPLUGIN_MODE@") -configuration.add("root", root) \ No newline at end of file diff --git a/TestPlugin/TestPluginPlugin.json b/TestPlugin/TestPluginPlugin.json deleted file mode 100644 index 3b2aa86ef..000000000 --- a/TestPlugin/TestPluginPlugin.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "plugin.schema.json", - "info": { - "title": "TestPlugin Plugin", - "callsign": "TestPlugin", - "locator": "libThunderTestPlugin.so", - "status": "development", - "description": [ - "" - ], - "version": "1.0" - }, - "interface": { - "$cppref": "{cppinterfacedir}/TestPluginImplementation.h" - } -} \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 62269842c..7938690a8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,6 +28,7 @@ option(STORE_TEST "Utility to verify PersistentStore and Dictionary Plugin behav option(TEST_AUTOMATION_TOOLS "Utility to verify Thunder functions trigerred by Automation Test Tools." OFF) option(PLUGIN_TESTCONTROLLER "Include TestController plugin" OFF) option(PLUGIN_TESTUTILITY "Include TestUtility plugin" OFF) +option(PLUGIN_TESTTEXTOPTIONS "Utility to verify the name of JSONRPC functions" OFF) if(STORE_TEST) add_subdirectory(StoreTest) @@ -47,3 +48,6 @@ if(PLUGIN_TESTUTILITY) add_subdirectory(TestUtility) endif() +if(PLUGIN_TESTTEXTOPTIONS) + add_subdirectory(TestTextOptions) +endif() \ No newline at end of file diff --git a/TestPlugin/CMakeLists.txt b/tests/TestTextOptions/CMakeLists.txt similarity index 84% rename from TestPlugin/CMakeLists.txt rename to tests/TestTextOptions/CMakeLists.txt index db10c777e..f53cc0425 100644 --- a/TestPlugin/CMakeLists.txt +++ b/tests/TestTextOptions/CMakeLists.txt @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -project(TestPlugin) +project(TestTextOptions) cmake_minimum_required(VERSION 3.15) @@ -27,8 +27,8 @@ set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME}) message("Setup ${MODULE_NAME} v${PROJECT_VERSION}") -set(PLUGIN_TESTPLUGIN_STARTMODE "Activated" CACHE STRING "Automatically start TestPlugin plugin") -set(PLUGIN_TESTPLUGIN_MODE "Local" CACHE STRING "Controls if the plugin should run in its own process, in process, container or remote.") +set(PLUGIN_TESTTEXTOPTIONS_STARTMODE "Activated" CACHE STRING "Automatically start TestTextOptions plugin") +set(PLUGIN_TESTTEXTOPTIONS_MODE "Local" CACHE STRING "Controls if the plugin should run in its own process, in process, container or remote.") if(BUILD_REFERENCE) add_definitions(-DBUILD_REFERENCE=${BUILD_REFERENCE}) @@ -40,8 +40,8 @@ find_package(${NAMESPACE}Messaging REQUIRED) find_package(CompileSettingsDebug CONFIG REQUIRED) add_library(${MODULE_NAME} SHARED - TestPlugin.cpp - TestPluginImplementation.cpp + TestTextOptions.cpp + TestTextOptionsImplementation.cpp Module.cpp ) diff --git a/TestPlugin/Module.cpp b/tests/TestTextOptions/Module.cpp similarity index 100% rename from TestPlugin/Module.cpp rename to tests/TestTextOptions/Module.cpp diff --git a/TestPlugin/Module.h b/tests/TestTextOptions/Module.h similarity index 95% rename from TestPlugin/Module.h rename to tests/TestTextOptions/Module.h index 192fd057b..20f6376a3 100644 --- a/TestPlugin/Module.h +++ b/tests/TestTextOptions/Module.h @@ -20,7 +20,7 @@ #pragma once #ifndef MODULE_NAME -#define MODULE_NAME Plugin_TestPlugin +#define MODULE_NAME Plugin_TestTextOptions #endif #include diff --git a/tests/TestTextOptions/TestTextOptions.conf.in b/tests/TestTextOptions/TestTextOptions.conf.in new file mode 100644 index 000000000..3bdb0fc7f --- /dev/null +++ b/tests/TestTextOptions/TestTextOptions.conf.in @@ -0,0 +1,7 @@ +startmode = "@PLUGIN_TESTTEXTOPTIONS_STARTMODE@" + +configuration = JSON() + +root = JSON() +root.add("mode", "@PLUGIN_TESTTEXTOPTIONS_MODE@") +configuration.add("root", root) \ No newline at end of file diff --git a/TestPlugin/TestPlugin.cpp b/tests/TestTextOptions/TestTextOptions.cpp similarity index 91% rename from TestPlugin/TestPlugin.cpp rename to tests/TestTextOptions/TestTextOptions.cpp index b17a4cc14..95143ca09 100644 --- a/TestPlugin/TestPlugin.cpp +++ b/tests/TestTextOptions/TestTextOptions.cpp @@ -17,14 +17,14 @@ * limitations under the License. */ -#include "TestPlugin.h" +#include "TestTextOptions.h" namespace Thunder { namespace Plugin { namespace { - static Metadatametadata( + static Metadatametadata( // Version 1, 0, 0, // Preconditions @@ -36,7 +36,7 @@ namespace Plugin { ); } - const string TestPlugin::Initialize(PluginHost::IShell* service) { + const string TestTextOptions::Initialize(PluginHost::IShell* service) { string message; ASSERT(_service == nullptr); @@ -51,7 +51,7 @@ namespace Plugin { _service->AddRef(); _service->Register(&_notification); - _implTestTextOptions = service->Root(_connectionId, timeout, _T("TestPluginImplementation")); + _implTestTextOptions = service->Root(_connectionId, timeout, _T("TestTextOptionsImplementation")); if (_implTestTextOptions == nullptr) { message = _T("Couldn't create instance of implTestTextOptions"); } else { @@ -79,7 +79,7 @@ namespace Plugin { return (message); } - void TestPlugin::Deinitialize(PluginHost::IShell* service) { + void TestTextOptions::Deinitialize(PluginHost::IShell* service) { ASSERT(_service == service); @@ -124,17 +124,16 @@ namespace Plugin { _connectionId = 0; } - string TestPlugin::Information() const { + string TestTextOptions::Information() const { return (string()); } - void TestPlugin::Deactivated(RPC::IRemoteConnection* connection) { + void TestTextOptions::Deactivated(RPC::IRemoteConnection* connection) { if (connection->Id() == _connectionId) { ASSERT(_service != nullptr); Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE)); } - } - + } } // Plugin } // Thunder \ No newline at end of file diff --git a/TestPlugin/TestPlugin.h b/tests/TestTextOptions/TestTextOptions.h similarity index 60% rename from TestPlugin/TestPlugin.h rename to tests/TestTextOptions/TestTextOptions.h index 28987c4d3..403fe8c85 100644 --- a/TestPlugin/TestPlugin.h +++ b/tests/TestTextOptions/TestTextOptions.h @@ -21,22 +21,22 @@ #include "Module.h" #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Thunder { namespace Plugin { - class TestPlugin : public PluginHost::IPlugin, public PluginHost::JSONRPC { + class TestTextOptions : public PluginHost::IPlugin, public PluginHost::JSONRPC { public: - TestPlugin(const TestPlugin&) = delete; - TestPlugin& operator=(const TestPlugin&) = delete; - TestPlugin(TestPlugin&&) = delete; - TestPlugin& operator=(TestPlugin&&) = delete; + TestTextOptions(const TestTextOptions&) = delete; + TestTextOptions& operator=(const TestTextOptions&) = delete; + TestTextOptions(TestTextOptions&&) = delete; + TestTextOptions& operator=(TestTextOptions&&) = delete; - TestPlugin() + TestTextOptions() : PluginHost::IPlugin() , PluginHost::JSONRPC() , _service(nullptr) @@ -49,61 +49,99 @@ namespace Plugin { { } - ~TestPlugin() override = default; + ~TestTextOptions() override = default; private: - class Notification : public RPC::IRemoteConnection::INotification, - public QualityAssurance::ITestTextOptions::INotification, - public QualityAssurance::ITestTextOptions::ITestLegacy::INotification, - public QualityAssurance::ITestTextOptions::ITestKeep::INotification, - public QualityAssurance::ITestTextOptions::ITestCustom::INotification { + class Notification; + + class NotificationTestTextOptions : public QualityAssurance::ITestTextOptions::INotification { + public: + explicit NotificationTestTextOptions(Notification& parent) + : _parent(parent) + { + } + + void TestEvent() override { + QualityAssurance::JTestTextOptions::Event::TestEvent(_parent.Parent()); + } + private: + Notification& _parent; + }; + + class NotificationTestLegacy : public QualityAssurance::ITestTextOptions::ITestLegacy::INotification { + public: + explicit NotificationTestLegacy(Notification& parent) + : _parent(parent) + { + } + + void TestEvent() override { + QualityAssurance::TestTextOptions::JTestLegacy::Event::TestEvent(_parent.Parent()); + } + private: + Notification& _parent; + }; + + class NotificationTestKeep : public QualityAssurance::ITestTextOptions::ITestKeep::INotification { + public: + explicit NotificationTestKeep(Notification& parent) + : _parent(parent) + { + } + + void TestEvent() override { + QualityAssurance::TestTextOptions::JTestKeep::Event::TestEvent(_parent.Parent()); + } + private: + Notification& _parent; + }; + + class NotificationTestCustom : public QualityAssurance::ITestTextOptions::ITestCustom::INotification { + public: + explicit NotificationTestCustom(Notification& parent) + : _parent(parent) + { + } + + void TestEvent() override { + QualityAssurance::TestTextOptions::JTestCustom::Event::TestEvent(_parent.Parent()); + } + private: + Notification& _parent; + }; + + class Notification : public RPC::IRemoteConnection::INotification, + public NotificationTestTextOptions, + public NotificationTestLegacy, + public NotificationTestKeep, + public NotificationTestCustom { public: Notification(const Notification&) = delete; Notification& operator=(const Notification&) = delete; Notification(Notification&&) = delete; Notification& operator=(Notification&&) = delete; Notification() = delete; - - explicit Notification(TestPlugin& parent) + + explicit Notification(TestTextOptions& parent) : RPC::IRemoteConnection::INotification() - , QualityAssurance::ITestTextOptions::INotification() - , QualityAssurance::ITestTextOptions::ITestLegacy::INotification() - , QualityAssurance::ITestTextOptions::ITestKeep::INotification() - , QualityAssurance::ITestTextOptions::ITestCustom::INotification() + , NotificationTestTextOptions(*this) + , NotificationTestLegacy(*this) + , NotificationTestKeep(*this) + , NotificationTestCustom(*this) , _parent(parent) - { + { } - + ~Notification() override = default; - - void Activated(RPC::IRemoteConnection*) override - { - } - - void Deactivated(RPC::IRemoteConnection* connection) override - { - _parent.Deactivated(connection); - } - - // TestEvent for ITestTextOptions::INotification - void TestEvent() override { - QualityAssurance::JTestTextOptions::Event::TestEvent(_parent); - } - // TestEvent for ITestTextOptions::ITestLegacy::INotification - void TestEvent() override { - QualityAssurance::TestTextOptions::JTestLegacy::Event::TestEvent(_parent); + void Activated(RPC::IRemoteConnection*) override {} + void Deactivated(RPC::IRemoteConnection* connection) override { + _parent.Deactivated(connection); } - // TestEvent for ITestTextOptions::ITestKeep::INotification - void TestEvent() override { - QualityAssurance::TestTextOptions::JTestKeep::Event::TestEvent(_parent); + TestTextOptions& Parent() { + return _parent; } - // TestEvent for ITestTextOptions::ITestCustom::INotification - void TestEvent() override { - QualityAssurance::TestTextOptions::JTestCustom::Event::TestEvent(_parent); - } - BEGIN_INTERFACE_MAP(Notification) INTERFACE_ENTRY(RPC::IRemoteConnection::INotification) INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::INotification) @@ -111,8 +149,9 @@ namespace Plugin { INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestKeep::INotification) INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestCustom::INotification) END_INTERFACE_MAP + private: - TestPlugin& _parent; + TestTextOptions& _parent; }; public: // IPlugin Methods @@ -122,7 +161,7 @@ namespace Plugin { void Deactivated(RPC::IRemoteConnection* connection); - BEGIN_INTERFACE_MAP(TestPlugin) + BEGIN_INTERFACE_MAP(TestTextOptions) INTERFACE_ENTRY(PluginHost::IPlugin) INTERFACE_ENTRY(PluginHost::IDispatcher) INTERFACE_AGGREGATE(QualityAssurance::ITestTextOptions, _implTestTextOptions) diff --git a/TestPlugin/TestPluginImplementation.cpp b/tests/TestTextOptions/TestTextOptionsImplementation.cpp similarity index 51% rename from TestPlugin/TestPluginImplementation.cpp rename to tests/TestTextOptions/TestTextOptionsImplementation.cpp index bf1c35a0d..8cb2c1b68 100644 --- a/TestPlugin/TestPluginImplementation.cpp +++ b/tests/TestTextOptions/TestTextOptionsImplementation.cpp @@ -23,28 +23,28 @@ namespace Thunder { namespace Plugin { - class TestPluginImplementation : public QualityAssurance::ITestTextOptions, + class TestTextOptionsImplementation : public QualityAssurance::ITestTextOptions, public QualityAssurance::ITestTextOptions::ITestLegacy, public QualityAssurance::ITestTextOptions::ITestKeep, public QualityAssurance::ITestTextOptions::ITestCustom { public: - TestPluginImplementation(const TestPluginImplementation&) = delete; - TestPluginImplementation& operator=(const TestPluginImplementation&) = delete; - TestPluginImplementation(TestPluginImplementation&&) = delete; - TestPluginImplementation& operator=(TestPluginImplementation&&) = delete; + TestTextOptionsImplementation(const TestTextOptionsImplementation&) = delete; + TestTextOptionsImplementation& operator=(const TestTextOptionsImplementation&) = delete; + TestTextOptionsImplementation(TestTextOptionsImplementation&&) = delete; + TestTextOptionsImplementation& operator=(TestTextOptionsImplementation&&) = delete; - TestPluginImplementation() + TestTextOptionsImplementation() : QualityAssurance::ITestTextOptions() , QualityAssurance::ITestTextOptions::ITestLegacy() , QualityAssurance::ITestTextOptions::ITestKeep() , QualityAssurance::ITestTextOptions::ITestCustom() { } - ~TestPluginImplementation() override = default; + ~TestTextOptionsImplementation() override = default; public: - BEGIN_INTERFACE_MAP(TestPluginImplementation) + BEGIN_INTERFACE_MAP(TestTextOptionsImplementation) INTERFACE_ENTRY(QualityAssurance::ITestTextOptions) INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestLegacy) INTERFACE_ENTRY(QualityAssurance::ITestTextOptions::ITestKeep) @@ -52,25 +52,29 @@ namespace Plugin { END_INTERFACE_MAP // ITestTextOptions methods - Core::hresult TestStandart(const uint32_t firstTestParam, const uint32_t secondTestParam, const ITestTextOptions::TestDetails& thirdTestParam, const ITestTextOptions::EnumTextOptions fourthTestParam) override { + Core::hresult TestStandart(const uint32_t firstTestParam VARIABLE_IS_NOT_USED, const uint32_t secondTestParam VARIABLE_IS_NOT_USED, + const QualityAssurance::ITestTextOptions::TestDetails& thirdTestParam VARIABLE_IS_NOT_USED, const QualityAssurance::ITestTextOptions::EnumTextOptions fourthTestParam VARIABLE_IS_NOT_USED) override { return Core::ERROR_NONE; } // ITestLegacy methods - Core::hresult TestLegacy(const uint32_t firstTestParam, const uint32_t secondTestParam, const ITestLegacy::TestDetails& thirdTestParam, const ITestLegacy::EnumTextOptions fourthTestParam) override { + Core::hresult TestLegacy(const uint32_t firstTestParam VARIABLE_IS_NOT_USED, const uint32_t secondTestParam VARIABLE_IS_NOT_USED, + const QualityAssurance::ITestTextOptions::ITestLegacy::TestDetails& thirdTestParam VARIABLE_IS_NOT_USED, const QualityAssurance::ITestTextOptions::ITestLegacy::EnumTextOptions fourthTestParam VARIABLE_IS_NOT_USED) override { return Core::ERROR_NONE; } // ITestKeep methods - Core::hresult TestKeeP(const uint32_t firstTestParaM, const uint32_t secondTestParaM, const ITestKeep::TestDetails& thirdTestParaM, const ITestKeep::EnumTextOptions fourthTestParaM) override { + Core::hresult TestKeeP(const uint32_t firstTestParaM VARIABLE_IS_NOT_USED, const uint32_t secondTestParaM VARIABLE_IS_NOT_USED, + const QualityAssurance::ITestTextOptions::ITestKeep::TestDetails& thirdTestParaM VARIABLE_IS_NOT_USED, const QualityAssurance::ITestTextOptions::ITestKeep::EnumTextOptions fourthTestParaM VARIABLE_IS_NOT_USED) override { return Core::ERROR_NONE; } // ITestCustom methods - Core::hresult TestCustom(const uint32_t firstTestParam, const uint32_t secondTestParam, const ITestCustom::TestDetails& thirdTestParam, const ITestCustom::EnumTextOptions fourthTestParam) override { + Core::hresult TestCustom(const uint32_t firstTestParam VARIABLE_IS_NOT_USED, const uint32_t secondTestParam VARIABLE_IS_NOT_USED, + const QualityAssurance::ITestTextOptions::ITestCustom::TestDetails& thirdTestParam VARIABLE_IS_NOT_USED, const QualityAssurance::ITestTextOptions::ITestCustom::EnumTextOptions fourthTestParam VARIABLE_IS_NOT_USED) override { return Core::ERROR_NONE; } }; - SERVICE_REGISTRATION(TestPluginImplementation, 1, 0) + SERVICE_REGISTRATION(TestTextOptionsImplementation, 1, 0) } // Plugin } // Thunder \ No newline at end of file diff --git a/tests/TestTextOptions/TestTextOptionsPlugin.json b/tests/TestTextOptions/TestTextOptionsPlugin.json new file mode 100644 index 000000000..3ed3f750d --- /dev/null +++ b/tests/TestTextOptions/TestTextOptionsPlugin.json @@ -0,0 +1,16 @@ +{ + "$schema": "plugin.schema.json", + "info": { + "title": "TestTextOptions Plugin", + "callsign": "TestTextOptions", + "locator": "libThunderTestTextOptions.so", + "status": "development", + "description": [ + "" + ], + "version": "1.0" + }, + "interface": { + "$cppref": "{cppinterfacedir}/TestTextOptionsImplementation.h" + } +} \ No newline at end of file From 77ac46f596501fd789430712c06d28495d88fd49 Mon Sep 17 00:00:00 2001 From: nxtumUbun Date: Mon, 5 May 2025 01:23:28 -0700 Subject: [PATCH 3/3] add metrological as copyright --- tests/TestTextOptions/CMakeLists.txt | 2 +- tests/TestTextOptions/Module.cpp | 2 +- tests/TestTextOptions/Module.h | 2 +- tests/TestTextOptions/TestTextOptions.cpp | 2 +- tests/TestTextOptions/TestTextOptions.h | 2 +- tests/TestTextOptions/TestTextOptionsImplementation.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/TestTextOptions/CMakeLists.txt b/tests/TestTextOptions/CMakeLists.txt index f53cc0425..a39c67166 100644 --- a/tests/TestTextOptions/CMakeLists.txt +++ b/tests/TestTextOptions/CMakeLists.txt @@ -1,7 +1,7 @@ # If not stated otherwise in this file or this component's license file the # following copyright and licenses apply: # -# Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +# Copyright 2025 Metrological # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/TestTextOptions/Module.cpp b/tests/TestTextOptions/Module.cpp index 80af52773..56f802326 100644 --- a/tests/TestTextOptions/Module.cpp +++ b/tests/TestTextOptions/Module.cpp @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * -* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* Copyright 2025 Metrological * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/TestTextOptions/Module.h b/tests/TestTextOptions/Module.h index 20f6376a3..4a4037230 100644 --- a/tests/TestTextOptions/Module.h +++ b/tests/TestTextOptions/Module.h @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * -* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* Copyright 2025 Metrological * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/TestTextOptions/TestTextOptions.cpp b/tests/TestTextOptions/TestTextOptions.cpp index 95143ca09..1055cdefe 100644 --- a/tests/TestTextOptions/TestTextOptions.cpp +++ b/tests/TestTextOptions/TestTextOptions.cpp @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * -* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* Copyright 2025 Metrological * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/TestTextOptions/TestTextOptions.h b/tests/TestTextOptions/TestTextOptions.h index 403fe8c85..37a1d7b87 100644 --- a/tests/TestTextOptions/TestTextOptions.h +++ b/tests/TestTextOptions/TestTextOptions.h @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * -* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* Copyright 2025 Metrological * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/TestTextOptions/TestTextOptionsImplementation.cpp b/tests/TestTextOptions/TestTextOptionsImplementation.cpp index 8cb2c1b68..acfa7547e 100644 --- a/tests/TestTextOptions/TestTextOptionsImplementation.cpp +++ b/tests/TestTextOptions/TestTextOptionsImplementation.cpp @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * -* Copyright 2025 [PLEASE ADD COPYRIGHT NAME!] +* Copyright 2025 Metrological * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.