a248769
From 42c1964bdc2311ec142453cf43a8737da81b2f0d Mon Sep 17 00:00:00 2001
a248769
From: Jim Meyering <meyering@redhat.com>
a248769
Date: Wed, 12 Sep 2012 10:43:17 +0200
0b7af91
Subject: [PATCH 25/89] tests: show that small dev now evokes "mklabel gpt"
a248769
 diagnostic
a248769
a248769
* tests/t0203-gpt-create-on-min-sized-device.sh: New test.
a248769
* tests/Makefile.am (TESTS): Add it.
a248769
---
a248769
 tests/Makefile.am                             |  1 +
a248769
 tests/t0203-gpt-create-on-min-sized-device.sh | 47 +++++++++++++++++++++++++++
a248769
 2 files changed, 48 insertions(+)
a248769
 create mode 100644 tests/t0203-gpt-create-on-min-sized-device.sh
a248769
a248769
diff --git a/tests/Makefile.am b/tests/Makefile.am
a248769
index c97400b..66b9361 100644
a248769
--- a/tests/Makefile.am
a248769
+++ b/tests/Makefile.am
a248769
@@ -16,6 +16,7 @@ TESTS = \
a248769
   t0202-gpt-pmbr.sh \
a248769
   t0203-gpt-tiny-device-abort.sh \
a248769
   t0203-gpt-shortened-device-primary-valid.sh \
a248769
+  t0203-gpt-create-on-min-sized-device.sh \
a248769
   t0205-gpt-list-clobbers-pmbr.sh \
a248769
   t0206-gpt-print-with-corrupt-primary-clobbers-pmbr.sh \
a248769
   t0207-IEC-binary-notation.sh \
a248769
diff --git a/tests/t0203-gpt-create-on-min-sized-device.sh b/tests/t0203-gpt-create-on-min-sized-device.sh
a248769
new file mode 100644
a248769
index 0000000..113e191
a248769
--- /dev/null
a248769
+++ b/tests/t0203-gpt-create-on-min-sized-device.sh
a248769
@@ -0,0 +1,47 @@
a248769
+#!/bin/sh
a248769
+# parted 3.1 and prior would exit with no diagnostic when failing
a248769
+# to create a GPT partition table on a device that was too small.
a248769
+
a248769
+# Copyright (C) 2012 Free Software Foundation, Inc.
a248769
+
a248769
+# This program is free software; you can redistribute it and/or modify
a248769
+# it under the terms of the GNU General Public License as published by
a248769
+# the Free Software Foundation; either version 3 of the License, or
a248769
+# (at your option) any later version.
a248769
+
a248769
+# This program is distributed in the hope that it will be useful,
a248769
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
a248769
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a248769
+# GNU General Public License for more details.
a248769
+
a248769
+# You should have received a copy of the GNU General Public License
a248769
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
a248769
+
a248769
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
a248769
+require_512_byte_sector_size_
a248769
+
a248769
+dev=loop-file
a248769
+ss=$sector_size_
a248769
+
a248769
+# Create the smallest file that can accommodate a GPT partition table.
a248769
+dd if=/dev/null of=$dev bs=$ss seek=67 || framework_failure
a248769
+
a248769
+# create a GPT partition table
a248769
+parted -s $dev mklabel gpt > out 2>&1 || fail=1
a248769
+# expect no output
a248769
+compare /dev/null out || fail=1
a248769
+
a248769
+# Create a file that is 1 sector smaller, and require failure,
a248769
+# *with* a diagnostic.
a248769
+rm -f $dev
a248769
+dd if=/dev/null of=$dev bs=$ss seek=66 || framework_failure
a248769
+
a248769
+echo Error: device is so small it cannot even accommodate GPT headers \
a248769
+  > exp || framework_failure
a248769
+
a248769
+# Try to create a GPT partition table in too little space.  This must fail.
a248769
+parted -s $dev mklabel gpt > out 2>&1 && fail=1
a248769
+# There must be a diagnostic.
a248769
+compare out exp || fail=1
a248769
+
a248769
+Exit $fail
a248769
-- 
0b7af91
1.8.5.3
a248769