From 652d6355b2a2a6362cd9979f852ab651273c5814 Mon Sep 17 00:00:00 2001 From: Alex Groce Date: Thu, 3 Jan 2019 11:59:55 -0700 Subject: [PATCH] More silent: nothing about test failures --- bin/deepstate/common.py | 8 +++++++- src/lib/DeepState.c | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/deepstate/common.py b/bin/deepstate/common.py index 9b71f70..bdb3c5e 100644 --- a/bin/deepstate/common.py +++ b/bin/deepstate/common.py @@ -359,21 +359,27 @@ class DeepState(object): test_dir = self.context['test_dir'] test_name = md5.new(input_bytes).hexdigest() + passing = False if self.context['failed']: test_name += ".fail" elif self.context['crashed']: test_name += ".crash" else: test_name += ".pass" + passing = True test_file = os.path.join(test_dir, test_name) - LOGGER.info("Saving input to {}".format(test_file)) try: with open(test_file, "wb") as f: f.write(input_bytes) except: LOGGER.critical("Error saving input to {}".format(test_file)) + if not passing: + LOGGER.info("Saved test case in file {}".format(test_file)) + else: + LOGGER.trace("Saved test case in file {}}".format(test_file)) + def report(self): """Report on the pass/fail status of a test case, and dump its log.""" info = self.context['info'] diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index ecd3b98..3807fd3 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -576,7 +576,7 @@ void makeFilename(char *name, size_t size) { } } -void writeInputData(char* name) { +void writeInputData(char* name, int important) { size_t path_len = 2 + sizeof(char) * (strlen(FLAGS_output_test_dir) + strlen(name)); char *path = (char *) malloc(path_len); snprintf(path, path_len, "%s/%s", FLAGS_output_test_dir, name); @@ -590,7 +590,11 @@ void writeInputData(char* name) { if (written != DeepState_InputSize) { DeepState_LogFormat(DeepState_LogError, "Failed to write to file `%s`", path); } else { - DeepState_LogFormat(DeepState_LogInfo, "Saved test case to file `%s`", path); + if (important) { + DeepState_LogFormat(DeepState_LogInfo, "Saved test case in file `%s`", path); + } else { + DeepState_LogFormat(DeepState_LogTrace, "Saved test case in file `%s`", path); + } } free(path); fclose(fp); @@ -602,7 +606,7 @@ void DeepState_SavePassingTest(void) { makeFilename(name, 40); name[40] = 0; strncat(name, ".pass", 48); - writeInputData(name); + writeInputData(name, 0); } /* Save a failing test to the output test directory. */ @@ -611,7 +615,7 @@ void DeepState_SaveFailingTest(void) { makeFilename(name, 40); name[40] = 0; strncat(name, ".fail", 48); - writeInputData(name); + writeInputData(name, 1); } /* Save a crashing test to the output test directory. */ @@ -620,7 +624,7 @@ void DeepState_SaveCrashingTest(void) { makeFilename(name, 40); name[40] = 0; strncat(name, ".crash", 48); - writeInputData(name); + writeInputData(name, 1); } /* Return the first test case to run. */