2016-02-08 21:44:16 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2018-05-06 21:58:06 +00:00
|
|
|
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
|
2016-02-08 21:44:16 +00:00
|
|
|
|
|
|
|
import os.path
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
@pytest.mark.buildconfigspec('ut_dm')
|
|
|
|
def test_ut_dm_init(u_boot_console):
|
|
|
|
"""Initialize data for ut dm tests."""
|
|
|
|
|
|
|
|
fn = u_boot_console.config.source_dir + '/testflash.bin'
|
|
|
|
if not os.path.exists(fn):
|
2019-10-24 15:59:22 +00:00
|
|
|
data = b'this is a test'
|
|
|
|
data += b'\x00' * ((4 * 1024 * 1024) - len(data))
|
2016-02-08 21:44:16 +00:00
|
|
|
with open(fn, 'wb') as fh:
|
|
|
|
fh.write(data)
|
|
|
|
|
|
|
|
fn = u_boot_console.config.source_dir + '/spi.bin'
|
|
|
|
if not os.path.exists(fn):
|
2019-10-24 15:59:22 +00:00
|
|
|
data = b'\x00' * (2 * 1024 * 1024)
|
2016-02-08 21:44:16 +00:00
|
|
|
with open(fn, 'wb') as fh:
|
|
|
|
fh.write(data)
|
|
|
|
|
|
|
|
def test_ut(u_boot_console, ut_subtest):
|
2020-05-06 16:26:07 +00:00
|
|
|
"""Execute a "ut" subtest.
|
|
|
|
|
|
|
|
The subtests are collected in function generate_ut_subtest() from linker
|
|
|
|
generated lists by applying a regular expression to the lines of file
|
|
|
|
u-boot.sym. The list entries are created using the C macro UNIT_TEST().
|
|
|
|
|
|
|
|
Strict naming conventions have to be followed to match the regular
|
|
|
|
expression. Use UNIT_TEST(foo_test_bar, _flags, foo_test) for a test bar in
|
|
|
|
test suite foo that can be executed via command 'ut foo bar' and is
|
|
|
|
implemented in C function foo_test_bar().
|
|
|
|
|
|
|
|
Args:
|
|
|
|
u_boot_console (ConsoleBase): U-Boot console
|
|
|
|
ut_subtest (str): test to be executed via command ut, e.g 'foo bar' to
|
|
|
|
execute command 'ut foo bar'
|
|
|
|
"""
|
2016-02-08 21:44:16 +00:00
|
|
|
|
|
|
|
output = u_boot_console.run_command('ut ' + ut_subtest)
|
|
|
|
assert output.endswith('Failures: 0')
|