Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Generate .sh runner for libfuzzer test. | 7 """Generate .sh runner for libfuzzer test. |
| 8 | 8 |
| 9 Invoked by GN from fuzzer_test.gni. | 9 Invoked by GN from fuzzer_test.gni. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import argparse | 12 import argparse |
| 13 import os | 13 import os |
| 14 import sys | 14 import sys |
| 15 | 15 |
| 16 | 16 |
| 17 parser = argparse.ArgumentParser(description="Generate fuzzer launcher.") | 17 parser = argparse.ArgumentParser(description="Generate fuzzer launcher.") |
| 18 parser.add_argument('--fuzzer', required=True) | 18 parser.add_argument('--fuzzer', required=True) |
| 19 parser.add_argument('--launcher', required=True) | 19 parser.add_argument('--launcher', required=True) |
| 20 parser.add_argument('--dict', required=True) | 20 parser.add_argument('--dict', required=False) |
| 21 parser.add_argument('--params', required=False) | |
| 21 args = parser.parse_args() | 22 args = parser.parse_args() |
| 22 | 23 |
| 23 out = open(args.launcher, 'w') | 24 out = open(args.launcher, 'w') |
| 24 out.write("""#!/bin/bash | 25 |
| 26 launcher_source_code = """#!/bin/bash | |
| 25 set -ue | 27 set -ue |
| 26 DIR=$(dirname $0) | 28 DIR=$(dirname $0) |
| 27 $DIR/%(fuzzer)s -dict=$DIR/%(dict)s $* | 29 $DIR/%(fuzzer)s""" % {"fuzzer": args.fuzzer} |
| 28 """ % { "fuzzer": args.fuzzer, "dict": args.dict }) | 30 |
| 31 if args.dict: | |
| 32 launcher_source_code += " -dict=$DIR/%(dict)s" % { "dict": args.dict } | |
|
aizatsky
2016/02/16 18:25:05
build arguments first and insert them into the tem
mmoroz
2016/02/17 10:36:48
Done.
| |
| 33 | |
| 34 launcher_source_code += " $*" | |
| 35 | |
| 36 # Put custom parameters after "$*" to overwrite default values from ClusterFuzz. | |
| 37 if args.params: | |
| 38 launcher_source_code += " %(params)s" % { "params": args.params[1 : -1]} | |
| 39 | |
| 40 launcher_source_code += "\n" | |
| 41 | |
| 42 out.write(launcher_source_code) | |
| 29 out.close() | 43 out.close() |
| 30 | 44 |
| 31 os.chmod(args.launcher, os.stat(args.launcher).st_mode | 0o111) # chmod a+x | 45 os.chmod(args.launcher, os.stat(args.launcher).st_mode | 0o111) # chmod a+x |
| OLD | NEW |