diff mbox

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

Message ID 1447816804-6312-2-git-send-email-swarren@wwwdotorg.org
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Stephen Warren Nov. 18, 2015, 3:19 a.m. UTC
From: Stephen Warren <swarren@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@nvidia.com>
---
 test/py/conftest.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Tom Rini Nov. 23, 2015, 11:44 p.m. UTC | #1
On Tue, Nov 17, 2015 at 08:19:59PM -0700, Stephen Warren wrote:

> From: Stephen Warren <swarren@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@nvidia.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
diff mbox

Patch

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