-
Notifications
You must be signed in to change notification settings - Fork 152
/
roi_all.py
executable file
·66 lines (50 loc) · 1.54 KB
/
roi_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017-2021 The Project X-Ray Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
import argparse
import multiprocessing as mp
import os
import re
import subprocess
import yaml
from prjxray import util
def worker(arglist):
part, cwd = arglist
cmd = "make roi_only"
env = os.environ.copy()
env['XRAY_PART'] = part
print("running subprocess")
subprocess.run(cmd.split(' '), check=True, env=env, cwd=cwd)
def main():
"""Rois all parts for a family by calling "make roi_only" over all parts
with the same device as XRAY_PART.
Example:
prjxray$ ./utils/roi_all.py --db-root database/artix7/ --part xc7a100tfgg676-1
"""
env = os.environ.copy()
db_root = util.get_db_root()
assert db_root
part = util.get_part()
assert part
information = util.get_part_information(db_root, part)
valid_devices = []
for name, device in util.get_devices(db_root).items():
if device['fabric'] == information['device']:
valid_devices.append(name)
tasks = []
for part, data in util.get_parts(db_root).items():
if data['device'] in valid_devices:
cwd = os.getenv('XRAY_FUZZERS_DIR')
tasks.append((part, cwd))
with mp.Pool() as pool:
for _ in pool.imap_unordered(worker, tasks):
pass
if __name__ == '__main__':
main()