blob: 73f5c50f6cdc976cb2559da4c880c55b56b80965 [file] [log] [blame]
Alison Chaikena2f42252017-09-09 23:47:13 -07001# Copyright (c) 2017 Alison Chaiken
2#
3# SPDX-License-Identifier: GPL-2.0
4
5# Test GPT manipulation commands.
6
7import os
8import pytest
9import u_boot_utils
10import make_test_disk
11
12"""
13These tests rely on a 4 MB block device called testdisk.raw
14which is automatically removed at the end of the tests.
15"""
16
17@pytest.mark.buildconfigspec('cmd_gpt')
18def 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')
29def 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')