Question: BASH AND COMMAND LINE SCRIPTS write two bash test scripts, named test1.sh and test2.sh: test1.sh passes if the file named test-code.c exists in the current
BASH AND COMMAND LINE SCRIPTS
write two bash test scripts, named test1.sh and test2.sh:
test1.sh passes if the file named test-code.c exists in the current working directory, successfully compiles, and the binary file test-code that is produced can be given execute permission. To say a program compiles means that gcc will compile the code with no errors when no libraries are specified. If test1.sh succeeds, then after it runs a binary file named test-code exists and has execute permission.
test2.sh passes if the binary file named test-code exists, and if binaries test-code (the code being tested) and gold-code (my reference implementation) produce the same output when the input is redirected to test2.txt. By the same output, I mean the same output when ignoring whitespace differences. You can assume binary test-code exists and has execute permission.
For example, to test your msh code, I would first run test1.sh, and then run test2.sh, where test2.txt might be a file having ls on the first line and exit on the second line.
Note: we will discuss redirection in class soon. I can write this at the bash command line:
./test-code < test2.txt
This means that when program test-code runs, and reads from standard input (normally standard input is the keyboard), the input will actually come from file test2.txt. This is called input redirection. Try it yourself from the command line with your msh code of last week.
There is also output redirection -- heres an example: (again at the command line)
ps > ps-out.txt
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
