Merge branch 'master' of git.bfh.ch:/staff/goc4/2018bti7061
[staff/goc4/2018bti7061.git] / c-project / test.sh
CommitLineData
462e967d
CG
1#!/bin/sh
2gcc ps.c -o ps || { echo "C code failed to compile"; exit 1; }
3timeout -s SIGKILL 1s ./ps > raw.out || { echo "Your 'ps' command failed to run" ; exit 1 ; }
4cat 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; }
6cat raw2.out | grep -v "COMMAND" | grep -v ps | sort -n > want.out
7diff -w want.out have.out > delta.txt || { echo "Fail, delta is:" ; cat delta.txt ; exit 1; }
8echo "Test passed"