[parted-devel] [PATCH 1/8] tests: t3310-flags.sh: List all the flags to be tested

Mike Fleetwood mike.fleetwood at googlemail.com
Sat Oct 1 08:45:53 UTC 2016


On 30 September 2016 at 17:59, Brian C. Lane <bcl at redhat.com> wrote:
> On Tue, Aug 16, 2016 at 08:42:35PM +0100, Mike Fleetwood wrote:
>> 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"')
>
> I don't think this is an improvement -- now we have to maintain the
> flags here, in the code, and in the docs. If the docs are out of date
> then they should be fixed and/or pull the flags directly from the source
> somehow.

I don't think tests of the code should be depending on the docs for an
accurate list of flags the code provides.  I'll write a helper which
queries libparted for the available flags.

I'll provide patchset v2 when done.

Thanks,
Mike



More information about the parted-devel mailing list