lundi 31 août 2015

Writing Bash script to test C Program

I am quite new to bash scripting and I am thinking of using it to run few test cases for my C program. I have my results expected in a file called output.txt

I run my program:

./a.out > output_res_gen.txt

diff output_gen.txt output_res_gen.txt

If the program has run correct I get the following difference:

10001c10001
< Time: 0.291555
---
> Time: 0.111091

(That is time taken to execute the code, which can vary).

I wrote my bash script as follows:

#!/bin/bash
cd ..
./a.out > ../tests/output_res_gen.txt
diff ../tests/output_gen.txt ../tests/output_res_gen.txt

However my code does not execute (./a.out does not run). Also is there a way to find the difference between the 2 files and verify that the only difference is in between the time to execute?

Aucun commentaire:

Enregistrer un commentaire