Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: tools/test.py

Issue 6127003: Enable sharding of individual testsuites in tools/test.py... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/testcfg.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2008 the V8 project authors. All rights reserved. 3 # Copyright 2008 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 dest="store_unexpected_output", action="store_false") 1174 dest="store_unexpected_output", action="store_false")
1175 result.add_option("--stress-only", 1175 result.add_option("--stress-only",
1176 help="Only run tests with --always-opt --stress-opt", 1176 help="Only run tests with --always-opt --stress-opt",
1177 default=False, action="store_true") 1177 default=False, action="store_true")
1178 result.add_option("--nostress", 1178 result.add_option("--nostress",
1179 help="Don't run crankshaft --always-opt --stress-op test", 1179 help="Don't run crankshaft --always-opt --stress-op test",
1180 default=False, action="store_true") 1180 default=False, action="store_true")
1181 result.add_option("--crankshaft", 1181 result.add_option("--crankshaft",
1182 help="Run with the --crankshaft flag", 1182 help="Run with the --crankshaft flag",
1183 default=False, action="store_true") 1183 default=False, action="store_true")
1184 result.add_option("--shard-count",
1185 help="Split testsuites into this number of shards",
1186 default=1, type="int")
1187 result.add_option("--shard-run",
1188 help="Run this shard from the split up tests.",
1189 default=1, type="int")
1184 result.add_option("--noprof", help="Disable profiling support", 1190 result.add_option("--noprof", help="Disable profiling support",
1185 default=False) 1191 default=False)
1186 return result 1192 return result
1187 1193
1188 1194
1189 def ProcessOptions(options): 1195 def ProcessOptions(options):
1190 global VERBOSE 1196 global VERBOSE
1191 VERBOSE = options.verbose 1197 VERBOSE = options.verbose
1192 options.mode = options.mode.split(',') 1198 options.mode = options.mode.split(',')
1193 for mode in options.mode: 1199 for mode in options.mode:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 def GetSuites(test_root): 1301 def GetSuites(test_root):
1296 def IsSuite(path): 1302 def IsSuite(path):
1297 return isdir(path) and exists(join(path, 'testcfg.py')) 1303 return isdir(path) and exists(join(path, 'testcfg.py'))
1298 return [ f for f in os.listdir(test_root) if IsSuite(join(test_root, f)) ] 1304 return [ f for f in os.listdir(test_root) if IsSuite(join(test_root, f)) ]
1299 1305
1300 1306
1301 def FormatTime(d): 1307 def FormatTime(d):
1302 millis = round(d * 1000) % 1000 1308 millis = round(d * 1000) % 1000
1303 return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis) 1309 return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis)
1304 1310
1311 def ShardTests(tests, options):
1312 if options.shard_count < 2:
1313 return tests
1314 if options.shard_run < 1 or options.shard_run > options.shard_count:
1315 print "shard-run not a valid number, should be in [1:shard-count]"
1316 print "defaulting back to running all tests"
1317 return tests
1318 count = 0;
1319 shard = []
1320 for test in tests:
1321 if count % options.shard_count == options.shard_run - 1:
1322 shard.append(test);
1323 count += 1
1324 return shard
1305 1325
1306 def Main(): 1326 def Main():
1307 parser = BuildOptions() 1327 parser = BuildOptions()
1308 (options, args) = parser.parse_args() 1328 (options, args) = parser.parse_args()
1309 if not ProcessOptions(options): 1329 if not ProcessOptions(options):
1310 parser.print_help() 1330 parser.print_help()
1311 return 1 1331 return 1
1312 1332
1313 workspace = abspath(join(dirname(sys.argv[0]), '..')) 1333 workspace = abspath(join(dirname(sys.argv[0]), '..'))
1314 suites = GetSuites(join(workspace, 'test')) 1334 suites = GetSuites(join(workspace, 'test'))
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 'simulator': options.simulator, 1398 'simulator': options.simulator,
1379 'crankshaft': options.crankshaft 1399 'crankshaft': options.crankshaft
1380 } 1400 }
1381 test_list = root.ListTests([], path, context, mode) 1401 test_list = root.ListTests([], path, context, mode)
1382 unclassified_tests += test_list 1402 unclassified_tests += test_list
1383 (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env) 1403 (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env)
1384 if globally_unused_rules is None: 1404 if globally_unused_rules is None:
1385 globally_unused_rules = set(unused_rules) 1405 globally_unused_rules = set(unused_rules)
1386 else: 1406 else:
1387 globally_unused_rules = globally_unused_rules.intersection(unused_rules) 1407 globally_unused_rules = globally_unused_rules.intersection(unused_rules)
1388 all_cases += cases 1408 all_cases += ShardTests(cases, options)
1389 all_unused.append(unused_rules) 1409 all_unused.append(unused_rules)
1390 1410
1391 if options.cat: 1411 if options.cat:
1392 visited = set() 1412 visited = set()
1393 for test in unclassified_tests: 1413 for test in unclassified_tests:
1394 key = tuple(test.path) 1414 key = tuple(test.path)
1395 if key in visited: 1415 if key in visited:
1396 continue 1416 continue
1397 visited.add(key) 1417 visited.add(key)
1398 print "--- begin source: %s ---" % test.GetLabel() 1418 print "--- begin source: %s ---" % test.GetLabel()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 for entry in timed_tests[:20]: 1458 for entry in timed_tests[:20]:
1439 t = FormatTime(entry.duration) 1459 t = FormatTime(entry.duration)
1440 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) 1460 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel()))
1441 index += 1 1461 index += 1
1442 1462
1443 return result 1463 return result
1444 1464
1445 1465
1446 if __name__ == '__main__': 1466 if __name__ == '__main__':
1447 sys.exit(Main()) 1467 sys.exit(Main())
OLDNEW
« no previous file with comments | « test/mjsunit/testcfg.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698