Просмотр исходного кода

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
Anonymous Maarten 1 месяц назад
Родитель
Сommit
d26fef415e
3 измененных файлов с 12 добавлено и 0 удалено
  1. 5 0
      src/test/SDL_test_common.c
  2. 1 0
      src/test/SDL_test_internal.h
  3. 6 0
      src/test/SDL_test_log.c

+ 5 - 0
src/test/SDL_test_common.c

@@ -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;

+ 1 - 0
src/test/SDL_test_internal.h

@@ -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"

+ 6 - 0
src/test/SDL_test_log.c

@@ -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);