xref: /OK3568_Linux_fs/u-boot/test/py/tests/test_ut.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
4*4882a593Smuzhiyun
5*4882a593Smuzhiyunimport os.path
6*4882a593Smuzhiyunimport pytest
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun@pytest.mark.buildconfigspec('ut_dm')
9*4882a593Smuzhiyundef test_ut_dm_init(u_boot_console):
10*4882a593Smuzhiyun    """Initialize data for ut dm tests."""
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun    fn = u_boot_console.config.source_dir + '/testflash.bin'
13*4882a593Smuzhiyun    if not os.path.exists(fn):
14*4882a593Smuzhiyun        data = 'this is a test'
15*4882a593Smuzhiyun        data += '\x00' * ((4 * 1024 * 1024) - len(data))
16*4882a593Smuzhiyun        with open(fn, 'wb') as fh:
17*4882a593Smuzhiyun            fh.write(data)
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun    fn = u_boot_console.config.source_dir + '/spi.bin'
20*4882a593Smuzhiyun    if not os.path.exists(fn):
21*4882a593Smuzhiyun        data = '\x00' * (2 * 1024 * 1024)
22*4882a593Smuzhiyun        with open(fn, 'wb') as fh:
23*4882a593Smuzhiyun            fh.write(data)
24*4882a593Smuzhiyun
25*4882a593Smuzhiyundef test_ut(u_boot_console, ut_subtest):
26*4882a593Smuzhiyun    """Execute a "ut" subtest."""
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun    output = u_boot_console.run_command('ut ' + ut_subtest)
29*4882a593Smuzhiyun    assert output.endswith('Failures: 0')
30