lundi 25 avril 2016

Compare executable output to text file using grep

I need a automated method to compare my C++ standard output to the 'expected output' test case files.

In the past I used a shell script that would execute my program by passing input, then comparing the output with grep to plain text. The problem now is that my output spans multiple lines and has much more test cases, making it much easier to compare expected output to a text file.

The test script I used in the past: cd / cd media/psf/Home/Developer/Project/ make

./a.out < tests/test01.txt | grep 'EXPECTED OUTPUT EXAMPLE' &> /dev/null
if [ $? == 0 ]; then
    echo "ERROR CODE 1.1: OK"
else
    echo "ERROR CODE 1.1: BAD"
fi
echo ""

How can I modify this to compare against a text file, rather than a literal string?

Aucun commentaire:

Enregistrer un commentaire