summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlison Chaiken <alison@peloton-tech.com>2017-09-09 23:47:12 -0700
committerTom Rini <trini@konsulko.com>2017-09-14 21:32:57 -0400
commitbf6d76b84ae13b463c0dca556118047e2d046f33 (patch)
treed5430256e83c440f81567773e7ee18897716fea7 /test
parent2f9455c8499345dcfa7553b4c1fd34e619be3ece (diff)
GPT: create block device for sandbox testing
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>
Diffstat (limited to 'test')
-rwxr-xr-xtest/py/make_test_disk.py19
1 files changed, 19 insertions, 0 deletions
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")