[prev] [index] [next]

Automating Testing (cont)

A simple generic testing "harness":

#!/bin/sh
# Executable program is called myprog
# Sample inputs are in test1.inp, test2.inp, ...
# Expected outputs are in test1.out, test2.out, ...

for data in test*.inp
do
    d=`basename $data .inp`
    ./myprog < $data > actual.out
    if diff $d.out actual.out >.diffs
    then
        : Ok, so say nothing
    else
        echo "$d fails"
        mv .diffs $d.errs
    fi
done