Skip to content

Commit 90243b7

Browse files
refine
1 parent ee9d3d8 commit 90243b7

6 files changed

Lines changed: 29 additions & 28 deletions

File tree

smtfuzz/bet/bet_mutator.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,29 @@
1717
import random
1818

1919
from z3 import *
20-
from z3.z3util import get_vars
20+
# from z3.z3util import get_vars # this one is slow
21+
22+
23+
def get_vars(exp):
24+
try:
25+
syms = set()
26+
stack = [exp]
27+
28+
while stack:
29+
e = stack.pop()
30+
if z3.is_app(e):
31+
if e.num_args() == 0 and e.decl().kind() == z3.Z3_OP_UNINTERPRETED:
32+
syms.add(e)
33+
else:
34+
# Add children in reverse order
35+
# This maintains DFS traversal order when using pop()
36+
# stack.extend(reversed(e.children())) # shoud we?
37+
stack.extend(e.children())
38+
39+
return list(syms)
40+
except z3.Z3Exception as ex:
41+
print(ex)
42+
return False
2143

2244

2345
def get_atoms(z3expr):

smtfuzz/bet/op_mutator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import random
22

3-
from smtfuzz.mutators.smt2_generator import generate_from_grammar_as_str
3+
from smtfuzz.bet.smt2_generator import generate_from_grammar_as_str
44

5-
from smtfuzz.mutators.cvc4option_mutator import mutate_cvc4_option
6-
from smtfuzz.mutators.z3option_mutator import mutate_z3_option
5+
from smtfuzz.options.cvc4option_mutator import mutate_cvc4_option
6+
from smtfuzz.options.z3option_mutator import mutate_z3_option
77

88
# import timeout_decorator
99

smtfuzz/bet/smt2_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
88
parentdir = os.path.dirname(currentdir)
99

10-
generator = 'smtfuzz' # FIXME: directly use the smtfuzz.py file?
10+
generator = os.path.join(parentdir, 'smtfuzz.py') # Fixed: use the actual smtfuzz.py file
1111

1212
strategies = ['noinc', 'noinc', 'CNFexp', 'cnf', 'ncnf', 'bool', 'bool']
1313

smtfuzz/cli.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,12 @@
66
"""
77

88
import sys
9-
from .smtfuzz import *
9+
from .smtfuzz import main
1010

1111

1212
def cli_main():
1313
"""Entry point for the smtfuzz command."""
14-
# Check if inter-theory mode is requested
15-
if len(sys.argv) > 1 and sys.argv[1] == 'inter':
16-
# Remove 'inter' from args and call inter-theory CLI
17-
sys.argv = [sys.argv[0]] + sys.argv[2:]
18-
from .inter.cli import main as inter_main
19-
inter_main()
20-
elif len(sys.argv) > 1 and sys.argv[1] == 'mutate':
21-
# Remove 'mutate' from args and call mutation CLI
22-
sys.argv = [sys.argv[0]] + sys.argv[2:]
23-
from .bet.bet_mutator import main as mutate_main
24-
mutate_main()
25-
else:
26-
# Default generation mode
27-
print("SMTFuzz - A fuzzer for SMT solvers")
28-
print("Modes: generation (default), mutate, inter")
29-
main()
30-
31-
32-
def main():
33-
"""Main entry point for the package."""
34-
cli_main()
35-
14+
main()
3615

3716
if __name__ == '__main__':
3817
cli_main()

0 commit comments

Comments
 (0)