test/py: regenerate persistent GPT image if code changes
PATCH 1/1 test/py: regenerate persistent GPT image if code changes
From: Stephen Warren <[email protected]>
test_gpt generates a persistent disk image which can be re-used across multiple test runs. Currently, if the Python code that generates the disk image change, the image is not regenerated, which could cause test failures e.g. if a test was updated to expect some new partition name or size, yet the persistent disk image contained the old name or size. This change introduces functionality to regenerate the disk image if the instructions to generate the image have changed.
--- test/py/tests/test_gpt.py | 35 +++++++++++----------- test/py/u_boot_utils.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 17 deletions(-)
test/py/tests/test_gpt.py +18 -17
@@ -32,23 +32,24 @@ class GptTestDiskImage(object): persistent = u_boot_console.config.persistent_data_dir + '/' + filename self.path = u_boot_console.config.result_dir + '/' + filename - if os.path.exists(persistent): - u_boot_console.log.action('Disk image file ' + persistent + - ' already exists') - else: - u_boot_console.log.action('Generating ' + persistent) - fd = os.open(persistent, os.O_RDWR | os.O_CREAT) - os.ftruncate(fd, 4194304) - os.close(fd) - cmd = ('sgdisk', '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe', - persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '--new=1:2048:2560', '-c 1:part1', persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '--new=2:4096:4608', '-c 2:part2', persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '-l', persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) + with u_boot_utils.persistent_file_helper(u_boot_console.log, persistent): + if os.path.exists(persistent): + u_boot_console.log.action('Disk image file ' + persistent + + ' already exists') + else: + u_boot_console.log.action('Generating ' + persistent) + fd = os.open(persistent, os.O_RDWR | os.O_CREAT) + os.ftruncate(fd, 4194304) + os.close(fd) + cmd = ('sgdisk', '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe', + persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + cmd = ('sgdisk', '--new=1:2048:2560', '-c 1:part1', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + cmd = ('sgdisk', '--new=2:4096:4608', '-c 2:part2', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + cmd = ('sgdisk', '-l', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) cmd = ('cp', persistent, self.path) u_boot_utils.run_and_log(u_boot_console, cmd)
test/py/u_boot_utils.py +74 -0
83 lines not on this page · raw message
Signature · 1 line
2.14.2
Quoted 11 lines · Stephen Warren
From: Stephen Warren <[email protected]>
test_gptgenerates a persistent disk image which can be re-used across multiple test runs. Currently, if the Python code that generates the disk image change, the image is not regenerated, which could cause test failures e.g. if a test was updated to expect some new partition name or size, yet the persistent disk image contained the old name or size. This change introduces functionality to regenerate the disk image if the instructions to generate the image have changed.Signed-off-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171106/cf715e69/attachment.sig>