cmd = ('cp', persistent, self.path)
u_boot_utils.run_and_log(u_boot_console, cmd)
-gtdi = None
@pytest.fixture(scope='function')
def state_disk_image(u_boot_console):
"""pytest fixture to provide a GptTestDiskImage object to tests.
This is function-scoped because it uses u_boot_console, which is also
- function-scoped. However, we don't need to actually do any function-scope
- work, so this simply returns the same object over and over each time."""
+ function-scoped. A new disk is returned each time to prevent tests from
+ interfering with each other."""
- global gtdi
- if not gtdi:
- gtdi = GptTestDiskImage(u_boot_console)
- return gtdi
+ return GptTestDiskImage(u_boot_console)
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpt')
u_boot_console.run_command('host bind 0 ' + state_disk_image.path)
output = u_boot_console.run_command('part list host 0')
- assert '0x00000800 0x00000fff "first"' in output
- assert '0x00001000 0x00001bff "second"' in output
- u_boot_console.run_command('gpt swap host 0 first second')
+ assert '0x00000800 0x00000fff "part1"' in output
+ assert '0x00001000 0x00001bff "part2"' in output
+ u_boot_console.run_command('gpt swap host 0 part1 part2')
output = u_boot_console.run_command('part list host 0')
- assert '0x00000800 0x00000fff "second"' in output
- assert '0x00001000 0x00001bff "first"' in output
+ assert '0x00000800 0x00000fff "part2"' in output
+ assert '0x00001000 0x00001bff "part1"' in output
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpt')