#!/bin/bash # # This is a simple test script that tests flip # to make sure I haven't broken it before a release. # # installed as: /usr/lib/debian-test/tests/flip if test -n "${DEBIANTEST_LIB}" ; then # make sure flip is installed test -e /usr/bin/flip || exit 0 . ${DEBIANTEST_LIB}/functions.sh Debian=1 else echo "Please install debian-test before running this script" exit 1 fi TESTDIR=/usr/lib/debian-test/tests/flip TMP=/tmp/flip-test.$$ test1(){ rm -rf $TMP mkdir $TMP pushd $TMP >/dev/null RESULT=0 cat >text <text.msdos cp text text.unix flip -m text diff text text.msdos || RESULT=1 popd >/dev/null rm -rf $TMP return $RESULT } test2(){ rm -rf $TMP mkdir $TMP pushd $TMP >/dev/null RESULT=0 cat >text.unix <text flip -u text diff text text.unix || RESULT=1 popd >/dev/null rm -rf $TMP return $RESULT } test3(){ rm -rf $TMP mkdir $TMP pushd $TMP >/dev/null RESULT=0 echo $'Now is t\345he time\r\nfor all good men\r' >binary cp binary binary.before # this should leave the file unchanged, since it appears to be binary flip -u binary 2>&1 diff binary.before binary || RESULT=1 popd >/dev/null rm -rf $TMP return $RESULT } runtest "convert file from Unix to DOS" test1 runtest "convert file from DOS to Unix" test2 runtest "do not convert a binary file" test3