OSDN Git Service

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