Verilator
1#!/usr/bin/env python3
2# pylint: disable=C0103,C0114,C0115,C0116,C0321,R0911
3######################################################################
4# DESCRIPTION: Fuzzer result checker
5#
6# Copyright 2019-2019 by Eric Rippey. This program is free software; you
7# can redistribute it and/or modify it under the terms of either the GNU Lesser
8# General Public License Version 3 or the Perl Artistic License Version 2.0.
9# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
10######################################################################
11
12# This script is designed to rerun examples to see whether they have
13# unexpected types of output besides the ones that afl-fuzz detects as
14# such.
15
16from glob import glob17from subprocess import getstatusoutput18from argparse import ArgumentParser19
20
21def interesting(s):22if 'assert' in s: return 123if 'Assert' in s: return 124if 'Aborted' in s: return 125if 'terminate' in s:26if 'unterminated' in s:27return 028return 129if 'Segmentation' in s:30return 131if 'internal error' in s:32return 133return 034
35
36def main():37p = ArgumentParser()38p.add_argument('--dir', default='out1/queue')39args = p.parse_args()40
41for infile in glob(args.dir + '/*'):42# Input filenames are known not to contain spaces or other unusual43# characters, therefore this works.44status, output = getstatusoutput('../../bin/verilator_bin --cc ' +45infile)46if interesting(output):47print(infile)48print(status)49print(output)50
51
52if __name__ == '__main__':53main()54