From patchwork Sun Sep 10 06:47:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Chaiken X-Patchwork-Id: 812040 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqhTR2Vhwz9sQl for ; Sun, 10 Sep 2017 16:48:11 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0C1F3C21E97; Sun, 10 Sep 2017 06:47:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E6F0CC21E54; Sun, 10 Sep 2017 06:47:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 61046C21EA8; Sun, 10 Sep 2017 06:47:26 +0000 (UTC) Received: from bonnet.exerciseforthereader.org (173-228-89-192.dsl.static.fusionbroadband.com [173.228.89.192]) by lists.denx.de (Postfix) with ESMTP id 3F6F8C21D65 for ; Sun, 10 Sep 2017 06:47:20 +0000 (UTC) Received: by bonnet.exerciseforthereader.org (Postfix, from userid 1000) id A5B1F5F787; Sat, 9 Sep 2017 23:47:18 -0700 (PDT) From: alison@peloton-tech.com To: u-boot@lists.denx.de Date: Sat, 9 Sep 2017 23:47:12 -0700 Message-Id: <20170910064713.31511-2-alison@peloton-tech.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170910064713.31511-1-alison@peloton-tech.com> References: <20170910064713.31511-1-alison@peloton-tech.com> Cc: alison@peloton-tech.com, alison@she-devel.com Subject: [U-Boot] [PATCH 1/2] GPT: create block device for sandbox testing X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Alison Chaiken 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 Reviewed-by: Simon Glass --- 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")