[U-Boot] [PATCH 1/6] test/py: require .config to exist

Stephen Warren swarren at wwwdotorg.org
Wed Nov 18 04:19:59 CET 2015


From: Stephen Warren <swarren at nvidia.com>

If .config doesn't exist, the test will currently throw an exception
because the shell prompt value can't be looked up. It's not obvious how
to resolve this. Fix the code to require that the .config file exist in
the build directory rather than ignoring the issue when it's missing.
Make the error message reference the fact that U-Boot doesn't appear to
be built, and mention how to solve that.

Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
 test/py/conftest.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/test/py/conftest.py b/test/py/conftest.py
index 4b40bdd89a60..da8618ba998c 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -99,15 +99,16 @@ def pytest_configure(config):
             ubconfig.__dict__[k] = v
 
     dot_config = build_dir + "/.config"
-    if os.path.exists(dot_config):
-        with open(dot_config, "rt") as f:
-            ini_str = "[root]\n" + f.read()
-            ini_sio = StringIO.StringIO(ini_str)
-            parser = ConfigParser.RawConfigParser()
-            parser.readfp(ini_sio)
-            ubconfig.buildconfig = dict(parser.items("root"))
-    else:
-        ubconfig.buildconfig = dict()
+    if not os.path.exists(dot_config):
+        raise Exception(".config file does not exist; " +
+            "try passing --build option?")
+
+    with open(dot_config, "rt") as f:
+        ini_str = "[root]\n" + f.read()
+        ini_sio = StringIO.StringIO(ini_str)
+        parser = ConfigParser.RawConfigParser()
+        parser.readfp(ini_sio)
+        ubconfig.buildconfig = dict(parser.items("root"))
 
     ubconfig.test_py_dir = test_py_dir
     ubconfig.source_dir = source_dir
-- 
1.9.1



More information about the U-Boot mailing list