home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2840 < prev    next >
Internet Message Format  |  1991-02-22  |  3KB

  1. From: wayne@csri.toronto.edu (Wayne Hayes)
  2. Newsgroups: comp.os.minix,alt.sources
  3. Subject: Useful script for Beta testers: on-the-fly compare output of 2 progs
  4. Message-ID: <1991Feb23.010328.18506@jarvis.csri.toronto.edu>
  5. Date: 23 Feb 91 06:03:28 GMT
  6.  
  7. (I cancelled the first article of this title about 30 seconds after
  8. posting it.  I hope it didn't get very far.  This version is better.)
  9.  
  10. I wrote this little shell script to Beta test some POSIX programs that
  11. are going to be included in Minix 1.6.  It's purpose is to compare the
  12. output of two versions of a program to ensure they are identical.  It
  13. uses a crude algorithm to find if it should read a file or the standard
  14. input.  (Basically if there are any arguments not beginning with "-" or
  15. "+" they are assumed to be filenames.  Otherwise stdin is read.)
  16.  
  17. -----
  18. #!/bin/sh
  19. # a shell script to ensure the output of two versions of a program are identical
  20.  
  21. prog=`basename $0`
  22. files=''
  23. for i
  24. do
  25.     case "$i" in
  26.         -*) ;;
  27.         +*) ;;
  28.         *) files=1 ;;
  29.     esac
  30. done
  31.  
  32. if test -f "$files" </dev/null; then        # there are files
  33.     # this is the "correct" version; substitute whatever path you need
  34.     /usr/ucb/$prog "$@" >/tmp/$prog.$$
  35.     # this one is being tested; sneak it into the path before the above
  36.     /e/wayne/bin/prog.new "$@" >/tmp/$prog.new.$$
  37. else    # read the standard input
  38.     # we use a named pipe rather than creating a temp file
  39.     tee /e/wayne/bin/named_pipe | /usr/ucb/$prog "$@" >/tmp/$prog.$$ &
  40.     /e/wayne/bin/$prog.new "$@" </e/wayne/bin/named_pipe >/tmp/$prog.new.$$
  41. fi
  42.  
  43. # test that they're the same
  44. if cmp /tmp/$prog.$$ /tmp/$prog.new.$$; then
  45.     cat /tmp/$prog.$$
  46.     rm /tmp/$prog.$$ /tmp/$prog.new.$$
  47. else
  48.     echo -n "ERROR with the new version of $prog.  Arguments were
  49. $@
  50. Press return to continue" >/dev/tty
  51.     line </dev/tty
  52.     exit 127
  53. fi
  54.  
  55. -- 
  56. "You ask me what I think about war and the death penalty. The latter question
  57. is simpler. I am not for punishment at all, but only for the measures that
  58. serve society and it's protection." -- Albert Einstein
  59.  
  60. Wayne Hayes     INTERNET: wayne@csri.utoronto.ca        CompuServe: 72401,3525
  61. -- 
  62. "You ask me what I think about war and the death penalty. The latter question
  63. is simpler. I am not for punishment at all, but only for the measures that
  64. serve society and it's protection." -- Albert Einstein
  65.  
  66. Wayne Hayes     INTERNET: wayne@csri.utoronto.ca        CompuServe: 72401,3525
  67. -- 
  68. "You ask me what I think about war and the death penalty. The latter question
  69. is simpler. I am not for punishment at all, but only for the measures that
  70. serve society and it's protection." -- Albert Einstein
  71.  
  72. Wayne Hayes     INTERNET: wayne@csri.utoronto.ca        CompuServe: 72401,3525
  73.