"Fossies" - the Fresh Open Source Software Archive

Member "hd2u-1.0.4/test.sh" (1 Sep 2017, 2227 Bytes) of package /linux/privat/hd2u-1.0.4.tgz:


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. See also the latest Fossies "Diffs" side-by-side code changes report for "test.sh": 1.0.3_vs_1.0.4.

    1 #!/bin/sh
    2 #
    3 # This performs testing conversion "circular" conversions:
    4 #   UNIX->MAC->DOS->UNIX and
    5 #   UNIX->DOS->MAC->UNIX
    6 # on hd2u thus testing all conversions - whether they do not corrupt data.
    7 #
    8 # Copyright (C) 2006 Peter Hanecak <hany@hany.sk>
    9 #
   10 # This program is free software; you can redistribute it and/or
   11 # modify it under the terms of the GNU General Public License
   12 # as published by the Free Software Foundation; either version 2
   13 # of the License, or (at your option) any later version.
   14 #
   15 # This program is distributed in the hope that it will be useful,
   16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18 # GNU General Public License for more details.
   19 #
   20 # You should have received a copy of the GNU General Public License
   21 # along with this program; if not, write to the Free Software
   22 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   23 #
   24 # See the COPYING file for license information.
   25 
   26 HD2U=./dos2unix
   27 MD5=`which md5sum`
   28 SILENT=false
   29 TEMP_FILE=$$.test.tmp
   30 
   31 
   32 if [ ! -e $MD5 ]; then
   33     echo "${0}: unable to locate md5 utility - unable to perform tests"
   34     exit -1
   35 fi
   36 if [ "$TEMP_FILE" == "" ]; then
   37     echo "${0}: TEMP_FILE is empty!"
   38     exit -2
   39 fi
   40 if [ -e "$TEMP_FILE" ]; then
   41     echo "${0}: temporary file $TEMP_FILE alredy exists!"
   42     exit -3
   43 fi
   44 
   45 
   46 if [ "$1" == "--silent" ]; then
   47     SILENT=true
   48     shift
   49 fi
   50 
   51 
   52 while [ "$1" != "" ]; do
   53     TEST_FILE=$1
   54     if [ ! -e "$TEST_FILE" ]; then
   55         echo "${0}: test file $TEST_FILE does not exists!"
   56         exit -4
   57     fi
   58     if [ "$SILENT" != "true" ]; then echo -n "testing conversions on ${TEST_FILE}: "; fi
   59 
   60     MD5_CS_ORIG=`cat $TEST_FILE | $MD5`
   61 
   62     cat $TEST_FILE \
   63         | $HD2U --u2m \
   64         | $HD2U --m2d \
   65         | $HD2U --d2u \
   66         > $TEMP_FILE
   67     MD5_CS_TEST=`cat $TEMP_FILE | $MD5`
   68     if [ "$MD5_CS_ORIG" != "$MD5_CS_TEST" ]; then
   69         echo "test 1 of circular conversion failed"
   70         exit -5
   71     fi
   72 
   73     cat $TEST_FILE \
   74         | $HD2U --u2d \
   75         | $HD2U --d2m \
   76         | $HD2U --m2u \
   77         > $TEMP_FILE
   78     MD5_CS_TEST=`cat $TEMP_FILE | $MD5`
   79     if [ "$MD5_CS_ORIG" != "$MD5_CS_TEST" ]; then
   80         echo "test 2 of circular conversion failed"
   81         exit -6
   82     fi
   83 
   84     if [ "$SILENT" != "true" ]; then echo "OK"; fi
   85 
   86     shift
   87 done
   88 
   89 rm -f $TEMP_FILE
   90 
   91 exit 0
   92