-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck-symex-str.py
executable file
·37 lines (33 loc) · 997 Bytes
/
check-symex-str.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
#!/usr/bin/env python2
import symex.fuzzy as fuzzy
def g(s):
if 'abc' in s:
return "Found abc in s"
if '' == s:
return "Empty s"
if len(s) > 30:
return "Too long"
if 'xyxy' == s + s:
return "Found the xyxy double"
if s.startswith('start'):
return "Starts with start"
if s.endswith('end'):
return "Ends with end"
if len(s) >= 4 and s[3] == 'q':
return "4th character is q"
return "Other stuff"
g_results = set()
def test_g():
s = fuzzy.mk_str('s')
v = g(s)
print s, '->', v
g_results.add(v)
print 'Testing g..'
fuzzy.concolic_test(test_g, verbose=10)
g_expected = ('Empty s', '4th character is q', 'Other stuff',
'Found abc in s', 'Too long', 'Found the xyxy double',
'Starts with start', 'Ends with end')
if all(x in g_results for x in g_expected):
print "Found all cases for g"
else:
print "Missing some cases for g:", set(g_expected) - set(g_results)