OSDN Git Service

Add a compiler clang
[lha/lha.git] / tests / lha-test.in
index 53c3dad..e9826ec 100644 (file)
@@ -1,5 +1,25 @@
 #!/bin/bash
 
+print_usage()
+{
+  cat <<EOF
+usage: $0 [-n] [test number]
+
+option:
+   -n:   do not cleanup.
+EOF
+  exit
+}
+
+for _opt
+do
+   case $_opt in
+   --help) print_usage ;;
+   -n) no_cleanup=true; shift ;;
+   *) perform_number=$1; shift ;;
+   esac
+done
+
 # Be Bourne compatible
 # -- followings are derived from configure script generated by autoconf 2.59 --
 if test -n "${ZSH_VERSION+set}" && (emulate ksh) >/dev/null 2>&1; then
@@ -16,8 +36,12 @@ DUALCASE=1; export DUALCASE # for MKS sh
 : ${lha_dir=@top_builddir@/src}
 : ${lha_cmd=$(cd $lha_dir && pwd)/lha}
 : ${srcdir=@srcdir@}
+: ${builddir=$(cd @builddir@ && pwd)}
 
-trap '_stat=$?; rm -rf test-*; exit $_stat' 0 1 2 3 15
+if [[ x$no_cleanup = x ]]; then
+  trap '_stat=$?; chmod -R 755 test-* 2>/dev/null;
+        rm -rf test-*; exit $_stat' 0 1 2 3 15
+fi
 
 typeset -i i   # for loop
 typeset -i test_number=0 error_num=0
@@ -57,9 +81,24 @@ check()
   fi
 }
 
+# On HP-UX 11.23, "chmod -R" cannot change the file permission in
+# non-writable and non-executable directory.
+chmod_R()
+{
+  typeset mode="$1"; shift
+  for x in "$@"
+  do
+    chmod $mode "$x"
+    test -d "$x" && (cd "$x" && chmod_R $mode *)
+  done
+}
+
 cleanup()
 {
-  rm -rf test-tmp*
+  if [[ x$no_cleanup = x ]]; then
+    chmod_R 755 test-tmp* 2>/dev/null
+    rm -rf test-tmp*
+  fi
 }
 
 testsuite()
@@ -87,38 +126,60 @@ change_timestamp()
     # touch $time "$@"
 }
 
+identical_timestamp()
+{
+    test "$1" -nt "$2" || test "$1" -ot "$2"
+    test $? -ne 0
+}
+
 # test start
 
 message testing $lha_cmd
 message `$lha --version 2>&1`
 
 testsuite lha-test1            # create test data. it is needed for each test
-testsuite lha-test2
-testsuite lha-test3
-testsuite lha-test4
-testsuite lha-test5
-#testsuite lha-test6           # this feature was removed.
-testsuite lha-test7
-testsuite lha-test8
-#testsuite lha-test9           # incomplete
-testsuite lha-test10
-testsuite lha-test11
-testsuite lha-test12
-testsuite lha-test13
-case `$lha --version 2>&1` in
-*djgpp* | *-pc-mingw*)
-  # No symlink support on DJGPP and MinGW
-  message testing to handle symbolic links ... skip
-  ;;
-*)
-  testsuite lha-test14
-esac
-testsuite lha-test15
-testsuite lha-test16
+
+if [[ $perform_number != "" ]] && [[ $perform_number != all ]]; then
+  testsuite lha-test$perform_number
+else
+  testsuite lha-test2
+  testsuite lha-test3
+  testsuite lha-test4
+  testsuite lha-test5
+  #testsuite lha-test6         # this feature was removed.
+  testsuite lha-test7
+  testsuite lha-test8
+  #testsuite lha-test9         # incomplete
+  testsuite lha-test10
+  testsuite lha-test11
+  testsuite lha-test12
+  testsuite lha-test13
+  case `$lha --version 2>&1` in
+  *djgpp* | *-pc-mingw*)
+    # No symlink support on DJGPP and MinGW
+    message testing to handle symbolic links ... skip
+    ;;
+  *)
+    testsuite lha-test14
+    ;;
+  esac
+  testsuite lha-test15
+  testsuite lha-test16
+  testsuite lha-test17
+  testsuite lha-test18
+  testsuite lha-test19
+  # followings will take a long time
+  if [[ $perform_number = all ]]; then
+    testsuite lha-test51       # extract 2G over files
+    testsuite lha-test52       # extract 4G over files
+  fi
+fi
 
 if (( $error_num != 0 )); then
   message $error_num tests failed!
   message test number: $error_tests
+else
+  message All tests succeeded.
 fi
 
 exit $result