[PATCH 2/2] iotests: Set LC_ALL=C for sort

Max Reitz posted 2 patches 5 years, 5 months ago
[PATCH 2/2] iotests: Set LC_ALL=C for sort
Posted by Max Reitz 5 years, 5 months ago
Otherwise the result is basically unpredictable.

(Note that the precise environment variable to control sorting order is
LC_COLLATE, but LC_ALL overrides LC_COLLATE, and we do not want the
sorting order to be messed up if LC_ALL is set in the environment.)

Reported-by: John Snow <jsnow@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/common.filter | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 345c3ca03e..4fd5c29b2a 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -177,7 +177,7 @@ _do_filter_img_create()
             -e 's/^\(data_file\)/3-\1/' \
             -e 's/^\(encryption\)/4-\1/' \
             -e 's/^\(preallocation\)/8-\1/' \
-        | sort \
+        | LC_ALL=C sort \
         | $SED -e 's/^[0-9]-//' \
         | tr '\n\0' ' \n' \
         | $SED -e 's/^ *$//' -e 's/ *$//'
-- 
2.26.2


Re: [PATCH 2/2] iotests: Set LC_ALL=C for sort
Posted by Alex Bennée 5 years, 5 months ago
Max Reitz <mreitz@redhat.com> writes:

> Otherwise the result is basically unpredictable.
>
> (Note that the precise environment variable to control sorting order is
> LC_COLLATE, but LC_ALL overrides LC_COLLATE, and we do not want the
> sorting order to be messed up if LC_ALL is set in the environment.)
>
> Reported-by: John Snow <jsnow@redhat.com>
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Queued to pr/100720-testing-and-misc-2, thanks.

I've skipped patch 1/2 for now as I have an alternative fix but we can
switch it back if you prefer?


> ---
>  tests/qemu-iotests/common.filter | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> index 345c3ca03e..4fd5c29b2a 100644
> --- a/tests/qemu-iotests/common.filter
> +++ b/tests/qemu-iotests/common.filter
> @@ -177,7 +177,7 @@ _do_filter_img_create()
>              -e 's/^\(data_file\)/3-\1/' \
>              -e 's/^\(encryption\)/4-\1/' \
>              -e 's/^\(preallocation\)/8-\1/' \
> -        | sort \
> +        | LC_ALL=C sort \
>          | $SED -e 's/^[0-9]-//' \
>          | tr '\n\0' ' \n' \
>          | $SED -e 's/^ *$//' -e 's/ *$//'


-- 
Alex Bennée

Re: [PATCH 2/2] iotests: Set LC_ALL=C for sort
Posted by Max Reitz 5 years, 5 months ago
On 11.07.20 10:57, Alex Bennée wrote:
> 
> Max Reitz <mreitz@redhat.com> writes:
> 
>> Otherwise the result is basically unpredictable.
>>
>> (Note that the precise environment variable to control sorting order is
>> LC_COLLATE, but LC_ALL overrides LC_COLLATE, and we do not want the
>> sorting order to be messed up if LC_ALL is set in the environment.)
>>
>> Reported-by: John Snow <jsnow@redhat.com>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
> 
> Queued to pr/100720-testing-and-misc-2, thanks.
> 
> I've skipped patch 1/2 for now as I have an alternative fix but we can
> switch it back if you prefer?

I see you’ve sent your pull request already, so I’ll see whether I’ll
include 1/2 in some block pull request.  Maybe, maybe not.

Thanks for queuing 2/2, anyway. :)

Max

Re: [PATCH 2/2] iotests: Set LC_ALL=C for sort
Posted by Eric Blake 5 years, 5 months ago
On 7/10/20 11:32 AM, Max Reitz wrote:
> Otherwise the result is basically unpredictable.
> 
> (Note that the precise environment variable to control sorting order is
> LC_COLLATE, but LC_ALL overrides LC_COLLATE, and we do not want the
> sorting order to be messed up if LC_ALL is set in the environment.)

Yep, that logic is correct.

> 
> Reported-by: John Snow <jsnow@redhat.com>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>   tests/qemu-iotests/common.filter | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> index 345c3ca03e..4fd5c29b2a 100644
> --- a/tests/qemu-iotests/common.filter
> +++ b/tests/qemu-iotests/common.filter
> @@ -177,7 +177,7 @@ _do_filter_img_create()
>               -e 's/^\(data_file\)/3-\1/' \
>               -e 's/^\(encryption\)/4-\1/' \
>               -e 's/^\(preallocation\)/8-\1/' \
> -        | sort \
> +        | LC_ALL=C sort \
>           | $SED -e 's/^[0-9]-//' \
>           | tr '\n\0' ' \n' \
>           | $SED -e 's/^ *$//' -e 's/ *$//'
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org