[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/9] tests/acceptance: Extract image_expand() helper
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 4/9] tests/acceptance: Extract image_expand() helper |
Date: |
Wed, 23 Jun 2021 20:00:16 +0200 |
To be able to expand an image to a non-power-of-2 value,
extract image_expand() from image_pow2ceil_expand().
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
tests/acceptance/boot_linux_console.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tests/acceptance/boot_linux_console.py
b/tests/acceptance/boot_linux_console.py
index 20d57c1a8c6..61069f0064f 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -35,15 +35,19 @@
def pow2ceil(x):
return 1 if x == 0 else 2**(x - 1).bit_length()
+"""
+Expand file size
+"""
+def image_expand(path, size):
+ if size != os.path.getsize(path):
+ with open(path, 'ab+') as fd:
+ fd.truncate(size)
+
"""
Expand file size to next power of 2
"""
def image_pow2ceil_expand(path):
- size = os.path.getsize(path)
- size_aligned = pow2ceil(size)
- if size != size_aligned:
- with open(path, 'ab+') as fd:
- fd.truncate(size_aligned)
+ image_expand(path, pow2ceil(os.path.getsize(path)))
class LinuxKernelTest(Test):
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
--
2.31.1
- [RFC PATCH 0/9] hw/sd: Allow card size not power of 2 again, Philippe Mathieu-Daudé, 2021/06/23
- [PATCH 1/9] hw/sd: When card is in wrong state, log which state it is, Philippe Mathieu-Daudé, 2021/06/23
- [PATCH 2/9] hw/sd: Extract address_in_range() helper, log invalid accesses, Philippe Mathieu-Daudé, 2021/06/23
- [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd', Philippe Mathieu-Daudé, 2021/06/23
- [PATCH 4/9] tests/acceptance: Extract image_expand() helper,
Philippe Mathieu-Daudé <=
- [PATCH 5/9] tests/acceptance: Use image_expand() in test_arm_orangepi_uboot_netbsd9, Philippe Mathieu-Daudé, 2021/06/23
- [RFC PATCH 6/9] tests/acceptance: Use image_expand() in test_arm_orangepi_bionic_20_08, Philippe Mathieu-Daudé, 2021/06/23
- [RFC PATCH 7/9] tests/acceptance: Do not expand SD card image in test_arm_orangepi_sd, Philippe Mathieu-Daudé, 2021/06/23
- [PATCH 8/9] tests/acceptance: Remove now unused pow2ceil(), Philippe Mathieu-Daudé, 2021/06/23
- [RFC PATCH 9/9] hw/sd: Allow card size not power of 2 again, Philippe Mathieu-Daudé, 2021/06/23
- Re: [RFC PATCH 0/9] hw/sd: Allow card size not power of 2 again, Alexander Bulekov, 2021/06/23