Improve testing framework

Replaced Criterrion with CMock. Added few tests, currently not working
properly. Random test upgrades.
This commit is contained in:
Piotr Krygier committed 2025-06-20 13:44:33 +02:00
1 parent 56c0b7922f
commit f5ab5f3f27
29 files changed
+140082 -310

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
add_library(rse_utilities SHARED)
target_include_directories(rse_utilities PRIVATE
+2 -6
View File
@@ -12,16 +12,11 @@
#ifndef RSE_LOGGER_H
#define RSE_LOGGER_H
#ifndef LOG_LEVEL
#define LOG_LEVEL LOGLEVEL_DEBUG
#endif
#include <stdio.h>
#include <string.h>
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define LOGGER(log_level, ...) _log_log(log_level, __FILENAME__, __LINE__, __VA_ARGS__)
// #define LOGGER(log_level, ...) printf("[##log_level] %s:%d", __FILE__, __LINE__); printf(__VA_ARGS__)
#define LOGT(...) LOGGER(LOGLEVEL_TRACE, __VA_ARGS__)
#define LOGD(...) LOGGER(LOGLEVEL_DEBUG, __VA_ARGS__)
@@ -41,7 +36,8 @@ enum log_level_t
LOGLEVEL_INFO,
LOGLEVEL_WARNING,
LOGLEVEL_ERROR,
LOGLEVEL_FATAL
LOGLEVEL_FATAL,
LOGLEVEL_NONE
};
void _log_log(unsigned int level, const char* file, int line, const char* fmt, ...);
+12 -2
View File
@@ -19,13 +19,23 @@
* @brief Macro for allocating memory and checking it on the same line
*
*/
#ifndef RSE_TEST
#define rse_malloc(ptr, size) \
ptr = malloc(size); \
if (ptr == NULL) { \
LOGF(common_messages[COMMON_ERROR_MEMORY_ALLOCATION_FAILED]); \
return RSE_COMMON_ERROR_MALLLOC_FAILED; \
LOGF(common_messages[COMMON_ERROR_MEMORY_ALLOCATION_FAILED]); \
exit(1); \
}
#define rse_free(ptr) free(ptr);
#define rse_memcpy(dst, src, size) memcpy(dst, src, size);
#else
#define rse_malloc(ptr, size) ptr = NULL;
#define rse_free(ptr)
#define rse_memcpy(dst, src, size)
#endif
/**
* @brief Error type for RSE
*
+9
View File
@@ -5,10 +5,19 @@ const char* log_levels[] = {
"[TRACE]", "[DEBUG]", "[INFO]", "WARNING", "[ERROR]", "[FATAL]"
};
#ifndef LOGLEVEL
#define LOGLEVEL LOGLEVEL_DEBUG
#endif
void _log_log(unsigned int level, const char* file, int line, const char* fmt, ...)
{
va_list list;
if (level < LOGLEVEL)
{
return;
}
va_start(list, fmt);
fprintf(stdout, "%s %s:%d: ", log_levels[level], file, line);
vfprintf(stdout, fmt, list);