All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing
@ 2017-09-03  0:18 alison at peloton-tech.com
  2017-09-03  0:18 ` [U-Boot] [PATCH 2/3] add pytest for 'gpt guid' command in sandbox alison at peloton-tech.com
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-03  0:18 UTC (permalink / raw)
  To: u-boot

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

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.

Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
---
 test/gpt/make-test-disk.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100755 test/gpt/make-test-disk.sh

diff --git a/test/gpt/make-test-disk.sh b/test/gpt/make-test-disk.sh
new file mode 100755
index 0000000..022acba
--- /dev/null
+++ b/test/gpt/make-test-disk.sh
@@ -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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 2/3] add pytest for 'gpt guid' command in sandbox
  2017-09-03  0:18 [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing alison at peloton-tech.com
@ 2017-09-03  0:18 ` alison at peloton-tech.com
  2017-09-03  0:18 ` [U-Boot] [PATCH 3/3] add pytests for 'gpt rename' and 'gpt swap' alison at peloton-tech.com
  2017-09-05  8:55 ` [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing Simon Glass
  2 siblings, 0 replies; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-03  0:18 UTC (permalink / raw)
  To: u-boot

From: Alison Chaiken <alison@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@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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 3/3] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-03  0:18 [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing alison at peloton-tech.com
  2017-09-03  0:18 ` [U-Boot] [PATCH 2/3] add pytest for 'gpt guid' command in sandbox alison at peloton-tech.com
@ 2017-09-03  0:18 ` alison at peloton-tech.com
  2017-09-05  8:55   ` Simon Glass
  2017-09-05  8:55 ` [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing Simon Glass
  2 siblings, 1 reply; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-03  0:18 UTC (permalink / raw)
  To: u-boot

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

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.

Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
---
 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

diff --git a/configs/sandbox_gpt_rename_defconfig b/configs/sandbox_gpt_rename_defconfig
new file mode 100644
index 0000000..e7a61bd
--- /dev/null
+++ b/configs/sandbox_gpt_rename_defconfig
@@ -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
diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py
index 2201f39..7d8603a 100644
--- a/test/py/tests/test_gpt.py
+++ b/test/py/tests/test_gpt.py
@@ -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')
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing
  2017-09-03  0:18 [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing alison at peloton-tech.com
  2017-09-03  0:18 ` [U-Boot] [PATCH 2/3] add pytest for 'gpt guid' command in sandbox alison at peloton-tech.com
  2017-09-03  0:18 ` [U-Boot] [PATCH 3/3] add pytests for 'gpt rename' and 'gpt swap' alison at peloton-tech.com
@ 2017-09-05  8:55 ` Simon Glass
  2017-09-10  6:47   ` [U-Boot] [PATCH 0/2] GPT: create block device for guid testing alison at peloton-tech.com
  2 siblings, 1 reply; 19+ messages in thread
From: Simon Glass @ 2017-09-05  8:55 UTC (permalink / raw)
  To: u-boot

Hi Alison,

On 3 September 2017 at 08:18,  <alison@peloton-tech.com> wrote:
> From: Alison Chaiken <alison@peloton-tech.com>
>
> 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.
>
> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
> ---
>  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.

> diff --git a/test/gpt/make-test-disk.sh b/test/gpt/make-test-disk.sh
> new file mode 100755
> index 0000000..022acba
> --- /dev/null
> +++ b/test/gpt/make-test-disk.sh
> @@ -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
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 3/3] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-03  0:18 ` [U-Boot] [PATCH 3/3] add pytests for 'gpt rename' and 'gpt swap' alison at peloton-tech.com
@ 2017-09-05  8:55   ` Simon Glass
  2017-09-10  6:54     ` [U-Boot] [PATCH v2 1/3] " alison at peloton-tech.com
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Glass @ 2017-09-05  8:55 UTC (permalink / raw)
  To: u-boot

Hi Alison,

On 3 September 2017 at 08:18,  <alison@peloton-tech.com> wrote:
> From: Alison Chaiken <alison@peloton-tech.com>
>
> 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.
>
> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 0/2] GPT: create block device for guid testing
  2017-09-05  8:55 ` [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing Simon Glass
@ 2017-09-10  6:47   ` alison at peloton-tech.com
  2017-09-10  6:47     ` [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing alison at peloton-tech.com
  2017-09-10  6:47     ` [U-Boot] [PATCH 2/2] add pytests for 'gpt guid' command in sandbox alison at peloton-tech.com
  0 siblings, 2 replies; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-10  6:47 UTC (permalink / raw)
  To: u-boot

From: Alison Chaiken <alison@she-devel.com>

Simon Glass <sjg@chromium.org> asked:
> 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

-- 
2.14.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing
  2017-09-10  6:47   ` [U-Boot] [PATCH 0/2] GPT: create block device for guid testing alison at peloton-tech.com
@ 2017-09-10  6:47     ` alison at peloton-tech.com
  2017-09-12 12:29       ` Simon Glass
  2017-09-15 12:23       ` [U-Boot] [U-Boot, " Tom Rini
  2017-09-10  6:47     ` [U-Boot] [PATCH 2/2] add pytests for 'gpt guid' command in sandbox alison at peloton-tech.com
  1 sibling, 2 replies; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-10  6:47 UTC (permalink / raw)
  To: u-boot

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

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.

Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
---
 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

diff --git a/board/sandbox/README.sandbox b/board/sandbox/README.sandbox
index 9dc2eb09d1..947241e3eb 100644
--- a/board/sandbox/README.sandbox
+++ b/board/sandbox/README.sandbox
@@ -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
 -----------------------
diff --git a/test/py/make_test_disk.py b/test/py/make_test_disk.py
new file mode 100755
index 0000000000..5288295588
--- /dev/null
+++ b/test/py/make_test_disk.py
@@ -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")
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 2/2] add pytests for 'gpt guid' command in sandbox
  2017-09-10  6:47   ` [U-Boot] [PATCH 0/2] GPT: create block device for guid testing alison at peloton-tech.com
  2017-09-10  6:47     ` [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing alison at peloton-tech.com
@ 2017-09-10  6:47     ` alison at peloton-tech.com
  2017-09-12 12:29       ` Simon Glass
  2017-09-15 12:28       ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 2 replies; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-10  6:47 UTC (permalink / raw)
  To: u-boot

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

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>
---
 test/py/tests/test_gpt.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 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 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.
+"""
+
+ 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')
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 1/3] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-05  8:55   ` Simon Glass
@ 2017-09-10  6:54     ` alison at peloton-tech.com
  2017-09-10  6:54       ` [U-Boot] [PATCH 1/1] " alison at peloton-tech.com
  0 siblings, 1 reply; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-10  6:54 UTC (permalink / raw)
  To: u-boot

From: Alison Chaiken <alison@she-devel.com>

On Tue, Sep 5, 2017 at 1:55 AM, Simon Glass <sjg@chromium.org> wrote:
> 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(+)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 1/1] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-10  6:54     ` [U-Boot] [PATCH v2 1/3] " alison at peloton-tech.com
@ 2017-09-10  6:54       ` alison at peloton-tech.com
  2017-09-12 12:29         ` Simon Glass
  2017-09-15 12:29         ` [U-Boot] [U-Boot, " Tom Rini
  0 siblings, 2 replies; 19+ messages in thread
From: alison at peloton-tech.com @ 2017-09-10  6:54 UTC (permalink / raw)
  To: u-boot

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

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.

Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
---
 configs/sandbox_defconfig |  1 +
 test/py/tests/test_gpt.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 4c4e4809be..e7a61bd61a 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -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
diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py
index 73f5c50f6c..06f24b66ce 100644
--- a/test/py/tests/test_gpt.py
+++ b/test/py/tests/test_gpt.py
@@ -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')
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing
  2017-09-10  6:47     ` [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing alison at peloton-tech.com
@ 2017-09-12 12:29       ` Simon Glass
  2017-09-15 12:23       ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Simon Glass @ 2017-09-12 12:29 UTC (permalink / raw)
  To: u-boot

On 10 September 2017 at 00:47,  <alison@peloton-tech.com> wrote:
> From: Alison Chaiken <alison@peloton-tech.com>
>
> 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.
>
> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
> ---
>  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

Reviewed-by: Simon Glass <sjg@chromium.org>

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 2/2] add pytests for 'gpt guid' command in sandbox
  2017-09-10  6:47     ` [U-Boot] [PATCH 2/2] add pytests for 'gpt guid' command in sandbox alison at peloton-tech.com
@ 2017-09-12 12:29       ` Simon Glass
  2017-09-15 12:28       ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Simon Glass @ 2017-09-12 12:29 UTC (permalink / raw)
  To: u-boot

On 10 September 2017 at 00:47,  <alison@peloton-tech.com> wrote:
> From: Alison Chaiken <alison@peloton-tech.com>
>
> 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>
> ---
>  test/py/tests/test_gpt.py | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>  create mode 100644 test/py/tests/test_gpt.py

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH 1/1] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-10  6:54       ` [U-Boot] [PATCH 1/1] " alison at peloton-tech.com
@ 2017-09-12 12:29         ` Simon Glass
  2017-09-15 12:29         ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Simon Glass @ 2017-09-12 12:29 UTC (permalink / raw)
  To: u-boot

On 10 September 2017 at 00:54,  <alison@peloton-tech.com> wrote:
> From: Alison Chaiken <alison@peloton-tech.com>
>
> 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.
>
> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
> ---
>  configs/sandbox_defconfig |  1 +
>  test/py/tests/test_gpt.py | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, 1/2] GPT: create block device for sandbox testing
  2017-09-10  6:47     ` [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing alison at peloton-tech.com
  2017-09-12 12:29       ` Simon Glass
@ 2017-09-15 12:23       ` Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Tom Rini @ 2017-09-15 12:23 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 09, 2017 at 11:47:12PM -0700, alison at peloton-tech.com wrote:

> From: Alison Chaiken <alison@peloton-tech.com>
> 
> 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.
> 
> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, 2/2] add pytests for 'gpt guid' command in sandbox
  2017-09-10  6:47     ` [U-Boot] [PATCH 2/2] add pytests for 'gpt guid' command in sandbox alison at peloton-tech.com
  2017-09-12 12:29       ` Simon Glass
@ 2017-09-15 12:28       ` Tom Rini
  1 sibling, 0 replies; 19+ messages in thread
From: Tom Rini @ 2017-09-15 12:28 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 09, 2017 at 11:47:13PM -0700, alison at peloton-tech.com wrote:

> From: Alison Chaiken <alison@peloton-tech.com>
> 
> 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>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, 1/1] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-10  6:54       ` [U-Boot] [PATCH 1/1] " alison at peloton-tech.com
  2017-09-12 12:29         ` Simon Glass
@ 2017-09-15 12:29         ` Tom Rini
  2017-09-15 15:40           ` Stephen Warren
  1 sibling, 1 reply; 19+ messages in thread
From: Tom Rini @ 2017-09-15 12:29 UTC (permalink / raw)
  To: u-boot

On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison at peloton-tech.com wrote:

> From: Alison Chaiken <alison@peloton-tech.com>
> 
> 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.
> 
> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, 1/1] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-15 12:29         ` [U-Boot] [U-Boot, " Tom Rini
@ 2017-09-15 15:40           ` Stephen Warren
  2017-09-15 16:16             ` Tom Rini
  0 siblings, 1 reply; 19+ messages in thread
From: Stephen Warren @ 2017-09-15 15:40 UTC (permalink / raw)
  To: u-boot

On 09/15/2017 06:29 AM, Tom Rini wrote:
> On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison at peloton-tech.com wrote:
>> From: Alison Chaiken <alison@peloton-tech.com>
>>
>> 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.
>>
>> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> 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')
 >       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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, 1/1] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-15 15:40           ` Stephen Warren
@ 2017-09-15 16:16             ` Tom Rini
  2017-09-15 16:29               ` Stephen Warren
  0 siblings, 1 reply; 19+ messages in thread
From: Tom Rini @ 2017-09-15 16:16 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 15, 2017 at 09:40:29AM -0600, Stephen Warren wrote:
> On 09/15/2017 06:29 AM, Tom Rini wrote:
> >On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison at peloton-tech.com wrote:
> >>From: Alison Chaiken <alison@peloton-tech.com>
> >>
> >>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.
> >>
> >>Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
> >>Reviewed-by: Simon Glass <sjg@chromium.org>
> >
> >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')
> >       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.

-- 
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>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, 1/1] add pytests for 'gpt rename' and 'gpt swap'
  2017-09-15 16:16             ` Tom Rini
@ 2017-09-15 16:29               ` Stephen Warren
  0 siblings, 0 replies; 19+ messages in thread
From: Stephen Warren @ 2017-09-15 16:29 UTC (permalink / raw)
  To: u-boot

On 09/15/2017 10:16 AM, Tom Rini wrote:
> On Fri, Sep 15, 2017 at 09:40:29AM -0600, Stephen Warren wrote:
>> On 09/15/2017 06:29 AM, Tom Rini wrote:
>>> On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison at peloton-tech.com wrote:
>>>> From: Alison Chaiken <alison@peloton-tech.com>
>>>>
>>>> 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.
>>>>
>>>> Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>
>>> 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')
>>>        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.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-09-15 16:29 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-03  0:18 [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing alison at peloton-tech.com
2017-09-03  0:18 ` [U-Boot] [PATCH 2/3] add pytest for 'gpt guid' command in sandbox alison at peloton-tech.com
2017-09-03  0:18 ` [U-Boot] [PATCH 3/3] add pytests for 'gpt rename' and 'gpt swap' alison at peloton-tech.com
2017-09-05  8:55   ` Simon Glass
2017-09-10  6:54     ` [U-Boot] [PATCH v2 1/3] " alison at peloton-tech.com
2017-09-10  6:54       ` [U-Boot] [PATCH 1/1] " alison at peloton-tech.com
2017-09-12 12:29         ` Simon Glass
2017-09-15 12:29         ` [U-Boot] [U-Boot, " Tom Rini
2017-09-15 15:40           ` Stephen Warren
2017-09-15 16:16             ` Tom Rini
2017-09-15 16:29               ` Stephen Warren
2017-09-05  8:55 ` [U-Boot] [PATCH 1/3] GPT: create block device for sandbox testing Simon Glass
2017-09-10  6:47   ` [U-Boot] [PATCH 0/2] GPT: create block device for guid testing alison at peloton-tech.com
2017-09-10  6:47     ` [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing alison at peloton-tech.com
2017-09-12 12:29       ` Simon Glass
2017-09-15 12:23       ` [U-Boot] [U-Boot, " Tom Rini
2017-09-10  6:47     ` [U-Boot] [PATCH 2/2] add pytests for 'gpt guid' command in sandbox alison at peloton-tech.com
2017-09-12 12:29       ` Simon Glass
2017-09-15 12:28       ` [U-Boot] [U-Boot, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.