mirror of https://github.com/openXC7/prjxray.git
maketodo: normalize tile prefix
Signed-off-by: John McMaster <johndmcmaster@gmail.com>
This commit is contained in:
parent
02d9e04ffa
commit
8b2d7860aa
|
|
@ -4,24 +4,64 @@ import os, re
|
|||
import sys
|
||||
|
||||
|
||||
def maketodo(pipfile, dbfile, intre, not_endswith=None, verbose=False):
|
||||
def noprefix(tag):
|
||||
n = tag.find('.')
|
||||
assert n > 0
|
||||
return tag[n + 1:]
|
||||
|
||||
|
||||
def getprefix(tag):
|
||||
n = tag.find('.')
|
||||
assert n > 0
|
||||
return tag[0:n]
|
||||
|
||||
|
||||
def load_pipfile(pipfile):
|
||||
'''Returns a set of tags containing real tile type prefixes (ex: INT_L)'''
|
||||
todos = set()
|
||||
tile_type = None
|
||||
with open(pipfile, "r") as f:
|
||||
# INT_L.WW2BEG0.SR1BEG_S0
|
||||
for line in f:
|
||||
line = line.split()
|
||||
todos.add(line[0])
|
||||
verbose and print(
|
||||
'%s: %u entries' % (pipfile, len(todos)), file=sys.stderr)
|
||||
tag = line[0]
|
||||
prefix_line = getprefix(tag)
|
||||
if tile_type is None:
|
||||
tile_type = prefix_line
|
||||
else:
|
||||
assert tile_type == prefix_line
|
||||
todos.add(tag)
|
||||
return todos, tile_type
|
||||
|
||||
|
||||
def maketodo(pipfile, dbfile, intre, not_endswith=None, verbose=False):
|
||||
'''
|
||||
db files start with INT., but pipfile lines start with INT_L
|
||||
Normalize by removing before the first dot
|
||||
050-intpips doesn't care about contents, but most fuzzers use the tile type prefix
|
||||
'''
|
||||
|
||||
todos, tile_type = load_pipfile(pipfile)
|
||||
verbose and print('%s: %u entries' % (pipfile, len(todos)))
|
||||
verbose and print("pipfile todo sample: %s" % list(todos)[0])
|
||||
|
||||
# Allow against empty db
|
||||
if os.path.exists(dbfile):
|
||||
verbose and print("Loading %s" % dbfile)
|
||||
with open(dbfile, "r") as f:
|
||||
# INT.BYP_ALT0.BYP_BOUNCE_N3_3 !22_07 !23_07 !25_07 21_07 24_07
|
||||
for line in f:
|
||||
line = line.split()
|
||||
tag = tile_type + '.' + noprefix(line[0])
|
||||
# bipips works on a subset
|
||||
if line[0] in todos:
|
||||
todos.remove(line[0])
|
||||
verbose and print(
|
||||
'Remove %s: %u entries' % (dbfile, len(todos)), file=sys.stderr)
|
||||
if tag in todos:
|
||||
todos.remove(tag)
|
||||
else:
|
||||
verbose and print(
|
||||
"WARNING: couldnt remove %s (line %s)" % (tag, line))
|
||||
else:
|
||||
verbose and print("WARNING: dbfile doesnt exist: %s" % dbfile)
|
||||
verbose and print('Remove %s: %u entries' % (dbfile, len(todos)))
|
||||
drops = 0
|
||||
lines = 0
|
||||
for line in todos:
|
||||
|
|
@ -31,8 +71,7 @@ def maketodo(pipfile, dbfile, intre, not_endswith=None, verbose=False):
|
|||
else:
|
||||
drops += 1
|
||||
lines += 1
|
||||
verbose and print(
|
||||
'Print %u entries w/ %u drops' % (lines, drops), file=sys.stderr)
|
||||
verbose and print('Print %u entries w/ %u drops' % (lines, drops))
|
||||
|
||||
|
||||
def run(build_dir, db_dir, intre, pip_type, not_endswith=None, verbose=False):
|
||||
|
|
@ -61,6 +100,7 @@ def main():
|
|||
parser = argparse.ArgumentParser(
|
||||
description="Print list of known but unsolved PIPs")
|
||||
|
||||
parser.add_argument('--verbose', action='store_true', help='')
|
||||
parser.add_argument('--build-dir', default="build", help='')
|
||||
parser.add_argument('--db-dir', default=None, help='')
|
||||
parser.add_argument('--re', required=True, help='')
|
||||
|
|
@ -74,7 +114,8 @@ def main():
|
|||
db_dir=args.db_dir,
|
||||
intre=args.re,
|
||||
pip_type=args.pip_type,
|
||||
not_endswith=args.not_endswith)
|
||||
not_endswith=args.not_endswith,
|
||||
verbose=args.verbose)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in New Issue