]> git.sur5r.net Git - u-boot/commitdiff
GPT: create block device for sandbox testing
authorAlison Chaiken <alison@peloton-tech.com>
Sun, 10 Sep 2017 06:47:12 +0000 (23:47 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 15 Sep 2017 01:32:57 +0000 (21:32 -0400)
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>
board/sandbox/README.sandbox
test/py/make_test_disk.py [new file with mode: 0755]

index 2e2c8193843e23f20a00f15723525f14526f35cc..9bc13e142bdce30acc45cc247ed448829deaff56 100644 (file)
@@ -337,6 +337,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 (executable)
index 0000000..5288295
--- /dev/null
@@ -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")