DASM
|
00001 #!/usr/bin/perl -w 00002 ## 00003 # Test rules for the test-interactive directory: positive tests of execution 00004 # and output. 00005 # 00006 # *.expect.output 00007 # The file *.dasm is assembled and run. 00008 # The script is run, using the *.input file as standard input. 00009 # The output is written to a file. 00010 # The result is compared to this file. 00011 # If they do not match, the differences are printed and we terminate. 00012 # This tests that the code execution is as expected - at least in 00013 # terms of the terminal registers. 00014 # 00015 # *.expect.screen 00016 # The file *.dasm is assembled and run. 00017 # The output is captured from within 'screen', as a 'hardcopy' of 00018 # the final screen. 00019 # If they do not match, the differences are printed and we terminate. 00020 # This tests that the code execution is as expected - at least in 00021 # terms of the terminal registers. 00022 # 00023 00024 00025 ## 00026 # Assemble the .dasm file and run it, with input redirected if present. 00027 addTest('name' => 'Assemble and run interactively', 00028 'input' => '(?<!expect)\.dasm$', 00029 'expect' => '.expect.output', 00030 'no-expect-skip' => 1, 00031 'generate' => sub { 00032 my ($directory, $input) = @_; 00033 00034 # If there's a '.input' file, we use it 00035 my $stdin = $input; 00036 $stdin =~ s/\.dasm/\.input/; 00037 if (-f "$directory/$stdin") 00038 { 00039 $stdin = "< $directory/$stdin"; 00040 } 00041 else 00042 { 00043 $stdin = ""; 00044 } 00045 00046 my $cmd = "./dasm.pl -showregs -nocounts -notimes -run -i $directory/$input $stdin"; 00047 my ($rc, $output) = capture_output($cmd); 00048 00049 return ($rc, $output, $cmd); 00050 }, 00051 00052 'compare' => \&compare, 00053 ); 00054 00055 00056 ## 00057 # Assemble the .dasm file and run it, with input redirected if present. 00058 addTest('name' => 'Assemble and run interactive screen', 00059 'input' => '(?<!expect)\.dasm$', 00060 'expect' => '.expect.screen', 00061 'no-expect-skip' => 1, 00062 'generate' => sub { 00063 my ($directory, $input) = @_; 00064 00065 # If there's a '.input' file, we use it 00066 my $stdin = $input; 00067 $stdin =~ s/\.dasm/\.input/; 00068 if (-f "$directory/$stdin") 00069 { 00070 $stdin = "$directory/$stdin"; 00071 } 00072 else 00073 { 00074 $stdin = "/dev/null"; 00075 } 00076 00077 00078 my $cmd = "screen -c $directory/screenrc -S dcpu16-test -D -m "; 00079 $cmd .= "test-interactive/capture.sh $stdin XXX.screen 80 32 "; 00080 $cmd .= "./dasm.pl -nocount -notimes -run -i $directory/$input"; 00081 00082 my ($rc, $output) = capture_output($cmd); 00083 if (!-f "XXX.screen") 00084 { 00085 # repeat the operation if the screen didn't appear - 00086 # seems to fail now and then on screen '4.00.03jw4' which 00087 # I use here. 00088 ($rc, $output) = capture_output($cmd); 00089 } 00090 00091 $output .= readfile("XXX.screen"); 00092 unlink "XXX.screen"; 00093 00094 return ($rc, $output, $cmd); 00095 }, 00096 00097 'compare' => \&compare, 00098 ); 00099 00100 00101 # Must return true 00102 1;