mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-10-31 12:08:19 +00:00 
			
		
		
		
	In the case of some unit tests we are working with providing a fake flash device that we have written some text strings in to. In this case we want to tell Python to encode things to bytes for us. Reviewed-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
		
			
				
	
	
		
			29 lines
		
	
	
		
			864 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			864 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| # SPDX-License-Identifier: GPL-2.0
 | |
| # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 | |
| 
 | |
| 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):
 | |
|         data = b'this is a test'
 | |
|         data += b'\x00' * ((4 * 1024 * 1024) - len(data))
 | |
|         with open(fn, 'wb') as fh:
 | |
|             fh.write(data)
 | |
| 
 | |
|     fn = u_boot_console.config.source_dir + '/spi.bin'
 | |
|     if not os.path.exists(fn):
 | |
|         data = b'\x00' * (2 * 1024 * 1024)
 | |
|         with open(fn, 'wb') as fh:
 | |
|             fh.write(data)
 | |
| 
 | |
| def test_ut(u_boot_console, ut_subtest):
 | |
|     """Execute a "ut" subtest."""
 | |
| 
 | |
|     output = u_boot_console.run_command('ut ' + ut_subtest)
 | |
|     assert output.endswith('Failures: 0')
 |