DASM
|
00001 #!/usr/bin/perl -w 00002 ## 00003 # Test rules for the test-binary directory: positive tests of binary 00004 # load/save 00005 # 00006 # This script provides regression tests to ensure that binary load 00007 # routines produce the right results when loaded. 00008 # 00009 # *.expect.dump 00010 # The file *.bin is loaded and then dumped. 00011 # The result is compared to this output. 00012 # If they do not match, the differences are printed and we terminate. 00013 # This tests that the binary load is the correct endianess 00014 # 00015 # *.expect.bin 00016 # The file *.dump is loaded and then written to a binary output. 00017 # The result is compared to this output. 00018 # If they do not match, the locations are printed and we terminate. 00019 # This tests that the binary load is the correct endianess 00020 # This is then repeated for the *.expect.binle for little endian 00021 # format. 00022 # And again repeated for the *.expect.binbe for big endian 00023 # format. 00024 # 00025 # *.dasm 00026 # The file is assembled and then written to a binary file. It is 00027 # then compared to the *.expect.bin file. 00028 # If they do not match the differences are printed and we 00029 # terminate. 00030 00031 00032 ## 00033 # Assemble the .dasm file and write to a binary; comparing to the expectation. 00034 addTest('name' => 'Assemble and write binary', 00035 'input' => '(?<!expect)\.dasm$', 00036 'expect' => '.expect.bin', 00037 'generate' => sub { 00038 my ($directory, $input) = @_; 00039 00040 my $cmd = "./dasm.pl -o .bin -i $directory/$input"; 00041 my ($rc, $output) = capture_output($cmd); 00042 00043 return ($rc, $output, $cmd); 00044 }, 00045 00046 'compare' => \&binarycompare, 00047 ); 00048 00049 ## 00050 # Load the .bin file and dump it; comparing to the expectation. 00051 addTest('name' => 'Load binary and dump', 00052 'input' => '(?<!expect)\.bin$', 00053 'expect' => '.expect.dump', 00054 'generate' => sub { 00055 my ($directory, $input) = @_; 00056 00057 my $cmd = "./dasm.pl -o .dump -i $directory/$input"; 00058 my ($rc, $output) = capture_output($cmd); 00059 00060 return ($rc, $output, $cmd); 00061 }, 00062 00063 'compare' => \&compare, 00064 ); 00065 00066 ## 00067 # Load a binary file and write out a little-endian binary 00068 addTest('name' => 'Load binary and write little-endian', 00069 'input' => '(?<!expect)\.bin$', 00070 'expect' => '.expect.binle', 00071 'generate' => sub { 00072 my ($directory, $input) = @_; 00073 00074 my $cmd = "./dasm.pl -o .binle -i $directory/$input"; 00075 my ($rc, $output) = capture_output($cmd); 00076 00077 return ($rc, $output, $cmd); 00078 }, 00079 00080 'compare' => \&compare, 00081 ); 00082 00083 00084 ## 00085 # Load a binary file and write out a big-endian binary 00086 addTest('name' => 'Load binary and write big-endian', 00087 'input' => '(?<!expect)\.bin$', 00088 'expect' => '.expect.binbe', 00089 'generate' => sub { 00090 my ($directory, $input) = @_; 00091 00092 my $cmd = "./dasm.pl -o .binbe -i $directory/$input"; 00093 my ($rc, $output) = capture_output($cmd); 00094 00095 return ($rc, $output, $cmd); 00096 }, 00097 00098 'compare' => \&compare, 00099 ); 00100 00101 00102 # Must return true 00103 1;