"Fossies" - the Fresh Open Source Software Archive

Member "sitecopy-0.16.6/tests/server.test" (2 Jan 2005, 2392 Bytes) of archive /linux/www/sitecopy-0.16.6.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 # Server testing.
    3 # Pass sitename as argument #1, directory as argument #2, logfile as #3
    4 # PRECONDITIONS: Localdir, remote dir empty, .sitecopy/sitename empty
    5 # TODO: Check whether preconditions hold.
    6 
    7 failexit() {
    8     echo
    9     echo FAIL: on test: $1
   10     echo $tests completed successfully before failure.
   11     echo
   12     exit 1
   13 }
   14 
   15 runsitecopy() {
   16     sitecopy $scargs $* $sitename 1>&3 2>&4
   17     return $?
   18 }
   19 
   20 # Called for a test which should succeed
   21 # with sitecopy optype as arg 1, test name as arg 2
   22 oktest() {
   23     echo "***** Test: $2 *****" 1>&3 1>&4
   24     echo "Runing test: $2"
   25     if ! runsitecopy $1; then
   26         echo "- Test failed."
   27         failexit $2
   28     else
   29         echo "- Test succeeded."
   30     fi
   31     tests=$[ tests + 1 ];
   32 }
   33 
   34 # Called for a test which should fail
   35 # with sitecopy optype as arg 1, test name as arg 2
   36 failtest() {
   37     # Failure test
   38     echo "Running test: $2"
   39     echo "***** Test: $2 *****" >&3 >&4
   40     if runsitecopy $1; then
   41         echo "- Test failed."
   42         failexit
   43     else
   44         echo "- Test succeeded."
   45     fi
   46     tests=$[ tests + 1 ];
   47 }
   48 
   49 if [ $# -ne 3 ]; then
   50     echo Usage: $0 sitename localdir logfile
   51     exit -1
   52 fi
   53 ### Set this appropriately ###
   54 scargs="--debug=9"
   55 tests=0
   56 sitename=$1
   57 ldir=$2
   58 cd $ldir
   59 logfile=$3-out
   60 debugfile=$3-debug
   61 # Use fd 3 for the logfile
   62 exec 3> $logfile
   63 exec 4> $debugfile
   64 echo Logging started 1>&3
   65 
   66 #### Create directory
   67 mkdir foo
   68 oktest --update "Create directory"
   69 
   70 ### Upload file
   71 echo "hello world" > foo/file
   72 oktest --update "Upload file"
   73 
   74 ### Move file
   75 mv foo/file file
   76 oktest --update "Move file"
   77 
   78 ### Remove directory
   79 rmdir foo
   80 oktest --update "Remove directory"
   81 
   82 ### Remove file
   83 rm file
   84 oktest --update "Remove file"
   85 
   86 ### Uploading weird filenames
   87 touch "this<is>>a>weird>name"
   88 oktest --update "Upload weird filename"
   89 
   90 ### Fetching weird filenames
   91 oktest --fetch "Fetch weird filename"
   92 
   93 ### Deleting weird filenames
   94 # Only here to clear the decks
   95 rm "this<is>>a>weird>name"
   96 oktest --update "Delete weird filename"
   97 
   98 ### Create an existing directory
   99 mkdir bar
  100 runsitecopy --update
  101 rmdir bar
  102 runsitecopy --init $sitename
  103 mkdir bar
  104 failtest --update "Create existing directory"
  105 
  106 ### Delete a nonexistent directory
  107 mkdir norman
  108 runsitecopy --catchup
  109 rmdir norman
  110 failtest --update "Delete nonexistent directory"
  111 
  112 ### Download file
  113 runsitecopy --catchup
  114 echo hello world > myfile
  115 runsitecopy --update
  116 rm myfile
  117 oktest --synch "Download file"
  118 
  119 ### End of tests
  120 echo
  121 echo PASS: $tests tests completed.
  122 echo
  123