Background
You will recall that, before the blur of Carnival, you implemented the SAMS Simulator as well as the compliant assembler. Since you are, no doubt, by this point in the semester, old and wise, you have already, surely, written a test driver to ensure the correctness of your solution.And, we want to give you credit for your effort. So, this week's lab is to write a test utility in either shell script or Perl. You might need to massage your existing test program to meet our spec -- but we're sure that it is close.
Should you discover any problems with your simulator or assembler during testing, please do correct the problems and let the course staff know by submitting a README.TXT, which describes your fixes, with your handin for this lab.
Invoking the Assembler and Simulator
Recall how the simulator is started:
ssim <memorysize> <assembledprogram> ssim 10000 someprogDitto for the assembler:
sas <sourceprog> <execprog> sas prog1.s prog1
Your task
Assume that you are given four directories
- One with test source files
- One with the expected output of these files
- One that will hold the assembled, executable version of the source files
- One that will hold the actual output of the executables
You are asked to write a test script that
- takes each file from the input directory, assembles it, and, if the assembler runs successfully, stores the resulting executible within the specified directory. If the assembler cannot complete, it should not create an output file (or delete any file it did create), and print to the console the message, "Source file XYZ could not be assembled." If would bebest to print this message to stderr rather than stdout.
- executes each of these executible files, storing the output into the output directory. If the simulator terminates abnormally, it should not delete any partial output, but should print to the console, "Simulator died running XYZ". As before, this would be best sent to stderr.
- Compares the output of each of these programs to the reference output, printing out, "Incorrect output for XYZ", if, and only if the output doesn't match. As before, stderr is best. No output should be produced if the reference output matches the program's actual output.
In order to make things straight-forward, please assume and follow the following naming convention:
- Source files end in .s
- Executible output files have the same name as the source files, but end in .o instead of .s
- The expected, reference output files have the same name as the .s files and the .o files, except they end in .ref
- The actual, program generated, output files have the same name as the .s files and the .o files, except they end in .out