#!/bin/bash : ${lha_dir=@top_builddir@/src} : ${lha=$(cd $lha_dir && pwd)/lha} : ${srcdir=@srcdir@} trap '_stat=$?; rm -rf test-*; exit $_stat' 0 1 2 3 15 typeset -i test_number=0 error_num=0 error_tests="" exec > test.log message() { echo "$@" >&2 echo "$@" } check() { ((test_number = test_number + 1)) typeset status=$1 typeset lineno=$2 if [[ $status -eq 0 ]]; then message test $test_number ... ok echo at line $lineno in $FILENAME else message test $test_number ... failed at line $lineno in $FILENAME ((error_num = error_num + 1)) error_tests="$error_tests #$test_number" result=1 fi } cleanup() { rm -rf test-tmp* } change_timestamp() { typeset time=$1; shift # assume that `touch' command supports POSIX's -t switch. # -t [[CC]YY]MMDDhhmm[.ss] touch -t $time "$@" # [[CC]YY]MMDDhhmm # touch $time "$@" } # create test data message testing $lha # the `FILENAME' variable should be set the each test filename. FILENAME=lha-test message testing to create/list/extract lha archive. typeset -i i=0 while (( i < 100 )) do echo foo ((i = i + 1)) done > test-a sed 's/foo/bar/g' < test-a > test-b sed 's/foo/baz/g' < test-a > test-c $lha c test-1.lzh test-a test-b test-c check $? $LINENO test -s test-1.lzh check $? $LINENO $lha l test-1.lzh check $? $LINENO test -d test-1 || mkdir test-1 mv test-[abc] test-1 $lha x test-1.lzh check $? $LINENO diff test-1/test-a test-a check $? $LINENO diff test-1/test-b test-b check $? $LINENO diff test-1/test-c test-c check $? $LINENO # followings are test data for remaining tests. test -f test-1.lzh && test -f test-a && test -f test-b && test -f test-c && test -d test-1 && test -f test-1/test-a && test -f test-1/test-b && test -f test-1/test-c check $? $LINENO . $srcdir/lha-test2; cleanup . $srcdir/lha-test3; cleanup . $srcdir/lha-test4; cleanup . $srcdir/lha-test5; cleanup # . $srcdir/lha-test6; cleanup # this feature was removed. . $srcdir/lha-test7; cleanup . $srcdir/lha-test8; cleanup case `$lha --version 2>&1` in *-pc-cygwin*|*-pc-mingw*) message testing extracting to existent files ... skip;; *) # . $srcdir/lha-test9; cleanup ;; esac . $srcdir/lha-test10; cleanup . $srcdir/lha-test11; cleanup . $srcdir/lha-test12; cleanup . $srcdir/lha-test13; cleanup case `$lha --version 2>&1` in *-pc-mingw*) message testing to handle symbolic links ... skip ;; *) . $srcdir/lha-test14; cleanup ;; esac . $srcdir/lha-test15; cleanup if (( $error_num != 0 )); then echo $error_num tests failed! >&2 echo test number: $error_tests >&2 fi exit $result