Skip to contentSkip to conversation

GPT: create block device for sandbox testing

PATCH New alison at peloton-tech.com 4 participants 19 messages Sep 3, 2017 – Sep 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 GPT: create block device for sandbox testing

From: Alison Chaiken <[email protected]>

Provide a shell script that creates a small block device for the purpose of testing the cmd/gpt.c functions in the u-boot sandbox. Running the tests removes the device file.

---
 test/gpt/make-test-disk.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100755 test/gpt/make-test-disk.sh
test/gpt/make-test-disk.sh new file +8 -0
new file mode 100755
index 0000000..022acba
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+/usr/bin/truncate -s 265K disk.raw
+echo -e "label: gpt\n,64K,U\n,,L" | /sbin/sgdisk ./disk.raw
+/sbin/sgdisk --new=1:34:161 ./disk.raw
+/sbin/sgdisk --new=2:162:496 ./disk.raw
+/sbin/sgdisk -U 375a56f7-d6c9-4e81-b5f0-09d41ca89efe ./disk.raw
+/sbin/gdisk -l ./disk.raw
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/3 add pytest for 'gpt guid' command in sandbox

From: Alison Chaiken <[email protected]>

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.

---
 test/py/tests/test_gpt.py | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 test/py/tests/test_gpt.py
test/py/tests/test_gpt.py new file +39 -0
new file mode 100644
index 0000000..2201f39
@@ -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')
Signature · 1 line
2.1.4
#2 lore raw

PATCH 3/3 add pytests for 'gpt rename' and 'gpt swap'

In reply to alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

Add unit tests for the 'gpt rename' and 'gpt swap' commands that rely
on the block device created by test/gpt/make-test-disk.sh. Create a
new configs/sandbox_gpt_rename_defconfig file to enable testing with CONFIG_CMD_GPT_RENAME. Remove the disk.raw test device at the end of the tests.

---
 configs/sandbox_gpt_rename_defconfig | 196 +++++++++++++++++++++++++++++++++++
 test/py/tests/test_gpt.py            |  31 ++++++
 2 files changed, 227 insertions(+)
 create mode 100644 configs/sandbox_gpt_rename_defconfig
configs/sandbox_gpt_rename_defconfig new file +196 -0
new file mode 100644
index 0000000..e7a61bd
@@ -0,0 +1,196 @@
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTSTAGE=y
+CONFIG_BOOTSTAGE_REPORT=y
+CONFIG_BOOTSTAGE_USER_COUNT=32
+CONFIG_BOOTSTAGE_FDT=y
+CONFIG_BOOTSTAGE_STASH=y
+CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
+CONFIG_CONSOLE_RECORD=y
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
+CONFIG_SILENT_CONSOLE=y
+CONFIG_PRE_CONSOLE_BUFFER=y
+CONFIG_PRE_CON_BUF_ADDR=0
+CONFIG_CMD_CPU=y
+CONFIG_CMD_LICENSE=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ENV_CALLBACK=y
+CONFIG_CMD_ENV_FLAGS=y
+CONFIG_LOOPW=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEMTEST=y
+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
+CONFIG_CMD_READ=y
+CONFIG_CMD_REMOTEPROC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_TFTPPUT=y
+CONFIG_CMD_TFTPSRV=y
+CONFIG_CMD_RARP=y
+CONFIG_CMD_CDP=y
+CONFIG_CMD_SNTP=y
+CONFIG_CMD_DNS=y
+CONFIG_CMD_LINK_LOCAL=y
+CONFIG_CMD_ETHSW=y
+CONFIG_CMD_BMP=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SOUND=y
+CONFIG_CMD_QFW=y
+CONFIG_CMD_BOOTSTAGE=y
+CONFIG_CMD_PMIC=y
+CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_TPM=y
+CONFIG_CMD_TPM_TEST=y
+CONFIG_CMD_CBFS=y
+CONFIG_CMD_CRAMFS=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_MAC_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_OF_HOSTFILE=y
+CONFIG_NETCONSOLE=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_DEVRES=y
+CONFIG_DEBUG_DEVRES=y
+CONFIG_ADC=y
+CONFIG_ADC_SANDBOX=y
+CONFIG_CLK=y
+CONFIG_CPU=y
+CONFIG_DM_DEMO=y
+CONFIG_DM_DEMO_SIMPLE=y
+CONFIG_DM_DEMO_SHAPE=y
+CONFIG_PM8916_GPIO=y
+CONFIG_SANDBOX_GPIO=y
+CONFIG_DM_I2C_COMPAT=y
+CONFIG_I2C_CROS_EC_TUNNEL=y
+CONFIG_I2C_CROS_EC_LDO=y
+CONFIG_DM_I2C_GPIO=y
+CONFIG_SYS_I2C_SANDBOX=y
+CONFIG_I2C_MUX=y
+CONFIG_SPL_I2C_MUX=y
+CONFIG_I2C_ARB_GPIO_CHALLENGE=y
+CONFIG_CROS_EC_KEYB=y
+CONFIG_I8042_KEYB=y
+CONFIG_LED=y
+CONFIG_LED_BLINK=y
+CONFIG_LED_GPIO=y
+CONFIG_DM_MAILBOX=y
+CONFIG_SANDBOX_MBOX=y
+CONFIG_MISC=y
+CONFIG_CROS_EC=y
+CONFIG_CROS_EC_I2C=y
+CONFIG_CROS_EC_LPC=y
+CONFIG_CROS_EC_SANDBOX=y
+CONFIG_CROS_EC_SPI=y
+CONFIG_PWRSEQ=y
+CONFIG_SPL_PWRSEQ=y
+CONFIG_I2C_EEPROM=y
+CONFIG_MMC_SANDBOX=y
+CONFIG_SPI_FLASH_SANDBOX=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_SST=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_DM_ETH=y
+CONFIG_NVME=y
+CONFIG_PCI=y
+CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCI_SANDBOX=y
+CONFIG_PHY=y
+CONFIG_PHY_SANDBOX=y
+CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
+CONFIG_PINCTRL_ROCKCHIP_RK3036=y
+CONFIG_PINCTRL_ROCKCHIP_RK3288=y
+CONFIG_PINCTRL_SANDBOX=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_SANDBOX_POWER_DOMAIN=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_ACT8846=y
+CONFIG_DM_PMIC_PFUZE100=y
+CONFIG_DM_PMIC_MAX77686=y
+CONFIG_PMIC_PM8916=y
+CONFIG_PMIC_RK8XX=y
+CONFIG_PMIC_S2MPS11=y
+CONFIG_DM_PMIC_SANDBOX=y
+CONFIG_PMIC_S5M8767=y
+CONFIG_PMIC_TPS65090=y
+CONFIG_DM_REGULATOR=y
+CONFIG_REGULATOR_ACT8846=y
+CONFIG_DM_REGULATOR_PFUZE100=y
+CONFIG_DM_REGULATOR_MAX77686=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_REGULATOR_RK8XX=y
+CONFIG_REGULATOR_S5M8767=y
+CONFIG_DM_REGULATOR_SANDBOX=y
+CONFIG_REGULATOR_TPS65090=y
+CONFIG_DM_PWM=y
+CONFIG_PWM_SANDBOX=y
+CONFIG_RAM=y
+CONFIG_REMOTEPROC_SANDBOX=y
+CONFIG_DM_RESET=y
+CONFIG_SANDBOX_RESET=y
+CONFIG_DM_RTC=y
+CONFIG_SANDBOX_SERIAL=y
+CONFIG_SOUND=y
+CONFIG_SOUND_SANDBOX=y
+CONFIG_SANDBOX_SPI=y
+CONFIG_SPMI=y
+CONFIG_SPMI_SANDBOX=y
+CONFIG_SYSRESET=y
+CONFIG_TIMER=y
+CONFIG_TIMER_EARLY=y
+CONFIG_SANDBOX_TIMER=y
+CONFIG_TPM_TIS_SANDBOX=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EMUL=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_SYS_USB_EVENT_POLL=y
+CONFIG_DM_VIDEO=y
+CONFIG_CONSOLE_ROTATION=y
+CONFIG_CONSOLE_TRUETYPE=y
+CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
+CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_WDT=y
+CONFIG_WDT_SANDBOX=y
+CONFIG_FS_CBFS=y
+CONFIG_FS_CRAMFS=y
+CONFIG_CMD_DHRYSTONE=y
+CONFIG_TPM=y
+CONFIG_LZ4=y
+CONFIG_ERRNO_STR=y
+CONFIG_UNIT_TEST=y
+CONFIG_UT_TIME=y
+CONFIG_UT_DM=y
+CONFIG_UT_ENV=y
test/py/tests/test_gpt.py +31 -0
index 2201f39..7d8603a 100644
@@ -36,4 +36,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
+
+ at 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 disk.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
+
+ at 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 disk.raw')
+    output = u_boot_console.run_command('part list host 0')
+    assert '0x00000021	"first"' in output
+    assert '0x000001f0	"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 '0x00000021	"second"' in output
+    assert '0x000001f0	"first"' in output
     os.remove('disk.raw')
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/3 add pytests for 'gpt rename' and 'gpt swap'

Hi Alison,

Quoted 8 lines · On 3 September 2017 at 08:18, <[email protected]> wrote:

From: Alison Chaiken <[email protected]>

Add unit tests for the 'gpt rename' and 'gpt swap' commands that rely
on the block device created by test/gpt/make-test-disk.sh. Create a
new configs/sandbox_gpt_rename_defconfig file to enable testing with CONFIG_CMD_GPT_RENAME. Remove the disk.raw test device at the end of the tests.

Quoted 6 lines
---
 configs/sandbox_gpt_rename_defconfig | 196 +++++++++++++++++++++++++++++++++++
 test/py/tests/test_gpt.py            |  31 ++++++
 2 files changed, 227 insertions(+)
 create mode 100644 configs/sandbox_gpt_rename_defconfig

How about we add this to sandbox_defconfig instead?

Regards,
Simon

#4 lore raw

PATCH v2 1/3 add pytests for 'gpt rename' and 'gpt swap'

From: Alison Chaiken <[email protected]>

Quoted 1 line · Simon Glass

How about we add this to sandbox_defconfig instead?

So done.

-- Alison

Alison Chaiken (1):
add pytests for 'gpt rename' and 'gpt swap'

 configs/sandbox_defconfig |  1 +
 test/py/tests/test_gpt.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
Signature · 1 line
2.14.1
#5 lore raw

PATCH 1/1 add pytests for 'gpt rename' and 'gpt swap'

From: Alison Chaiken <[email protected]>

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.

---
 configs/sandbox_defconfig |  1 +
 test/py/tests/test_gpt.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
configs/sandbox_defconfig +1 -0
index 4c4e4809be..e7a61bd61a 100644
@@ -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
test/py/tests/test_gpt.py +31 -0
index 73f5c50f6c..06f24b66ce 100644
@@ -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
+
+ at 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
+
+ at 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')
Signature · 1 line
2.14.1
#6 lore raw

PATCH 1/1 add pytests for 'gpt rename' and 'gpt swap'

Quoted 7 lines · On 10 September 2017 at 00:54, <[email protected]> wrote:

From: Alison Chaiken <[email protected]>

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.

Quoted 5 lines
---
 configs/sandbox_defconfig |  1 +
 test/py/tests/test_gpt.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
#7 lore raw

PATCH 1/1 add pytests for 'gpt rename' and 'gpt swap'

In reply to alison at peloton-tech.com
Quoted 9 lines · alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170915/f1ae2cd5/attachment.sig>
#8 lore raw

PATCH 1/1 add pytests for 'gpt rename' and 'gpt swap'

Quoted 8 lines · Tom Rini
Quoted 7 lines · alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

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.

Quoted 4 lines
Quoted 2 lines

Applied to u-boot/master, thanks!

As of commit cd3e8a72a6fb "test/py: u_boot_console_base.py: fix typo", in u-boot/master, test/py is failing test_gpt_*, with the log below. I assume that's due to this commit, since it relates to GPT, but I haven't bisected.

=> host bind 0 testdisk.raw
Failed to access host backing file 'testdisk.raw'
exit not allowed from main input shell.
=> gpt guid host 0
do_gpt: host dev 0 NOT available
=>

FAILED:
u_boot_console = <u_boot_console_sandbox.ConsoleSandbox object@ 0x7f60875a7e10>

@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')

Quoted 1 line
      assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output

E assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in 'do_gpt: host
dev 0 NOT available'

src/u-boot/test/py/tests/test_gpt.py:26: AssertionError

#9 lore raw

PATCH 1/1 add pytests for 'gpt rename' and 'gpt swap'

Quoted 40 lines · Stephen Warren
Quoted 8 lines · Tom Rini
Quoted 7 lines · alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

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.

Quoted 4 lines
Quoted 2 lines

Applied to u-boot/master, thanks!

As of commit cd3e8a72a6fb "test/py: u_boot_console_base.py: fix typo", in u-boot/master, test/py is failing test_gpt_*, with the log below. I assume that's due to this commit, since it relates to GPT, but I haven't bisected.

=> host bind 0 testdisk.raw
Failed to access host backing file 'testdisk.raw'
exit not allowed from main input shell.
=> gpt guid host 0
do_gpt: host dev 0 NOT available
=>

FAILED:
u_boot_console = <u_boot_console_sandbox.ConsoleSandbox object at 0x7f60875a7e10>

@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')

Quoted 5 lines
Quoted 1 line
      assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output

E assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in 'do_gpt:
host dev 0 NOT available'

src/u-boot/test/py/tests/test_gpt.py:26: AssertionError

The "good" news is that it's not something blatantly wrong in the test, it runs for me and in travis as well.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170915/479cfc5a/attachment.sig>
#10 lore raw

PATCH 1/1 add pytests for 'gpt rename' and 'gpt swap'

Quoted 41 lines · Tom Rini
Quoted 40 lines · Stephen Warren
Quoted 8 lines · Tom Rini
Quoted 7 lines · alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

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.

Quoted 4 lines
Quoted 2 lines

Applied to u-boot/master, thanks!

As of commit cd3e8a72a6fb "test/py: u_boot_console_base.py: fix typo", in u-boot/master, test/py is failing test_gpt_*, with the log below. I assume that's due to this commit, since it relates to GPT, but I haven't bisected.

=> host bind 0 testdisk.raw
Failed to access host backing file 'testdisk.raw'
exit not allowed from main input shell.
=> gpt guid host 0
do_gpt: host dev 0 NOT available
=>

FAILED:
u_boot_console = <u_boot_console_sandbox.ConsoleSandbox object at 0x7f60875a7e10>

@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')

Quoted 8 lines
Quoted 5 lines
Quoted 1 line
       assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output

E assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in 'do_gpt:
host dev 0 NOT available'

src/u-boot/test/py/tests/test_gpt.py:26: AssertionError

The "good" news is that it's not something blatantly wrong in the test, it runs for me and in travis as well.

Ah. The issue happens when the current working directory isn't the root of the U-Boot source tree.

It looks like make_test_disk.py creates the disk image in the current working directory rather than putting it into the correct test/py runtime data directory and referencing that path explicitly within the U-Boot console. I'll see if it's an easy fix or not.

#11 lore raw

PATCH 1/3 GPT: create block device for sandbox testing

In reply to alison at peloton-tech.com

Hi Alison,

Quoted 6 lines · On 3 September 2017 at 08:18, <[email protected]> wrote:

From: Alison Chaiken <[email protected]>

Provide a shell script that creates a small block device for the purpose of testing the cmd/gpt.c functions in the u-boot sandbox. Running the tests removes the device file.

Quoted 6 lines
---
 test/gpt/make-test-disk.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100755 test/gpt/make-test-disk.sh

Can you please move this into the Python script so that it is created automatically and deleted at the end.

Quoted 17 lines
test/gpt/make-test-disk.sh new file +8 -1
new file mode 100755
index 0000000..022acba
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+/usr/bin/truncate -s 265K disk.raw
+echo -e "label: gpt\n,64K,U\n,,L" | /sbin/sgdisk ./disk.raw
+/sbin/sgdisk --new=1:34:161 ./disk.raw
+/sbin/sgdisk --new=2:162:496 ./disk.raw
+/sbin/sgdisk -U 375a56f7-d6c9-4e81-b5f0-09d41ca89efe ./disk.raw
+/sbin/gdisk -l ./disk.raw
--

2.1.4

#12 lore raw

cover GPT: create block device for guid testing

From: Alison Chaiken <[email protected]>

Simon Glass <[email protected]> asked:

Quoted 2 lines

Can you please move this into the Python script so that it is created automatically and deleted at the end.

In this version, the device creation is moved to a Python function that the pytest framework can invoke, and a description of the function is added to README.sandbox. The test of the 'gpt guid' command now creates the device at the start of the test and removes it again at the end.

Alison Chaiken (2):
GPT: create block device for sandbox testing
add pytests for 'gpt guid' command in sandbox

 board/sandbox/README.sandbox |  5 +++++
 test/py/make_test_disk.py    | 19 +++++++++++++++++++
 test/py/tests/test_gpt.py    | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+)
 create mode 100755 test/py/make_test_disk.py
 create mode 100644 test/py/tests/test_gpt.py
Signature · 1 line
2.14.1
#13 lore raw

PATCH 1/2 GPT: create block device for sandbox testing

From: Alison Chaiken <[email protected]>

Provide a Python function that creates a small block device for the purpose of testing the cmd/gpt.c or cmd/part.c functions in the u-boot sandbox.

---
 board/sandbox/README.sandbox |  5 +++++
 test/py/make_test_disk.py    | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100755 test/py/make_test_disk.py
board/sandbox/README.sandbox +5 -0
index 9dc2eb09d1..947241e3eb 100644
@@ -338,6 +338,11 @@ $> lodev=`sudo losetup -P -f --show ./disk.raw`
 $> sudo mkfs.vfat -n EFI -v ${lodev}p1
 $> sudo mkfs.ext4 -L ROOT -v ${lodev}p2
 
+or utilize the device described in test/py/make_test_disk.py:
+
+   #!/usr/bin/python
+   import make_test_disk
+   make_test_disk.makeDisk()
 
 Writing Sandbox Drivers
 -----------------------
test/py/make_test_disk.py new file +19 -0
new file mode 100755
index 0000000000..5288295588
@@ -0,0 +1,19 @@
+# Copyright (c) 2017 Alison Chaiken
+#
+# SPDX-License-Identifier: GPL-2.0
+#
+# Create a block device for testing of 'gpt' and 'part' commands.
+
+import os
+
+def makeDisk():
+    if (os.path.exists("testdisk.raw")):
+        os.remove("testdisk.raw")
+    fd = os.open("testdisk.raw", os.O_RDWR|os.O_CREAT )
+    os.ftruncate(fd, 4194304)
+    os.close(fd)
+    os.spawnl(os.P_WAIT, "/sbin/sgdisk", "sgdisk", "-U",
+          "375a56f7-d6c9-4e81-b5f0-09d41ca89efe", "testdisk.raw")
+    os.spawnl(os.P_WAIT, "/sbin/sgdisk", "sgdisk", "--new=1:2048:2560", "testdisk.raw")
+    os.spawnl(os.P_WAIT, "/sbin/sgdisk", "sgdisk", "--new=2:4096:4608", "testdisk.raw")
+    os.spawnl(os.P_WAIT, "/sbin/gdisk", "sgdisk", "-l", "testdisk.raw")
Signature · 1 line
2.14.1
#14 lore raw

PATCH 1/2 GPT: create block device for sandbox testing

Quoted 6 lines · On 10 September 2017 at 00:47, <[email protected]> wrote:

From: Alison Chaiken <[email protected]>

Provide a Python function that creates a small block device for the purpose of testing the cmd/gpt.c or cmd/part.c functions in the u-boot sandbox.

Quoted 6 lines
---
 board/sandbox/README.sandbox |  5 +++++
 test/py/make_test_disk.py    | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100755 test/py/make_test_disk.py

I wonder whether the 'testdisk.raw' filename could be returned by this function so callers do not have to know it?

#15 lore raw

PATCH 1/2 GPT: create block device for sandbox testing

In reply to alison at peloton-tech.com
Quoted 8 lines · alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

Provide a Python function that creates a small block device for the purpose of testing the cmd/gpt.c or cmd/part.c functions in the u-boot sandbox.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170915/7dcbe4b1/attachment.sig>
#16 lore raw

PATCH 2/2 add pytests for 'gpt guid' command in sandbox

In reply to alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

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.

---
 test/py/tests/test_gpt.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 test/py/tests/test_gpt.py
test/py/tests/test_gpt.py new file +38 -0
new file mode 100644
index 0000000000..73f5c50f6c
@@ -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.
+"""
+
+ 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')
+    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
+
+ 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 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')
Signature · 1 line
2.14.1
#17 lore raw

PATCH 2/2 add pytests for 'gpt guid' command in sandbox

Quoted 11 lines · On 10 September 2017 at 00:47, <[email protected]> wrote:

From: Alison Chaiken <[email protected]>

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.

---
 test/py/tests/test_gpt.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 test/py/tests/test_gpt.py
#18 lore raw

PATCH 2/2 add pytests for 'gpt guid' command in sandbox

In reply to alison at peloton-tech.com
Quoted 8 lines · alison at peloton-tech.com

From: Alison Chaiken <[email protected]>

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170915/041ba197/attachment.sig>