summaryrefslogtreecommitdiffstats
path: root/testsuite/check.sh
blob: dbbf0760dfdbd2acf12688fdb7221cb1fac85b7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#! /bin/sh
# check script for Zutils - Utilities dealing with compressed files
# Copyright (C) 2009 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
# to copy, distribute and modify it.

LC_ALL=C
export LC_ALL
objdir=`pwd`
testdir=`cd "$1" ; pwd`
ZCAT="${objdir}"/zcat
ZDIFF="${objdir}"/zdiff
ZGREP="${objdir}"/zgrep
compressors="gzip bzip2 lzip"
extensions="gz bz2 lz"
framework_failure() { echo 'failure in testing framework'; exit 1; }

if [ ! -x "${ZCAT}" ] ; then
	echo "${ZCAT}: cannot execute"
	exit 1
fi

if [ -d tmp ] ; then rm -r tmp ; fi
mkdir tmp
echo -n "testing zutils..."
cd "${objdir}"/tmp

for i in ${compressors}; do
	cat "${testdir}"/../COPYING > in || framework_failure
	$i in || framework_failure
	echo -n .
done

cat "${testdir}"/../COPYING > in || framework_failure
cat in > -in- || framework_failure
cat in.lz > -in-.lz || framework_failure
cat in in in in in > in5 || framework_failure
fail=0


for i in ${extensions}; do
	"${ZCAT}" in.$i > copy || fail=1
	cmp in copy || fail=1
	echo -n .
done

"${ZCAT}" in > copy || fail=1
cmp in copy || fail=1
echo -n .
"${ZCAT}" in in.gz in.bz2 in.lz -- -in- > copy5 || fail=1
cmp in5 copy5 || fail=1
echo -n .


for i in ${extensions}; do
	"${ZDIFF}" --cmp in.$i || fail=1
	echo -n .
	"${ZDIFF}" --cmp in in.$i || fail=1
	echo -n .
	"${ZDIFF}" --cmp in.$i in || fail=1
	echo -n .
done


for i in ${extensions}; do
	"${ZDIFF}" in.$i || fail=1
	echo -n .
	"${ZDIFF}" in in.$i || fail=1
	echo -n .
	"${ZDIFF}" in.$i in || fail=1
	echo -n .
done

"${ZDIFF}" in || fail=1
echo -n .
"${ZDIFF}" in.lz in.gz || fail=1
echo -n .
"${ZDIFF}" in.gz -- -in-.lz || fail=1
echo -n .
"${ZDIFF}" -- -in-.lz in.gz || fail=1
echo -n .
"${ZDIFF}" in -- -in-.lz || fail=1
echo -n .
"${ZDIFF}" -- -in- in.lz || fail=1
echo -n .
"${ZDIFF}" in.lz -- -in- || fail=1
echo -n .
"${ZDIFF}" -- -in-.lz in || fail=1
echo -n .
"${ZDIFF}" -- -in- in || fail=1
echo -n .
"${ZDIFF}" in -- -in- || fail=1
echo -n .


for i in ${extensions}; do
	"${ZGREP}" License in.$i 2>&1 > /dev/null || fail=1
	echo -n .
done

"${ZGREP}" License in 2>&1 > /dev/null || fail=1
echo -n .
"${ZGREP}" License -- -in- 2>&1 > /dev/null || fail=1
echo -n .
"${ZGREP}" License -- -in-.lz 2>&1 > /dev/null || fail=1
echo -n .
"${ZGREP}" License in in.gz in.bz2 in.lz -- -in- 2>&1 > /dev/null || fail=1
echo -n .


echo
if [ ${fail} = 0 ]; then
	echo "tests completed successfully."
	cd "${objdir}" && rm -r tmp
else
	echo "tests failed."
fi
exit ${fail}