From 80e285a3bc13b14a1bfbbf278881520e62074f2c Mon Sep 17 00:00:00 2001 From: Alex Groce Date: Thu, 3 Jan 2019 14:29:55 -0700 Subject: [PATCH] Change fuzzing status to timestamped speed and failure count --- src/include/deepstate/DeepState.h | 4 ++-- src/include/deepstate/DeepState.hpp | 8 ++++---- src/lib/DeepState.c | 16 +++++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/include/deepstate/DeepState.h b/src/include/deepstate/DeepState.h index cbac2a2..af2ef28 100644 --- a/src/include/deepstate/DeepState.h +++ b/src/include/deepstate/DeepState.h @@ -773,7 +773,7 @@ static int DeepState_RunSingleSavedTestDir(void) { dir_fd = opendir(FLAGS_input_test_files_dir); if (dir_fd == NULL) { DeepState_LogFormat(DeepState_LogInfo, - "No tests to run."); + "No tests to run"); return 0; } @@ -825,7 +825,7 @@ static int DeepState_RunSavedTestCases(void) { /* Start DeepState and run the tests. Returns the number of failed tests. */ static int DeepState_Run(void) { if (!DeepState_OptionsAreInitialized) { - DeepState_Abandon("Please call DeepState_InitOptions(argc, argv) in main."); + DeepState_Abandon("Please call DeepState_InitOptions(argc, argv) in main"); } if (HAS_FLAG_input_test_dir) { diff --git a/src/include/deepstate/DeepState.hpp b/src/include/deepstate/DeepState.hpp index f895550..fc8ae98 100644 --- a/src/include/deepstate/DeepState.hpp +++ b/src/include/deepstate/DeepState.hpp @@ -301,7 +301,7 @@ static T Pump(T val, unsigned max=10) { return val; } if (!max) { - DeepState_Abandon("Must have a positive maximum number of values to pump."); + DeepState_Abandon("Must have a positive maximum number of values to Pump"); } for (auto i = 0U; i < max - 1; ++i) { T min_val = Minimize(val); @@ -341,7 +341,7 @@ inline static void OneOf(FuncTys&&... funcs) { inline static char OneOf(const char *str) { if (!str || !str[0]) { - DeepState_Abandon("NULL or empty string passed to OneOf."); + DeepState_Abandon("NULL or empty string passed to OneOf"); } return str[DeepState_IntInRange(0, strlen(str) - 1)]; } @@ -349,7 +349,7 @@ inline static char OneOf(const char *str) { template inline static const T &OneOf(const std::vector &arr) { if (arr.empty()) { - DeepState_Abandon("Empty vector passed to OneOf."); + DeepState_Abandon("Empty vector passed to OneOf"); } return arr[DeepState_IntInRange(0, arr.size() - 1)]; } @@ -358,7 +358,7 @@ inline static const T &OneOf(const std::vector &arr) { template inline static const T &OneOf(T (&arr)[len]) { if (!len) { - DeepState_Abandon("Empty array passed to OneOf."); + DeepState_Abandon("Empty array passed to OneOf"); } return arr[DeepState_IntInRange(0, len - 1)]; } diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index 0ef3291..81ca6c0 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -90,7 +90,7 @@ void DeepState_AllocCurrentTestRun(void) { mem_vis, 0, 0); if (shared_mem == MAP_FAILED) { - DeepState_Log(DeepState_LogError, "Unable to map shared memory."); + DeepState_Log(DeepState_LogError, "Unable to map shared memory"); exit(1); } @@ -173,11 +173,11 @@ void *DeepState_ConcretizeData(void *begin, void *end) { /* Return a symbolic C string of length `len`. */ char *DeepState_CStr(size_t len) { if (SIZE_MAX == len) { - DeepState_Abandon("Can't create an SIZE_MAX-length string."); + DeepState_Abandon("Can't create an SIZE_MAX-length string"); } char *str = (char *) malloc(sizeof(char) * (len + 1)); if (NULL == str) { - DeepState_Abandon("Can't allocate memory."); + DeepState_Abandon("Can't allocate memory"); } if (len) { DeepState_SymbolizeData(str, &(str[len - 1])); @@ -695,8 +695,10 @@ int DeepState_Fuzz(void){ while (diff < FLAGS_timeout) { i++; if ((diff != last_status) && ((diff % 30) == 0) ) { - DeepState_LogFormat(DeepState_LogInfo, "Ran %u tests in %u seconds (%u tests/second). %d failed tests so far.", - i, diff, i/diff, num_failed_tests); + time_t t = time(NULL); + struct tm tm = *localtime(&t); + DeepState_LogFormat(DeepState_LogInfo, "%d-%02d-%02d %02d:%02d:%02d: %u tests/second / %d failed tests so far", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, i/diff, num_failed_tests); last_status = diff; } num_failed_tests += DeepState_FuzzOneTestCase(test); @@ -705,7 +707,7 @@ int DeepState_Fuzz(void){ diff = current-start; } - DeepState_LogFormat(DeepState_LogInfo, "Done fuzzing! Ran %u tests (%u tests/second). %d failed tests.", + DeepState_LogFormat(DeepState_LogInfo, "Done fuzzing! Ran %u tests (%u tests/second) with %d failed tests", i, i/diff, num_failed_tests); return num_failed_tests; @@ -804,7 +806,7 @@ void __assert_fail(const char * assertion, const char * file, } void __stack_chk_fail(void) { - DeepState_Log(DeepState_LogFatal, "Stack smash detected."); + DeepState_Log(DeepState_LogFatal, "Stack smash detected"); __builtin_unreachable(); }