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,41 +1,109 @@
/********************************************************************************
* 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
#include <interfaces/app.h>
#define DO_NOT_INCLUDE_IN_UNIT_TEST
#include "../../../sdv_services/core/app_control.h"
#include "../../../sdv_services/core/sdv_core.h"
#include <support/component_impl.h>
#include "../../../global/exec_dir_helper.h"
#include "../../../sdv_services/core/installation_manifest.h"
class CMock
// Prevent including app_settings.h and app_control.h
#define APP_SETTINGS_H
#define APP_CONTROL_H
#define LOGGER_H
#define LOGGER_CONTROL_H
/**
* @brief CAppSettings redefined
*/
class CAppSettings : public sdv::IInterfaceAccess
{
public:
//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() { return false; }
bool IsExternalApplication() const { return false; }
bool IsConsoleSilent() { return true; }
bool IsConsoleVerbose() { return false; }
uint32_t GetInstanceID() { return 1000u; }
void RequestShutdown() {}
sdv::app::EAppOperationState GetOperationState() const { return sdv::app::EAppOperationState::running; }
std::filesystem::path GetInstallDir() const { return std::filesystem::path(); }
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 {}; }
std::filesystem::path GetRootDir() const { return GetExecDirectory(); }
std::filesystem::path GetInstallDir() const { return GetExecDirectory(); }
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 CAppControl CMock
#define GetAppControl GetMock
#define GetAppConfig GetMock
/**
* @brief CAppControl redefined
*/
class CAppControl : public sdv::IInterfaceAccess
{
public:
BEGIN_SDV_INTERFACE_MAP()
END_SDV_INTERFACE_MAP()
// CAppControl mocked functions
void RequestShutdown() {}
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;
}
/**
* @brief CLoggerControl redefined
*/
class CLoggerControl : public sdv::IInterfaceAccess
{
public:
BEGIN_SDV_INTERFACE_MAP()
END_SDV_INTERFACE_MAP()
};
/**
* @brief Return the logger control.
* @return Reference to the logger control.
*/
inline CLoggerControl& GetLoggerControl()
{
static CLoggerControl logger_control;
return logger_control;
}
#include "../../../sdv_services/core/toml_parser/parser_toml.h"
#include "../../../sdv_services/core/toml_parser/parser_node_toml.h"
@@ -43,7 +111,8 @@ inline CMock& GetMock()
#include "../../../sdv_services/core/repository.h"
#include "../../../sdv_services/core/app_config.h"
inline std::filesystem::path GetCoreDirectory() { return "../../bin"; }
//inline std::filesystem::path GetCoreDirectoryMock() { return "../../bin"; }
//#define GetCoreDirectory GetCoreDirectoryMock
class CHelper
{
@@ -69,5 +138,7 @@ public:
inline CModuleControl& GetModuleControl() { return CHelper::GetModuleControl(); }
inline CRepository& GetRepository() { return CHelper::GetRepository(); }
#define GetModuleControl GetModuleControl
#define GetRepository GetRepository
#endif // !defined MOCK_H