|
21 | 21 | import sys
|
22 | 22 | import os
|
23 | 23 | import getopt
|
| 24 | +from shutil import copy |
24 | 25 | from time import time
|
25 | 26 |
|
26 | 27 | # set path to our package
|
@@ -289,35 +290,25 @@ def generate_graphml(path, source, prps, is32bit, is_correctness_wit, terminatio
|
289 | 290 | assert path is None
|
290 | 291 | gen.write(saveto)
|
291 | 292 |
|
292 |
| -def generate_testcase(path, source, is32bit, is_correctness_test): |
| 293 | +def generate_test_metadata(path, source, is32bit): |
293 | 294 | saveto = '{0}/test-suite/{1}.xml'.format(environment.symbiotic_dir, os.path.basename(path))
|
294 | 295 | saveto = os.path.abspath(saveto)
|
295 | 296 |
|
296 |
| - #print('Generating {0} test: {1}'.format('correctness' if is_correctness_test else 'error', saveto)) |
| 297 | + print('Generating metadata') |
297 | 298 |
|
298 | 299 | savetomd = '{0}/metadata.xml'.format(os.path.dirname(saveto))
|
299 | 300 | savetomd = os.path.abspath(savetomd)
|
300 | 301 |
|
301 |
| - gen = TestCaseWriter(source, not is_correctness_test) |
302 | 302 | 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) |
309 | 303 | gen_md.write(savetomd)
|
310 | 304 |
|
311 | 305 | def get_testcases(bindir):
|
312 | 306 | abd = os.path.abspath(bindir)
|
313 | 307 | testcases = []
|
314 |
| - is_correctness_test = True |
315 | 308 | 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 |
321 | 312 |
|
322 | 313 | def get_testcase(bindir):
|
323 | 314 | abd = os.path.abspath(bindir)
|
@@ -353,9 +344,10 @@ def generate_tests(bindir, sources, is32bit):
|
353 | 344 | rm_tmp_dir(tmpdir, True)
|
354 | 345 | os.mkdir(tmpdir)
|
355 | 346 |
|
356 |
| - (paths, is_correctness_test) = get_testcases(bindir) |
| 347 | + generate_test_metadata(bindir, sources[0], is32bit) |
| 348 | + paths = get_testcases(bindir) |
357 | 349 | for pth in paths:
|
358 |
| - generate_testcase(pth, sources[0], is32bit, is_correctness_test) |
| 350 | + copy(pth, os.path.join(tmpdir)) |
359 | 351 |
|
360 | 352 | print("Generated {0} testcases".format(len(paths)))
|
361 | 353 |
|
@@ -781,21 +773,21 @@ if __name__ == "__main__":
|
781 | 773 | ###################################################################
|
782 | 774 | srcdir = os.path.dirname(symbiotic.llvmfile)
|
783 | 775 | # 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') |
799 | 791 |
|
800 | 792 | print('--------------------------------------------------------------------------------')
|
801 | 793 |
|
|
0 commit comments