qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 08/14] iotests: prepare 124 and 257 bitmap q


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [Qemu-devel] [PATCH v10 08/14] iotests: prepare 124 and 257 bitmap querying for backup-top filter
Date: Mon, 9 Sep 2019 13:49:56 +0000

09.09.2019 16:25, Max Reitz wrote:
> On 30.08.19 18:12, Vladimir Sementsov-Ogievskiy wrote:
>> After backup-top filter appearing it's not possible to see dirty
>> bitmaps in top node, so use node-name instead.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
>> ---
>>   tests/qemu-iotests/124        |  83 ++++----
>>   tests/qemu-iotests/257        |  49 ++---
>>   tests/qemu-iotests/257.out    | 364 +++++++++++++---------------------
>>   tests/qemu-iotests/iotests.py |  27 +++
>>   4 files changed, 219 insertions(+), 304 deletions(-)
> 
> [...]
> 
>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
>> index 84438e837c..1906eb72f3 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -643,6 +643,33 @@ class VM(qtest.QEMUQtestMachine):
> 
> [...]
> 
>> +    def check_bitmap_status(self, node_name, bitmap_name, fields):
>> +        ret = self.get_bitmap(node_name, bitmap_name)
>> +
>> +        return fields.items() <= ret.items()
> 
> Why the <=?  AFAIU, it will compare each of the arrays’ elements one by
> one and return true if all of the ones in @fields are less than or equal
> to the ones in @ret.

No, it's a valid way to check that one dict is subdict of another,
as dict_view works like Set class:

$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> {1,2,3} <= {4,5,6}
False
 >>> {1,2,3} <= {0,3,2,1}
True
 >>> {'c':1, 'b':2}.items() <= {'a':4, 'b':2, 'c':1}.items()
True
 >>> {'c':1, 'b':2}.items() <= {'a':4, 'b':2, 'c':2}.items()
False
 >>> {'c':1, 'b':2}.items() <= {'a':4, 'b':2, 'c':0}.items()
False
 >>> {'c':1, 'b':2}.items() <= {'d':4, 'b':2}.items()
False
 >>> {'c':1, 'b':2}.items() <= {'c':1, 'b':3}.items()
False

Bad thing is that it's not so for python2, in which we need to use .viewitems() 
instead..

$ python2
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> {1,2,3} <= {0,3,2,1}
True
 >>> {'c':1, 'b':2}.items() <= {'a':4, 'b':2, 'c':1}.items()
False
 >>> {'c':1, 'b':2}.items() <= {'d':4, 'b':2}.items()
False
 >>>
 >>> {'c':1, 'b':2}.items() <= {'c':1, 'b':2}.items()
True
 >>> {'c':1, 'b':2}.items() <= {'c':1, 'b':3}.items()
True
 >>> {'c':1, 'b':2}.items() <= {'c':1, 'b':3}.items()
True

Should I care about python2 now, or we already dropped its support in iotests?

[and, honestly, I learned it all mostly from here 
https://stackoverflow.com/questions/30818694/test-if-dict-contained-in-dict]

> 
> But that would mean that the values given in @fields no longer need to
> be equal to the ones in @ret.  On top of that, I suppose if
> @fields.items() at some index contains a key that is not equal to the
> key in @ret.items() at the same index, luck will determine whether the
> comparison passes or not.
> 
> Why not just loop through all keys of @fields and check that @fields and
> @ret contain the same value for all of them?
> 
> Max
> 


-- 
Best regards,
Vladimir

reply via email to

[Prev in Thread] Current Thread [Next in Thread]