Skip to content

Commit fd3f777

Browse files
committed
fix generating testcases
1 parent fe2d4ed commit fd3f777

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

klee

Submodule klee updated from e1cc126 to b85a3bc

scripts/symbiotic

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import sys
2222
import os
2323
import getopt
24+
from shutil import copy
2425
from time import time
2526

2627
# set path to our package
@@ -289,35 +290,25 @@ def generate_graphml(path, source, prps, is32bit, is_correctness_wit, terminatio
289290
assert path is None
290291
gen.write(saveto)
291292

292-
def generate_testcase(path, source, is32bit, is_correctness_test):
293+
def generate_test_metadata(path, source, is32bit):
293294
saveto = '{0}/test-suite/{1}.xml'.format(environment.symbiotic_dir, os.path.basename(path))
294295
saveto = os.path.abspath(saveto)
295296

296-
#print('Generating {0} test: {1}'.format('correctness' if is_correctness_test else 'error', saveto))
297+
print('Generating metadata')
297298

298299
savetomd = '{0}/metadata.xml'.format(os.path.dirname(saveto))
299300
savetomd = os.path.abspath(savetomd)
300301

301-
gen = TestCaseWriter(source, not is_correctness_test)
302302
gen_md = MetadataWriter(source, is32bit)
303-
304-
if is_correctness_test:
305-
gen.parseTest(path, source)
306-
else:
307-
gen.parseTest(path, source)
308-
gen.write(saveto)
309303
gen_md.write(savetomd)
310304

311305
def get_testcases(bindir):
312306
abd = os.path.abspath(bindir)
313307
testcases = []
314-
is_correctness_test = True
315308
for path in os.listdir('{0}/klee-last'.format(abd)):
316-
if path.endswith('.path') or path.endswith('.err'):
317-
testcases.append(os.path.abspath('{0}/klee-last/{1}'.format(abd, path[:path.find(".")])) + '.path')
318-
if path.endswith('.err'):
319-
is_correctness_test = False
320-
return testcases, is_correctness_test
309+
if path.endswith('.xml'):
310+
testcases.append(os.path.abspath('{0}/klee-last/{1}'.format(abd, path)))
311+
return testcases
321312

322313
def get_testcase(bindir):
323314
abd = os.path.abspath(bindir)
@@ -353,9 +344,10 @@ def generate_tests(bindir, sources, is32bit):
353344
rm_tmp_dir(tmpdir, True)
354345
os.mkdir(tmpdir)
355346

356-
(paths, is_correctness_test) = get_testcases(bindir)
347+
generate_test_metadata(bindir, sources[0], is32bit)
348+
paths = get_testcases(bindir)
357349
for pth in paths:
358-
generate_testcase(pth, sources[0], is32bit, is_correctness_test)
350+
copy(pth, os.path.join(tmpdir))
359351

360352
print("Generated {0} testcases".format(len(paths)))
361353

@@ -781,21 +773,21 @@ if __name__ == "__main__":
781773
###################################################################
782774
srcdir = os.path.dirname(symbiotic.llvmfile)
783775
# FIXME: make tool specific
784-
#if not test_comp and tool.name().startswith('klee') and \
785-
# not opts.noslice and res and res.startswith('false'):
786-
# print_stdout("Found {0}".format(res))
787-
# print_stdout("Trying to confirm the error path")
788-
# # replay the counterexample on non-sliced module
789-
# ktest = get_ktest(srcdir)
790-
# newpath = os.path.join(srcdir, os.path.basename(ktest))
791-
# # move the file out of klee-last directory as the new run
792-
# # will create a new such directory (link)
793-
# os.rename(ktest, newpath)
794-
# newres = symbiotic.replay_nonsliced(newpath)
795-
796-
# if res != newres:
797-
# dbg("Replayed result: {0}".format(newres))
798-
# res = 'cex not-confirmed'
776+
if tool.name().startswith('klee') and \
777+
opts.property.errorcall() and res and res.startswith('done'):
778+
print_stdout("Found {0}".format(res))
779+
print_stdout("Trying to confirm the error path")
780+
# replay the counterexample on non-sliced module
781+
ktest = get_ktest(srcdir)
782+
newpath = os.path.join(srcdir, os.path.basename(ktest))
783+
# move the file out of klee-last directory as the new run
784+
# will create a new such directory (link)
785+
os.rename(ktest, newpath)
786+
newres = symbiotic.replay_nonsliced(newpath)
787+
788+
if res != newres:
789+
dbg("Replayed result: {0}".format(newres))
790+
print_stdout('cex not-confirmed... emitting the test anyway')
799791

800792
print('--------------------------------------------------------------------------------')
801793

0 commit comments

Comments
 (0)