[parted-devel] [PATCH 6/8] tests: t3310-flags.sh: Add test for mac table flags

Mike Fleetwood mike.fleetwood at googlemail.com
Tue Aug 16 19:42:40 UTC 2016


MAC partition table reserves partition 1 for the partition map
partition, so the created test partition will be number 2.  Adapt
accordingly.

Setting flags 'root' and 'swap' also sets the partition name to 'root'
and 'swap' respectively, so no longer match the partition name in
extract_flags().

Don't test lvm and raid flags as they fail to be cleared with a single
set off command.  See FIXME comment in the test for more details.
---
 tests/t3310-flags.sh |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh
index d20d6d4..7f1f65b 100644
--- a/tests/t3310-flags.sh
+++ b/tests/t3310-flags.sh
@@ -22,10 +22,11 @@ dev=dev-file
 
 extract_flags()
 {
-  perl -nle '/^1:2048s:4095s:2048s::(?:PTNNAME)?:(.+);$/ and print $1' "$@"
+  perl -nle '/^[^:]*:2048s:4095s:2048s::[^:]*:(.+);$/ and print $1' "$@"
 }
 
-for table_type in bsd gpt msdos; do
+for table_type in bsd gpt mac msdos; do
+  ptn_num=1
 
   # Get the full list of flags to be tested from each table types'
   # libparted/labels/*.c *_partition_is_flag_available() function.
@@ -36,6 +37,19 @@ for table_type in bsd gpt msdos; do
     gpt)   primary_or_name='PTNNAME'
            flags='raid lvm boot bios_grub hp-service msftres msftdata diag atvrecv hidden legacy_boot prep irst esp'
            ;;
+    mac)   primary_or_name='PTNNAME'
+           # FIXME: Setting root or swap flags also sets the partition
+           # name to root or swap respectively.  Probably intended
+           # behaviour.  Setting lvm or raid flags after root or swap
+           # takes clearing two goes to clear the lvm or raid flag.  Is
+           # this intended?  For now don't test lvm or raid flags as
+           # this test only tries to clear the flags once which causes
+           # this test to fail.
+           flags='boot root swap'
+           # MAC table has the partition map partition as the first
+           # partition so the created test partition will be number 2.
+           ptn_num=2
+           ;;
     msdos) primary_or_name='primary'
            flags='hidden boot raid lvm lba palo prep irst esp diag'
            ;;
@@ -52,7 +66,7 @@ for table_type in bsd gpt msdos; do
   for mode in on_only on_and_off ; do
     for flag in $flags; do
       # Turn on each flag, one at a time.
-      parted -m -s $dev set 1 $flag on unit s print > raw 2> err || fail=1
+      parted -m -s $dev set $ptn_num $flag on unit s print > raw 2> err || fail=1
       extract_flags raw > out
       grep -w "$flag" out \
         || { warn_ "$ME_: $table_type: flag '$flag' not turned on: $(cat out)"; fail=1; }
@@ -60,7 +74,7 @@ for table_type in bsd gpt msdos; do
 
       if test $mode = on_and_off; then
         # Turn it off
-        parted -m -s $dev set 1 $flag off unit s print > raw 2> err || fail=1
+        parted -m -s $dev set $ptn_num $flag off unit s print > raw 2> err || fail=1
         extract_flags raw > out
         grep -w "$flag" out \
           && { warn_ "$ME_: $table_type: flag '$flag' not turned off: $(cat out)"; fail=1; }
-- 
1.7.1




More information about the parted-devel mailing list