summaryrefslogtreecommitdiff
path: root/test/py/tests/test_gpt.py
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2023-08-31 10:51:41 -0600
committerTom Rini <trini@konsulko.com>2023-09-11 16:27:49 -0400
commit7cc1d87d7e1e64d7bb280ead94c55a51c4f3ee63 (patch)
treeb25b1f678e1a30d0ac3f8b02a8fb4c3791ba39d2 /test/py/tests/test_gpt.py
parent648140f77aff55d3bab072166a88ef179c474524 (diff)
cmd: gpt: Add command to swap partition order
Adds a command called "gpt transpose" which will swap the order two partition table entries in the GPT partition table (but leaves them pointing to the same locations on disk). This can be useful for swapping bootloaders in systems that use an A/B partitioning scheme where the bootrom is hard coded to look for the bootloader in a specific index in the GPT partition table. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Diffstat (limited to 'test/py/tests/test_gpt.py')
-rw-r--r--test/py/tests/test_gpt.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py
index b4c03bc3a2d..6e135b663e8 100644
--- a/test/py/tests/test_gpt.py
+++ b/test/py/tests/test_gpt.py
@@ -329,3 +329,22 @@ def test_gpt_write(state_disk_image, u_boot_console):
assert '0x00001000 0x00001bff "second"' in output
output = u_boot_console.run_command('gpt guid host 0')
assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
+
+@pytest.mark.buildconfigspec('cmd_gpt')
+@pytest.mark.buildconfigspec('cmd_gpt_rename')
+@pytest.mark.buildconfigspec('cmd_part')
+@pytest.mark.requiredtool('sgdisk')
+def test_gpt_transpose(state_disk_image, u_boot_console):
+ """Test the gpt transpose command."""
+
+ u_boot_console.run_command('host bind 0 ' + state_disk_image.path)
+ output = u_boot_console.run_command('part list host 0')
+ assert '1\t0x00000800\t0x00000fff\t"part1"' in output
+ assert '2\t0x00001000\t0x00001bff\t"part2"' in output
+
+ output = u_boot_console.run_command('gpt transpose host 0 1 2')
+ assert 'success!' in output
+
+ output = u_boot_console.run_command('part list host 0')
+ assert '2\t0x00000800\t0x00000fff\t"part1"' in output
+ assert '1\t0x00001000\t0x00001bff\t"part2"' in output