DASM
|
00001 #!/usr/bin/perl -w 00002 ## 00003 # Test rules for the test-assemble directory: positive tests. 00004 # 00005 # These routines provide regression tests to ensure that the assemble 00006 # routines generate the same results in repeated runs. 00007 # We process the files in this directories: 00008 # 00009 # *.expect.dump 00010 # The file *.dasm is assembled and then dumped. 00011 # The result is compared to this file. 00012 # If they do not match, the differences are printed and we terminate. 00013 # This tests that the assembler is generating the expected output 00014 # and that the dumped output is the same. 00015 # 00016 # *.expect.dasm 00017 # The file *.dasm is assembled and then disassembled. 00018 # The result is compared to this file. 00019 # If they do not match, the differences are printed and we terminate. 00020 # This tests that the assembly and disassembly are consistent. 00021 # This file is /also/ assembled and compared to the *.expect.dump 00022 # file. 00023 00024 00025 ## 00026 # Assemble the .dasm file and dump it; comparing to the expectation. 00027 addTest('name' => 'Assemble and dump', 00028 'input' => '(?<!expect)\.dasm$', 00029 'expect' => '.expect.dump', 00030 'generate' => sub { 00031 my ($directory, $input) = @_; 00032 00033 my $cmd = "./dasm.pl -o .dump -i $directory/$input"; 00034 my ($rc, $output) = capture_output($cmd); 00035 00036 return ($rc, $output, $cmd); 00037 }, 00038 00039 'compare' => \&compare, 00040 ); 00041 00042 ## 00043 # Assemble the .dasm file and disassemble it; compare to the expectation. 00044 addTest('name' => 'Assemble and Disassemble', 00045 'input' => '(?<!expect)\.dasm$', 00046 'expect' => '.expect.dasm', 00047 'generate' => sub { 00048 my ($directory, $input) = @_; 00049 00050 my $cmd = "./dasm.pl -o .dasm -i $directory/$input"; 00051 my ($rc, $output) = capture_output($cmd); 00052 00053 return ($rc, $output, $cmd); 00054 }, 00055 00056 'compare' => \&compare, 00057 ); 00058 00059 00060 ## 00061 # Assemble the .dasm file, disassemble it, reassemble and dump it; 00062 # Compare to the expectation. 00063 addTest('name' => 'Assemble, Disassemble and Dump', 00064 'input' => '(?<!expect)\.dasm$', 00065 'expect' => '.expect.dump', 00066 'generate' => sub { 00067 my ($directory, $input) = @_; 00068 00069 # Run the assembly 00070 unlink "XXX.dasm"; 00071 my $cmd1 = "./dasm.pl -o XXX.dasm -i $directory/$input"; 00072 my $cmd2; 00073 my ($rc, $output) = capture_output($cmd1); 00074 00075 if ($rc == 0) 00076 { 00077 # Only continue if the assembly was successful 00078 $cmd2 = "./dasm.pl -o .dump -i XXX.dasm"; 00079 my $moreoutput; 00080 ($rc, $moreoutput) = capture_output($cmd2); 00081 $output .= $moreoutput; 00082 unlink "XXX.dasm"; 00083 } 00084 00085 return ($rc, $output, "$cmd1\n$cmd2"); 00086 }, 00087 00088 'compare' => \&compare, 00089 ); 00090 00091 # Must return true 00092 1;