Mercurial > repos > blastem
changeset 572:0f32f52fc98e
Make some small changes in trans so that it is more likely to produce the same output as mustrans when given misbehaving programs. Add lea to testcases.txt. Improve the output of comparetest.py so that known issues can easily be separated from new ones.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 03 Mar 2014 21:08:43 -0800 |
parents | c90fc522e7e3 |
children | 29d99db6f55d |
files | comparetests.py testcases.txt trans.c |
diffstat | 3 files changed, 50 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/comparetests.py Sun Mar 02 17:53:32 2014 -0800 +++ b/comparetests.py Mon Mar 03 21:08:43 2014 -0800 @@ -18,6 +18,49 @@ else: prefixes.append(argv[i]) +def print_mismatch(path, b, m): + blines = b.split('\n') + mlines = m.split('\n') + if len(blines) != len(mlines): + print '-----------------------------' + print 'Unknown mismatch in', path + print 'blastem output:' + print b + print 'musashi output:' + print m + print '-----------------------------' + return + prevline = '' + differences = [] + flagmismatch = False + regmismatch = False + for i in xrange(0, len(blines)): + if blines[i] != mlines[i]: + if prevline == 'XNZVC': + differences.append((prevline, prevline)) + flagmismatch = True + else: + regmismatch = True + differences.append((blines[i], mlines[i])) + prevline = blines[i] + if flagmismatch and regmismatch: + mtype = 'General' + elif flagmismatch: + mtype = 'Flag' + elif regmismatch: + mtype = 'Register' + else: + mtype = 'Unknown' + print '-----------------------------' + print mtype, 'mismatch in', path + for i in xrange(0, 2): + print 'musashi' if i else 'blastem', 'output:' + for diff in differences: + print diff[i] + print '-----------------------------' + + + for path in glob('generated_tests/*/*.bin'): if path in skip: continue @@ -36,13 +79,8 @@ m = subprocess.check_output(['musashi/mustrans', path]) #_,_,b = b.partition('\n') if b != m: - print '-----------------------------' - print 'Mismatch in ' + path - print 'blastem output:' - print b - print 'musashi output:' - print m - print '-----------------------------' + print_mismatch(path, b, m) + else: print path, 'passed' except subprocess.CalledProcessError as e:
--- a/testcases.txt Sun Mar 02 17:53:32 2014 -0800 +++ b/testcases.txt Mon Mar 03 21:08:43 2014 -0800 @@ -84,4 +84,5 @@ #sle b d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l #swap w d tst bwl d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l +lea l (a);(n,a);(n,a,x);(n).w;(n).l;(n,pc);(n,pc,x) a
--- a/trans.c Sun Mar 02 17:53:32 2014 -0800 +++ b/trans.c Mon Mar 03 21:08:43 2014 -0800 @@ -30,8 +30,9 @@ fseek(f, 0, SEEK_END); filesize = ftell(f); fseek(f, 0, SEEK_SET); - filebuf = malloc(filesize > 0x400000 ? filesize : 0x400000); - fread(filebuf, 2, filesize/2, f); + filebuf = malloc(0x400000); + memset(filebuf, 0, 0x400000); + fread(filebuf, 2, filesize/2 > 0x200000 ? 0x200000 : filesize/2, f); fclose(f); for(cur = filebuf; cur - filebuf < (filesize/2); ++cur) { @@ -49,6 +50,7 @@ memmap[1].mask = 0xFFFF; memmap[1].flags = MMAP_READ | MMAP_WRITE | MMAP_CODE; memmap[1].buffer = malloc(64 * 1024); + memset(memmap[1].buffer, 0, 64 * 1024); init_m68k_opts(&opts, memmap, 2); init_68k_context(&context, opts.gen.native_code_map, &opts); context.mem_pointers[0] = memmap[0].buffer;