Alison Chaiken | 1b11fb0 | 2017-09-09 23:47:13 -0700 | [diff] [blame^] | 1 | # Copyright (c) 2017 Alison Chaiken |
| 2 | # |
| 3 | # SPDX-License-Identifier: GPL-2.0 |
| 4 | |
| 5 | # Test GPT manipulation commands. |
| 6 | |
| 7 | import os |
| 8 | import pytest |
| 9 | import u_boot_utils |
| 10 | import make_test_disk |
| 11 | |
| 12 | """ |
| 13 | These tests rely on a 4 MB block device called testdisk.raw |
| 14 | which is automatically removed at the end of the tests. |
| 15 | """ |
| 16 | |
| 17 | @pytest.mark.buildconfigspec('cmd_gpt') |
| 18 | def test_gpt_guid(u_boot_console): |
| 19 | """Test the gpt guid command.""" |
| 20 | |
| 21 | if u_boot_console.config.buildconfig.get('config_cmd_gpt', 'n') != 'y': |
| 22 | pytest.skip('gpt command not supported') |
| 23 | make_test_disk.makeDisk() |
| 24 | u_boot_console.run_command('host bind 0 testdisk.raw') |
| 25 | output = u_boot_console.run_command('gpt guid host 0') |
| 26 | assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output |
| 27 | |
| 28 | @pytest.mark.buildconfigspec('cmd_gpt') |
| 29 | def test_gpt_save_guid(u_boot_console): |
| 30 | """Test the gpt guid command to save GUID into a string.""" |
| 31 | |
| 32 | if u_boot_console.config.buildconfig.get('config_cmd_gpt', 'n') != 'y': |
| 33 | pytest.skip('gpt command not supported') |
| 34 | u_boot_console.run_command('host bind 0 testdisk.raw') |
| 35 | output = u_boot_console.run_command('gpt guid host 0 newguid') |
| 36 | output = u_boot_console.run_command('printenv newguid') |
| 37 | assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output |
| 38 | os.remove('testdisk.raw') |