Skip to contentSkip to conversation

test/py: gpt: make use of infra-structure

PATCH New Stephen Warren 2 participants 3 messages Sep 15, 2017 – Sep 22, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 test/py: gpt: make use of infra-structure

From: Stephen Warren <[email protected]>

Make various changes to the GPT test:

1) Reference the disk image using an absolute path in all cases. This allows test/py to operate correctly if it's run from a directory other than the root of the U-Boot source tree.

2) Store the disk image in the teswt/py persistent data directory. This removes the need to re-generate it every time the tests are run.

3) Execute sgdisk using u_boot_utils.run_and_log() so that its output is captured in the test log. This allows debugging any problems running it.

4) Make the disk image a test fixture. This removes the requirement to always run all GPT tests, and run them in order. The current code doesn't create the disk image if e.g. just test_gpt_uuid() is executed via the test.py -k command-line option.

5) Use @pytest.mark.buildconfigspec for all feature dependencies, rather than manually implementing some of them.

6) Make all tests depend on sandbox, since they use the sandbox-specific host command.

Fixes a2f422555fc8 ("add pytests for 'gpt guid' command in sandbox")
Fixes c5772188ede9 ("add pytests for 'gpt rename' and 'gpt swap'")

---
v2: Add dependency on sandbox.

---
 test/py/make_test_disk.py | 19 -----------
 test/py/tests/test_gpt.py | 87 +++++++++++++++++++++++++++++++++++------------
 2 files changed, 66 insertions(+), 40 deletions(-)
 delete mode 100755 test/py/make_test_disk.py
test/py/make_test_disk.py deleted +0 -19
deleted file mode 100755
index 5288295588a7..000000000000
@@ -1,19 +0,0 @@
-# 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")
test/py/tests/test_gpt.py +66 -21

131 lines not on this page · raw message

Signature · 1 line
2.14.1
#1 lore raw

PATCH v2 1/1 test/py: gpt: make use of infra-structure

Quoted 22 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Make various changes to the GPT test:

1) Reference the disk image using an absolute path in all cases. This allows test/py to operate correctly if it's run from a directory other than the root of the U-Boot source tree.

2) Store the disk image in the teswt/py persistent data directory. This removes the need to re-generate it every time the tests are run.

3) Execute sgdisk using u_boot_utils.run_and_log() so that its output is captured in the test log. This allows debugging any problems running it.

4) Make the disk image a test fixture. This removes the requirement to always run all GPT tests, and run them in order. The current code doesn't create the disk image if e.g. just test_gpt_uuid() is executed via the test.py -k command-line option.

5) Use @pytest.mark.buildconfigspec for all feature dependencies, rather than manually implementing some of them.

Quoted 6 lines

6) Make all tests depend on sandbox, since they use the sandbox-specific host command.

Fixes a2f422555fc8 ("add pytests for 'gpt guid' command in sandbox")
Fixes c5772188ede9 ("add pytests for 'gpt rename' and 'gpt swap'")
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/ac1c6b5e/attachment.sig>
#2 lore raw

PATCH v2 1/1 test/py: gpt: make use of infra-structure

In reply to Stephen Warren
Quoted 22 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Make various changes to the GPT test:

1) Reference the disk image using an absolute path in all cases. This allows test/py to operate correctly if it's run from a directory other than the root of the U-Boot source tree.

2) Store the disk image in the teswt/py persistent data directory. This removes the need to re-generate it every time the tests are run.

3) Execute sgdisk using u_boot_utils.run_and_log() so that its output is captured in the test log. This allows debugging any problems running it.

4) Make the disk image a test fixture. This removes the requirement to always run all GPT tests, and run them in order. The current code doesn't create the disk image if e.g. just test_gpt_uuid() is executed via the test.py -k command-line option.

5) Use @pytest.mark.buildconfigspec for all feature dependencies, rather than manually implementing some of them.

Quoted 7 lines

6) Make all tests depend on sandbox, since they use the sandbox-specific host command.

Fixes a2f422555fc8 ("add pytests for 'gpt guid' command in sandbox")
Fixes c5772188ede9 ("add pytests for 'gpt rename' and 'gpt swap'")

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/20170922/c277c89f/attachment.sig>