2022-01-24 19:08:33 +08:00
|
|
|
#include "pika_config_gtest.h"
|
2022-01-03 21:12:05 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2021-11-15 22:52:30 +08:00
|
|
|
#include "dataMemory.h"
|
|
|
|
|
2022-01-03 21:12:05 +08:00
|
|
|
char log_buff[LOG_BUFF_MAX][LOG_SIZE] = {0};
|
|
|
|
uint32_t log_index = 0;
|
|
|
|
|
|
|
|
/* save printf content to log_buff */
|
2022-12-29 18:06:22 +08:00
|
|
|
void pika_platform_printf(char* fmt, ...) {
|
2022-01-03 21:12:05 +08:00
|
|
|
va_list args;
|
|
|
|
for (int i = LOG_BUFF_MAX - 2; i >= 0; i--) {
|
|
|
|
memcpy(log_buff[i + 1], log_buff[i], LOG_SIZE);
|
|
|
|
}
|
2022-01-03 21:51:42 +08:00
|
|
|
va_start(args, fmt);
|
2022-12-24 15:41:54 +08:00
|
|
|
__platform_vsnprintf(log_buff[0], LOG_SIZE - 1, fmt, args);
|
2022-01-03 21:51:42 +08:00
|
|
|
va_end(args);
|
2022-12-24 15:41:54 +08:00
|
|
|
/* putchar */
|
|
|
|
for (int i = 0; i < strlen(log_buff[0]); i++) {
|
|
|
|
__platform_putchar(log_buff[0][i]);
|
|
|
|
}
|
2022-01-03 21:12:05 +08:00
|
|
|
}
|
|
|
|
|
2023-01-14 15:36:16 +00:00
|
|
|
// static volatile uint64_t tick_ms = 0;
|
2023-02-01 00:41:19 +08:00
|
|
|
// int64_t pika_platform_get_tick(void) {
|
2023-01-14 15:36:16 +00:00
|
|
|
// tick_ms += 50;
|
|
|
|
// return tick_ms;
|
|
|
|
// }
|
2023-01-09 20:35:22 +08:00
|
|
|
|
2021-11-17 22:30:52 +08:00
|
|
|
/* quick_malloc is always open */
|
|
|
|
uint8_t __is_quick_malloc(void) {
|
|
|
|
// return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2022-10-26 16:57:29 +08:00
|
|
|
|
|
|
|
void __gtest_hook_default(void) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
typedef void (*hook_func)(void);
|
|
|
|
|
|
|
|
volatile int g_hook_cnt = 0;
|
|
|
|
volatile hook_func g_hook_func = __gtest_hook_default;
|
|
|
|
void __pks_hook_instruct(void) {
|
|
|
|
g_hook_cnt++;
|
|
|
|
g_hook_func();
|
|
|
|
}
|