11cd85f57SStephen Warren# SPDX-License-Identifier: GPL-2.0 2*83d290c5STom Rini# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 31cd85f57SStephen Warren 41cd85f57SStephen Warrenimport os.path 51cd85f57SStephen Warrenimport pytest 61cd85f57SStephen Warren 71cd85f57SStephen Warren@pytest.mark.buildconfigspec('ut_dm') 81cd85f57SStephen Warrendef test_ut_dm_init(u_boot_console): 91cd85f57SStephen Warren """Initialize data for ut dm tests.""" 101cd85f57SStephen Warren 111cd85f57SStephen Warren fn = u_boot_console.config.source_dir + '/testflash.bin' 121cd85f57SStephen Warren if not os.path.exists(fn): 131cd85f57SStephen Warren data = 'this is a test' 141cd85f57SStephen Warren data += '\x00' * ((4 * 1024 * 1024) - len(data)) 151cd85f57SStephen Warren with open(fn, 'wb') as fh: 161cd85f57SStephen Warren fh.write(data) 171cd85f57SStephen Warren 181cd85f57SStephen Warren fn = u_boot_console.config.source_dir + '/spi.bin' 191cd85f57SStephen Warren if not os.path.exists(fn): 201cd85f57SStephen Warren data = '\x00' * (2 * 1024 * 1024) 211cd85f57SStephen Warren with open(fn, 'wb') as fh: 221cd85f57SStephen Warren fh.write(data) 231cd85f57SStephen Warren 241cd85f57SStephen Warrendef test_ut(u_boot_console, ut_subtest): 251cd85f57SStephen Warren """Execute a "ut" subtest.""" 261cd85f57SStephen Warren 271cd85f57SStephen Warren output = u_boot_console.run_command('ut ' + ut_subtest) 281cd85f57SStephen Warren assert output.endswith('Failures: 0') 29