home *** CD-ROM | disk | FTP | other *** search
- From: wayne@csri.toronto.edu (Wayne Hayes)
- Newsgroups: comp.os.minix,alt.sources
- Subject: Useful script for Beta testers: on-the-fly compare output of 2 progs
- Message-ID: <1991Feb23.010328.18506@jarvis.csri.toronto.edu>
- Date: 23 Feb 91 06:03:28 GMT
-
- (I cancelled the first article of this title about 30 seconds after
- posting it. I hope it didn't get very far. This version is better.)
-
- I wrote this little shell script to Beta test some POSIX programs that
- are going to be included in Minix 1.6. It's purpose is to compare the
- output of two versions of a program to ensure they are identical. It
- uses a crude algorithm to find if it should read a file or the standard
- input. (Basically if there are any arguments not beginning with "-" or
- "+" they are assumed to be filenames. Otherwise stdin is read.)
-
- -----
- #!/bin/sh
- # a shell script to ensure the output of two versions of a program are identical
-
- prog=`basename $0`
- files=''
- for i
- do
- case "$i" in
- -*) ;;
- +*) ;;
- *) files=1 ;;
- esac
- done
-
- if test -f "$files" </dev/null; then # there are files
- # this is the "correct" version; substitute whatever path you need
- /usr/ucb/$prog "$@" >/tmp/$prog.$$
- # this one is being tested; sneak it into the path before the above
- /e/wayne/bin/prog.new "$@" >/tmp/$prog.new.$$
- else # read the standard input
- # we use a named pipe rather than creating a temp file
- tee /e/wayne/bin/named_pipe | /usr/ucb/$prog "$@" >/tmp/$prog.$$ &
- /e/wayne/bin/$prog.new "$@" </e/wayne/bin/named_pipe >/tmp/$prog.new.$$
- fi
-
- # test that they're the same
- if cmp /tmp/$prog.$$ /tmp/$prog.new.$$; then
- cat /tmp/$prog.$$
- rm /tmp/$prog.$$ /tmp/$prog.new.$$
- else
- echo -n "ERROR with the new version of $prog. Arguments were
- $@
- Press return to continue" >/dev/tty
- line </dev/tty
- exit 127
- fi
-
- --
- "You ask me what I think about war and the death penalty. The latter question
- is simpler. I am not for punishment at all, but only for the measures that
- serve society and it's protection." -- Albert Einstein
-
- Wayne Hayes INTERNET: wayne@csri.utoronto.ca CompuServe: 72401,3525
- --
- "You ask me what I think about war and the death penalty. The latter question
- is simpler. I am not for punishment at all, but only for the measures that
- serve society and it's protection." -- Albert Einstein
-
- Wayne Hayes INTERNET: wayne@csri.utoronto.ca CompuServe: 72401,3525
- --
- "You ask me what I think about war and the death penalty. The latter question
- is simpler. I am not for punishment at all, but only for the measures that
- serve society and it's protection." -- Albert Einstein
-
- Wayne Hayes INTERNET: wayne@csri.utoronto.ca CompuServe: 72401,3525
-