summary refs log tree commit diff stats
path: root/tests/image-fuzzer/runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/image-fuzzer/runner.py')
-rwxr-xr-xtests/image-fuzzer/runner.py38
1 files changed, 16 insertions, 22 deletions
diff --git a/tests/image-fuzzer/runner.py b/tests/image-fuzzer/runner.py
index 96a1c11b2f..8de656933e 100755
--- a/tests/image-fuzzer/runner.py
+++ b/tests/image-fuzzer/runner.py
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 import sys
 import os
 import signal
@@ -36,9 +37,8 @@ except ImportError:
     try:
         import simplejson as json
     except ImportError:
-        print >>sys.stderr, \
-            "Warning: Module for JSON processing is not found.\n" \
-            "'--config' and '--command' options are not supported."
+        print("Warning: Module for JSON processing is not found.\n" \
+            "'--config' and '--command' options are not supported.", file=sys.stderr)
 
 # Backing file sizes in MB
 MAX_BACKING_FILE_SIZE = 10
@@ -158,9 +158,8 @@ class TestEnv(object):
         try:
             os.makedirs(self.current_dir)
         except OSError as e:
-            print >>sys.stderr, \
-                "Error: The working directory '%s' cannot be used. Reason: %s"\
-                % (self.work_dir, e[1])
+            print("Error: The working directory '%s' cannot be used. Reason: %s"\
+                % (self.work_dir, e[1]), file=sys.stderr)
             raise TestException
         self.log = open(os.path.join(self.current_dir, "test.log"), "w")
         self.parent_log = open(run_log, "a")
@@ -277,7 +276,7 @@ class TestEnv(object):
 if __name__ == '__main__':
 
     def usage():
-        print """
+        print("""
         Usage: runner.py [OPTION...] TEST_DIR IMG_GENERATOR
 
         Set up test environment in TEST_DIR and run a test in it. A module for
@@ -326,7 +325,7 @@ if __name__ == '__main__':
 
         If '--config' argument is specified, fields not listed in
         the configuration array will not be fuzzed.
-        """
+        """)
 
     def run_test(test_id, seed, work_dir, run_log, cleanup, log_all,
                  command, fuzz_config):
@@ -357,8 +356,7 @@ if __name__ == '__main__':
                                        ['command=', 'help', 'seed=', 'config=',
                                         'keep_passed', 'verbose', 'duration='])
     except getopt.error as e:
-        print >>sys.stderr, \
-            "Error: %s\n\nTry 'runner.py --help' for more information" % e
+        print("Error: %s\n\nTry 'runner.py --help' for more information" % e, file=sys.stderr)
         sys.exit(1)
 
     command = None
@@ -375,9 +373,8 @@ if __name__ == '__main__':
             try:
                 command = json.loads(arg)
             except (TypeError, ValueError, NameError) as e:
-                print >>sys.stderr, \
-                    "Error: JSON array of test commands cannot be loaded.\n" \
-                    "Reason: %s" % e
+                print("Error: JSON array of test commands cannot be loaded.\n" \
+                    "Reason: %s" % e, file=sys.stderr)
                 sys.exit(1)
         elif opt in ('-k', '--keep_passed'):
             cleanup = False
@@ -391,15 +388,13 @@ if __name__ == '__main__':
             try:
                 config = json.loads(arg)
             except (TypeError, ValueError, NameError) as e:
-                print >>sys.stderr, \
-                    "Error: JSON array with the fuzzer configuration cannot" \
-                    " be loaded\nReason: %s" % e
+                print("Error: JSON array with the fuzzer configuration cannot" \
+                    " be loaded\nReason: %s" % e, file=sys.stderr)
                 sys.exit(1)
 
     if not len(args) == 2:
-        print >>sys.stderr, \
-            "Expected two parameters\nTry 'runner.py --help'" \
-            " for more information."
+        print("Expected two parameters\nTry 'runner.py --help'" \
+            " for more information.", file=sys.stderr)
         sys.exit(1)
 
     work_dir = os.path.realpath(args[0])
@@ -415,9 +410,8 @@ if __name__ == '__main__':
     try:
         image_generator = __import__(generator_name)
     except ImportError as e:
-        print >>sys.stderr, \
-            "Error: The image generator '%s' cannot be imported.\n" \
-            "Reason: %s" % (generator_name, e)
+        print("Error: The image generator '%s' cannot be imported.\n" \
+            "Reason: %s" % (generator_name, e), file=sys.stderr)
         sys.exit(1)
 
     # Enable core dumps