blob: cd338fb136ae4e917c7f51148e39f94f647456c0 [file] [log] [blame]
Wojciech Staszkiewicz176dc642016-09-23 17:41:27 -07001#!/usr/bin/env python3.4
2#
3# Copyright (C) 2016 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17import argparse
18import os
19import subprocess
20import sys
21
22from tempfile import TemporaryFile
23
24# Default arguments for run_jfuzz_test.py.
25DEFAULT_ARGS = ['--num_tests=20000']
26
27# run_jfuzz_test.py success string.
28SUCCESS_STRING = 'success (no divergences)'
29
30# Constant returned by string find() method when search fails.
31NOT_FOUND = -1
32
33def main(argv):
34 cwd = os.path.dirname(os.path.realpath(__file__))
35 cmd = [cwd + '/run_jfuzz_test.py'] + DEFAULT_ARGS
36 parser = argparse.ArgumentParser()
37 parser.add_argument('--num_proc', default=8,
38 type=int, help='number of processes to run')
39 # Unknown arguments are passed to run_jfuzz_test.py.
40 (args, unknown_args) = parser.parse_known_args()
41 output_files = [TemporaryFile('wb+') for _ in range(args.num_proc)]
42 processes = []
43 for output_file in output_files:
44 processes.append(subprocess.Popen(cmd + unknown_args, stdout=output_file,
45 stderr=subprocess.STDOUT))
46 try:
47 # Wait for processes to terminate.
48 for proc in processes:
49 proc.wait()
50 except KeyboardInterrupt:
51 for proc in processes:
52 proc.kill()
53 # Output results.
54 for i, output_file in enumerate(output_files):
55 output_file.seek(0)
56 output_str = output_file.read().decode('ascii')
57 output_file.close()
58 print('Tester', i)
59 if output_str.find(SUCCESS_STRING) == NOT_FOUND:
60 print(output_str)
61 else:
62 print(SUCCESS_STRING)
63
64if __name__ == '__main__':
65 main(sys.argv)