]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
run.py: add aggressive-cleanup option 2437/head
authorShivani Bhardwaj <shivanib134@gmail.com>
Thu, 10 Apr 2025 12:16:33 +0000 (17:46 +0530)
committerShivani Bhardwaj <shivanib134@gmail.com>
Thu, 10 Apr 2025 12:22:39 +0000 (17:52 +0530)
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.

run.py

diff --git a/run.py b/run.py
index 51f9235f22518fe03c2146d98a143d3139ef6715..177341fbc85ad31fb930202b0b83beec8377bf54 100755 (executable)
--- 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: