[CRIU] [RFC PATCHv2 04/32] zdtm: zdtm.py: implement exhaustive group generation (still subject to test compatibility screening)

Ivan Shapovalov intelfx at intelfx.name
Sat Mar 12 00:42:03 PST 2016


Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
 test/zdtm.py | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index d84e1cc..c3f900a 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -18,6 +18,7 @@ import imp
 import socket
 import fcntl
 import errno
+import itertools
 
 os.chdir(os.path.dirname(os.path.abspath(__file__)))
 
@@ -1331,25 +1332,37 @@ def group_tests(opts):
 	random.shuffle(tlist)
 	if opts['exclude']:
 		excl = re.compile(".*(" + "|".join(opts['exclude']) + ")")
+		tlist = filter(lambda t: not excl.match(t), tlist)
 		print "Compiled exclusion list"
 
-	for t in tlist:
-		if excl and excl.match(t):
-			continue
+	tdlist = itertools.imap(get_test_desc, tlist)
 
-		td = get_test_desc(t)
-
-		for g in pend_groups:
-			if g.merge(t, td):
-				if g.size() == maxs:
-					pend_groups.remove(g)
-					groups.append(g)
-				break
-		else:
+	if opts['exhaustive']:
+		for tgroup in itertools.combinations(zip(tlist, tdlist), maxs):
+			t, td = tgroup[0]
 			g = group(t, td)
-			pend_groups.append(g)
+			for t, td in tgroup[1:]:
+				# because we are enumerating all combinations,
+				# we skip the whole combination on incompatibility
+				# (i. e. we do not allow short groups).
+				if not g.merge(t, td):
+					break
+			else:
+				groups.append(g)
 
-	groups += pend_groups
+	else:
+		for t, td in zip(tlist, tdlist):
+			for g in pend_groups:
+				if g.merge(t, td):
+					if g.size() == maxs:
+						pend_groups.remove(g)
+						groups.append(g)
+					break
+			else:
+				g = group(t, td)
+				pend_groups.append(g)
+
+		groups += pend_groups
 
 	nr = 0
 	suf = opts['name'] or 'group'
@@ -1442,6 +1455,7 @@ gp.set_defaults(action = group_tests)
 gp.add_argument("-m", "--max-size", help = "Maximum number of tests in group")
 gp.add_argument("-n", "--name", help = "Common name for group tests")
 gp.add_argument("-x", "--exclude", help = "Exclude tests from --all run", action = 'append')
+gp.add_argument("--exhaustive", help = "Generate groups for all possible combinations of tests", action = 'store_true')
 
 cp = sp.add_parser("clean", help = "Clean something")
 cp.set_defaults(action = clean_stuff)
-- 
2.7.2



More information about the CRIU mailing list