13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# -*- coding: utf-8 -*- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry#------------------------------------------------------------------------- 43c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# drawElements Quality Program utilities 53c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# -------------------------------------- 63c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# 73c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# Copyright 2015 The Android Open Source Project 83c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# 93c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# Licensed under the Apache License, Version 2.0 (the "License"); 103c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# you may not use this file except in compliance with the License. 113c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# You may obtain a copy of the License at 123c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# 133c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# http://www.apache.org/licenses/LICENSE-2.0 143c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# 153c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# Unless required by applicable law or agreed to in writing, software 163c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# distributed under the License is distributed on an "AS IS" BASIS, 173c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# See the License for the specific language governing permissions and 193c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# limitations under the License. 203c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry# 213c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry#------------------------------------------------------------------------- 223c77ed4e119083afaec64a173bfdcf024c271635Jarkko Pöyry 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport sys 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport random 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport string 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport subprocess 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfrom optparse import OptionParser 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef all (results, predicate): 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for result in results: 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if not predicate(result): 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return False 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return True 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef any (results, predicate): 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for result in results: 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if predicate(result): 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return True 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return False 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FilterRule: 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry def __init__ (self, name, description, filters): 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry self.name = name 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry self.description = description 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry self.filters = filters 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TestCaseResult: 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry def __init__ (self, name, results): 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry self.name = name 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry self.results = results 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Group: 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry def __init__ (self, name): 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry self.name = name 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry self.cases = [] 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef readCaseList (filename): 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry f = open(filename, 'rb') 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cases = [] 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for line in f: 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if line[:6] == "TEST: ": 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case = line[6:].strip() 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if len(case) > 0: 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cases.append(case) 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return cases 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef toResultList (caselist): 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = [] 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for case in caselist: 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results.append(TestCaseResult(case, [])) 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return results 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef addResultsToCaseList (caselist, results): 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry resultMap = {} 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry caseListRes = toResultList(caselist) 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for res in caseListRes: 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry resultMap[res.name] = res 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for result in results: 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if result.name in resultMap: 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry resultMap[result.name].results += result.results 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return caseListRes 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef readTestResults (filename): 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry f = open(filename, 'rb') 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry csvData = f.read() 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry csvLines = csvData.splitlines() 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = [] 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry f.close() 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for line in csvLines[1:]: 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args = line.split(',') 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if len(args) == 1: 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue # Ignore 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results.append(TestCaseResult(args[0], args[1:])) 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if len(results) == 0: 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry raise Exception("Empty result list") 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry # Sanity check for results 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numResultItems = len(results[0].results) 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry seenResults = set() 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for result in results: 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if result.name in seenResults: 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry raise Exception("Duplicate result row for test case '%s'" % result.name) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if len(result.results) != numResultItems: 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry raise Exception("Found %d results for test case '%s', expected %d" % (len(result.results), result.name, numResultItems)) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry seenResults.add(result.name) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return results 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef readGroupList (filename): 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry f = open(filename, 'rb') 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups = [] 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for line in f: 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group = line.strip() 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if group != "": 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups.append(group) 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return groups 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef createGroups (results, groupNames): 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups = [] 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry matched = set() 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for groupName in groupNames: 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group = Group(groupName) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups.append(group) 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry prefix = groupName + "." 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry prefixLen = len(prefix) 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for case in results: 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if case.name[:prefixLen] == prefix: 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if case in matched: 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry die("Case '%s' matched by multiple groups (when processing '%s')" % (case.name, group.name)) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group.cases.append(case) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry matched.add(case) 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return groups 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef createLeafGroups (results): 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups = [] 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupMap = {} 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for case in results: 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry parts = case.name.split('.') 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupName = string.join(parts[:-1], ".") 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if not groupName in groupMap: 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group = Group(groupName) 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups.append(group) 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupMap[groupName] = group 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else: 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group = groupMap[groupName] 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group.cases.append(case) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return groups 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef filterList (results, condition): 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filtered = [] 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for case in results: 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if condition(case.results): 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filtered.append(case) 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return filtered 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef getFilter (list, name): 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for filter in list: 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if filter.name == name: 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return filter 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return None 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef getNumCasesInGroups (groups): 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numCases = 0 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for group in groups: 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numCases += len(group.cases) 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return numCases 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef getCasesInSet (results, caseSet): 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filtered = [] 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for case in results: 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if case in caseSet: 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filtered.append(case) 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return filtered 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef selectCasesInGroups (results, groups): 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry casesInGroups = set() 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for group in groups: 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for case in group.cases: 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry casesInGroups.add(case) 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return getCasesInSet(results, casesInGroups) 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef selectRandomSubset (results, groups, limit, seed): 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry selectedCases = set() 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numSelect = min(limit, getNumCasesInGroups(groups)) 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry random.seed(seed) 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry random.shuffle(groups) 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupNdx = 0 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while len(selectedCases) < numSelect: 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group = groups[groupNdx] 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if len(group.cases) == 0: 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry del groups[groupNdx] 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if groupNdx == len(groups): 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupNdx -= 1 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue # Try next 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry selected = random.choice(group.cases) 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry selectedCases.add(selected) 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group.cases.remove(selected) 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupNdx = (groupNdx + 1) % len(groups) 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return getCasesInSet(results, selectedCases) 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef die (msg): 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry print msg 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sys.exit(-1) 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# Named filter lists 2253c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFILTER_RULES = [ 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterRule("all", "No filtering", []), 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterRule("all-pass", "All results must be 'Pass'", [lambda l: all(l, lambda r: r == 'Pass')]), 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterRule("any-pass", "Any of results is 'Pass'", [lambda l: any(l, lambda r: r == 'Pass')]), 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterRule("any-fail", "Any of results is not 'Pass' or 'NotSupported'", [lambda l: not all(l, lambda r: r == 'Pass' or r == 'NotSupported')]), 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterRule("prev-failing", "Any except last result is failure", [lambda l: l[-1] == 'Pass' and not all(l[:-1], lambda r: r == 'Pass')]), 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterRule("prev-passing", "Any except last result is 'Pass'", [lambda l: l[-1] != 'Pass' and any(l[:-1], lambda r: r == 'Pass')]) 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry] 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryif __name__ == "__main__": 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry parser = OptionParser(usage = "usage: %prog [options] [caselist] [result csv file]") 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry parser.add_option("-f", "--filter", dest="filter", default="all", help="filter rule name") 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry parser.add_option("-l", "--list", action="store_true", dest="list", default=False, help="list available rules") 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry parser.add_option("-n", "--num", dest="limit", default=0, help="limit number of cases") 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry parser.add_option("-s", "--seed", dest="seed", default=0, help="use selected seed for random selection") 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry parser.add_option("-g", "--groups", dest="groups_file", default=None, help="select cases based on group list file") 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (options, args) = parser.parse_args() 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if options.list: 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry print "Available filter rules:" 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for filter in FILTER_RULES: 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry print " %s: %s" % (filter.name, filter.description) 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sys.exit(0) 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if len(args) == 0: 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry die("No input files specified") 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry elif len(args) > 2: 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry die("Too many arguments") 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry # Fetch filter 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filter = getFilter(FILTER_RULES, options.filter) 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if filter == None: 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry die("Unknown filter '%s'" % options.filter) 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry # Read case list 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry caselist = readCaseList(args[0]) 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if len(args) > 1: 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = readTestResults(args[1]) 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = addResultsToCaseList(caselist, results) 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else: 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = toResultList(caselist) 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry # Execute filters for results 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for rule in filter.filters: 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = filterList(results, rule) 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if options.limit != 0: 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if options.groups_file != None: 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups = createGroups(results, readGroupList(options.groups_file)) 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else: 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups = createLeafGroups(results) 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = selectRandomSubset(results, groups, int(options.limit), int(options.seed)) 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry elif options.groups_file != None: 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groups = createGroups(results, readGroupList(options.groups_file)) 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry results = selectCasesInGroups(results, groups) 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry # Print test set 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for result in results: 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry print result.name 285