[parted-devel] [PATCH 1/8] tests: t3310-flags.sh: List all the flags to be tested
Mike Fleetwood
mike.fleetwood at googlemail.com
Tue Aug 16 19:42:35 UTC 2016
Replace scanning the documentation for an incomplete list of flags with
an explicit list of all the available flags pulled from the source code.
Correct $ME -> $ME_ in the warning messages. Improve the warning
messages by including the table type and flag name not correctly set or
cleared.
Plus minor changes:
(1) use slightly longer variable name primary_or_name;
(2) use longer test partition name PTNNAME; and
(3) stop shortening parted unit command to u.
---
tests/t3310-flags.sh | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh
index cb3024a..368ec13 100644
--- a/tests/t3310-flags.sh
+++ b/tests/t3310-flags.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Exercise the exclusive, single-bit flags.
+# Exercise partition flags.
# Copyright (C) 2010-2014 Free Software Foundation, Inc.
@@ -22,26 +22,27 @@ dev=dev-file
extract_flags()
{
- perl -nle '/^1:2048s:4095s:2048s::(?:P1)?:(.+);$/ and print $1' "$@"
+ perl -nle '/^1:2048s:4095s:2048s::(?:PTNNAME)?:(.+);$/ and print $1' "$@"
}
for table_type in msdos gpt; do
- # Extract flag names of type $table_type from the texinfo documentation.
+ # Get the full list of flags to be tested from each table types'
+ # libparted/labels/*.c *_partition_is_flag_available() function.
case $table_type in
- msdos) search_term=MS-DOS; pri_or_name=pri;;
- gpt) search_term=GPT; pri_or_name=P1;;
+ gpt) primary_or_name='PTNNAME'
+ flags='raid lvm boot bios_grub hp-service msftres msftdata diag atvrecv hidden legacy_boot prep irst esp'
+ ;;
+ msdos) primary_or_name='primary'
+ flags='hidden boot raid lvm lba palo prep irst esp diag'
+ ;;
esac
- flags=$(sed -n '/^@node set/,/^@node/p' \
- "$abs_top_srcdir/doc/parted.texi" \
- | perl -00 -ne \
- '/^\@item (\w+).*'"$search_term"'/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 $table_type \
- mkpart $pri_or_name ext2 $((1*2048))s $((2*2048-1))s \
+ mkpart $primary_or_name ext2 $((1*2048))s $((2*2048-1))s \
> out 2> err || fail=1
compare /dev/null out || fail=1
@@ -53,18 +54,18 @@ for table_type in msdos gpt; do
case $flag in boot|lba|hidden) continue;; esac
# Turn on each flag, one at a time.
- parted -m -s $dev set 1 $flag on u s print > raw 2> err || fail=1
+ parted -m -s $dev set 1 $flag on unit s print > raw 2> err || fail=1
extract_flags raw > out
grep -F "$flag" out \
- || { warn_ "$ME: flag not turned on: $(cat out)"; fail=1; }
+ || { warn_ "$ME_: $table_type: flag '$flag' not turned on: $(cat out)"; fail=1; }
compare /dev/null err || fail=1
if test $mode = on_and_off; then
# Turn it off
- parted -m -s $dev set 1 $flag off u s print > raw 2> err || fail=1
+ parted -m -s $dev set 1 $flag off unit s print > raw 2> err || fail=1
extract_flags raw > out
grep -F "$flag" out \
- && { warn_ "$ME: flag not turned off: $(cat out)"; fail=1; }
+ && { warn_ "$ME_: $table_type: flag '$flag' not turned off: $(cat out)"; fail=1; }
compare /dev/null err || fail=1
fi
done
--
1.7.1
More information about the parted-devel
mailing list