From: Shivani Bhardwaj Date: Thu, 10 Apr 2025 12:16:33 +0000 (+0530) Subject: run.py: add aggressive-cleanup option X-Git-Tag: suricata-7.0.11~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9eb2011f1259857ef61d943cae336c4594189213;p=thirdparty%2Fsuricata-verify.git run.py: add aggressive-cleanup option This option enables one to delete an output dir if the tests are passing. This is useful mostly for QA scenarios where the artifacts are not really needed if all went well for a test. --- diff --git a/run.py b/run.py index 51f9235f2..177341fbc 100755 --- a/run.py +++ b/run.py @@ -1044,7 +1044,13 @@ def run_test(dirpath, args, cwd, suricata_config): count_dict["skipped"] += 1 elif results["success"] > 0: with lock: - count_dict["passed"] += 1 + count_dict["passed"] += 1 + if args.aggressivecleanup: + try: + shutil.rmtree(outdir) + except Exception as err: + print("ERR: Couldn't delete output dir in aggressive cleanup mode") + traceback.print_exc() except UnsatisfiedRequirementError as ue: if not args.quiet: print("===> {}: SKIPPED: {}".format(os.path.basename(dirpath), ue)) @@ -1122,6 +1128,8 @@ def main(): help="Prints debug output for failed tests") parser.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="Only show failures and end summary") + parser.add_argument("--aggressive-cleanup", dest="aggressivecleanup", action="store_true", + help="Clean up output directories of passing tests") parser.add_argument("--no-validation", action="store_true", help="Disable EVE validation") parser.add_argument("patterns", nargs="*", default=[]) if LINUX: