u_boot_pylib: Correct case for test_result

This should be in capitals and defined at the start of the file. Update
it.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2025-02-03 09:26:42 -07:00 committed by Tom Rini
parent 752321b625
commit d6900a778a
3 changed files with 23 additions and 24 deletions

View file

@ -303,7 +303,7 @@ class TestFunctional(unittest.TestCase):
def setUp(self):
# Enable this to turn on debugging output
# tout.init(tout.DEBUG)
command.test_result = None
command.TEST_RESULT = None
def tearDown(self):
"""Remove the temporary output directory"""
@ -780,11 +780,11 @@ class TestFunctional(unittest.TestCase):
def testFullHelpInternal(self):
"""Test that the full help is displayed with -H"""
try:
command.test_result = command.CommandResult()
command.TEST_RESULT = command.CommandResult()
result = self._DoBinman('-H')
help_file = os.path.join(self._binman_dir, 'README.rst')
finally:
command.test_result = None
command.TEST_RESULT = None
def testHelp(self):
"""Test that the basic help is displayed with -h"""
@ -1872,7 +1872,7 @@ class TestFunctional(unittest.TestCase):
def testGbb(self):
"""Test for the Chromium OS Google Binary Block"""
command.test_result = self._HandleGbbCommand
command.TEST_RESULT = self._HandleGbbCommand
entry_args = {
'keydir': 'devkeys',
'bmpblk': 'bmpblk.bin',
@ -1941,7 +1941,7 @@ class TestFunctional(unittest.TestCase):
def testVblock(self):
"""Test for the Chromium OS Verified Boot Block"""
self._hash_data = False
command.test_result = self._HandleVblockCommand
command.TEST_RESULT = self._HandleVblockCommand
entry_args = {
'keydir': 'devkeys',
}
@ -1974,7 +1974,7 @@ class TestFunctional(unittest.TestCase):
def testVblockContent(self):
"""Test that the vblock signs the right data"""
self._hash_data = True
command.test_result = self._HandleVblockCommand
command.TEST_RESULT = self._HandleVblockCommand
entry_args = {
'keydir': 'devkeys',
}
@ -5496,7 +5496,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
def testFitSubentryUsesBintool(self):
"""Test that binman FIT subentries can use bintools"""
command.test_result = self._HandleGbbCommand
command.TEST_RESULT = self._HandleGbbCommand
entry_args = {
'keydir': 'devkeys',
'bmpblk': 'bmpblk.bin',

View file

@ -187,7 +187,7 @@ class TestFunctional(unittest.TestCase):
self._git_dir = os.path.join(self._base_dir, 'src')
self._buildman_pathname = sys.argv[0]
self._buildman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
command.test_result = self._HandleCommand
command.TEST_RESULT = self._HandleCommand
bsettings.setup(None)
bsettings.add_file(settings_data)
self.setupToolchains()
@ -266,7 +266,7 @@ class TestFunctional(unittest.TestCase):
return result
def testFullHelp(self):
command.test_result = None
command.TEST_RESULT = None
result = self._RunBuildman('-H')
help_file = os.path.join(self._buildman_dir, 'README.rst')
# Remove possible extraneous strings
@ -277,7 +277,7 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(0, result.return_code)
def testHelp(self):
command.test_result = None
command.TEST_RESULT = None
result = self._RunBuildman('-h')
help_file = os.path.join(self._buildman_dir, 'README.rst')
self.assertTrue(len(result.stdout) > 1000)
@ -286,11 +286,11 @@ class TestFunctional(unittest.TestCase):
def testGitSetup(self):
"""Test gitutils.Setup(), from outside the module itself"""
command.test_result = command.CommandResult(return_code=1)
command.TEST_RESULT = command.CommandResult(return_code=1)
gitutil.setup()
self.assertEqual(gitutil.use_no_decorate, False)
command.test_result = command.CommandResult(return_code=0)
command.TEST_RESULT = command.CommandResult(return_code=0)
gitutil.setup()
self.assertEqual(gitutil.use_no_decorate, True)

View file

@ -6,6 +6,13 @@ import os
from u_boot_pylib import cros_subprocess
# This permits interception of RunPipe for test purposes. If it is set to
# a function, then that function is called with the pipe list being
# executed. Otherwise, it is assumed to be a CommandResult object, and is
# returned as the result for every run_pipe() call.
# When this value is None, commands are executed as normal.
TEST_RESULT = None
"""Shell command ease-ups for Python."""
class CommandResult:
@ -32,14 +39,6 @@ class CommandResult:
self.combined = self.combined.decode('utf-8')
return self
# This permits interception of RunPipe for test purposes. If it is set to
# a function, then that function is called with the pipe list being
# executed. Otherwise, it is assumed to be a CommandResult object, and is
# returned as the result for every run_pipe() call.
# When this value is None, commands are executed as normal.
test_result = None
def run_pipe(pipe_list, infile=None, outfile=None,
capture=False, capture_stderr=False, oneline=False,
raise_on_error=True, cwd=None, binary=False,
@ -63,14 +62,14 @@ def run_pipe(pipe_list, infile=None, outfile=None,
Returns:
CommandResult object
"""
if test_result:
if hasattr(test_result, '__call__'):
if TEST_RESULT:
if hasattr(TEST_RESULT, '__call__'):
# pylint: disable=E1102
result = test_result(pipe_list=pipe_list)
result = TEST_RESULT(pipe_list=pipe_list)
if result:
return result
else:
return test_result
return TEST_RESULT
# No result: fall through to normal processing
result = CommandResult(b'', b'', b'')
last_pipe = None