]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
add pytests for 'gpt rename' and 'gpt swap'
authorAlison Chaiken <alison@peloton-tech.com>
Sun, 10 Sep 2017 06:54:51 +0000 (23:54 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 15 Sep 2017 01:32:59 +0000 (21:32 -0400)
Add unit tests for the 'gpt rename' and 'gpt swap' commands that
rely on the block device created by test/py/make_test_disk.py.
Add CONFIG_CMD_GPT_RENAME to the sandbox_defconfig.  Remove the
testdisk.raw test device at the end of the tests.

Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
configs/sandbox_defconfig
test/py/tests/test_gpt.py

index 4c4e4809be764e6e23b03d2eb6f94a5c37f8c0d7..e7a61bd61a0b1e2d02c42053d2ff700833c7607b 100644 (file)
@@ -34,6 +34,7 @@ CONFIG_CMD_MX_CYCLIC=y
 CONFIG_CMD_DEMO=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
+CONFIG_CMD_GPT_RENAME=y
 CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_PCI=y
index 73f5c50f6cdc976cb2559da4c880c55b56b80965..06f24b66cef8732c86879a8f72bf7ba787046d59 100644 (file)
@@ -35,4 +35,35 @@ def test_gpt_save_guid(u_boot_console):
     output = u_boot_console.run_command('gpt guid host 0 newguid')
     output = u_boot_console.run_command('printenv newguid')
     assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
+
+@pytest.mark.buildconfigspec('cmd_gpt')
+def test_gpt_rename_partition(u_boot_console):
+    """Test the gpt rename command to write partition names."""
+
+    if u_boot_console.config.buildconfig.get('config_cmd_gpt_rename', 'n') != 'y':
+        pytest.skip('gpt rename command not supported')
+    u_boot_console.run_command('host bind 0 testdisk.raw')
+    u_boot_console.run_command('gpt rename host 0 1 first')
+    output = u_boot_console.run_command('gpt read host 0')
+    assert 'name first' in output
+    u_boot_console.run_command('gpt rename host 0 2 second')
+    output = u_boot_console.run_command('gpt read host 0')
+    assert 'name second' in output
+
+@pytest.mark.buildconfigspec('cmd_gpt')
+def test_gpt_swap_partitions(u_boot_console):
+    """Test the gpt swap command to exchange two partition names."""
+
+    if u_boot_console.config.buildconfig.get('config_cmd_gpt_rename', 'n') != 'y':
+        pytest.skip('gpt rename command not supported')
+    if u_boot_console.config.buildconfig.get('config_cmd_part', 'n') != 'y':
+        pytest.skip('gpt swap test needs CMD_PART')
+    u_boot_console.run_command('host bind 0 testdisk.raw')
+    output = u_boot_console.run_command('part list host 0')
+    assert '0x000007ff "first"' in output
+    assert '0x000017ff "second"' in output
+    u_boot_console.run_command('gpt swap host 0 first second')
+    output = u_boot_console.run_command('part list host 0')
+    assert '0x000007ff "second"' in output
+    assert '0x000017ff "first"' in output
     os.remove('testdisk.raw')