[Piglit] [PATCH 1/2] framework/programs/run.py: Clear directory before starting

Dylan Baker baker.dylan.c at gmail.com
Mon Feb 1 15:12:38 PST 2016


Currently piglit will run if a directory already exists, or die in a
fire if the results_directory is pointed at a file.

Both are bad, in the fist case if there are already X+Y tests in the
'tests' directory, and the current run only writes X tests, then Y-X
tests from the previous run will be included (which can overwrite tests
depending on the order that they were written).

This clears those out, solving the problem.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/programs/run.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/framework/programs/run.py b/framework/programs/run.py
index 328e0b0..1cc1b4a 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -28,6 +28,7 @@ import os.path as path
 import time
 import ConfigParser
 import ctypes
+import shutil
 
 from framework import core, backends, exceptions, options
 import framework.results
@@ -247,7 +248,14 @@ def run(input_):
     # Change working directory to the root of the piglit directory
     piglit_dir = path.dirname(path.realpath(sys.argv[0]))
     os.chdir(piglit_dir)
-    core.checkDir(args.results_path, False)
+
+    # Clear results directory, completely remove it and recreate it whether
+    # it's a directory or a file.
+    if os.path.isdir(args.results_path):
+        shutil.rmtree(args.results_path)
+    else:
+        os.unlink(args.results_path)
+    os.makedirs(args.results_path)
 
     results = framework.results.TestrunResult()
     backends.set_meta(args.backend, results)
-- 
2.7.0



More information about the Piglit mailing list