xref: /OK3568_Linux_fs/u-boot/test/py/make_test_disk.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1# Copyright (c) 2017 Alison Chaiken
2#
3# SPDX-License-Identifier: GPL-2.0
4#
5# Create a block device for testing of 'gpt' and 'part' commands.
6
7import os
8
9def makeDisk():
10    if (os.path.exists("testdisk.raw")):
11        os.remove("testdisk.raw")
12    fd = os.open("testdisk.raw", os.O_RDWR|os.O_CREAT )
13    os.ftruncate(fd, 4194304)
14    os.close(fd)
15    os.spawnl(os.P_WAIT, "/sbin/sgdisk", "sgdisk", "-U",
16          "375a56f7-d6c9-4e81-b5f0-09d41ca89efe", "testdisk.raw")
17    os.spawnl(os.P_WAIT, "/sbin/sgdisk", "sgdisk", "--new=1:2048:2560", "testdisk.raw")
18    os.spawnl(os.P_WAIT, "/sbin/sgdisk", "sgdisk", "--new=2:4096:4608", "testdisk.raw")
19    os.spawnl(os.P_WAIT, "/sbin/gdisk", "sgdisk", "-l", "testdisk.raw")
20