initial import
[staff/goc4/2018bti7061.git] / c-project / test.sh
1 #!/bin/sh
2 gcc ps.c -o ps || { echo "C code failed to compile"; exit 1; }
3 timeout -s SIGKILL 1s ./ps > raw.out || { echo "Your 'ps' command failed to run" ; exit 1 ; }
4 cat raw.out | grep -v ps | grep -v timeout | sort -n > have.out
5 /bin/ps x -o pid,comm,rss > raw2.out || { echo "System 'ps' failed to run"; exit 2; }
6 cat raw2.out | grep -v "COMMAND" | grep -v ps | sort -n > want.out
7 diff -w want.out have.out > delta.txt || { echo "Fail, delta is:" ; cat delta.txt ; exit 1; }
8 echo "Test passed"