rusefi/unit_tests/global.h

78 lines
1.5 KiB
C
Raw Permalink Normal View History

2015-07-10 06:01:56 -07:00
/*
2019-01-03 15:29:38 -08:00
* @file global.h
2015-07-10 06:01:56 -07:00
*
2018-09-16 17:12:25 -07:00
* Global header file for unit tests
*
2015-07-10 06:01:56 -07:00
* @date Nov 28, 2013
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
2019-11-19 22:35:08 -08:00
#pragma once
2015-07-10 06:01:56 -07:00
2018-09-16 19:00:14 -07:00
#include <stdio.h>
2018-09-16 20:10:06 -07:00
#include <time.h>
2018-09-16 19:00:14 -07:00
2018-09-16 20:10:06 -07:00
#include "common_headers.h"
2024-04-30 13:05:13 -07:00
#include "test_executor.h"
2018-09-16 19:00:14 -07:00
2024-01-07 09:49:32 -08:00
#define EFU_UNIT_TESTS fail("typo please EFU_UNIT_TEST");
2019-09-19 18:55:27 -07:00
typedef uint32_t iomode_t;
typedef uint32_t ioportid_t;
typedef uint32_t ioportmask_t;
#define DL_OUTPUT_BUFFER 200
// just a stub implementation for unit tests
2019-02-23 09:33:49 -08:00
#define getCurrentRemainingStack() (999999)
2021-12-24 13:51:31 -08:00
#define EXPECT_NEAR_M3(x, y) EXPECT_NEAR((x), (y), 1e-3)
#define EXPECT_NEAR_M4(a, b) EXPECT_NEAR(a, b, 1e-4)
2019-01-20 20:44:05 -08:00
2018-09-16 19:00:14 -07:00
#ifdef __cplusplus
#include "mock-threads.h"
2018-12-08 15:11:28 -08:00
// todo: include it right here? #include "unit_test_framework.h"
2018-09-16 19:00:14 -07:00
extern "C"
{
2018-12-08 11:32:45 -08:00
#endif /* __cplusplus */
2018-09-16 19:00:14 -07:00
#define CH_FREQUENCY 1000
2020-04-13 10:12:55 -07:00
#define NO_CACHE
2018-09-16 19:00:14 -07:00
typedef int bool_t;
typedef uint32_t systime_t;
void chDbgAssert(int c, char *msg, void *arg);
#define TICKS_IN_MS 100
#define chDbgCheck(x, y) chDbgAssert(x, y, NULL)
#ifdef __cplusplus
}
2018-12-08 11:32:45 -08:00
#endif /* __cplusplus */
2018-09-16 19:00:14 -07:00
2019-01-11 16:08:15 -08:00
#define VCS_VERSION "321"
#define RUS_EFI_VERSION_TAG "rusEfiVersion"
2015-07-10 06:01:56 -07:00
#define EFI_ERROR_CODE 0xffffffff
#define CCM_OPTIONAL
2021-12-03 22:01:37 -08:00
#define chSysLock() {}
#define chSysUnlock() {}
#define osalThreadDequeueNextI(x, y) {}
#ifdef __cplusplus
namespace chibios_rt {
// Noop for unit tests - this does real lock in FW/sim
class CriticalSectionLocker { };
}
#endif
#define UNIT_TEST_BUSY_WAIT_CALLBACK() { advanceTimeUs(1); }
#define chsnprintf snprintf
#define chvsnprintf vsnprintf