test: Fix up some missed review comments
cover test: Fix up some missed review comments
The vboot test conversion was applied quickly as it fixed a test breakage. I did not get time to go through the review comments. This series addresses most of those.
A few things have not changed:
- I've kept the trailing '/' on the end of tmpdir as it feels pretty natural to me
- I haven't used ubconfig.persistent_data_dir as the files are small and most must be regenerated each time
- Anything else I missed
Simon Glass (9):
Makefile: Allow 'make tests' to run tests
test: Fix typos and tidy up
test: Check exit status in run_and_log_expect_exception()
test: Fix typos in comments
test: Drop the cmd() function
test: Rename sha to sha_algo and pass it around
test: vboot: Put each test variant in its own section
test: Add a function to restart U-Boot
test: Adjust run_command_list() to return a list of strings
Makefile | 5 +- test/README | 8 +-- test/py/multiplexed_log.py | 2 + test/py/tests/test_vboot.py | 108 ++++++++++++++++++++++------------------- test/py/u_boot_console_base.py | 14 ++++-- test/py/u_boot_utils.py | 27 ++++------- 6 files changed, 88 insertions(+), 76 deletions(-)
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 1/9 Makefile: Allow 'make tests' to run tests
Add this shortcut for running tests. Unfortunately 'make test' cannot be used as it is an existing directory.
---
Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +4 -1
@@ -425,7 +425,7 @@ timestamp_h := include/generated/timestamp_autogenerated.h no-dot-config-targets := clean clobber mrproper distclean \ help %docs check% coccicheck \ - ubootversion backup + ubootversion backup tests config-targets := 0 mixed-targets := 0
@@ -1489,6 +1489,7 @@ help: @echo '' @echo 'Other generic targets:' @echo ' all - Build all necessary images depending on configuration' + @echo ' tests - Build U-Boot for sandbox and run tests' @echo '* u-boot - Build the bare u-boot' @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[oisS] - Build specified target only'
@@ -1521,6 +1522,8 @@ help: @echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'For further info see the ./README file' +tests: + $(srctree)/test/run # Documentation targets # ---------------------------------------------------------------------------
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 1/9 Makefile: Allow 'make tests' to run tests
Quoted 5 lines · Simon Glass
Add this shortcut for running tests. Unfortunately 'make test' cannot be used as it is an existing directory.
Signed-off-by Simon Glass <[email protected]>Suggested-by Teddy Reed <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/ee423517/attachment.sig>
PATCH 2/9 test: Fix typos and tidy up
In reply to Simon GlassFix review comments that were missed at the time. Also explain why we need to regenerate the device tree for each test.
---
test/README | 8 ++++---- test/py/tests/test_vboot.py | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-)
test/README +4 -4
@@ -13,7 +13,7 @@ To run most tests on sandbox, type this: test/run in the U-Boot directory. Note that only the pytest suite is run using this -comment. +command. Sandbox
@@ -29,7 +29,7 @@ Pytest Suite Many tests are available using the pytest suite, in test/py. This can run either on sandbox or on real hardware. It relies on the U-Boot console to inject test commands and check the result. It is slower to run than C code, -but provides the ability to unify lots of test and summarise their results. +but provides the ability to unify lots of tests and summarise their results. You can run the tests on sandbox with:
@@ -55,11 +55,11 @@ Ad-hoc tests There are several ad-hoc tests which run outside the pytest environment: test/fs - File system test (shell script) - test/image - FIT and lagacy image tests (shell script and Python) + test/image - FIT and legacy image tests (shell script and Python) test/stdint - A test that stdint.h can be used in U-Boot (shell script) trace - Test for the tracing feature (shell script) -The above should be converted to run as part of the pytest suite. +TODO: Move these into pytest. When to write tests
test/py/tests/test_vboot.py +4 -2
@@ -106,7 +106,9 @@ def test_vboot(u_boot_console): algo = sha - # Compile our device tree files for kernel and U-Boot + # Compile our device tree files for kernel and U-Boot. These are + # regenerated here since mkimage will modify them (by adding a + # public key) below. dtc('sandbox-kernel.dts') dtc('sandbox-u-boot.dts')
@@ -139,7 +141,7 @@ def test_vboot(u_boot_console): sig = util.cmd(cons, 'fdtget -t bx %s %s value' % (fit, sig_node)) byte_list = sig.split() byte = int(byte_list[0], 16) - byte_list = ['%x' % (byte + 1)] + byte_list[1:] + byte_list[0] = '%x' % (byte + 1) sig = ' '.join(byte_list) util.cmd(cons, 'fdtput -t bx %s %s value %s' % (fit, sig_node, sig))
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 2/9 test: Fix typos and tidy up
Quoted 7 lines · Simon Glass
Fix review comments that were missed at the time. Also explain why we need to regenerate the device tree for each test.
Reported-by Teddy Reed <[email protected]>Suggested-by Stephen Warren <[email protected]>Signed-off-by Simon Glass <[email protected]>Fixes f6349c3c (test: Add a README)
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/d336c892/attachment.sig>
PATCH 3/9 test: Check exit status in run_and_log_expect_exception()
In reply to Simon GlassThis check was missed. Add it and make the message more verbose.
---
test/py/multiplexed_log.py | 2 ++ test/py/u_boot_utils.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
test/py/multiplexed_log.py +2 -0
@@ -102,6 +102,7 @@ class RunAndLog(object): self.name = name self.chained_file = chained_file self.output = None + self.exit_status = None def close(self): """Clean up any resources managed by this object."""
@@ -166,6 +167,7 @@ class RunAndLog(object): # Store the output so it can be accessed if we raise an exception. self.output = output + self.exit_status = exit_status if exception: raise exception return output
test/py/u_boot_utils.py +3 -1
@@ -201,9 +201,11 @@ def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) runner.run(cmd) except Exception as e: + assert(retcode == runner.exit_status) assert(msg in runner.output) else: - raise Exception('Expected exception, but not raised') + raise Exception("Expected an exception with retcode %d message '%s'," + "but it was not raised" % (retcode, msg)) finally: runner.close()
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 3/9 test: Check exit status in run_and_log_expect_exception()
Quoted 5 lines · Simon Glass
This check was missed. Add it and make the message more verbose.
Signed-off-by Simon Glass <[email protected]>Reported-by Tom Rini <[email protected]>Fixes 9e17b034 (test/py: Provide a way to check that a command fails)
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/39c211f8/attachment.sig>
PATCH 4/9 test: Fix typos in comments
In reply to Simon GlassFix some typos in various files introduced with the vboot test conversion.
---
test/py/tests/test_vboot.py | 12 ++++++------ test/py/u_boot_console_base.py | 4 ++-- test/py/u_boot_utils.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-)
test/py/tests/test_vboot.py +6 -6
@@ -1,4 +1,4 @@ -# Copyright (c) 2013, Google Inc. +# Copyright (c) 2016, Google Inc. # # SPDX-License-Identifier: GPL-2.0+ #
@@ -16,7 +16,7 @@ For image verification: For configuration verification: - Corrupt signature and check for failure - Create FIT (with unsigned configuration) with mkimage -- Check that image veriication works +- Check that image verification works - Sign the FIT and mark the key as 'required' for verification - Check that image verification works - Corrupt the signature
@@ -41,7 +41,7 @@ def test_vboot(u_boot_console): key-generation process is quite slow and we want to avoid doing it twice. """ def dtc(dts): - """Run the device-tree compiler to compile a .dts file + """Run the device tree compiler to compile a .dts file The output file will be the same as the input file but with a .dtb extension.
@@ -73,12 +73,12 @@ def test_vboot(u_boot_console): assert(expect_string in output) def make_fit(its): - """Make a new FIT from the .its source file + """Make a new FIT from the .its source file. This runs 'mkimage -f' to create a new FIT. Args: - its: Filename containing .its source + its: Filename containing .its source. """ util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', '%s%s' % (datadir, its), fit])
@@ -94,7 +94,7 @@ def test_vboot(u_boot_console): '-r', fit]) def test_with_algo(sha): - """Test verified boot with the given hash algorithm + """Test verified boot with the given hash algorithm. This is the main part of the test code. The same procedure is followed for both hashing algorithms.
test/py/u_boot_console_base.py +2 -2
@@ -223,9 +223,9 @@ class ConsoleBase(object): for each command in a list. Args: - cmd: List of commands (each a string) + cmd: List of commands (each a string). Returns: - Combined output of all commands, as a string + Combined output of all commands, as a string. """ output = '' for cmd in cmds:
test/py/u_boot_utils.py +2 -2
@@ -186,7 +186,7 @@ def cmd(u_boot_console, cmd_str): return run_and_log(u_boot_console, cmd_str.split()) def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): - """Run a command which is expected to fail. + """Run a command that is expected to fail. This runs a command and checks that it fails with the expected return code and exception method. If not, an exception is raised.
@@ -195,7 +195,7 @@ def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): u_boot_console: A console connection to U-Boot. cmd: The command to run, as an array of argv[]. retcode: Expected non-zero return code from the command. - msg: String which should be contained within the command's output. + msg: String that should be contained within the command's output. """ try: runner = u_boot_console.log.get_runner(cmd[0], sys.stdout)
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 4/9 test: Fix typos in comments
Quoted 5 lines · Simon Glass
Fix some typos in various files introduced with the vboot test conversion.
Reported-by Teddy Reed <[email protected]>Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/48a04205/attachment.sig>
PATCH 5/9 test: Drop the cmd() function
In reply to Simon GlassInstead of this, use the existing run_and_log() function, enhanced to support a command string as well as a list of arguments.
---
test/py/tests/test_vboot.py | 22 ++++++++++++---------- test/py/u_boot_utils.py | 19 +++++-------------- 2 files changed, 17 insertions(+), 24 deletions(-)
test/py/tests/test_vboot.py +12 -10
@@ -50,8 +50,8 @@ def test_vboot(u_boot_console): dts: Device tree file to compile. """ dtb = dts.replace('.dts', '.dtb') - util.cmd(cons, 'dtc %s %s%s -O dtb ' - '-o %s%s' % (dtc_args, datadir, dts, tmpdir, dtb)) + util.run_and_log(cons, 'dtc %s %s%s -O dtb ' + '-o %s%s' % (dtc_args, datadir, dts, tmpdir, dtb)) def run_bootm(test_type, expect_string): """Run a 'bootm' command U-Boot.
@@ -138,12 +138,14 @@ def test_vboot(u_boot_console): '-k', dtb]) # Increment the first byte of the signature, which should cause failure - sig = util.cmd(cons, 'fdtget -t bx %s %s value' % (fit, sig_node)) + sig = util.run_and_log(cons, 'fdtget -t bx %s %s value' % + (fit, sig_node)) byte_list = sig.split() byte = int(byte_list[0], 16) byte_list[0] = '%x' % (byte + 1) sig = ' '.join(byte_list) - util.cmd(cons, 'fdtput -t bx %s %s value %s' % (fit, sig_node, sig)) + util.run_and_log(cons, 'fdtput -t bx %s %s value %s' % + (fit, sig_node, sig)) run_bootm('Signed config with bad hash', 'Bad Data Hash')
@@ -164,14 +166,14 @@ def test_vboot(u_boot_console): # Create an RSA key pair public_exponent = 65537 - util.cmd(cons, 'openssl genpkey -algorithm RSA -out %sdev.key ' - '-pkeyopt rsa_keygen_bits:2048 ' - '-pkeyopt rsa_keygen_pubexp:%d ' - '2>/dev/null' % (tmpdir, public_exponent)) + util.run_and_log(cons, 'openssl genpkey -algorithm RSA -out %sdev.key ' + '-pkeyopt rsa_keygen_bits:2048 ' + '-pkeyopt rsa_keygen_pubexp:%d ' + '2>/dev/null' % (tmpdir, public_exponent)) # Create a certificate containing the public key - util.cmd(cons, 'openssl req -batch -new -x509 -key %sdev.key -out ' - '%sdev.crt' % (tmpdir, tmpdir)) + util.run_and_log(cons, 'openssl req -batch -new -x509 -key %sdev.key -out ' + '%sdev.crt' % (tmpdir, tmpdir)) # Create a number kernel image with zeroes with open('%stest-kernel.bin' % tmpdir, 'w') as fd:
test/py/u_boot_utils.py +5 -14
@@ -158,7 +158,9 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False): Args: u_boot_console: A console connection to U-Boot. - cmd: The command to run, as an array of argv[]. + cmd: The command to run, as an array of argv[], or a string. + If a string, note that it is split up so that quoted spaces + will not be preserved. E.g. "fred and" becomes ['"fred', 'and"'] ignore_errors: Indicate whether to ignore errors. If True, the function will simply return if the command cannot be executed or exits with an error code, otherwise an exception will be raised if such
@@ -167,24 +169,13 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False): Returns: The output as a string. """ - + if isinstance(cmd, str): + cmd = cmd.split() runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) output = runner.run(cmd, ignore_errors=ignore_errors) runner.close() return output -def cmd(u_boot_console, cmd_str): - """Run a single command string and log its output. - - Args: - u_boot_console: A console connection to U-Boot. - cmd: The command to run, as a string. - - Returns: - The output as a string. - """ - return run_and_log(u_boot_console, cmd_str.split()) - def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): """Run a command that is expected to fail.
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 5/9 test: Drop the cmd() function
Quoted 6 lines · Simon Glass
Instead of this, use the existing
run_and_log()function, enhanced to support a command string as well as a list of arguments.Suggested-by Stephen Warren <[email protected]>Signed-off-by Simon Glass <[email protected]>
Nit: Drop the blank line between those two tags.
PATCH 5/9 test: Drop the cmd() function
In reply to Simon GlassQuoted 6 lines · Simon Glass
Instead of this, use the existing
run_and_log()function, enhanced to support a command string as well as a list of arguments.Suggested-by Stephen Warren <[email protected]>Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/ee2864ee/attachment.sig>
PATCH 6/9 test: Rename sha to sha_algo and pass it around
In reply to Simon GlassRename this argument and pass it to each function that needs it, instead of making it global.
---
test/py/tests/test_vboot.py | 53 ++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-)
test/py/tests/test_vboot.py +28 -25
@@ -53,19 +53,21 @@ def test_vboot(u_boot_console): util.run_and_log(cons, 'dtc %s %s%s -O dtb ' '-o %s%s' % (dtc_args, datadir, dts, tmpdir, dtb)) - def run_bootm(test_type, expect_string): + def run_bootm(sha_algo, test_type, expect_string): """Run a 'bootm' command U-Boot. This always starts a fresh U-Boot instance since the device tree may contain a new public key. Args: - test_type: A string identifying the test type - expect_string: A string which is expected in the output + test_type: A string identifying the test type. + expect_string: A string which is expected in the output. + sha_algo: Either 'sha1' or 'sha256', to select the algorithm to + use. """ cons.cleanup_spawn() cons.ensure_spawned() - cons.log.action('%s: Test Verified Boot Run: %s' % (algo, test_type)) + cons.log.action('%s: Test Verified Boot Run: %s' % (sha_algo, test_type)) output = cons.run_command_list( ['sb load hostfs - 100 %stest.fit' % tmpdir, 'fdt addr 100',
@@ -83,29 +85,30 @@ def test_vboot(u_boot_console): util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', '%s%s' % (datadir, its), fit]) - def sign_fit(): + def sign_fit(sha_algo): """Sign the FIT Signs the FIT and writes the signature into it. It also writes the public key into the dtb. + + Args: + sha_algo: Either 'sha1' or 'sha256', to select the algorithm to + use. """ - cons.log.action('%s: Sign images' % algo) + cons.log.action('%s: Sign images' % sha_algo) util.run_and_log(cons, [mkimage, '-F', '-k', tmpdir, '-K', dtb, '-r', fit]) - def test_with_algo(sha): + def test_with_algo(sha_algo): """Test verified boot with the given hash algorithm. This is the main part of the test code. The same procedure is followed for both hashing algorithms. Args: - sha: Either 'sha1' or 'sha256', to select the algorithm to use + sha_algo: Either 'sha1' or 'sha256', to select the algorithm to + use. """ - global algo - - algo = sha - # Compile our device tree files for kernel and U-Boot. These are # regenerated here since mkimage will modify them (by adding a # public key) below.
@@ -113,26 +116,26 @@ def test_vboot(u_boot_console): dtc('sandbox-u-boot.dts') # Build the FIT, but don't sign anything yet - cons.log.action('%s: Test FIT with signed images' % algo) - make_fit('sign-images-%s.its' % algo) - run_bootm('unsigned images', 'dev-') + cons.log.action('%s: Test FIT with signed images' % sha_algo) + make_fit('sign-images-%s.its' % sha_algo) + run_bootm(sha_algo, 'unsigned images', 'dev-') # Sign images with our dev keys - sign_fit() - run_bootm('signed images', 'dev+') + sign_fit(sha_algo) + run_bootm(sha_algo, 'signed images', 'dev+') # Create a fresh .dtb without the public keys dtc('sandbox-u-boot.dts') - cons.log.action('%s: Test FIT with signed configuration' % algo) - make_fit('sign-configs-%s.its' % algo) - run_bootm('unsigned config', '%s+ OK' % algo) + cons.log.action('%s: Test FIT with signed configuration' % sha_algo) + make_fit('sign-configs-%s.its' % sha_algo) + run_bootm(sha_algo, 'unsigned config', '%s+ OK' % sha_algo) # Sign images with our dev keys - sign_fit() - run_bootm('signed config', 'dev+') + sign_fit(sha_algo) + run_bootm(sha_algo, 'signed config', 'dev+') - cons.log.action('%s: Check signed config on the host' % algo) + cons.log.action('%s: Check signed config on the host' % sha_algo) util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', tmpdir, '-k', dtb])
@@ -147,9 +150,9 @@ def test_vboot(u_boot_console): util.run_and_log(cons, 'fdtput -t bx %s %s value %s' % (fit, sig_node, sig)) - run_bootm('Signed config with bad hash', 'Bad Data Hash') + run_bootm(sha_algo, 'Signed config with bad hash', 'Bad Data Hash') - cons.log.action('%s: Check bad config on the host' % algo) + cons.log.action('%s: Check bad config on the host' % sha_algo) util.run_and_log_expect_exception(cons, [fit_check_sign, '-f', fit, '-k', dtb], 1, 'Failed to verify required signature')
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 6/9 test: Rename sha to sha_algo and pass it around
Quoted 7 lines · Simon Glass
Rename this argument and pass it to each function that needs it, instead of making it global.
Suggested-by Stephen Warren <[email protected]>Suggested-by Teddy Reed <[email protected]>Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/953965a5/attachment.sig>
PATCH 7/9 test: vboot: Put each test variant in its own section
In reply to Simon GlassUse 'cons.log.section' feature to split up the test output. This makes it easier to read.
---
test/py/tests/test_vboot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
test/py/tests/test_vboot.py +5 -5
@@ -67,11 +67,11 @@ def test_vboot(u_boot_console): """ cons.cleanup_spawn() cons.ensure_spawned() - cons.log.action('%s: Test Verified Boot Run: %s' % (sha_algo, test_type)) - output = cons.run_command_list( - ['sb load hostfs - 100 %stest.fit' % tmpdir, - 'fdt addr 100', - 'bootm 100']) + with cons.log.section('Verified boot %s %s' % (sha_algo, test_type)): + output = cons.run_command_list( + ['sb load hostfs - 100 %stest.fit' % tmpdir, + 'fdt addr 100', + 'bootm 100']) assert(expect_string in output) def make_fit(its):
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 7/9 test: vboot: Put each test variant in its own section
Quoted 6 lines · Simon Glass
Use 'cons.log.section' feature to split up the test output. This makes it easier to read.
Suggested-by Stephen Warren <[email protected]>Signed-off-by Simon Glass <[email protected]>
The same nit I mentioned before applies to a few other commits too, such as this one.
test/py/tests/test_vboot.py def test_vboot(u_boot_console): · line 75
Quoted 13 lines
test/py/tests/test_vboot.py +5
-5- cons.log.action('%s: Test Verified Boot Run: %s' % (sha_algo, test_type)) - output = cons.run_command_list( - ['sb load hostfs - 100 %stest.fit' % tmpdir, - 'fdt addr 100', - 'bootm 100']) + with cons.log.section('Verified boot %s %s' % (sha_algo, test_type)): + output = cons.run_command_list( + ['sb load hostfs - 100 %stest.fit' % tmpdir, + 'fdt addr 100', + 'bootm 100']) assert(expect_string in output)
I'd suggest putting the assert inside the "with" block too, so that any error messages it raises are part of that block.
PATCH 7/9 test: vboot: Put each test variant in its own section
In reply to Simon GlassQuoted 6 lines · Simon Glass
Use 'cons.log.section' feature to split up the test output. This makes it easier to read.
Suggested-by Stephen Warren <[email protected]>Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/33ffaa41/attachment.sig>
PATCH 8/9 test: Add a function to restart U-Boot
In reply to Simon GlassAdd a proper function for this rather than using internal functions. Use it in the single call site.
Also, do a restart at the end of the vboot test to reset to the normal device tree.
---
test/py/tests/test_vboot.py | 5 +++-- test/py/u_boot_console_base.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-)
test/py/tests/test_vboot.py +3 -2
@@ -65,8 +65,7 @@ def test_vboot(u_boot_console): sha_algo: Either 'sha1' or 'sha256', to select the algorithm to use. """ - cons.cleanup_spawn() - cons.ensure_spawned() + cons.restart_uboot() with cons.log.section('Verified boot %s %s' % (sha_algo, test_type)): output = cons.run_command_list( ['sb load hostfs - 100 %stest.fit' % tmpdir,
@@ -190,4 +189,6 @@ def test_vboot(u_boot_console): test_with_algo('sha1') test_with_algo('sha256') finally: + # Go back to the original U-Boot with the correct dtb. cons.config.dtb = old_dtb + cons.restart_uboot()
test/py/u_boot_console_base.py +5 -0
@@ -393,6 +393,11 @@ class ConsoleBase(object): pass self.p = None + def restart_uboot(self): + """Shut down and restart U-Boot.""" + self.cleanup_spawn() + self.ensure_spawned() + def get_spawn_output(self): """Return the start-up output from U-Boot
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 8/9 test: Add a function to restart U-Boot
Quoted 8 lines · Simon Glass
Add a proper function for this rather than using internal functions. Use it in the single call site.
Also, do a restart at the end of the vboot test to reset to the normal device tree.
Signed-off-by Simon Glass <[email protected]>Suggested-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/23bf5c7e/attachment.sig>
PATCH 9/9 test: Adjust run_command_list() to return a list of strings
In reply to Simon GlassReturn one string for each command that was executed. This seems cleaner.
---
test/py/tests/test_vboot.py | 2 +- test/py/u_boot_console_base.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
test/py/tests/test_vboot.py +1 -1
@@ -71,7 +71,7 @@ def test_vboot(u_boot_console): ['sb load hostfs - 100 %stest.fit' % tmpdir, 'fdt addr 100', 'bootm 100']) - assert(expect_string in output) + assert(expect_string in ''.join(output)) def make_fit(its): """Make a new FIT from the .its source file.
test/py/u_boot_console_base.py +4 -3
@@ -225,11 +225,12 @@ class ConsoleBase(object): Args: cmd: List of commands (each a string). Returns: - Combined output of all commands, as a string. + A list of output strings from each command, one element for each + command. """ - output = '' + output = [] for cmd in cmds: - output += self.run_command(cmd) + output.append(self.run_command(cmd)) return output def ctrlc(self):
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 9/9 test: Adjust run_command_list() to return a list of strings
Quoted 1 line · Simon Glass
Return one string for each command that was executed. This seems cleaner.
The series,
PATCH 9/9 test: Adjust run_command_list() to return a list of strings
In reply to Simon GlassQuoted 5 lines · Simon Glass
Return one string for each command that was executed. This seems cleaner.
Suggested-by Teddy Reed <[email protected]>Signed-off-by Simon Glass <[email protected]>Reviewed-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/ea1a72a2/attachment.sig>