rusefi-1/unit_tests/global.h

108 lines
2.2 KiB
C++

/*
* @file global.h
*
* Global header file for unit tests
*
* @date Nov 28, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#include <stdio.h>
#include <time.h>
#include "common_headers.h"
typedef uint32_t iomode_t;
typedef uint32_t ioportid_t;
typedef uint32_t ioportmask_t;
#define DL_OUTPUT_BUFFER 200
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 100
// just a stub implementation for unit tests
#define EXPECTED_REMAINING_STACK 1
#define getCurrentRemainingStack() (999999)
// this is needed by all DECLARE_ENGINE_PARAMETER_* usages
#include "engine_configuration_generated_structures.h"
#ifdef __cplusplus
// this is needed by all DECLARE_ENGINE_PARAMETER_* usages
class Engine;
#endif /* __cplusplus */
#ifdef __cplusplus
// todo: include it right here? #include "unit_test_framework.h"
extern "C"
{
#endif /* __cplusplus */
#define CH_FREQUENCY 1000
#define NO_CACHE
typedef int bool_t;
typedef uint32_t systime_t;
void chDbgAssert(int c, char *msg, void *arg);
void print(const char *fmt, ...);
#define TICKS_IN_MS 100
#define chDbgCheck(x, y) chDbgAssert(x, y, NULL)
#ifdef __cplusplus
}
#endif /* __cplusplus */
#define US_TO_NT_MULTIPLIER 100
#define VCS_VERSION "321"
#define RUS_EFI_VERSION_TAG "rusEfiVersion"
#define ALWAYS_INLINE INLINE
#define US2NT(x) (US_TO_NT_MULTIPLIER * (x))
#define NT2US(x) ((x) / US_TO_NT_MULTIPLIER)
#define INLINE inline
#define EFI_ERROR_CODE 0xffffffff
#define CCM_OPTIONAL
#define EXTERN_ENGINE extern EnginePins enginePins; \
extern engine_configuration_s & activeConfiguration
#define EXTERN_CONFIG
#define DEFINE_CONFIG_PARAM(x, y) , x y
#define PASS_CONFIG_PARAM(x) , x
/**
* this macro provides references to engine from EngineTestHelper
*/
#define EXPAND_EngineTestHelper \
Engine *engine = &eth.engine; \
EXPAND_Engine
#define WITH_ENGINE_TEST_HELPER_SENS(x, sensorvals) \
EngineTestHelper eth(x, sensorvals); \
EXPAND_EngineTestHelper;
#define WITH_ENGINE_TEST_HELPER(x) \
EngineTestHelper eth(x, std::unordered_map<SensorType, float>{}); \
EXPAND_EngineTestHelper;
#define CONFIG_PARAM(x) (x)
#define lockAnyContext() false
#define unlockAnyContext() {}
#define UNIT_TEST_BUSY_WAIT_CALLBACK() { timeNowUs++; }