[U-Boot] [PATCH 2/3] add pytest for 'gpt guid' command in sandbox

alison at peloton-tech.com alison at peloton-tech.com
Sun Sep 3 00:18:58 UTC 2017


From: Alison Chaiken <alison at peloton-tech.com>

Run unit tests for the 'gpt guid' command, making use of the disk.raw
block device created by test/gpt/make-test-disk.sh script.  Remove
this device at the end of the tests.

Signed-off-by: Alison Chaiken <alison at peloton-tech.com>
---
 test/py/tests/test_gpt.py | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 test/py/tests/test_gpt.py

diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py
new file mode 100644
index 0000000..2201f39
--- /dev/null
+++ b/test/py/tests/test_gpt.py
@@ -0,0 +1,39 @@
+# Copyright (c) 2017 Alison Chaiken
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Test GPT manipulation commands.
+# Before executing the test, please run the test/gpt/make-test-disk.sh script.
+
+import os
+import pytest
+import u_boot_utils
+
+"""
+These tests rely on a 256KB block device called disk.raw.  Run
+    test/gpt/make-test-disk.sh
+in order to create this device, which is automatically removed at the end of the
+tests.
+"""
+
+ at 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')
+    u_boot_console.run_command('host bind 0 disk.raw')
+    output = u_boot_console.run_command('gpt guid host 0')
+    assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
+
+ at 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 disk.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('disk.raw')
-- 
2.1.4



More information about the U-Boot mailing list