bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: test all boolean flags


From: Jim Meyering
Subject: [PATCH] tests: test all boolean flags
Date: Wed, 28 Apr 2010 18:28:03 +0200

Here's a more thorough test of the MSDOS flags.
Hans, note that currently this would not test your new DIAG flag,
since there was no sentence for it in the texinfo documentation.
Would you care to add one?

>From 97961ee49e8461458a0667137550608c993904c6 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 21 Apr 2010 14:00:26 +0200
Subject: [PATCH] tests: test all boolean flags

* tests/t3310-flags.sh: New test, suggested by Hans De Goede.
* tests/Makefile.am (TESTS): Add it.
---
 tests/Makefile.am    |    1 +
 tests/t3310-flags.sh |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100644 tests/t3310-flags.sh

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6f7730d..2388ec3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -27,6 +27,7 @@ TESTS = \
   t3000-resize-fs.sh \
   t3200-type-change.sh \
   t3300-palo-prep.sh \
+  t3310-flags.sh \
   t4000-sun-raid-type.sh \
   t4001-sun-vtoc.sh \
   t4100-msdos-partition-limits.sh \
diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh
new file mode 100644
index 0000000..05d38ac
--- /dev/null
+++ b/tests/t3310-flags.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Exercise the exclusive, single-bit flags.
+
+# Copyright (C) 2010 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/>.
+
+if test "$VERBOSE" = yes; then
+  set -x
+  parted --version
+fi
+
+: ${srcdir=.}
+: ${abs_top_srcdir=$(cd .. && pwd)}
+. $srcdir/t-lib.sh
+ss=$sector_size_
+
+fail=0
+dev=dev-file
+
+# Extract all msdos flag names from the texinfo documentation.
+msdos_flags=$(sed -n '/address@hidden set/,/address@hidden/p' 
"$abs_top_srcdir/doc/parted.texi" \
+  | perl -00 -ne '/address@hidden (\w+).*MS-DOS/s and print lc($1), "\n"')
+
+n_sectors=5000
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+
+parted -s $dev mklabel msdos \
+  mkpart pri ext2 $((1*2048))s $((2*2048-1))s \
+    > out 2> err || fail=1
+compare out /dev/null || fail=1
+
+for mode in on_only on_and_off ; do
+  for flag in $msdos_flags; do
+
+    # Exclude the supplemental flags.
+    # These are not boolean, like the others.
+    case $flag in boot|lba|hidden) continue;; esac
+    echo $flag > exp || fail=1
+
+    # Turn on each flag, one at a time.
+    parted -m -s $dev set 1 $flag on u s print > raw 2> err || fail=1
+    perl -nle '/^1:2048s:4095s:2048s:::(\w+);$/ and print $1' raw > out
+    compare out exp || fail=1
+    compare err /dev/null || fail=1
+
+    if test $mode = on_and_off; then
+      # Turn it off
+      : > exp
+      parted -m -s $dev set 1 $flag off u s print > raw 2> err || fail=1
+      perl -nle '/^1:2048s:4095s:2048s:::.*;$/ and print $1' raw > out
+      compare err /dev/null || fail=1
+    fi
+  done
+done
+
+Exit $fail
--
1.7.1.328.g9993c




reply via email to

[Prev in Thread] Current Thread [Next in Thread]