1 From 81b397bbc9eb270ef0b3ed52d40c3a76ecd9ac80 Mon Sep 17 00:00:00 2001
2 From: Mike Fleetwood <mike.fleetwood@googlemail.com>
3 Date: Sat, 1 Oct 2016 16:40:21 +0100
4 Subject: [PATCH 50/53] tests: t3310-flags.sh: Add test for mac table flags
6 MAC partition table reserves partition 1 for the partition map
7 partition, so the created test partition will be number 2. Adapt
10 Setting flags 'root' and 'swap' also sets the partition name to 'root'
11 and 'swap' respectively, so no longer match the partition name in
14 Don't test lvm and raid flags as they fail to be cleared with a single
15 set off command. See FIXME comment in the test for more details.
17 Signed-off-by: Brian C. Lane <bcl@redhat.com>
19 tests/print-flags.c | 12 +++++++-----
20 tests/t3310-flags.sh | 27 ++++++++++++++++++++++-----
21 2 files changed, 29 insertions(+), 10 deletions(-)
23 diff --git a/tests/print-flags.c b/tests/print-flags.c
24 index 3176ca6..db088e8 100644
25 --- a/tests/print-flags.c
26 +++ b/tests/print-flags.c
27 @@ -12,11 +12,12 @@ main (int argc, char **argv)
33 set_program_name (argv[0]);
36 - fprintf (stderr, "Usage: %s <device>\n", argv[0]);
38 + fprintf (stderr, "Usage: %s <device> <ptnnum>\n", argv[0]);
42 @@ -38,11 +39,12 @@ main (int argc, char **argv)
46 - part = ped_disk_get_partition (disk, 1);
47 + partnum = atoi (argv[2]);
48 + part = ped_disk_get_partition (disk, partnum);
51 - "Error: failed to get partition 1 from device %s\n",
53 + "Error: failed to get partition %d from device %s\n",
58 diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh
59 index 3f80213..672160d 100644
60 --- a/tests/t3310-flags.sh
61 +++ b/tests/t3310-flags.sh
62 @@ -22,16 +22,22 @@ dev=dev-file
66 - perl -nle '/^1:2048s:4095s:2048s::(?:PTNNAME)?:(.+);$/ and print $1' "$@"
67 + perl -nle '/^[^:]*:2048s:4095s:2048s::[^:]*:(.+);$/ and print $1' "$@"
70 -for table_type in bsd gpt msdos; do
71 +for table_type in bsd gpt mac msdos; do
75 bsd) primary_or_name=''
77 gpt) primary_or_name='PTNNAME'
79 + mac) primary_or_name='PTNNAME'
80 + # MAC table has the partition map partition as the first
81 + # partition so the created test partition will be number 2.
84 msdos) primary_or_name='primary'
87 @@ -45,14 +51,25 @@ for table_type in bsd gpt msdos; do
88 compare /dev/null out || fail=1
90 # Query libparted for the available flags for this test partition.
91 - flags=`print-flags $dev` \
92 + flags=`print-flags $dev $ptn_num` \
93 || { warn_ "$ME_: $table_type: failed to get available flags";
96 + mac) # FIXME: Setting root or swap flags also sets the partition
97 + # name to root or swap respectively. Probably intended
98 + # behaviour. Setting lvm or raid flags after root or swap
99 + # takes two goes to clear the lvm or raid flag. Is this
100 + # intended? For now don't test lvm or raid flags as this
101 + # test only tries to clear the flags once which causes this
103 + flags=`echo "$flags" | egrep -v 'lvm|raid'`
107 for mode in on_only on_and_off ; do
108 for flag in $flags; do
109 # Turn on each flag, one at a time.
110 - parted -m -s $dev set 1 $flag on unit s print > raw 2> err || fail=1
111 + parted -m -s $dev set $ptn_num $flag on unit s print > raw 2> err || fail=1
112 extract_flags raw > out
113 grep -w "$flag" out \
114 || { warn_ "$ME_: $table_type: flag '$flag' not turned on: $(cat out)"; fail=1; }
115 @@ -60,7 +77,7 @@ for table_type in bsd gpt msdos; do
117 if test $mode = on_and_off; then
119 - parted -m -s $dev set 1 $flag off unit s print > raw 2> err || fail=1
120 + parted -m -s $dev set $ptn_num $flag off unit s print > raw 2> err || fail=1
121 extract_flags raw > out
122 grep -w "$flag" out \
123 && { warn_ "$ME_: $table_type: flag '$flag' not turned off: $(cat out)"; fail=1; }