summaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
authorAlison Chaiken <alison@peloton-tech.com>2017-09-09 23:47:13 -0700
committerTom Rini <trini@konsulko.com>2017-09-14 21:32:57 -0400
commita2f422555fc80144aea418c0d8e95341acfe6868 (patch)
treee70ad75fc422360297e7e6bf3b6002ffea7846c7 /test/py
parentbf6d76b84ae13b463c0dca556118047e2d046f33 (diff)
add pytests for 'gpt guid' command in sandbox
Run unit tests for the 'gpt guid' command, making use of the block device created by test/py/make_test_disk.py. Remove this device at the end of the tests. Signed-off-by: Alison Chaiken <alison@peloton-tech.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/py')
-rw-r--r--test/py/tests/test_gpt.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py
new file mode 100644
index 0000000000..73f5c50f6c
--- /dev/null
+++ b/test/py/tests/test_gpt.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2017 Alison Chaiken
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Test GPT manipulation commands.
+
+import os
+import pytest
+import u_boot_utils
+import make_test_disk
+
+"""
+These tests rely on a 4 MB block device called testdisk.raw
+which is automatically removed at the end of the tests.
+"""
+
+@pytest.mark.buildconfigspec('cmd_gpt')
+def test_gpt_guid(u_boot_console):
+ """Test the gpt guid command."""
+
+ if u_boot_console.config.buildconfig.get('config_cmd_gpt', 'n') != 'y':
+ pytest.skip('gpt command not supported')
+ make_test_disk.makeDisk()
+ u_boot_console.run_command('host bind 0 testdisk.raw')
+ output = u_boot_console.run_command('gpt guid host 0')
+ assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
+
+@pytest.mark.buildconfigspec('cmd_gpt')
+def test_gpt_save_guid(u_boot_console):
+ """Test the gpt guid command to save GUID into a string."""
+
+ if u_boot_console.config.buildconfig.get('config_cmd_gpt', 'n') != 'y':
+ pytest.skip('gpt command not supported')
+ u_boot_console.run_command('host bind 0 testdisk.raw')
+ 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
+ os.remove('testdisk.raw')