-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen2.py
executable file
·48 lines (41 loc) · 1.13 KB
/
gen2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
"""
Generate input files with different shapes for each system call.
"""
import os
from gen import *
defaultBuf = Alloc(8)
defaultStr = '12345678'
argMap = {
'buffer': defaultBuf,
'fd': StdFile(1),
'filename': Filename('testing'),
'int': 0,
'ptr': defaultBuf,
'signalno': 0,
'string': defaultStr,
'len': Len(),
}
def parseArg(arg, stdFile=False):
if arg == 'fd' and not stdFile:
return File('testing')
return argMap.get(arg, defaultBuf)
def main() :
try:
os.mkdir('gen2-inputs')
except OSError:
pass
already = set()
for callnr in xrange(360) :
i = 0
with open('gen2-shapes.txt', 'r') as f:
for line in f:
for stdFile in (True, False):
args = [parseArg(arg, stdFile) for arg in line.strip().split(',')]
buf = mkSyscall(callnr, *args)
if not buf in already:
writeFn('gen2-inputs/call%03d-%d' % (callnr, i), buf)
i += 1
already.add(buf)
if __name__ == '__main__' :
main()