OSDN Git Service

53c3dade4731282fe1117a1e567f98af56056fa1
[lha/lha.git] / tests / lha-test.in
1 #!/bin/bash
2
3 # Be Bourne compatible
4 # -- followings are derived from configure script generated by autoconf 2.59 --
5 if test -n "${ZSH_VERSION+set}" && (emulate ksh) >/dev/null 2>&1; then
6   emulate ksh
7   NULLCMD=:
8   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
9   # is contrary to our usage.  Disable this feature.
10   alias -g '${1+"$@"}'='"$@"'
11 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
12   set -o posix
13 fi
14 DUALCASE=1; export DUALCASE # for MKS sh
15
16 : ${lha_dir=@top_builddir@/src}
17 : ${lha_cmd=$(cd $lha_dir && pwd)/lha}
18 : ${srcdir=@srcdir@}
19
20 trap '_stat=$?; rm -rf test-*; exit $_stat' 0 1 2 3 15
21
22 typeset -i i    # for loop
23 typeset -i test_number=0 error_num=0
24 error_tests=""
25
26 # fd 1: for logging
27 # fd 2: output screen
28 # fd 5: for logging
29 exec 5>test.log >&5
30
31 lha=exec_lha
32 exec_lha()
33 {
34   echo "$ lha $@" >&5   # for logging (stdout(fd 1) may be redirected)
35   $lha_cmd "$@"
36 }
37
38 message()
39 {
40   echo "$@" >&2
41   echo "$@"
42 }
43
44 check()
45 {
46   ((test_number = test_number + 1))
47   typeset exit_status=$1
48   typeset lineno=$2
49   if [[ $exit_status -eq 0 ]]; then
50     echo    "$FILENAME #$test_number ... ok" >&2
51     echo    "$FILENAME #$test_number ... ok at line $lineno"
52   else
53     message "$FILENAME #$test_number ... failed at line $lineno"
54     ((error_num = error_num + 1))
55     error_tests="$error_tests $FILENAME #$test_number"
56     result=1
57   fi
58 }
59
60 cleanup()
61 {
62   rm -rf test-tmp*
63 }
64
65 testsuite()
66 {
67     # the `FILENAME' variable should be set the each test filename.
68     FILENAME=$1 test_number=0
69
70     . $srcdir/$FILENAME
71
72     cleanup
73 }
74
75 # utility functions
76
77 change_timestamp()
78 {
79     typeset time=$1; shift
80
81     # assume that `touch' command supports POSIX's -t switch.
82
83     # -t [[CC]YY]MMDDhhmm[.ss]
84     touch -t $time "$@"
85
86     # [[CC]YY]MMDDhhmm
87     # touch $time "$@"
88 }
89
90 # test start
91
92 message testing $lha_cmd
93 message `$lha --version 2>&1`
94
95 testsuite lha-test1             # create test data. it is needed for each test
96 testsuite lha-test2
97 testsuite lha-test3
98 testsuite lha-test4
99 testsuite lha-test5
100 #testsuite lha-test6            # this feature was removed.
101 testsuite lha-test7
102 testsuite lha-test8
103 #testsuite lha-test9            # incomplete
104 testsuite lha-test10
105 testsuite lha-test11
106 testsuite lha-test12
107 testsuite lha-test13
108 case `$lha --version 2>&1` in
109 *djgpp* | *-pc-mingw*)
110   # No symlink support on DJGPP and MinGW
111   message testing to handle symbolic links ... skip
112   ;;
113 *)
114   testsuite lha-test14
115 esac
116 testsuite lha-test15
117 testsuite lha-test16
118
119 if (( $error_num != 0 )); then
120   message $error_num tests failed!
121   message test number: $error_tests
122 fi
123
124 exit $result