Question
In part C (the final part of the assignment) you will be writing a program in python for testing if executables are compiling and running
In part C (the final part of the assignment) you will be writing a program in python for testing if executables are compiling and running correctly. For this particular PA, you should use it to test out the pythagorean.c program. In future assignments, you can re-use this program to test out other PAs. You are also welcome to add additional features to it in the future, though for the purpose of this PA you should stick to only the features described in the spec. The program you will write should be named sbt.py (Super Basic Tester) and should be located in the sbt directory within the pa1 directory, as indicated in the assignment summary. This program should accept two input values via standard input. The first will be the path / name of the .c file that it will be testing. The second will be the path / name to a directory containing test cases for the program. Your program should expect that the test directory will have the following structure:
The test directory should contain 0 or more directories within it, with names that correspond to what the name of that particular test. Each of these directories should have exactly two files within it named input.txt and output.txt. input.txt should contain whatever content you want to be sent as the standard input to the program being tested for this case. output.txt should contain the exact test that you expect your program to produce, given the corresponding standard input from input.txt. The outline of what this python program should do is as follows: 1. Ask the user for the two input values (.c file name and test directory) 2. Run a command to compile the .c program ( gcc -Wall -Werror -stc=c11 FILE.c ) 3. If the compilation failed for any reason, print "failed to compile your code" and then exit. 4. If it worked, loop through each of the directories within the test directory folder 5. For each one: a. Run the executable and give it the standard input text from input.txt b. Store / save what it prints to standard output c. Compare the result with the contents of the output.txt file d. If the same, print "#### Test: DIR_NAME passed! ####" e. If different, print "#### Test: DIR_NAME failed! ####" and then print out a comparison of the results.
test_directory test-A - 1 input.txt output.txt test-B F input.txt output.txt test_directory test-A - 1 input.txt output.txt test-B F input.txt output.txtStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started