Skip to content

Instantly share code, notes, and snippets.

@Forty-Bot
Created August 5, 2020 14:48
Show Gist options
  • Save Forty-Bot/acb1a87f12a06adb409c67536ade43d4 to your computer and use it in GitHub Desktop.
Save Forty-Bot/acb1a87f12a06adb409c67536ade43d4 to your computer and use it in GitHub Desktop.
$ PATH="../u-boot-build/u-boot-test/:$PATH" test/py/test.py --bd=sipeed_maix_bitm -ra --build-dir=.
+u-boot-test-flash sipeed_maix_bitm na
... u-boot-test-flash ...
=========================================================== test session starts ============================================================
platform linux -- Python 3.8.5, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: /home/sean/software/u-boot/test/py, inifile: pytest.ini
collected 347 items
test/py/tests/test_000_version.py . [ 0%]
test/py/tests/test_bind.py ss [ 0%]
test/py/tests/test_button.py s [ 0%]
test/py/tests/test_dfu.py s [ 0%]
test/py/tests/test_dm.py ... [ 0%]
test/py/tests/test_efi_fit.py s [ 0%]
test/py/tests/test_efi_loader.py .sssss [ 0%]
test/py/tests/test_efi_selftest.py sssss [ 0%]
test/py/tests/test_env.py .......F....sss [ 0%]
test/py/tests/test_fit.py s [ 0%]
test/py/tests/test_fpga.py ssssssssssssssssssssssssssss [ 0%]
test/py/tests/test_gpio.py ss [ 0%]
test/py/tests/test_gpt.py sssssss [ 0%]
test/py/tests/test_handoff.py s [ 0%]
test/py/tests/test_help.py . [ 0%]
test/py/tests/test_hush_if_test.py ......................................................................s [ 0%]
test/py/tests/test_log.py ss [ 0%]
test/py/tests/test_lsblk.py s [ 0%]
test/py/tests/test_md.py .. [ 0%]
test/py/tests/test_mmc_rd.py ssss [ 0%]
test/py/tests/test_mmc_wr.py s [ 0%]
test/py/tests/test_net.py .sssss [ 0%]
test/py/tests/test_ofplatdata.py ss [ 0%]
test/py/tests/test_part.py s [ 0%]
test/py/tests/test_pinmux.py sssssss [ 0%]
test/py/tests/test_sandbox_exit.py ss [ 0%]
test/py/tests/test_sf.py ssss [ 0%]
test/py/tests/test_shell_basics.py ..F. [ 0%]
test/py/tests/test_sleep.py . [ 0%]
test/py/tests/test_tpm2.py sssssssssss [ 0%]
test/py/tests/test_ums.py s [ 0%]
test/py/tests/test_unknown_cmd.py . [ 0%]
test/py/tests/test_ut.py s.......................... [ 0%]
test/py/tests/test_vboot.py ssssssssss [ 0%]
test/py/tests/test_android/test_ab.py s [ 0%]
test/py/tests/test_android/test_abootimg.py s [ 0%]
test/py/tests/test_android/test_avb.py ssssss [ 0%]
test/py/tests/test_efi_secboot/test_authvar.py sssss [ 0%]
test/py/tests/test_efi_secboot/test_signed.py ssssss [ 0%]
test/py/tests/test_efi_secboot/test_unsigned.py sss [ 0%]
test/py/tests/test_fs/test_basic.py sssssssssssssssssssssssssssssssssssssss [ 0%]
test/py/tests/test_fs/test_ext.py ssssssssssssssssssssss [ 0%]
test/py/tests/test_fs/test_fs_cmd.py s [ 0%]
test/py/tests/test_fs/test_mkdir.py ssssssssssss [ 0%]
test/py/tests/test_fs/test_symlink.py ssss [ 0%]
test/py/tests/test_fs/test_unlink.py ssssssssssssss
================================================================= FAILURES =================================================================
________________________________________________________ test_env_expansion_spaces _________________________________________________________
state_test_env = <test_env.StateTestEnv object at 0x7fad11abb760>
def test_env_expansion_spaces(state_test_env):
"""Test expanding a variable that contains a space in its value."""
var_space = None
var_test = None
try:
var_space = state_test_env.get_non_existent_var()
set_var(state_test_env, var_space, ' ')
var_test = state_test_env.get_non_existent_var()
value = ' 1${%(var_space)s}${%(var_space)s} 2 ' % locals()
> set_var(state_test_env, var_test, value)
test/py/tests/test_env.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
state_test_env = <test_env.StateTestEnv object at 0x7fad11abb760>, var = 'test_env_1', value = ' 1${test_env_0}${test_env_0} 2 '
def set_var(state_test_env, var, value):
"""Set an environment variable.
This both executes a U-Boot shell command and updates a StateTestEnv
object.
Args:
state_test_env: The StateTestEnv object to update.
var: The variable name to set.
value: The value to set the variable to.
Returns:
Nothing.
"""
bc = state_test_env.u_boot_console.config.buildconfig
if bc.get('config_hush_parser', None):
quote = '"'
else:
quote = ''
if ' ' in value:
pytest.skip('Space in variable value on non-Hush shell')
> state_test_env.u_boot_console.run_command(
'setenv %s %s%s%s' % (var, quote, value, quote))
test/py/tests/test_env.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <u_boot_console_exec_attach.ConsoleExecAttach object at 0x7fad11e40520>, cmd = '', wait_for_echo = True, send_nl = True
wait_for_prompt = True
def run_command(self, cmd, wait_for_echo=True, send_nl=True,
wait_for_prompt=True):
"""Execute a command via the U-Boot console.
The command is always sent to U-Boot.
U-Boot echoes any command back to its output, and this function
typically waits for that to occur. The wait can be disabled by setting
wait_for_echo=False, which is useful e.g. when sending CTRL-C to
interrupt a long-running command such as "ums".
Command execution is typically triggered by sending a newline
character. This can be disabled by setting send_nl=False, which is
also useful when sending CTRL-C.
This function typically waits for the command to finish executing, and
returns the console output that it generated. This can be disabled by
setting wait_for_prompt=False, which is useful when invoking a long-
running command such as "ums".
Args:
cmd: The command to send.
wait_for_echo: Boolean indicating whether to wait for U-Boot to
echo the command text back to its output.
send_nl: Boolean indicating whether to send a newline character
after the command string.
wait_for_prompt: Boolean indicating whether to wait for the
command prompt to be sent by U-Boot. This typically occurs
immediately after the command has been executed.
Returns:
If wait_for_prompt == False:
Nothing.
Else:
The output from U-Boot during command execution. In other
words, the text U-Boot emitted between the point it echod the
command string and emitted the subsequent command prompts.
"""
if self.at_prompt and \
self.at_prompt_logevt != self.logstream.logfile.cur_evt:
self.logstream.write(self.prompt, implicit=True)
try:
self.at_prompt = False
if send_nl:
cmd += '\n'
while cmd:
# Limit max outstanding data, so UART FIFOs don't overflow
chunk = cmd[:self.max_fifo_fill]
cmd = cmd[self.max_fifo_fill:]
self.p.send(chunk)
if not wait_for_echo:
continue
chunk = re.escape(chunk)
chunk = chunk.replace('\\\n', '[\r\n]')
m = self.p.expect([chunk] + self.bad_patterns)
if m != 0:
self.at_prompt = False
raise Exception('Bad pattern found on console: ' +
self.bad_pattern_ids[m - 1])
if not wait_for_prompt:
return
> m = self.p.expect([self.prompt_compiled] + self.bad_patterns)
test/py/u_boot_console_base.py:203:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <u_boot_spawn.Spawn object at 0x7fad11b2b220>
patterns = [re.compile('^=>\\ ', re.MULTILINE), re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))'), re.compile('(U-Boot \\d{4}...pile('Hit any key to stop autoboot: '), re.compile("Unknown command '.*' - try 'help'"), re.compile('## Error: '), ...]
def expect(self, patterns):
"""Wait for the sub-process to emit specific data.
This function waits for the process to emit one pattern from the
supplied list of patterns, or for a timeout to occur.
Args:
patterns: A list of strings or regex objects that we expect to
see in the sub-process' stdout.
Returns:
The index within the patterns array of the pattern the process
emitted.
Notable exceptions:
Timeout, if the process did not emit any of the patterns within
the expected time.
"""
for pi in range(len(patterns)):
if type(patterns[pi]) == type(''):
patterns[pi] = re.compile(patterns[pi])
tstart_s = time.time()
try:
while True:
earliest_m = None
earliest_pi = None
for pi in range(len(patterns)):
pattern = patterns[pi]
m = pattern.search(self.buf)
if not m:
continue
if earliest_m and m.start() >= earliest_m.start():
continue
earliest_m = m
earliest_pi = pi
if earliest_m:
pos = earliest_m.start()
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()
if self.timeout:
tdelta_ms = (tnow_s - tstart_s) * 1000
poll_maxwait = self.timeout - tdelta_ms
if tdelta_ms > self.timeout:
raise Timeout()
else:
poll_maxwait = None
events = self.poll.poll(poll_maxwait)
if not events:
> raise Timeout()
E u_boot_spawn.Timeout
test/py/u_boot_spawn.py:170: Timeout
During handling of the above exception, another exception occurred:
state_test_env = <test_env.StateTestEnv object at 0x7fad11abb760>
def test_env_expansion_spaces(state_test_env):
"""Test expanding a variable that contains a space in its value."""
var_space = None
var_test = None
try:
var_space = state_test_env.get_non_existent_var()
set_var(state_test_env, var_space, ' ')
var_test = state_test_env.get_non_existent_var()
value = ' 1${%(var_space)s}${%(var_space)s} 2 ' % locals()
set_var(state_test_env, var_test, value)
value = ' 1 2 '
validate_set(state_test_env, var_test, value)
finally:
if var_space:
> unset_var(state_test_env, var_space)
test/py/tests/test_env.py:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/py/tests/test_env.py:113: in unset_var
state_test_env.u_boot_console.run_command('setenv %s' % var)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <u_boot_console_exec_attach.ConsoleExecAttach object at 0x7fad11e40520>, cmd = '0\n', wait_for_echo = True, send_nl = True
wait_for_prompt = True
def run_command(self, cmd, wait_for_echo=True, send_nl=True,
wait_for_prompt=True):
"""Execute a command via the U-Boot console.
The command is always sent to U-Boot.
U-Boot echoes any command back to its output, and this function
typically waits for that to occur. The wait can be disabled by setting
wait_for_echo=False, which is useful e.g. when sending CTRL-C to
interrupt a long-running command such as "ums".
Command execution is typically triggered by sending a newline
character. This can be disabled by setting send_nl=False, which is
also useful when sending CTRL-C.
This function typically waits for the command to finish executing, and
returns the console output that it generated. This can be disabled by
setting wait_for_prompt=False, which is useful when invoking a long-
running command such as "ums".
Args:
cmd: The command to send.
wait_for_echo: Boolean indicating whether to wait for U-Boot to
echo the command text back to its output.
send_nl: Boolean indicating whether to send a newline character
after the command string.
wait_for_prompt: Boolean indicating whether to wait for the
command prompt to be sent by U-Boot. This typically occurs
immediately after the command has been executed.
Returns:
If wait_for_prompt == False:
Nothing.
Else:
The output from U-Boot during command execution. In other
words, the text U-Boot emitted between the point it echod the
command string and emitted the subsequent command prompts.
"""
if self.at_prompt and \
self.at_prompt_logevt != self.logstream.logfile.cur_evt:
self.logstream.write(self.prompt, implicit=True)
try:
self.at_prompt = False
if send_nl:
cmd += '\n'
while cmd:
# Limit max outstanding data, so UART FIFOs don't overflow
chunk = cmd[:self.max_fifo_fill]
cmd = cmd[self.max_fifo_fill:]
> self.p.send(chunk)
E AttributeError: 'NoneType' object has no attribute 'send'
test/py/u_boot_console_base.py:191: AttributeError
----------------------------------------------------------- Captured stdout call -----------------------------------------------------------
=> setenv test_env_0 " "
=> => setenv test_env_1 " 1${test_env_0}${test_env_0} 2 "
________________________________________________________ test_shell_semicolon_three ________________________________________________________
u_boot_console = <u_boot_console_exec_attach.ConsoleExecAttach object at 0x7fad11e40520>
def test_shell_semicolon_three(u_boot_console):
"""Test three shell commands separate by a semi-colon, with variable
expansion dependencies between them."""
cmd = 'setenv list 1; setenv list ${list}2; setenv list ${list}3; ' + \
'echo ${list}'
> response = u_boot_console.run_command(cmd)
test/py/tests/test_shell_basics.py:30:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/py/u_boot_console_base.py:203: in run_command
m = self.p.expect([self.prompt_compiled] + self.bad_patterns)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <u_boot_spawn.Spawn object at 0x7fad11ab6ca0>
patterns = [re.compile('^=>\\ ', re.MULTILINE), re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))'), re.compile('(U-Boot \\d{4}...pile('Hit any key to stop autoboot: '), re.compile("Unknown command '.*' - try 'help'"), re.compile('## Error: '), ...]
def expect(self, patterns):
"""Wait for the sub-process to emit specific data.
This function waits for the process to emit one pattern from the
supplied list of patterns, or for a timeout to occur.
Args:
patterns: A list of strings or regex objects that we expect to
see in the sub-process' stdout.
Returns:
The index within the patterns array of the pattern the process
emitted.
Notable exceptions:
Timeout, if the process did not emit any of the patterns within
the expected time.
"""
for pi in range(len(patterns)):
if type(patterns[pi]) == type(''):
patterns[pi] = re.compile(patterns[pi])
tstart_s = time.time()
try:
while True:
earliest_m = None
earliest_pi = None
for pi in range(len(patterns)):
pattern = patterns[pi]
m = pattern.search(self.buf)
if not m:
continue
if earliest_m and m.start() >= earliest_m.start():
continue
earliest_m = m
earliest_pi = pi
if earliest_m:
pos = earliest_m.start()
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()
if self.timeout:
tdelta_ms = (tnow_s - tstart_s) * 1000
poll_maxwait = self.timeout - tdelta_ms
if tdelta_ms > self.timeout:
raise Timeout()
else:
poll_maxwait = None
events = self.poll.poll(poll_maxwait)
if not events:
> raise Timeout()
E u_boot_spawn.Timeout
test/py/u_boot_spawn.py:170: Timeout
----------------------------------------------------------- Captured stdout call -----------------------------------------------------------
=> setenv list 1; setenv list ${list}2; setenv list ${list}3; echo ${list}
========================================================= short test summary info ==========================================================
SKIPPED [2] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_bind" not enabled
SKIPPED [139] /home/sean/software/u-boot/test/py/conftest.py:468: board "sipeed_maix_bitm" not supported
SKIPPED [1] tests/test_dfu.py:114: got empty parameter set ['env__usb_dev_port'], function test_dfu at /home/sean/software/u-boot/test/py/tests/test_dfu.py:113
SKIPPED [6] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "fit" not enabled
SKIPPED [2] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_dhcp" not enabled
SKIPPED [4] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "net" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_bootefi_hello_compile" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_bootefi_hello" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_bootefi" not enabled
SKIPPED [5] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_bootefi_selftest" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_nvedit_info" not enabled
SKIPPED [13] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_fpga" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_fpga_loadp" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_fpga_loadbp" not enabled
SKIPPED [6] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "image_format_legacy" not enabled
SKIPPED [2] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_log" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_lsblk" not enabled
SKIPPED [1] tests/test_mmc_rd.py:134: got empty parameter set ['env__mmc_dev_config'], function test_mmc_dev at /home/sean/software/u-boot/test/py/tests/test_mmc_rd.py:133
SKIPPED [1] tests/test_mmc_rd.py:155: got empty parameter set ['env__mmc_dev_config'], function test_mmc_rescan at /home/sean/software/u-boot/test/py/tests/test_mmc_rd.py:154
SKIPPED [1] tests/test_mmc_rd.py:181: got empty parameter set ['env__mmc_dev_config'], function test_mmc_info at /home/sean/software/u-boot/test/py/tests/test_mmc_rd.py:180
SKIPPED [1] tests/test_mmc_rd.py:218: got empty parameter set ['env__mmc_rd_config'], function test_mmc_rd at /home/sean/software/u-boot/test/py/tests/test_mmc_rd.py:217
SKIPPED [1] tests/test_mmc_wr.py:38: got empty parameter set ['env__mmc_wr_config'], function test_mmc_wr at /home/sean/software/u-boot/test/py/tests/test_mmc_wr.py:37
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_ping" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_net" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_nfs" not enabled
SKIPPED [2] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "spl_of_platdata" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "efi_partition" not enabled
SKIPPED [3] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_pinmux" not enabled
SKIPPED [1] tests/test_sf.py:167: got empty parameter set ['env__sf_config'], function test_sf_read at /home/sean/software/u-boot/test/py/tests/test_sf.py:166
SKIPPED [1] tests/test_sf.py:174: got empty parameter set ['env__sf_config'], function test_sf_read_twice at /home/sean/software/u-boot/test/py/tests/test_sf.py:173
SKIPPED [1] tests/test_sf.py:186: got empty parameter set ['env__sf_config'], function test_sf_erase at /home/sean/software/u-boot/test/py/tests/test_sf.py:185
SKIPPED [1] tests/test_sf.py:209: got empty parameter set ['env__sf_config'], function test_sf_update at /home/sean/software/u-boot/test/py/tests/test_sf.py:208
SKIPPED [11] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_tpm_v2" not enabled
SKIPPED [1] tests/test_ums.py:76: got empty parameter set ['env__usb_dev_port'], function test_ums at /home/sean/software/u-boot/test/py/tests/test_ums.py:75
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "ut_dm" not enabled
SKIPPED [3] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_mmc" not enabled
SKIPPED [2] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "cmd_avb" not enabled
SKIPPED [1] /home/sean/software/u-boot/test/py/conftest.py:487: .config feature "optee_ta_avb" not enabled
FAILED test/py/tests/test_env.py::test_env_expansion_spaces - AttributeError: 'NoneType' object has no attribute 'send'
FAILED test/py/tests/test_shell_basics.py::test_shell_semicolon_three - u_boot_spawn.Timeout
========================================== 2 failed, 121 passed, 224 skipped in 71.53s (0:01:11) ===========================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment