]> git.pld-linux.org Git - packages/parted.git/blob - 0050-tests-t3310-flags.sh-Add-test-for-mac-table-flags.patch
- rel 4; tons of patches from FC
[packages/parted.git] / 0050-tests-t3310-flags.sh-Add-test-for-mac-table-flags.patch
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
5
6 MAC partition table reserves partition 1 for the partition map
7 partition, so the created test partition will be number 2.  Adapt
8 accordingly.
9
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
12 extract_flags().
13
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.
16
17 Signed-off-by: Brian C. Lane <bcl@redhat.com>
18 ---
19  tests/print-flags.c  | 12 +++++++-----
20  tests/t3310-flags.sh | 27 ++++++++++++++++++++++-----
21  2 files changed, 29 insertions(+), 10 deletions(-)
22
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)
28         PedDevice *dev;
29         PedDisk *disk;
30         PedPartition *part;
31 +       int partnum;
32  
33         set_program_name (argv[0]);
34  
35 -       if (argc != 2 ) {
36 -               fprintf (stderr, "Usage: %s <device>\n", argv[0]);
37 +       if (argc != 3 ) {
38 +               fprintf (stderr, "Usage: %s <device> <ptnnum>\n", argv[0]);
39                 return EXIT_FAILURE;
40         }
41  
42 @@ -38,11 +39,12 @@ main (int argc, char **argv)
43                 return EXIT_FAILURE;
44         }
45  
46 -       part = ped_disk_get_partition (disk, 1);
47 +       partnum = atoi (argv[2]);
48 +       part = ped_disk_get_partition (disk, partnum);
49         if (!part) {
50                 fprintf (stderr,
51 -                        "Error: failed to get partition 1 from device %s\n",
52 -                        argv[1]);
53 +                        "Error: failed to get partition %d from device %s\n",
54 +                        partnum, argv[1]);
55                 return EXIT_FAILURE;
56         }
57  
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
63  
64  extract_flags()
65  {
66 -  perl -nle '/^1:2048s:4095s:2048s::(?:PTNNAME)?:(.+);$/ and print $1' "$@"
67 +  perl -nle '/^[^:]*:2048s:4095s:2048s::[^:]*:(.+);$/ and print $1' "$@"
68  }
69  
70 -for table_type in bsd gpt msdos; do
71 +for table_type in bsd gpt mac msdos; do
72 +  ptn_num=1
73  
74    case $table_type in
75      bsd)   primary_or_name=''
76             ;;
77      gpt)   primary_or_name='PTNNAME'
78             ;;
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.
82 +           ptn_num=2
83 +           ;;
84      msdos) primary_or_name='primary'
85             ;;
86    esac
87 @@ -45,14 +51,25 @@ for table_type in bsd gpt msdos; do
88    compare /dev/null out || fail=1
89  
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";
94           fail=1; continue; }
95 +  case $table_type in
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
102 +           # test to fail.
103 +           flags=`echo "$flags" | egrep -v 'lvm|raid'`
104 +           ;;
105 +  esac
106  
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
116  
117        if test $mode = on_and_off; then
118          # Turn it off
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; }
124 -- 
125 2.7.4
126
This page took 0.13635 seconds and 3 git commands to generate.