"Fossies" - the Fresh Open Source Software Archive

Member "cook-2.34/test/00/t0051a.sh" (25 Sep 2010, 2804 Bytes) of package /linux/misc/old/cook-2.34.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #
    3 #       cook - file construction tool
    4 #       Copyright (C) 1994, 1997, 1998, 2003, 2007, 2008 Peter Miller
    5 #
    6 #       This program is free software; you can redistribute it and/or modify
    7 #       it under the terms of the GNU General Public License as published by
    8 #       the Free Software Foundation; either version 3 of the License, or
    9 #       (at your option) any later version.
   10 #
   11 #       This program is distributed in the hope that it will be useful,
   12 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 #       GNU General Public License for more details.
   15 #
   16 #       You should have received a copy of the GNU General Public License
   17 #       along with this program. If not, see
   18 #       <http://www.gnu.org/licenses/>.
   19 #
   20 work=${COOK_TMP:-/tmp}/$$
   21 PAGER=cat
   22 export PAGER
   23 umask 022
   24 unset COOK
   25 here=`pwd`
   26 if test $? -ne 0 ; then exit 1; fi
   27 
   28 bin="$here/${1-.}/bin"
   29 
   30 fail()
   31 {
   32         set +x
   33         echo 'FAILED test of the newest/oldest mtime functionality' 1>&2
   34         cd $here
   35         rm -rf $work
   36         exit 1
   37 }
   38 pass()
   39 {
   40         set +x
   41         cd $here
   42         rm -rf $work
   43         exit 0
   44 }
   45 trap \"fail\" 1 2 3 15
   46 
   47 mkdir $work $work/lib
   48 if test $? -ne 0 ; then exit 1; fi
   49 cd $work
   50 if test $? -ne 0 ; then fail; fi
   51 
   52 #
   53 # Use the default error messages.  There is no other way to get
   54 # predictable test behaviour on the unknown systems we will be tested on.
   55 #
   56 COOK_MESSAGE_LIBRARY=$work/no-such-dir
   57 export COOK_MESSAGE_LIBRARY
   58 unset LANG
   59 
   60 #
   61 # create the input files
   62 #
   63 cat > Howto.cook << 'fubar'
   64 set fingerprint update;
   65 test: first second
   66 {
   67         sleep 2
   68                 set silent;
   69         cat first second > test;
   70 }
   71 
   72 first: same
   73 {
   74         if [exists first] then
   75         {
   76                 echo this should not happen
   77                         set silent;
   78                 fail;
   79         }
   80         sleep 2
   81                 set silent;
   82         cat same same > first;
   83 }
   84 
   85 second: different
   86 {
   87         sleep 2
   88                 set silent;
   89         cat different different > second;
   90 }
   91 
   92 same different: leaf
   93 {
   94         sleep 2
   95                 set silent;
   96         echo same > same;
   97         date > different;
   98         cat leaf leaf >> different;
   99 }
  100 fubar
  101 if test $? -ne 0 ; then fail; fi
  102 echo "boring" > leaf
  103 if test $? -ne 0 ; then fail; fi
  104 
  105 #
  106 # let the clock tick over
  107 #
  108 sleep 2
  109 
  110 #
  111 # cook everything up
  112 #
  113 $bin/cook -nl -silent
  114 if test $? -ne 0 ; then fail; fi
  115 
  116 #
  117 # let the clock tick over
  118 #
  119 sleep 2
  120 
  121 #
  122 # change the leaf-most file
  123 #
  124 echo "ha ha" > leaf
  125 
  126 #
  127 # cook everything up
  128 #       should not hit the "fail" action
  129 #
  130 $bin/cook -nl -silent
  131 if test $? -ne 0 ; then fail; fi
  132 
  133 #
  134 # Only definite negatives are possible.
  135 # The functionality exercised by this test appears to work,
  136 # no other guarantees are made.
  137 #
  138 pass