OLD | NEW |
1 #!/usr/bin/python2.6 | 1 #!/usr/bin/python2.6 |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 LICENSE = ( | 6 LICENSE = ( |
7 "/*", | 7 "/*", |
8 " * Copyright (c) 2011 The Native Client Authors. All rights reserved.", | 8 " * Copyright (c) 2011 The Native Client Authors. All rights reserved.", |
9 " * Use of this source code is governed by a BSD-style license that can be", | 9 " * Use of this source code is governed by a BSD-style license that can be", |
10 " * found in the LICENSE file.", | 10 " * found in the LICENSE file.", |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 lines.append(line) | 311 lines.append(line) |
312 return lines | 312 return lines |
313 | 313 |
314 def GenerateTest(settings): | 314 def GenerateTest(settings): |
315 random.seed(settings.seed) | 315 random.seed(settings.seed) |
316 | 316 |
317 functions = [ TestFunction(settings, i) | 317 functions = [ TestFunction(settings, i) |
318 for i in xrange(settings.num_functions) ] | 318 for i in xrange(settings.num_functions) ] |
319 | 319 |
320 calls = [ ] | 320 calls = [ ] |
| 321 callcount = 0 |
321 for f in functions: | 322 for f in functions: |
322 calls += [ TestCall(settings, i, f) | 323 for i in xrange(settings.calls_per_func): |
323 for i in xrange(settings.calls_per_func) ] | 324 calls.append(TestCall(settings, callcount, f)) |
| 325 callcount += 1 |
324 | 326 |
325 num_asserts = sum([ c.num_asserts for c in calls ]) | 327 num_asserts = sum([ c.num_asserts for c in calls ]) |
326 return (functions, calls, num_asserts) | 328 return (functions, calls, num_asserts) |
327 | 329 |
328 | 330 |
329 class TestCall(object): | 331 class TestCall(object): |
330 def __init__(self, settings, test_id, function): | 332 def __init__(self, settings, call_id, function): |
331 self.settings = settings | 333 self.settings = settings |
332 self.id = test_id | 334 self.id = call_id |
333 self.f = function | 335 self.f = function |
334 | 336 |
335 self.num_var_args = random.randint(0, self.settings.max_args_per_func - | 337 self.num_var_args = random.randint(0, self.settings.max_args_per_func - |
336 self.f.num_fixed_args) | 338 self.f.num_fixed_args) |
337 | 339 |
338 # Generate argument inputs | 340 # Generate argument inputs |
339 self.num_args = self.f.num_fixed_args + self.num_var_args | 341 self.num_args = self.f.num_fixed_args + self.num_var_args |
340 args = [] | 342 args = [] |
341 fmtstr = '' | 343 fmtstr = '' |
342 for i in xrange(self.num_args): | 344 for i in xrange(self.num_args): |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 i = make_int() | 543 i = make_int() |
542 j = make_char() | 544 j = make_char() |
543 k = make_short() | 545 k = make_short() |
544 l = make_char() | 546 l = make_char() |
545 m = make_char() | 547 m = make_char() |
546 return "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % \ | 548 return "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % \ |
547 (a,b,c,d,e,f,g,h,i,j,k,l,m) | 549 (a,b,c,d,e,f,g,h,i,j,k,l,m) |
548 | 550 |
549 if __name__ == "__main__": | 551 if __name__ == "__main__": |
550 sys.exit(main(sys.argv[1:])) | 552 sys.exit(main(sys.argv[1:])) |
OLD | NEW |