OSDN Git Service

tests: test 'parted print' with empty disk
authorPetr Uzel <petr.uzel@suse.cz>
Fri, 11 Mar 2011 12:50:01 +0000 (13:50 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 16 Mar 2011 17:25:45 +0000 (18:25 +0100)
* tests/t0101-print-empty.sh: New test.
* tests/Makefile.am: Add it.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
tests/Makefile.am
tests/t0101-print-empty.sh [new file with mode: 0755]

index feafbed..4f95429 100644 (file)
@@ -7,6 +7,7 @@ TESTS = \
   t0001-tiny.sh \
   t0010-script-no-ctrl-chars.sh \
   t0100-print.sh \
+  t0101-print-empty.sh \
   t0200-gpt.sh \
   t0201-gpt.sh \
   t0202-gpt-pmbr.sh \
diff --git a/tests/t0101-print-empty.sh b/tests/t0101-print-empty.sh
new file mode 100755 (executable)
index 0000000..3e77850
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+# test 'parted $dev print' on empty device (without label)
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+ss=$sector_size_
+
+ss=$sector_size_
+dev=loop-file
+
+{
+  cat <<EOF
+Error: .../$dev: unrecognised disk label
+Model:  (file)
+Disk .../$dev: 8s
+Sector size (logical/physical): ${ss}B/${ss}B
+Partition Table: unknown
+EOF
+} > exp || framework_failure
+
+# create 'empty' device
+dd if=/dev/zero of=$dev bs=$(expr 8 '*' $ss) count=1 >/dev/null 2>&1 || fail=1
+
+# print the empty table
+parted -s $dev unit s print >out 2>&1 || fail=1
+
+# prepare actual and expected output
+mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:,; \
+                  s,^Error: .*/$dev:,Error: .../$dev:," o2 > out || fail=1
+
+# check for expected output
+compare out exp || fail=1
+
+Exit $fail