summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2016-07-15 08:06:22 -0400
committerTom Rini <trini@konsulko.com>2016-07-15 08:06:22 -0400
commitebe621d5fb2f5c15aff50e0610372f2751fd152f (patch)
tree12985b43f1a8500332de8e20274cc2dd26f5a040 /test
parent36b898b6bea839de7141b65df6ec02a97615c467 (diff)
parent1269625177f120d659f66b18de4b532b16c44561 (diff)
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'test')
-rw-r--r--test/py/conftest.py2
-rw-r--r--test/py/tests/test_ofplatdata.py42
-rw-r--r--test/py/u_boot_console_base.py12
-rw-r--r--test/py/u_boot_console_sandbox.py6
-rw-r--r--test/py/u_boot_spawn.py13
5 files changed, 72 insertions, 3 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 5b16456e6b..5b3a92316b 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -193,7 +193,7 @@ def pytest_configure(config):
for v in env_vars:
os.environ['U_BOOT_' + v.upper()] = getattr(ubconfig, v)
- if board_type == 'sandbox':
+ if board_type.startswith('sandbox'):
import u_boot_console_sandbox
console = u_boot_console_sandbox.ConsoleSandbox(log, ubconfig)
else:
diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py
new file mode 100644
index 0000000000..c8b309e3d2
--- /dev/null
+++ b/test/py/tests/test_ofplatdata.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2016 Google, Inc
+#
+# SPDX-License-Identifier: GPL-2.0+
+
+import pytest
+
+OF_PLATDATA_OUTPUT = '''
+of-platdata probe:
+bool 1
+byte 05
+bytearray 06 00 00
+int 1
+intarray 2 3 4 0
+longbytearray 09 0a 0b 0c 0d 0e 0f 10 11
+string message
+stringarray "multi-word" "message" ""
+of-platdata probe:
+bool 0
+byte 08
+bytearray 01 23 34
+int 3
+intarray 5 0 0 0
+longbytearray 09 00 00 00 00 00 00 00 00
+string message2
+stringarray "another" "multi-word" "message"
+of-platdata probe:
+bool 0
+byte 00
+bytearray 00 00 00
+int 0
+intarray 0 0 0 0
+longbytearray 00 00 00 00 00 00 00 00 00
+string <NULL>
+stringarray "one" "" ""
+'''
+
+@pytest.mark.buildconfigspec('spl')
+def test_ofplatdata(u_boot_console):
+ """Test that of-platdata can be generated and used in sandbox"""
+ cons = u_boot_console
+ output = cons.get_spawn_output().replace('\r', '')
+ assert OF_PLATDATA_OUTPUT in output
diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index b5aad7cb94..4606ad48bf 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -345,7 +345,7 @@ class ConsoleBase(object):
m = self.p.expect([pattern_u_boot_spl_signon] +
self.bad_patterns)
if m != 0:
- raise Exception('Bad pattern found on console: ' +
+ raise Exception('Bad pattern found on SPL console: ' +
self.bad_pattern_ids[m - 1])
m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns)
if m != 0:
@@ -393,6 +393,16 @@ class ConsoleBase(object):
pass
self.p = None
+ def get_spawn_output(self):
+ """Return the start-up output from U-Boot
+
+ Returns:
+ The output produced by ensure_spawed(), as a string.
+ """
+ if self.p:
+ return self.p.get_expect_output()
+ return None
+
def validate_version_string_in_text(self, text):
"""Assert that a command's output includes the U-Boot signon message.
diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py
index b4404971c4..647e1f879f 100644
--- a/test/py/u_boot_console_sandbox.py
+++ b/test/py/u_boot_console_sandbox.py
@@ -39,11 +39,15 @@ class ConsoleSandbox(ConsoleBase):
A u_boot_spawn.Spawn object that is attached to U-Boot.
"""
+ bcfg = self.config.buildconfig
+ config_spl = bcfg.get('config_spl', 'n') == 'y'
+ fname = '/spl/u-boot-spl' if config_spl else '/u-boot'
+ print fname
cmd = []
if self.config.gdbserver:
cmd += ['gdbserver', self.config.gdbserver]
cmd += [
- self.config.build_dir + '/u-boot',
+ self.config.build_dir + fname,
'-v',
'-d',
self.config.dtb
diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index d15517389e..3a0fbfad90 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -18,6 +18,9 @@ class Timeout(Exception):
class Spawn(object):
"""Represents the stdio of a freshly created sub-process. Commands may be
sent to the process, and responses waited for.
+
+ Members:
+ output: accumulated output from expect()
"""
def __init__(self, args, cwd=None):
@@ -34,6 +37,7 @@ class Spawn(object):
self.waited = False
self.buf = ''
+ self.output = ''
self.logfile_read = None
self.before = ''
self.after = ''
@@ -154,6 +158,7 @@ class Spawn(object):
posafter = earliest_m.end()
self.before = self.buf[:pos]
self.after = self.buf[pos:posafter]
+ self.output += self.buf[:posafter]
self.buf = self.buf[posafter:]
return earliest_pi
tnow_s = time.time()
@@ -198,3 +203,11 @@ class Spawn(object):
if not self.isalive():
break
time.sleep(0.1)
+
+ def get_expect_output(self):
+ """Return the output read by expect()
+
+ Returns:
+ The output processed by expect(), as a string.
+ """
+ return self.output