DASM
test-comparison/Tests.pm
Go to the documentation of this file.
00001 #!/usr/bin/perl -w
00002 ##
00003 # Test rules for the test-comparison directory: miscellaneous tests.
00004 #
00005 # Run the comparison suite from:
00006 #   http://0x10cwiki.com/wiki/Comparison_of_Developer_Tools
00007 # through the compiler to check that we conform well.
00008 #
00009 # The initial scores for DASM were:
00010 #
00011 # Group                    : Pass : Fail : Total
00012 # ------------------------ : ---- : ---- : ----
00013 # Errors                   :   17 :   13 :   30
00014 # Instructions             :    1 :    0 :    1
00015 # Notch                    :    0 :    1 :    1
00016 # Operands                 :    0 :    1 :    1
00017 # Test Code                :    1 :    0 :    1
00018 # _TOTAL_                  :   19 :   15 :   34
00019 #
00020 # Failures are caused by:
00021 #  * The tests assume that the order of the offset and register in the
00022 #    indexed operand format is reversible. The specification states that
00023 #    the format is 'nextword + register', not the converse.
00024 #    Action: Update assembler to allow the 'register + nextword' format.
00025 #
00026 #  * errors-15 uses 'DIV a,0' as a test. This is an INVALID test as the
00027 #    specification explicitly states that this is acceptable and results
00028 #    in both a and O being set to 0. This may be a reasonable operation,
00029 #    and produces a word in memory of 0x8002 which may be used for some
00030 #    magic code.
00031 #    Action: None. Test is invalid, and has been removed.
00032 #
00033 #  * errors-12 allows 'jsr a,a', when it should not be accepted.
00034 #    errors-11 also fails for the same reason.
00035 #    Action: Fix existing code; had a missing '^' anchor when checking
00036 #    the following line content. A few places in the instruction and symbol
00037 #    processing had omitted anchors; these were updated to correct the
00038 #    checks.
00039 #
00040 #  * errors-3 checks for too large a constant, which is being accepted.
00041 #    Action: Update the checks in the operand processing for constant
00042 #    values being outside the range. Allow -ve values for -0x10000 to -1,
00043 #    though, because they are useful.
00044 #
00045 #  * Test code was incorrectly penalising the first 'error' output for
00046 #    the output generated by the previous test.
00047 #    Action: Fixed the test code to look at the right file.
00048 #
00049 # Improvements based on results:
00050 #  * 'Parse error: Could not resolve all symbols to write out Address file'
00051 #    is produced if there are undefined symbols.
00052 #    Action: The report now includes the unresolved symbols.
00053 #
00054 # These tests are mostly a subset of those in the test-assemble and
00055 # test-assemble-fail directories.
00056 #
00057 
00058 
00059 ##
00060 # Assemble the .dasm file and run it; comparing to the expectation.
00061 addTest('name' => 'Assemble, checking output',
00062         'input'    => '(?<!errors-\d\d)(?<!.expect)\.dasm$',
00063         'expect'   => '.expect.dasm',
00064         'generate' => sub {
00065                 my ($directory, $input) = @_;
00066 
00067                 my $cmd = "./dasm.pl -o .dasm -i $directory/$input";
00068                 my ($rc, $output) = capture_output($cmd);
00069 
00070                 return ($rc, $output, $cmd);
00071             },
00072 
00073         'compare' => \&compare,
00074        );
00075 
00076 
00077 ##
00078 # Assemble the .dasm file, checking for expected failures
00079 addTest('name' => 'Assemble, expecting failures',
00080         'input'    => '(?<=errors-\d\d)\.dasm$',
00081         'expect'   => '.fail.output',
00082         'generate' => sub {
00083                 my ($directory, $input) = @_;
00084 
00085                 my $cmd = "./dasm.pl -o .dump -i $directory/$input";
00086                 my ($rc, $output) = capture_output($cmd);
00087 
00088                 return ($rc, $output, $cmd);
00089             },
00090 
00091         'compare' => \&comparefail,
00092        );
00093 
00094 
00095 # Must return true
00096 1;