[Piglit] [PATCH 04/19] results.py: Make fsync a keyword argument

Dylan Baker baker.dylan.c at gmail.com
Thu Aug 28 15:35:32 PDT 2014


Since fsync is not relevant to all backends, changing it to file_fsync
makes it fit better into the Backend API

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/programs/run.py        | 6 ++++--
 framework/results.py             | 4 ++--
 framework/tests/results_tests.py | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/framework/programs/run.py b/framework/programs/run.py
index 3efd5bf..dbcc2c6 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -211,7 +211,9 @@ def run(input_):
     # Begin json.
     result_filepath = path.join(args.results_path, 'results.json')
     result_file = open(result_filepath, 'w')
-    json_writer = framework.results.JSONWriter(result_file, opts.sync)
+    json_writer = framework.results.JSONWriter(
+        result_file,
+        file_fsync=opts.sync)
 
     # Create a dictionary to pass to initialize json, it needs the contents of
     # the env dictionary and profile and platform information
@@ -270,7 +272,7 @@ def resume(input_):
 
     results_path = path.join(args.results_path, 'results.json')
     json_writer = framework.results.JSONWriter(open(results_path, 'w+'),
-                                               opts.sync)
+                                               file_fsync=opts.sync)
     results.options['env'] = core.collect_system_info()
     json_writer.initialize_json(results.options)
 
diff --git a/framework/results.py b/framework/results.py
index 724faf2..5e1f06d 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -176,9 +176,9 @@ class JSONWriter(object):
 
     INDENT = 4
 
-    def __init__(self, f, fsync):
+    def __init__(self, f, file_fsync=False):
         self.file = f
-        self.fsync = fsync
+        self.fsync = file_fsync
         self.__indent_level = 0
         self.__inhibit_next_indent = False
         self.__encoder = json.JSONEncoder(indent=self.INDENT,
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py
index 54661cc..95e76db 100644
--- a/framework/tests/results_tests.py
+++ b/framework/tests/results_tests.py
@@ -63,7 +63,7 @@ def test_initialize_jsonwriter():
 
     """
     with tempfile.TemporaryFile() as tfile:
-        func = results.JSONWriter(tfile, False)
+        func = results.JSONWriter(tfile, file_fsync=False)
         assert isinstance(func, results.JSONWriter)
 
 
-- 
2.1.0



More information about the Piglit mailing list