improve check function
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 17 Dec 2014 07:58:02 +0000 (08:58 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 17 Dec 2014 07:58:02 +0000 (08:58 +0100)
lib/sata/test/common.py

index 69d0211bc51153841a64bd777f54d6969fb2d68a..243898068985ed2b99136571f783156ef64e7aa8 100644 (file)
@@ -1,4 +1,4 @@
-import random
+import random, copy
 
 from lib.sata.common import *
 
@@ -8,10 +8,16 @@ def seed_to_data(seed, random=True):
        else:
                return seed
 
-def check(ref, res):
-       if isinstance(ref, int):
-               return 0, 1, int(ref != res)
+def check(p1, p2):
+       p1 = copy.deepcopy(p1)
+       p2 = copy.deepcopy(p2)
+       if isinstance(p1, int):
+               return 0, 1, int(p1 != p2)
        else:
+               if len(p1) >= len(p2):
+                       ref, res = p1, p2
+               else:
+                       ref, res = p2, p1
                shift = 0
                while((ref[0] != res[0]) and (len(res)>1)):
                        res.pop(0)