# Tests for tail command; invoked by command file "fulltests"
#   Written by Dave Tribby (August 1997)
#   $Id: dotests,v 1.2 1997/10/03 03:52:25 gdr Exp $

# Location of the tail command to be tested
set testcmd="../tail"

# Record starting time
echo -n "Testing command $testcmd beginning at"
date

set src="file500.txt"
set cmp="f500.10l"
set dest="/tmp/$cmp"
echo "Listing last ten lines (default) of $src"
$testcmd $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}A"
echo "Listing last ten lines (default) of $src using stdin"
$testcmd < $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}B"
echo "Listing last ten lines (explicit) of $src"
$testcmd -n 10 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}C"
echo "Listing last ten lines (obsolescent) of $src"
$testcmd -10 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""


set cmp="f500.90c"
set dest="/tmp/$cmp"
echo "Listing last 90 chars of $src"
$testcmd -c 90 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}B"
echo "Listing last 90 chars (obsolescent) of $src"
$testcmd -90c $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""


set cmp="f500.1b"
set dest="/tmp/$cmp"
echo "Listing last block of $src"
$testcmd -b 1 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}A"
echo "Listing last block (obsolescent) of $src"
$testcmd -1b $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""


set cmp="f500.p400l"
set dest="/tmp/$cmp"
echo "Listing $src beginning at line 400"
$testcmd -n +400 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}A"
echo "Listing $src beginning at line 400 (obsolescent)"
$testcmd +400 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}B"
echo "Listing $src beginning at line 400 (obsolescent/explicit)"
$testcmd +400l $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""


set cmp="f500.p12040c"
set dest="/tmp/$cmp"
echo "Listing $src beginning at char 12040"
$testcmd -c +12040 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set dest="/tmp/${cmp}A"
echo "Listing $src beginning at char 12040 (obsolescent)"
$testcmd +12040c $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""


set cmp="$src"
set dest="/tmp/${cmp}N"
echo "Listing all of $src using -n option"
$testcmd -n +1 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set cmp="$src"
set dest="/tmp/${cmp}B"
echo "Listing all of $src using -b option"
$testcmd -b +1 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""

set cmp="$src"
set dest="/tmp/${cmp}C"
echo "Listing all of $src using -c option"
$testcmd -c +1 $src > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""


set cmp="multi.out"
set dest="/tmp/$cmp"
echo "Listing last 3 lines of f*.*"
$testcmd -n 3 f*.* > $dest
echo "  Completion status = $status"
echo "Checking results against control file $cmp (no differences expected)"
cmp $cmp $dest
echo "  Completion status = $status"
echo ""


echo "***** Error Messages *****"

set dest="/tmp/err.cond"

echo ""
echo "Expected error: illegal option"
$testcmd -x $src > $dest
echo "  Error completion status = $status (expected: 1)"

echo ""
echo "Expected error: illegal offset"
$testcmd -n 12x $src > $dest
echo "  Error completion status = $status (expected: 1)"

echo ""
set src="badname"
echo "Expected error: $src: no such file or directory"
$testcmd $src > $dest
echo "  Error completion status = $status (expected: 1)"
