SDL_test: add --no-time option to not log times

Combining this new option with a known seed hash allows easy diff-ing between runs
This commit is contained in:
Anonymous Maarten
2026-01-30 19:28:31 +01:00
committed by Anonymous Maarten
parent e8065ad9a0
commit d26fef415e
3 changed files with 12 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ static const char *common_usage[] = {
"[--trackmem]",
"[--randmem]",
"[--no-color]",
"[--no-time]",
"[--info all|video|modes|render|event|event_motion]",
"[--log all|error|system|audio|video|render|input]",
NULL
@@ -159,6 +160,10 @@ static int SDLCALL SDLTest_CommonStateParseCommonArguments(void *data, char **ar
SDLTest_Color = false;
return 1;
}
if (SDL_strcasecmp(argv[index], "--no-time") == 0) {
SDLTest_Time = false;
return 1;
}
if (SDL_strcasecmp(argv[index], "--randmem") == 0) {
/* Already handled in SDLTest_CommonCreateState() */
return 1;

View File

@@ -22,6 +22,7 @@
#define SDL_test_internal_h
extern bool SDLTest_Color;
extern bool SDLTest_Time;
#define COLOR_RAW_RED "\033[0;31m"
#define COLOR_RAW_GREEN "\033[0;32m"

View File

@@ -31,6 +31,8 @@
#include <time.h> /* Needed for localtime() */
bool SDLTest_Time = true;
/* work around compiler warning on older GCCs. */
#if (defined(__GNUC__) && (__GNUC__ <= 2))
static size_t strftime_gcc2_workaround(char *s, size_t max, const char *fmt, const struct tm *tm)
@@ -61,6 +63,10 @@ static const char *SDLTest_TimestampToString(const time_t timestamp)
struct tm *local;
size_t result = 0;
if (!SDLTest_Time) {
return "";
}
SDL_memset(buffer, 0, sizeof(buffer));
copy = timestamp;
local = localtime(&copy);