From 2477aecd8f12c87fe0bba124f893ceb012cbfe96 Mon Sep 17 00:00:00 2001 From: John McMaster Date: Tue, 27 Nov 2018 14:27:05 -0800 Subject: [PATCH] rempips: support generate without existing db Signed-off-by: John McMaster --- fuzzers/056-rempips/maketodo.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/fuzzers/056-rempips/maketodo.py b/fuzzers/056-rempips/maketodo.py index 98585551..8702c95d 100644 --- a/fuzzers/056-rempips/maketodo.py +++ b/fuzzers/056-rempips/maketodo.py @@ -12,19 +12,22 @@ def maketodo(pipfile, dbfile, strict=True): line = line.split() todos.add(line[0]) print('%s: %u entries' % (pipfile, len(todos)), file=sys.stderr) - with open(dbfile, "r") as f: - for line in f: - line = line.split() - pip = line[0] - try: - todos.remove(pip) - except KeyError: - # DB (incorrectly) had multiple entries - # Workaround for testing on old DB revision - if strict: - raise - print( - 'WARNING: failed to remove pip %s' % pip, file=sys.stderr) + # Support generate without existing DB + if os.path.exists(dbfile) or strict: + with open(dbfile, "r") as f: + for line in f: + line = line.split() + pip = line[0] + try: + todos.remove(pip) + except KeyError: + # DB (incorrectly) had multiple entries + # Workaround for testing on old DB revision + if strict: + raise + print( + 'WARNING: failed to remove pip %s' % pip, + file=sys.stderr) print('Remove %s: %u entries' % (dbfile, len(todos)), file=sys.stderr) drops = 0 lines = 0