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