Expose symbolic files to command line interface, implement whence for symbolic seek (#394)
* add --file <symbolic file> flag * fix seek argument count error, add rudimentary whence support * symbolic file seek: fix docstring and semantics
This commit is contained in:
parent
47a5d9752f
commit
be2494df44
@ -32,6 +32,8 @@ def parse_arguments():
|
|||||||
help='Initial concrete concrete_data for the input symbolic buffer')
|
help='Initial concrete concrete_data for the input symbolic buffer')
|
||||||
parser.add_argument('--env', type=str, nargs=1, default=[], action='append',
|
parser.add_argument('--env', type=str, nargs=1, default=[], action='append',
|
||||||
help='Specify symbolic environment variable VARNAME=++++++')
|
help='Specify symbolic environment variable VARNAME=++++++')
|
||||||
|
parser.add_argument('--file', type=str, action='append', dest='files',
|
||||||
|
help='Specify symbolic input file, \'+\' marks symbolic bytes')
|
||||||
parser.add_argument('--policy', type=str, default='random',
|
parser.add_argument('--policy', type=str, default='random',
|
||||||
help='Search policy. random|adhoc|uncovered|dicount|icount|syscount|depth.'\
|
help='Search policy. random|adhoc|uncovered|dicount|icount|syscount|depth.'\
|
||||||
' (use + (max) or - (min) to specify order. e.g. +random)')
|
' (use + (max) or - (min) to specify order. e.g. +random)')
|
||||||
@ -98,6 +100,10 @@ def main():
|
|||||||
name, val = entry[0].split('=')
|
name, val = entry[0].split('=')
|
||||||
m.env_add(name, val)
|
m.env_add(name, val)
|
||||||
|
|
||||||
|
if args.files:
|
||||||
|
for file in args.files:
|
||||||
|
m.add_symbolic_file(file)
|
||||||
|
|
||||||
if args.assertions:
|
if args.assertions:
|
||||||
m.load_assertions(args.assertions)
|
m.load_assertions(args.assertions)
|
||||||
|
|
||||||
|
|||||||
@ -113,7 +113,7 @@ class SymbolicFile(File):
|
|||||||
:param constraints: the SMT constraints
|
:param constraints: the SMT constraints
|
||||||
:param str path: the pathname of the symbolic file
|
:param str path: the pathname of the symbolic file
|
||||||
:param str mode: the access permissions of the symbolic file
|
:param str mode: the access permissions of the symbolic file
|
||||||
:param max_size: Maximun amount of bytes of the symbolic file
|
:param max_size: Maximum amount of bytes of the symbolic file
|
||||||
:param str wildcard: Wildcard to be used in symbolic file
|
:param str wildcard: Wildcard to be used in symbolic file
|
||||||
'''
|
'''
|
||||||
super(SymbolicFile, self).__init__(path, mode)
|
super(SymbolicFile, self).__init__(path, mode)
|
||||||
@ -170,14 +170,30 @@ class SymbolicFile(File):
|
|||||||
'''
|
'''
|
||||||
return self.pos
|
return self.pos
|
||||||
|
|
||||||
def seek(self, pos):
|
def seek(self, offset, whence = os.SEEK_SET):
|
||||||
'''
|
'''
|
||||||
Returns the read/write file offset
|
Repositions the file C{offset} according to C{whence}.
|
||||||
|
Returns the resulting offset or -1 in case of error.
|
||||||
:rtype: int
|
:rtype: int
|
||||||
:return: the read/write file offset.
|
:return: the file offset.
|
||||||
'''
|
'''
|
||||||
assert isinstance(pos, (int, long))
|
assert isinstance(offset, (int, long))
|
||||||
self.pos = pos
|
assert whence in (os.SEEK_SET, os.SEEK_CUR, os.SEEK_END)
|
||||||
|
|
||||||
|
new_position = 0
|
||||||
|
if whence == os.SEEK_SET:
|
||||||
|
new_position = offset
|
||||||
|
elif whence == os.SEEK_CUR:
|
||||||
|
new_position = self.pos + offset
|
||||||
|
elif whence == os.SEEK_END:
|
||||||
|
new_position = self.max_size + offset
|
||||||
|
|
||||||
|
if new_position < 0:
|
||||||
|
return -1
|
||||||
|
|
||||||
|
self.pos = new_position
|
||||||
|
|
||||||
|
return self.pos
|
||||||
|
|
||||||
def read(self, count):
|
def read(self, count):
|
||||||
'''
|
'''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user