lib: uuid: alignment error in gen_rand_uuid()
[oweals/u-boot.git] / test / py / conftest.py
index 83eaca46a908dcf83de55cd20678114ec6f805a6..00d8ef8ba99ce76ce4a48df0d81773ef10237892 100644 (file)
@@ -1,7 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2015 Stephen Warren
 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
-#
-# SPDX-License-Identifier: GPL-2.0
 
 # Implementation of pytest run-time hook functions. These are invoked by
 # pytest at certain points during operation, e.g. startup, for each executed
@@ -19,11 +18,15 @@ import os
 import os.path
 import pytest
 from _pytest.runner import runtestprotocol
-import ConfigParser
 import re
 import StringIO
 import sys
 
+try:
+    import configparser
+except:
+    import ConfigParser as configparser
+
 # Globals: The HTML log file, and the connection to the U-Boot console.
 log = None
 console = None
@@ -114,8 +117,8 @@ def pytest_configure(config):
     mkdir_p(persistent_data_dir)
 
     gdbserver = config.getoption('gdbserver')
-    if gdbserver and board_type != 'sandbox':
-        raise Exception('--gdbserver only supported with sandbox')
+    if gdbserver and not board_type.startswith('sandbox'):
+        raise Exception('--gdbserver only supported with sandbox targets')
 
     import multiplexed_log
     log = multiplexed_log.Logfile(result_dir + '/test-log.html')
@@ -167,7 +170,7 @@ def pytest_configure(config):
         with open(dot_config, 'rt') as f:
             ini_str = '[root]\n' + f.read()
             ini_sio = StringIO.StringIO(ini_str)
-            parser = ConfigParser.RawConfigParser()
+            parser = configparser.RawConfigParser()
             parser.readfp(ini_sio)
             ubconfig.buildconfig.update(parser.items('root'))
 
@@ -457,11 +460,15 @@ def setup_buildconfigspec(item):
     """
 
     mark = item.get_marker('buildconfigspec')
-    if not mark:
-        return
-    for option in mark.args:
-        if not ubconfig.buildconfig.get('config_' + option.lower(), None):
-            pytest.skip('.config feature "%s" not enabled' % option.lower())
+    if mark:
+        for option in mark.args:
+            if not ubconfig.buildconfig.get('config_' + option.lower(), None):
+                pytest.skip('.config feature "%s" not enabled' % option.lower())
+    notmark = item.get_marker('notbuildconfigspec')
+    if notmark:
+        for option in notmark.args:
+            if ubconfig.buildconfig.get('config_' + option.lower(), None):
+                pytest.skip('.config feature "%s" enabled' % option.lower())
 
 def tool_is_in_path(tool):
     for path in os.environ["PATH"].split(os.pathsep):
@@ -587,7 +594,7 @@ def pytest_runtest_protocol(item, nextitem):
         # is fixed, if this exception still exists, it will then be logged as
         # part of the test's stdout.
         import traceback
-        print 'Exception occurred while logging runtest status:'
+        print('Exception occurred while logging runtest status:')
         traceback.print_exc()
         # FIXME: Can we force a test failure here?