Thread: Shell script- regression testing

  1. #1

    Unhappy Shell script- regression testing

    I'm a beginner at shell scripts and i want to build a suite of tests so that all of the tests that have been executed on my program in the past can be executed on it again to check against bugs in a program.

    So basically the shell script runs a program with given inputs and compares the output with some expected output.

    I want the shell script to execute all tests instead of typing a command like this every time...
    ./this_program < input-1 > actual-output-1
    diff actual-output-1 expected-output-1

    Im thinking of using loops to interate over each case of a lot of inputs (input-1, input-2,...) and a lot of expected outputs (expected-output-1, expected-output-2,...) and I want it to be able to take the name of the program to invoke, the number of tests, and the directory that the tests they are in so i can test any program easily......I just don't know how to start the actual coding and the structure of it and use the name of the program etc..

    Can anyone please help???

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Rather than counting 1,2,3 etc, just assume that all the files in a directory are test files and test result files.

    By using known file suffixes, you can easily tell them apart, and also derive one from the other.

    cd $2
    # for each .txt input file, there is a .res file
    # containing the expected results
    for i in *.txt; do
      res=`basename $i .txt`.res
      $prog < $i > tmp
      diff $res tmp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. invoking shell script
    By agoel01 in forum C Programming
    Replies: 1
    Last Post: 12-01-2005, 11:37 AM
  2. testing a cgi script on my computer
    By Bigbio2002 in forum C Programming
    Replies: 1
    Last Post: 12-14-2003, 07:26 PM
  3. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM
  4. Running 'exec' twice in one UNIX shell script
    By Zughiaq in forum Tech Board
    Replies: 2
    Last Post: 05-03-2003, 12:04 AM
  5. Arguements with a shell script
    By Doh in forum Linux Programming
    Replies: 1
    Last Post: 11-28-2002, 02:20 PM