Update sdv_packager (#6)

This commit is contained in:
tompzf
2026-03-27 14:12:49 +01:00
committed by GitHub
parent 234be8917f
commit aefefd52f7
717 changed files with 42252 additions and 11334 deletions

View File

@@ -1,3 +1,16 @@
#*******************************************************************************
# Copyright (c) 2025-2026 ZF Friedrichshafen AG
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# Erik Verhoeven - initial API and implementation
#*******************************************************************************
# Define project (multiple EXEs)
project(ModuleControlTests VERSION 1.0 LANGUAGES CXX)

View File

@@ -1,3 +1,16 @@
/********************************************************************************
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Erik Verhoeven - initial API and implementation
********************************************************************************/
#include <gtest/gtest.h>
#include "../../../global/process_watchdog.h"
#include "mock.h"
@@ -7,9 +20,11 @@
#include "../../../sdv_services/core/toml_parser/parser_node_toml.cpp"
#include "../../../sdv_services/core/toml_parser/character_reader_utf_8.cpp"
#include "../../../sdv_services/core/toml_parser/miscellaneous.cpp"
#include "../../../sdv_services/core/toml_parser/code_snippet.cpp"
#include "../../../sdv_services/core/module_control.cpp"
#include "../../../sdv_services/core/module.cpp"
#include "../../../sdv_services/core/app_config.cpp"
#include "../../../sdv_services/core/app_config_file.cpp"
#include "../../../sdv_services/core/installation_manifest.cpp"
#if defined(_WIN32) && defined(_UNICODE)

View File

@@ -1,56 +1,123 @@
/********************************************************************************
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Erik Verhoeven - initial API and implementation
********************************************************************************/
#ifndef MOCK_H
#define MOCK_H
#define DO_NOT_INCLUDE_IN_UNIT_TEST
#include "../../../sdv_services/core/module_control.h"
#include "../../../sdv_services/core/module.h"
#include "../../../sdv_services/core/sdv_core.h"
#include <interfaces/app.h>
#include <support/component_impl.h>
#include "../../../sdv_services/core/installation_manifest.h"
#include "../../../global/exec_dir_helper.h"
#include "../../../sdv_services/core/app_config.h"
class CMock
// Prevent including app_settings.h and app_control.h
#define APP_SETTINGS_H
#define APP_CONTROL_H
#define REPOSITORY_H
#define LOGGER_H
#define LOGER_CONTROL_H
/**
* @brief CAppSettings redefined
*/
class CAppSettings : public sdv::IInterfaceAccess
{
public:
CMock() {}
void DestroyModuleObjects(sdv::core::TModuleID) {}
BEGIN_SDV_INTERFACE_MAP()
END_SDV_INTERFACE_MAP()
// CAppSettings mocked functions
sdv::app::EAppContext GetContextType() const { return sdv::app::EAppContext::standalone; }
bool IsStandaloneApplication() { return true; }
bool IsEssentialApplication() { return false; }
bool IsMainApplication() { return false; }
bool IsIsolatedApplication() { return false; }
bool IsMaintenanceApplication() { return false; }
bool IsExternalApplication() const { return false; }
bool IsConsoleSilent() { return true; }
bool IsConsoleVerbose() { return false; }
uint32_t GetInstanceID() { return 1234u; }
sdv::app::EAppOperationState GetOperationState() const { return sdv::app::EAppOperationState::running; }
std::filesystem::path GetRootDir() const { return GetExecDirectory(); }
std::filesystem::path GetInstallDir() const { return GetExecDirectory(); }
std::filesystem::path FindInstalledModule(const std::filesystem::path&) const { return {}; }
std::optional<CInstallManifest::SComponent> FindInstalledComponent(const std::string&) const { return {}; }
std::string FindInstalledModuleManifest(const std::filesystem::path&) { return {}; }
sdv::core::TObjectID CreateObjectFromModule(sdv::core::TModuleID, const sdv::u8string&, const sdv::u8string&, const sdv::u8string&) { return 0; }
sdv::core::TObjectID CreateObject2(const sdv::u8string&, const sdv::u8string&, const sdv::u8string&) { return 0; }
std::string SaveConfig() { return {}; }
void ResetConfigBaseline() {}
sdv::core::TModuleID Load(const sdv::u8string&) { return 0; }
sdv::core::TModuleID ContextLoad(const std::filesystem::path&, const sdv::u8string&) { return 0; }
bool ContextUnload(sdv::core::TModuleID, bool) { return false; }
bool m_bIsMain = false;
bool m_bIsIsolated = false;
std::vector<std::filesystem::path> GetSystemConfigPaths() const { return {}; }
std::filesystem::path GetUserConfigPath() const { return {}; }
};
inline CMock& GetMock()
/**
* @brief Return the application settings class.
* @return Reference to the application settings.
*/
inline CAppSettings& GetAppSettings()
{
static CMock mock;
return mock;
static CAppSettings app_settings;
return app_settings;
}
#define CRepository CMock
#define CAppControl CMock
#define GetRepository GetMock
#define GetAppControl GetMock
#define GetAppConfig GetMock
#define GetModuleControl GetMock
/**
* @brief CAppControl redefined
*/
class CAppControl : public sdv::IInterfaceAccess
{
public:
BEGIN_SDV_INTERFACE_MAP()
END_SDV_INTERFACE_MAP()
inline std::filesystem::path GetCoreDirectory() { return "../../bin"; }
// CAppControl mocked functions
sdv::app::EAppOperationState GetOperationState() const { return sdv::app::EAppOperationState::running; }
};
/**
* @brief Return the application control.
* @return Reference to the application control.
*/
inline CAppControl& GetAppControl()
{
static CAppControl app_control;
return app_control;
}
class CAppConfigFile;
/**
* @brief CRepository redefined
*/
class CRepository : public sdv::IInterfaceAccess
{
public:
BEGIN_SDV_INTERFACE_MAP()
END_SDV_INTERFACE_MAP()
// CRepository mocked functions
void DestroyModuleObjects(sdv::core::TModuleID /*tModuleID*/) {}
sdv::core::EConfigProcessResult StartFromConfig(const CAppConfigFile&, bool) { return sdv::core::EConfigProcessResult::failed; }
void ResetConfigBaseline() {}
};
/**
* @brief Return the repository.
* @return Reference to the repository.
*/
inline CRepository& GetRepository()
{
static CRepository repository;
return repository;
}
#include "../../../sdv_services/core/module_control.h"
#include "../../../sdv_services/core/module.h"
#include "../../../sdv_services/core/app_settings.h"
#include "../../../sdv_services/core/app_config.h"
//inline std::filesystem::path GetCoreDirectoryMock() { return "../../bin"; }
//#define GetCoreDirectory GetCoreDirectoryMock
#endif // !defined MOCK_H

View File

@@ -1,3 +1,16 @@
/********************************************************************************
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Erik Verhoeven - initial API and implementation
********************************************************************************/
#include <gtest/gtest.h>
#include "mock.h"
#include "../../../global/exec_dir_helper.h"