"Fossies" - the Fresh Open Source Software Archive

Member "zutils-1.10/testsuite/check.sh" (5 Jan 2021, 21985 Bytes) of package /linux/privat/zutils-1.10.tar.lz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes reports for "check.sh": 1.10-rc1_vs_1.10 or 1.9_vs_1.10.

    1 #! /bin/sh
    2 # check script for Zutils - Utilities dealing with compressed files
    3 # Copyright (C) 2009-2021 Antonio Diaz Diaz.
    4 #
    5 # This script is free software: you have unlimited permission
    6 # to copy, distribute, and modify it.
    7 
    8 LC_ALL=C
    9 export LC_ALL
   10 objdir=`pwd`
   11 testdir=`cd "$1" ; pwd`
   12 ZCAT="${objdir}"/zcat
   13 ZCMP="${objdir}"/zcmp
   14 ZDIFF="${objdir}"/zdiff
   15 ZGREP="${objdir}"/zgrep
   16 ZEGREP="${objdir}"/zegrep
   17 ZFGREP="${objdir}"/zfgrep
   18 ZTEST="${objdir}"/ztest
   19 ZUPDATE="${objdir}"/zupdate
   20 compressors="bzip2 gzip lzip"
   21 extensions="bz2 gz lz"
   22 compressor_needed() { echo "${compressors} are needed to run tests" ; exit 1 ; }
   23 framework_failure() { echo "failure in testing framework" ; exit 1 ; }
   24 
   25 if [ ! -f "${ZUPDATE}" ] || [ ! -x "${ZUPDATE}" ] ; then
   26     echo "${ZUPDATE}: cannot execute"
   27     exit 1
   28 fi
   29 
   30 [ -e "${ZUPDATE}" ] 2> /dev/null ||
   31     {
   32     echo "$0: a POSIX shell is required to run the tests"
   33     echo "Try bash -c \"$0 $1 $2\""
   34     exit 1
   35     }
   36 
   37 if [ -d tmp ] ; then rm -rf tmp ; fi
   38 mkdir tmp
   39 cd "${objdir}"/tmp || framework_failure
   40 
   41 for i in ${compressors}; do
   42     cat "${testdir}"/test.txt > in || framework_failure
   43     $i in || compressor_needed
   44     printf "Hello World!\n" > hello || framework_failure
   45     $i hello || compressor_needed
   46 done
   47 
   48 cat "${testdir}"/test.txt > in || framework_failure
   49 cat "${testdir}"/test.txt.tar > in.tar || framework_failure
   50 printf "01234567890" > pin.tar || framework_failure
   51 cat in.tar in.tar in.tar in.tar >> pin.tar || framework_failure
   52 cat in > -in- || framework_failure
   53 cat in.lz > -in-.lz || framework_failure
   54 cat in.lz > lz_only.lz || framework_failure
   55 cat in in in in in in > in6 || framework_failure
   56 bad0_lz="${testdir}"/zero_bad_crc.lz
   57 bad0_gz="${testdir}"/zero_bad_crc.gz
   58 bad1_lz="${testdir}"/test_bad_crc.lz
   59 touch empty empty.bz2 empty.gz empty.lz
   60 fail=0
   61 test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; }
   62 
   63 printf "testing    zcat-%s..." "$2"
   64 
   65 for i in ${extensions}; do
   66     "${ZCAT}" -N in.$i > copy || test_failed $LINENO $i
   67     cmp in copy || test_failed $LINENO $i
   68     "${ZCAT}" -N empty.$i in.$i > copy || test_failed $LINENO $i
   69     cmp in copy || test_failed $LINENO $i
   70     "${ZCAT}" -N --format=un in.$i > copy || test_failed $LINENO $i
   71     cmp in copy || test_failed $LINENO $i
   72     "${ZCAT}" -N --force-format=$i in.$i > copy || test_failed $LINENO $i
   73     cmp in copy || test_failed $LINENO $i
   74     "${ZCAT}" -N in.$i | dd bs=1000 count=1 > copy 2> /dev/null ||
   75         test_failed $LINENO $i
   76     dd if=in bs=1000 count=1 2> /dev/null | cmp - copy ||
   77         test_failed $LINENO $i
   78 done
   79 
   80 printf "LZIP\001-.............................." | "${ZCAT}" -N > /dev/null 2>&1
   81 [ $? = 1 ] || test_failed $LINENO
   82 printf "LZIPxxxxxx" | "${ZCAT}" -N > /dev/null || test_failed $LINENO
   83 printf "BZh9xxxxxx" | "${ZCAT}" -N > /dev/null || test_failed $LINENO
   84 "${ZCAT}" -N -v -s "${testdir}"/zcat_vs.dat > /dev/null || test_failed $LINENO
   85 "${ZCAT}" -N < in > copy || test_failed $LINENO
   86 cmp in copy || test_failed $LINENO
   87 "${ZCAT}" -N < in.gz > copy || test_failed $LINENO
   88 cmp in copy || test_failed $LINENO
   89 "${ZCAT}" -N < in.bz2 > copy || test_failed $LINENO
   90 cmp in copy || test_failed $LINENO
   91 "${ZCAT}" -N < in.lz > copy || test_failed $LINENO
   92 cmp in copy || test_failed $LINENO
   93 "${ZCAT}" -N -O lz - - < in.lz > copy || test_failed $LINENO
   94 cmp in copy || test_failed $LINENO
   95 "${ZCAT}" -N --lz='lzip -q' < in.lz > copy || test_failed $LINENO
   96 cmp in copy || test_failed $LINENO
   97 "${ZCAT}" -N in > copy || test_failed $LINENO
   98 cmp in copy || test_failed $LINENO
   99 "${ZCAT}" -N lz_only > copy || test_failed $LINENO
  100 cmp in copy || test_failed $LINENO
  101 cat in.lz in in in in | "${ZCAT}" -N > copy || test_failed $LINENO  # tdata
  102 cmp in copy || test_failed $LINENO
  103 "${ZCAT}" -N in in.gz in.bz2 in.lz -- -in- -in-.lz > copy || test_failed $LINENO
  104 cmp in6 copy || test_failed $LINENO
  105 "${ZCAT}" -Nq in in.gz in.bz2 in.lz "${bad0_lz}" -- -in- -in-.lz > copy
  106 [ $? = 1 ] || test_failed $LINENO
  107 cmp in6 copy || test_failed $LINENO
  108 "${ZCAT}" -Nq "${bad1_lz}" -- -in-.lz in in.gz in.bz2 in.lz > copy
  109 [ $? = 1 ] || test_failed $LINENO
  110 cmp in6 copy || test_failed $LINENO
  111 "${ZCAT}" -N . || test_failed $LINENO
  112 "${ZCAT}" -N -r . > /dev/null || test_failed $LINENO
  113 "${ZCAT}" -N -r > /dev/null || test_failed $LINENO
  114 "${ZCAT}" -N -R . > /dev/null || test_failed $LINENO
  115 "${ZCAT}" -N -R > /dev/null || test_failed $LINENO
  116 
  117 "${ZCAT}" -Nq "" < in.lz > /dev/null
  118 [ $? = 1 ] || test_failed $LINENO
  119 "${ZCAT}" -Nq --format=, in.lz
  120 [ $? = 1 ] || test_failed $LINENO
  121 "${ZCAT}" -Nq --format=,lz in.lz
  122 [ $? = 1 ] || test_failed $LINENO
  123 "${ZCAT}" -Nq --format=gz,,lz in.lz
  124 [ $? = 1 ] || test_failed $LINENO
  125 "${ZCAT}" -Nq --format=lz,, in.lz
  126 [ $? = 1 ] || test_failed $LINENO
  127 "${ZCAT}" -Nq --format=nc in.lz
  128 [ $? = 1 ] || test_failed $LINENO
  129 "${ZCAT}" -Nq --lz='-lzip -q' in.lz
  130 [ $? = 1 ] || test_failed $LINENO
  131 "${ZCAT}" -N --force-format=gz in.bz2 2> /dev/null
  132 [ $? = 1 ] || test_failed $LINENO
  133 "${ZCAT}" -N --force-format=bz2 in.lz 2> /dev/null
  134 [ $? = 1 ] || test_failed $LINENO
  135 "${ZCAT}" -Nq --force-format=lz in.gz
  136 [ $? = 1 ] || test_failed $LINENO
  137 "${ZCAT}" -N --bad-option 2> /dev/null
  138 [ $? = 1 ] || test_failed $LINENO
  139 
  140 
  141 printf "\ntesting    zcmp-%s..." "$2"
  142 
  143 for i in ${extensions}; do
  144     "${ZCMP}" -N in.$i || test_failed $LINENO $i
  145     "${ZCMP}" -N in in.$i || test_failed $LINENO $i
  146     "${ZCMP}" -N in in.$i --force-format=,$i || test_failed $LINENO $i
  147     "${ZCMP}" -N in.$i in || test_failed $LINENO $i
  148     "${ZCMP}" -N in.$i in --force-format=$i || test_failed $LINENO $i
  149     "${ZCMP}" -N -i 1kB:1000 -n 500 in6 in.$i || test_failed $LINENO $i
  150     "${ZCMP}" -N -i 1KiB:1024 -n 50 in.$i in6 || test_failed $LINENO $i
  151     "${ZCMP}" -N empty empty.$i || test_failed $LINENO $i
  152 done
  153 
  154 "${ZCMP}" -Nq in in6
  155 [ $? = 1 ] || test_failed $LINENO
  156 "${ZCMP}" -N -n 0 in in6 || test_failed $LINENO
  157 "${ZCMP}" -N -n 100B in in6 || test_failed $LINENO
  158 "${ZCMP}" -N -n 1k in in6 || test_failed $LINENO
  159 "${ZCMP}" -N -n 10kB in in6 || test_failed $LINENO
  160 "${ZCMP}" -Nq in.tar pin.tar
  161 [ $? = 1 ] || test_failed $LINENO
  162 "${ZCMP}" -Nq -i 0B:11B in.tar pin.tar
  163 [ $? = 1 ] || test_failed $LINENO
  164 "${ZCMP}" -N -i 0:11 -n 0 in.tar pin.tar || test_failed $LINENO
  165 "${ZCMP}" -N -i 0:11 -n 100 in.tar pin.tar || test_failed $LINENO
  166 "${ZCMP}" -N -i 0:11 -n 1Ki in.tar pin.tar || test_failed $LINENO
  167 "${ZCMP}" -N -i 0:11 -n 10KiB in.tar pin.tar || test_failed $LINENO
  168 "${ZCMP}" -N - - || test_failed $LINENO
  169 "${ZCMP}" -Nq -
  170 [ $? = 2 ] || test_failed $LINENO
  171 "${ZCMP}" -N in in || test_failed $LINENO
  172 "${ZCMP}" -N in || test_failed $LINENO
  173 "${ZCMP}" -N --format=gz,bz2 in || test_failed $LINENO
  174 "${ZCMP}" -N --format=gz in || test_failed $LINENO
  175 "${ZCMP}" -N in.lz in.gz || test_failed $LINENO
  176 "${ZCMP}" -N --lz='lzip -q' in.lz in.gz || test_failed $LINENO
  177 "${ZCMP}" -N in.gz -- -in-.lz || test_failed $LINENO
  178 "${ZCMP}" -N -- -in-.lz in.gz || test_failed $LINENO
  179 "${ZCMP}" -N in -- -in-.lz || test_failed $LINENO
  180 "${ZCMP}" -N -- -in- in.lz || test_failed $LINENO
  181 "${ZCMP}" -N in.lz -- -in- || test_failed $LINENO
  182 "${ZCMP}" -N -- -in-.lz in || test_failed $LINENO
  183 "${ZCMP}" -N -- -in- in || test_failed $LINENO
  184 "${ZCMP}" -N in -- -in- || test_failed $LINENO
  185 "${ZCMP}" -N in.lz - < in || test_failed $LINENO
  186 "${ZCMP}" -N - in.lz < in || test_failed $LINENO
  187 "${ZCMP}" -N in - < in.lz || test_failed $LINENO
  188 "${ZCMP}" -N - in < in.lz || test_failed $LINENO
  189 "${ZCMP}" -N lz_only.lz - < in || test_failed $LINENO
  190 "${ZCMP}" -Nq lz_only.lz
  191 [ $? = 2 ] || test_failed $LINENO
  192 "${ZCMP}" -Nq "" in
  193 [ $? = 2 ] || test_failed $LINENO
  194 "${ZCMP}" -Nq --force-format=lz in.lz
  195 [ $? = 2 ] || test_failed $LINENO
  196 "${ZCMP}" -Nq --force-format=lz in.gz in.lz
  197 r=$?
  198 { [ $r = 1 ] || [ $r = 2 ] ; } || test_failed $LINENO
  199 "${ZCMP}" -Nq -i 100BB in in
  200 [ $? = 2 ] || test_failed $LINENO
  201 "${ZCMP}" -Nq -i 100BB:100 in in
  202 [ $? = 2 ] || test_failed $LINENO
  203 "${ZCMP}" -Nq -i 100: in in
  204 [ $? = 2 ] || test_failed $LINENO
  205 "${ZCMP}" -Nq -n -1 in in
  206 [ $? = 2 ] || test_failed $LINENO
  207 "${ZCMP}" -N -q -n 100BB in in
  208 [ $? = 2 ] || test_failed $LINENO
  209 "${ZCMP}" -N --bad-option in in 2> /dev/null
  210 [ $? = 2 ] || test_failed $LINENO
  211 
  212 
  213 printf "\ntesting   zdiff-%s..." "$2"
  214 
  215 for i in ${extensions}; do
  216     "${ZDIFF}" -N in.$i > /dev/null || test_failed $LINENO $i
  217     "${ZDIFF}" -N in in.$i > /dev/null || test_failed $LINENO $i
  218     "${ZDIFF}" -N in in.$i --force-format=,$i > /dev/null ||
  219         test_failed $LINENO $i
  220     "${ZDIFF}" -N in.$i in > /dev/null || test_failed $LINENO $i
  221     "${ZDIFF}" -N in.$i in --force-format=$i, > /dev/null ||
  222         test_failed $LINENO $i
  223     "${ZDIFF}" -N empty empty.$i > /dev/null || test_failed $LINENO $i
  224 done
  225 
  226 "${ZDIFF}" -N in in6 > /dev/null
  227 [ $? = 1 ] || test_failed $LINENO
  228 # GNU diff 3.0 returns 2 when binary files differ
  229 "${ZDIFF}" -N in.tar pin.tar > /dev/null && test_failed $LINENO
  230 "${ZDIFF}" -N - - || test_failed $LINENO
  231 "${ZDIFF}" -N - 2> /dev/null
  232 [ $? = 2 ] || test_failed $LINENO
  233 "${ZDIFF}" -N in in || test_failed $LINENO
  234 "${ZDIFF}" -N in || test_failed $LINENO
  235 "${ZDIFF}" -N --format=gz,bz2 in || test_failed $LINENO
  236 "${ZDIFF}" -N --format=gz in || test_failed $LINENO
  237 "${ZDIFF}" -N in.lz in.gz > /dev/null || test_failed $LINENO
  238 "${ZDIFF}" -N --lz='lzip -q' in.lz in.gz > /dev/null || test_failed $LINENO
  239 "${ZDIFF}" -N in.gz -- -in-.lz > /dev/null || test_failed $LINENO
  240 "${ZDIFF}" -N -- -in-.lz in.gz > /dev/null || test_failed $LINENO
  241 "${ZDIFF}" -N in -- -in-.lz > /dev/null || test_failed $LINENO
  242 "${ZDIFF}" -N -- -in- in.lz > /dev/null || test_failed $LINENO
  243 "${ZDIFF}" -N in.lz -- -in- > /dev/null || test_failed $LINENO
  244 "${ZDIFF}" -N -- -in-.lz in > /dev/null || test_failed $LINENO
  245 "${ZDIFF}" -N -- -in- in > /dev/null || test_failed $LINENO
  246 "${ZDIFF}" -N in -- -in- > /dev/null || test_failed $LINENO
  247 "${ZDIFF}" -N in.lz - < in > /dev/null || test_failed $LINENO
  248 "${ZDIFF}" -N - in.lz < in > /dev/null || test_failed $LINENO
  249 "${ZDIFF}" -N in - < in.lz > /dev/null || test_failed $LINENO
  250 "${ZDIFF}" -N - in < in.lz > /dev/null || test_failed $LINENO
  251 "${ZDIFF}" -N lz_only.lz - < in > /dev/null || test_failed $LINENO
  252 "${ZDIFF}" -N lz_only.lz 2> /dev/null
  253 [ $? = 2 ] || test_failed $LINENO
  254 "${ZDIFF}" -N "" in 2> /dev/null
  255 [ $? = 2 ] || test_failed $LINENO
  256 "${ZDIFF}" -N --bz2='-bzip2' in.bz2 2> /dev/null
  257 [ $? = 2 ] || test_failed $LINENO
  258 "${ZDIFF}" -Nq --force-format=bz2 in.bz2 2> /dev/null
  259 [ $? = 2 ] || test_failed $LINENO
  260 "${ZDIFF}" -N -q --force-format=,lz in.lz in.bz2 > /dev/null 2>&1
  261 r=$?
  262 { [ $r = 1 ] || [ $r = 2 ] ; } || test_failed $LINENO
  263 "${ZDIFF}" -N --bad-option 2> /dev/null
  264 [ $? = 2 ] || test_failed $LINENO
  265 
  266 mkdir tmp2
  267 cat in > tmp2/a || framework_failure
  268 cat in.lz > tmp2/a.lz || framework_failure
  269 "${ZDIFF}" -N --format=bz2 tmp2/a 2> /dev/null
  270 [ $? = 2 ] || test_failed $LINENO
  271 "${ZDIFF}" -N --format=gz tmp2/a 2> /dev/null
  272 [ $? = 2 ] || test_failed $LINENO
  273 "${ZDIFF}" -N --format=lz tmp2/a.lz 2> /dev/null
  274 [ $? = 2 ] || test_failed $LINENO
  275 "${ZDIFF}" -N --format=lz tmp2/a || test_failed $LINENO
  276 "${ZDIFF}" -N --format=un tmp2/a.lz || test_failed $LINENO
  277 rm -r tmp2 || framework_failure
  278 
  279 
  280 printf "\ntesting   zgrep-%s..." "$2"
  281 
  282 for i in ${extensions}; do
  283     "${ZGREP}" -N "GNU" in.$i > /dev/null || test_failed $LINENO $i
  284     "${ZGREP}" -N "GNU" in.$i hello.$i > /dev/null || test_failed $LINENO $i
  285     "${ZGREP}" -N "GNU" hello.$i in.$i > /dev/null || test_failed $LINENO $i
  286     "${ZGREP}" -N -q "GNU" in.$i hello.$i || test_failed $LINENO $i
  287     "${ZGREP}" -N -q "GNU" hello.$i in.$i || test_failed $LINENO $i
  288     "${ZGREP}" -N "GNU" < in.$i > /dev/null || test_failed $LINENO $i
  289     "${ZGREP}" -N -l "GNU" in.$i > /dev/null || test_failed $LINENO $i
  290     "${ZGREP}" -N -L "GNU" in.$i || test_failed $LINENO $i
  291     "${ZGREP}" -N --force-format=$i "GNU" in.$i > /dev/null ||
  292         test_failed $LINENO $i
  293     "${ZGREP}" -N -v "nx_pattern" in.$i > /dev/null ||
  294         test_failed $LINENO $i
  295     "${ZGREP}" -N "nx_pattern" in.$i && test_failed $LINENO $i
  296     "${ZGREP}" -N -l "nx_pattern" in.$i && test_failed $LINENO $i
  297     "${ZGREP}" -N -L "nx_pattern" in.$i > /dev/null &&
  298         test_failed $LINENO $i
  299     "${ZGREP}" -N --force-format=$i "GNU" in 2> /dev/null
  300     [ $? = 2 ] || test_failed $LINENO $i
  301     "${ZGREP}" -N "nx_pattern" empty.$i && test_failed $LINENO $i
  302 done
  303 
  304 "${ZGREP}" -N pin.tar -e "GNU" > /dev/null || test_failed $LINENO
  305 "${ZGREP}" -N "GNU" < pin.tar > /dev/null || test_failed $LINENO
  306 "${ZGREP}" -N -r "GNU" . > /dev/null || test_failed $LINENO
  307 "${ZGREP}" -N -r "GNU" > /dev/null || test_failed $LINENO
  308 "${ZGREP}" -N -R "GNU" . > /dev/null || test_failed $LINENO
  309 "${ZGREP}" -N -R "GNU" > /dev/null || test_failed $LINENO
  310 "${ZGREP}" -N "nx_pattern" -r . in > /dev/null && test_failed $LINENO
  311 "${ZGREP}" -N -e "GNU" in > /dev/null || test_failed $LINENO
  312 "${ZGREP}" -N "GNU" < in > /dev/null || test_failed $LINENO
  313 "${ZGREP}" -N -O lz "nx_pattern" - - < in.lz > /dev/null && test_failed $LINENO
  314 "${ZGREP}" -N -e "-free" --lz='lzip -q' < in.lz > /dev/null ||
  315     test_failed $LINENO
  316 "${ZGREP}" -N -- "-free" -in- > /dev/null || test_failed $LINENO
  317 "${ZGREP}" -N -q -- "-free" nx_file -in-.lz || test_failed $LINENO
  318 "${ZGREP}" -N "GNU" in in.gz in.bz2 in.lz -- -in- > /dev/null ||
  319     test_failed $LINENO
  320 "${ZGREP}" -N -l "GNU" in in.gz in.bz2 in.lz -- -in- > /dev/null ||
  321     test_failed $LINENO
  322 "${ZGREP}" -N -L "GNU" in in.gz in.bz2 in.lz -- -in- || test_failed $LINENO
  323 "${ZGREP}" -N -l "nx_pattern" in in.gz in.bz2 in.lz -- -in- &&
  324     test_failed $LINENO
  325 "${ZGREP}" -N -L "nx_pattern" in in.gz in.bz2 in.lz -- -in- > /dev/null &&
  326     test_failed $LINENO
  327 "${ZGREP}" -Nq -l "01234567890" in "${bad1_lz}" in.lz && test_failed $LINENO
  328 "${ZGREP}" -Nq -l "01234567890" in "${bad1_lz}" in.lz pin.tar > /dev/null ||
  329     test_failed $LINENO
  330 
  331 "${ZGREP}" -N "GNU" .
  332 [ $? = 1 ] || test_failed $LINENO
  333 "${ZGREP}" -N "GNU" "" < in.lz 2> /dev/null
  334 [ $? = 2 ] || test_failed $LINENO
  335 "${ZGREP}" -N --bad-option 2> /dev/null
  336 [ $? = 2 ] || test_failed $LINENO
  337 "${ZGREP}" -N "GNU" -s nx_file
  338 [ $? = 2 ] || test_failed $LINENO
  339 "${ZGREP}" -N -q
  340 [ $? = 2 ] || test_failed $LINENO
  341 
  342 "${ZEGREP}" -N "GNU" in > /dev/null || test_failed $LINENO
  343 "${ZFGREP}" -N "GNU" in > /dev/null || test_failed $LINENO
  344 
  345 
  346 printf "\ntesting   ztest-%s..." "$2"
  347 
  348 for i in ${extensions}; do
  349     "${ZTEST}" -N --force-format=$i < in.$i || test_failed $LINENO $i
  350     "${ZTEST}" -N --force-format=$i < in 2> /dev/null
  351     [ $? = 2 ] || test_failed $LINENO $i
  352     "${ZTEST}" -N --force-format=$i in 2> /dev/null
  353     [ $? = 2 ] || test_failed $LINENO $i
  354 done
  355 
  356 "${ZTEST}" -N in in.gz in.bz2 in.lz -- -in- || test_failed $LINENO
  357 "${ZTEST}" -N < in.gz || test_failed $LINENO
  358 "${ZTEST}" -N < in.bz2 || test_failed $LINENO
  359 "${ZTEST}" -N < in.lz || test_failed $LINENO
  360 "${ZTEST}" -N - < in.lz || test_failed $LINENO
  361 "${ZTEST}" -N - in.gz - < in.lz || test_failed $LINENO
  362 "${ZTEST}" -N --lz='lzip -q' < in.lz || test_failed $LINENO
  363 "${ZTEST}" -N -r . || test_failed $LINENO
  364 "${ZTEST}" -N -r || test_failed $LINENO
  365 "${ZTEST}" -N -R . || test_failed $LINENO
  366 "${ZTEST}" -N -R || test_failed $LINENO
  367 "${ZTEST}" -N empty empty.bz2 empty.gz empty.lz || test_failed $LINENO
  368 
  369 "${ZTEST}" -Nq in.gz "${bad0_lz}" in.bz2 "${bad1_lz}" in.lz
  370 [ $? = 2 ] || test_failed $LINENO
  371 lines=`"${ZTEST}" -N in.gz "${bad0_lz}" in.bz2 "${bad1_lz}" in.lz 2>&1 | wc -l`
  372 [ "${lines}" -eq 2 ] || test_failed $LINENO "${lines}"
  373 lines=`"${ZTEST}" -Nv in.gz "${bad0_lz}" in.bz2 "${bad1_lz}" in.lz 2>&1 | wc -l`
  374 [ "${lines}" -eq 6 ] || test_failed $LINENO "${lines}"
  375 "${ZTEST}" -Nq < in
  376 [ $? = 2 ] || test_failed $LINENO
  377 "${ZTEST}" -Nq "" < in.lz
  378 [ $? = 1 ] || test_failed $LINENO
  379 dd if=in.lz bs=1000 count=1 2> /dev/null | "${ZTEST}" -N -q
  380 [ $? = 2 ] || test_failed $LINENO
  381 "${ZTEST}" -Nq --force-format=lz in.bz2
  382 [ $? = 2 ] || test_failed $LINENO
  383 "${ZTEST}" -N --lz='lzip --bad-option' in.lz 2> /dev/null
  384 [ $? = 1 ] || test_failed $LINENO
  385 "${ZTEST}" -N --bad-option 2> /dev/null
  386 [ $? = 1 ] || test_failed $LINENO
  387 
  388 
  389 printf "\ntesting zupdate-%s..." "$2"
  390 
  391 "${ZUPDATE}" -N "" || test_failed $LINENO
  392 cat in.bz2 > a.bz2 || framework_failure
  393 cat in.gz > a.gz || framework_failure
  394 "${ZUPDATE}" -Nq --bz2=bad_command a.bz2
  395 [ $? = 1 ] || test_failed $LINENO
  396 "${ZUPDATE}" -N --bz2='bzip2 --bad-option' a.bz2 > /dev/null 2>&1
  397 [ $? = 1 ] || test_failed $LINENO
  398 "${ZUPDATE}" -Nq --gz=bad_command a.gz
  399 [ $? = 1 ] || test_failed $LINENO
  400 "${ZUPDATE}" -N --gz='gzip --bad-option' a.gz 2> /dev/null
  401 [ $? = 1 ] || test_failed $LINENO
  402 "${ZUPDATE}" -Nq --lz=bad_command a.gz
  403 [ $? = 1 ] || test_failed $LINENO
  404 "${ZUPDATE}" -N --lz='lzip --bad-option' a.gz 2> /dev/null
  405 [ $? = 1 ] || test_failed $LINENO
  406 "${ZUPDATE}" -N --bad-option 2> /dev/null
  407 [ $? = 1 ] || test_failed $LINENO
  408 
  409 cat in.lz in.lz > a.lz || framework_failure
  410 "${ZUPDATE}" -Nq -f a.bz2 a.gz
  411 [ $? = 1 ] || test_failed $LINENO
  412 [ -e a.bz2 ] || test_failed $LINENO
  413 [ -e a.gz ] || test_failed $LINENO
  414 [ -e a.lz ] || test_failed $LINENO
  415 rm -f a.lz || framework_failure
  416 
  417 "${ZUPDATE}" -N a.bz2 || test_failed $LINENO
  418 [ ! -e a.bz2 ] || test_failed $LINENO
  419 [ -e a.gz ] || test_failed $LINENO
  420 [ -e a.lz ] || test_failed $LINENO
  421 rm -f a.lz || framework_failure
  422 "${ZUPDATE}" -N a.gz || test_failed $LINENO
  423 [ ! -e a.bz2 ] || test_failed $LINENO
  424 [ ! -e a.gz ] || test_failed $LINENO
  425 [ -e a.lz ] || test_failed $LINENO
  426 rm -f a.lz || framework_failure
  427 
  428 cat in.bz2 > a.bz2 || framework_failure
  429 cat in.gz > a.gz || framework_failure
  430 "${ZUPDATE}" -Nq a.bz2 a.gz
  431 [ $? = 1 ] || test_failed $LINENO
  432 [ ! -e a.bz2 ] || test_failed $LINENO
  433 [ -e a.gz ] || test_failed $LINENO
  434 [ -e a.lz ] || test_failed $LINENO
  435 rm -f a.lz || framework_failure
  436 
  437 cat in.bz2 > a.bz2 || framework_failure
  438 cat in.gz > a.gz || framework_failure
  439 "${ZUPDATE}" -N -f -k a.bz2 a.gz || test_failed $LINENO
  440 [ -e a.bz2 ] || test_failed $LINENO
  441 [ -e a.gz ] || test_failed $LINENO
  442 [ -e a.lz ] || test_failed $LINENO
  443 rm -f a.lz || framework_failure
  444 
  445 cat in.bz2 > a.bz2 || framework_failure
  446 cat in.gz > a.gz || framework_failure
  447 "${ZUPDATE}" -N -f a.bz2 a.gz || test_failed $LINENO
  448 [ ! -e a.bz2 ] || test_failed $LINENO
  449 [ ! -e a.gz ] || test_failed $LINENO
  450 [ ! -e a ] || test_failed $LINENO
  451 [ -e a.lz ] || test_failed $LINENO
  452 rm -f a.lz || framework_failure
  453 
  454 cat in.bz2 > a.tbz || framework_failure     # keep combined extensions
  455 cat in.bz2 > b.tbz2 || framework_failure
  456 cat in.gz > c.tgz || framework_failure
  457 "${ZUPDATE}" -N a.tbz b.tbz2 c.tgz || test_failed $LINENO
  458 [ ! -e a.tbz ] || test_failed $LINENO
  459 [ ! -e b.tbz2 ] || test_failed $LINENO
  460 [ ! -e c.tgz ] || test_failed $LINENO
  461 [ ! -e a ] || test_failed $LINENO
  462 [ ! -e b ] || test_failed $LINENO
  463 [ ! -e c ] || test_failed $LINENO
  464 [ ! -e a.lz ] || test_failed $LINENO
  465 [ ! -e b.lz ] || test_failed $LINENO
  466 [ ! -e c.lz ] || test_failed $LINENO
  467 [ -e a.tlz ] || test_failed $LINENO
  468 [ -e b.tlz ] || test_failed $LINENO
  469 [ -e c.tlz ] || test_failed $LINENO
  470 rm -f a.tlz b.tlz c.tlz || framework_failure
  471 
  472 cat in.bz2 > a.bz2 || framework_failure
  473 cat "${bad0_gz}" > b.gz || framework_failure
  474 cat in.gz > c.gz || framework_failure
  475 "${ZUPDATE}" -N -f a.bz2 b.gz c.gz 2> /dev/null && test_failed $LINENO
  476 [ ! -e a.bz2 ] || test_failed $LINENO
  477 [ -e b.gz ] || test_failed $LINENO
  478 [ -e c.gz ] || test_failed $LINENO
  479 [ ! -e a ] || test_failed $LINENO
  480 [ ! -e b ] || test_failed $LINENO
  481 [ ! -e c ] || test_failed $LINENO
  482 [ -e a.lz ] || test_failed $LINENO
  483 rm -f a.lz b.gz c.gz || framework_failure
  484 
  485 cat in.bz2 > a.bz2 || framework_failure
  486 "${ZUPDATE}" -N -1 -q a.bz2 || test_failed $LINENO
  487 [ ! -e a.bz2 ] || test_failed $LINENO
  488 [ -e a.lz ] || test_failed $LINENO
  489 rm -f a.lz || framework_failure
  490 
  491 cat in.gz > 'name with spaces.gz' || framework_failure
  492 "${ZUPDATE}" -N -1 -q 'name with spaces.gz' || test_failed $LINENO
  493 [ ! -e 'name with spaces.gz' ] || test_failed $LINENO
  494 [ -e 'name with spaces.lz' ] || test_failed $LINENO
  495 "${ZCMP}" -N in 'name with spaces.lz' || test_failed $LINENO
  496 rm -f 'name with spaces.lz' || framework_failure
  497 
  498 mkdir tmp2
  499 mkdir tmp2/tmp3
  500 cat in.bz2 > tmp2/tmp3/a.bz2 || framework_failure
  501 cat in.gz > tmp2/tmp3/a.gz || framework_failure
  502 "${ZUPDATE}" -N -r --format=gz tmp2 || test_failed $LINENO
  503 [ -e tmp2/tmp3/a.bz2 ] || test_failed $LINENO
  504 [ ! -e tmp2/tmp3/a.gz ] || test_failed $LINENO
  505 [ -e tmp2/tmp3/a.lz ] || test_failed $LINENO
  506 rm -f tmp2/tmp3/a.lz || framework_failure
  507 "${ZUPDATE}" -N -r --format=bz2 tmp2 || test_failed $LINENO
  508 [ ! -e tmp2/tmp3/a.bz2 ] || test_failed $LINENO
  509 [ ! -e tmp2/tmp3/a.gz ] || test_failed $LINENO
  510 [ -e tmp2/tmp3/a.lz ] || test_failed $LINENO
  511 rm -f tmp2/tmp3/a.lz || framework_failure
  512 cat in.bz2 > tmp2/tmp3/a.bz2 || framework_failure
  513 cat in.gz > tmp2/tmp3/a.gz || framework_failure
  514 cd tmp2 || framework_failure
  515 "${ZUPDATE}" -N -r -k -f . || test_failed $LINENO
  516 [ -e tmp3/a.bz2 ] || test_failed $LINENO
  517 [ -e tmp3/a.gz ] || test_failed $LINENO
  518 [ -e tmp3/a.lz ] || test_failed $LINENO
  519 rm -f tmp3/a.lz || framework_failure
  520 "${ZUPDATE}" -N -r -k -f || test_failed $LINENO
  521 [ -e tmp3/a.bz2 ] || test_failed $LINENO
  522 [ -e tmp3/a.gz ] || test_failed $LINENO
  523 [ -e tmp3/a.lz ] || test_failed $LINENO
  524 rm -f tmp3/a.lz || framework_failure
  525 "${ZUPDATE}" -N -R -k -f . || test_failed $LINENO
  526 [ -e tmp3/a.bz2 ] || test_failed $LINENO
  527 [ -e tmp3/a.gz ] || test_failed $LINENO
  528 [ -e tmp3/a.lz ] || test_failed $LINENO
  529 rm -f tmp3/a.lz || framework_failure
  530 "${ZUPDATE}" -N -R -k -f || test_failed $LINENO
  531 [ -e tmp3/a.bz2 ] || test_failed $LINENO
  532 [ -e tmp3/a.gz ] || test_failed $LINENO
  533 [ -e tmp3/a.lz ] || test_failed $LINENO
  534 rm -f tmp3/a.lz || framework_failure
  535 "${ZUPDATE}" -N -r -f . || test_failed $LINENO
  536 [ ! -e tmp3/a.bz2 ] || test_failed $LINENO
  537 [ ! -e tmp3/a.gz ] || test_failed $LINENO
  538 [ -e tmp3/a.lz ] || test_failed $LINENO
  539 cd .. || framework_failure
  540 rm -r tmp2 || framework_failure
  541 
  542 rm -f empty empty.bz2 empty.gz empty.lz || framework_failure
  543 if ln -s '.' slink 2> /dev/null ; then
  544     "${ZCAT}" -N -r slink > /dev/null || test_failed $LINENO
  545     "${ZGREP}" -N -r "GNU" slink > /dev/null || test_failed $LINENO
  546     "${ZTEST}" -N -r slink || test_failed $LINENO
  547     "${ZUPDATE}" -N -r -f slink || test_failed $LINENO
  548 else
  549     printf "\nwarning: skipping link test: 'ln' does not work on your system."
  550 fi
  551 rm -f slink || framework_failure
  552 
  553 echo
  554 if [ ${fail} = 0 ] ; then
  555     echo "tests completed successfully."
  556     cd "${objdir}" && rm -r tmp
  557 else
  558     echo "tests failed."
  559 fi
  560 exit ${fail}