The shell.c
file in this repo is a copy of the original file provided with the first homework assignment. Along with it are text files which you can use to run a comprehensive set of commands to ensure your code meets the requirement laid out in the homework specifications. Some of these tests are based on the manual test description in the Testers/2022A/ex2
folder from the shared TAU Computer Science Drive.
- Clone this repository and copy your
myshell.c
file into the resulting folder. - Compile your code along with the test file using
gcc -O3 -D_POSIX_C_SOURCE=200809 -Wall -std=c11 shell.c myshell.c -o shell
- Run the following command:
./shell < in.txt
. The automated tests should start running, with information on each step and its expected output displayed throughout. Please note that incorrect code may lead to unexpected behavior. - If you wish, you may redirect your test output into a new file by running
./shell < in.txt > myout.txt
. This is not recommended without first looking at the output in real time because the automated tests partially rely on timing which is not reflected in the output in retrospect. - This repository also includes an expected output file
out.txt
if you would like to compare your output to the expected output in its entirety. The easiest way to do so is to rundiff out.txt myout.txt -y -d
(make sure your terminal is in fullscreen mode for this). You can also view only the expected output by runningcat < out.txt
. Please note that this file contains the expected output when run on Nova, which is slightly different from the output you will get if you run the tests on your virtual machine. - When running the tests on Nova, you might see error messages such as
pkill: killing pid ##### failed: Operation not permitted
after the tests' output. This is perfectly fine. (Messages like this are caused by the pkill command at the end ofin.txt
, which is used to terminate the long background sleep used in the last part of the input file.)
Unfortunately, not all of the necessary test cases could be appropriately automated. It is therefore highly recommended that you run the following commands manually after the automated tests finish running:
man echo
should open the manual entry forecho
, enabling you to scroll with theEnter
key and exit with theq
key.- Each of the following commands should result in an error message:
undefined
undefined &
undefined < test.txt
cat < undefined.txt
undefined | undefined
(should yield two error messages!)echo hi | undefined
(might yieldwrite error: Broken pipe
in addition to standard error message on Nova)undefined | echo hi
(either an error message then "hi" or just an error message should be alright)
- Signal handling tests (important! don't skip these):
- See the various tests that include
SIGINT
(^C
) and other signals throughout the PDF on Google Drive.
You can also put your code to the test by opening a shell session via ./shell
, then running ./shell < in.txt
within that session. Note that redirecting the output is not possible in this setting since our custom shell doesn't support output redirection.
If you come across what you believe to be unexpected test behavior or edge cases that are not covered by the tests in their current form, please make sure there are no problems with your code. If not, you are welcome to submit a PR with a fix.