<s> '''<STR_LIT>''' <EOL> import logging <EOL> from . import subprocess_helper as subp <EOL> logger = logging . getLogger ( __name__ ) <EOL> logger . setLevel ( logging . DEBUG ) <EOL> class ZzufTestCase : <EOL> def __init__ ( self , seedfile , seed , range , outfile ) : <EOL> '''<STR_LIT>''' <EOL> self . seedfile = seedfile <EOL> self . seed = seed <EOL> self . range = range <EOL> self . outfile = outfile <EOL> self . _set_cmdline ( ) <EOL> def _set_cmdline ( self ) : <EOL> self . cmdline = '<STR_LIT>' % ( self . seedfile , self . seed , self . range , self . outfile ) <EOL> def generate ( self ) : <EOL> subp . run_without_timer ( self . cmdline ) <EOL> class Zzuf : <EOL> def __init__ ( self , dir , s1 , s2 , cmd , seedfile , file , copymode , ratiomin , ratiomax , timeout , quiet = True ) : <EOL> '''<STR_LIT>''' <EOL> self . dir = dir <EOL> self . s1 = s1 <EOL> self . s2 = s2 <EOL> self . cmd = cmd <EOL> self . include = seedfile <EOL> self . file = file <EOL> self . copymode = copymode <EOL> self . ratiomin = ratiomin <EOL> self . ratiomax = ratiomax <EOL> self . timeout = timeout <EOL> self . quiet = quiet <EOL> self . zzuf_args = self . _get_zzuf_args ( ) <EOL> self . saw_crash = False <EOL> def _get_go_fuzz_cmdline ( self ) : <EOL> if self . quiet : <EOL> template = "<STR_LIT>" <EOL> else : <EOL> template = "<STR_LIT>" <EOL> cmdline = template % ( self . dir , self . zzuf_args , self . cmd , self . file ) <EOL> logger . info ( cmdline ) <EOL> return cmdline <EOL> def go ( self ) : <EOL> '''<STR_LIT>''' <EOL> command = self . _get_go_fuzz_cmdline ( ) <EOL> retcode = subp . run_without_timer ( command ) <EOL> if retcode : <EOL> self . saw_crash = True <EOL> return self . saw_crash <EOL> def generate_test_case ( self , seedfile , seed , range , outfile ) : <EOL> '''<STR_LIT>''' <EOL> testcase = ZzufTestCase ( seedfile , seed , range , outfile ) <EOL> testcase . generate ( ) <EOL> return testcase <EOL> def _get_zzuf_args ( self ) : <EOL> '''<STR_LIT>''' <EOL> parts = [ ] <EOL> if self . quiet : <EOL> parts . append ( "<STR_LIT>" ) <EOL> parts . append ( '<STR_LIT>' % self . include ) <EOL> parts . append ( "<STR_LIT>" ) <EOL> parts . append ( "<STR_LIT>" ) <EOL> parts . append ( "<STR_LIT>" % ( self . ratiomin , self . ratiomax ) ) <EOL> parts . append ( "<STR_LIT>" % self . timeout ) <EOL> if ( self . copymode ) : <EOL> parts . append ( "<STR_LIT>" ) <EOL> parts . append ( "<STR_LIT>" % ( self . s1 , self . s2 ) ) <EOL> return "<STR_LIT:U+0020>" . join ( [ "<STR_LIT>" % p for p in parts ] ) </s>
