File: gzipcompatibility

package info (click to toggle)
ncompress 5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 468 kB
  • sloc: ansic: 1,291; sh: 1,030; makefile: 24
file content (111 lines) | stat: -rw-r--r-- 2,786 bytes parent folder | download | duplicates (5)
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
#!/bin/sh

# Make sure $AUTOPKGTEST_TMP is available
if [ "${AUTOPKGTEST_TMP}"F = "F" ]; then
   echo "Error: expected environment variable AUTOPKGTEST_TMP is not set."
   exit 1
fi

# Make sure $AUTOPKGTEST_ARTIFACTS is available
if [ "${AUTOPKGTEST_ARTIFACTS}"F = "F" ]; then
   echo "Error: expected environment variable AUTOPKGTEST_ARTIFACTS is not set."
   exit 1
fi

# Determine the test execution mode 
if [ "${1}"F = "F" ]; then
   MODE="autopkgtest"
elif [ "${1}" = "-r" ]; then
   MODE="debian/rules"
else 
   echo "usage: $0 [-r]\n-r Run in debian/rules mode instead of autopkgtest mode"
   exit 2
fi

# Determine locations of required tools
SOURCE_TREE="${PWD}"
if [ "${MODE}" = "debian/rules" ]; then
   # In debian/rules mode, the executables are assumed to be in the source tree
   COMPRESS="${PWD}/compress"
   UNCOMPRESS="${PWD}/compress -d"
   DIFF="/usr/bin/diff"
   GZIP="/bin/uncompress"
else
   # In autopkgtest mode, the executables are assumed to be installed
   COMPRESS="/usr/bin/compress"
   UNCOMPRESS="/usr/bin/uncompress.real"
   DIFF="/usr/bin/diff"
   GZIP="/bin/uncompress"
fi

# Print a test summary
echo ""
echo "========================================================================="
echo "Running ${0} in mode: ${MODE}"
echo "========================================================================="
echo "SOURCE_TREE..........: ${SOURCE_TREE}"
echo "AUTOPKGTEST_TMP......: ${AUTOPKGTEST_TMP}"
echo "AUTOPKGTEST_ARTIFACTS: ${AUTOPKGTEST_ARTIFACTS}"
echo "COMPRESS.............: ${COMPRESS}"
echo "UNCOMPRESS...........: ${UNCOMPRESS}"
echo "DIFF.................: ${DIFF}"
echo "GZIP.................: ${GZIP}"
echo "========================================================================="
echo ""

# Always run tests from within $AUTOPKGTEST_TMP
cd ${AUTOPKGTEST_TMP}

# Create an input file
echo -n "Creating input file..."
SAMPLE=${SOURCE_TREE}/debian/tests/data/sample.txt

cp ${SAMPLE} input >/dev/null 2>&1
if [ $? != 0 ]; then
   echo "failed"
   exit 1
fi

echo "done."

# Compress the input file
echo -n "Compressing the input file..."

${COMPRESS} input >/dev/null 2>&1
if [ $? != 0 ]; then
   echo "failed"
   exit 1
fi

if [ ! -f input.Z ]; then
   echo "failed: did not get expected output file input.Z"
   exit 1
fi

echo "done."

# Check for compatibility by uncompressing the input file with the gzip uncompress
echo -n "Checking for compatibility with gzip..."

${GZIP} input.Z >/dev/null 2>&1
if [ $? != 0 ]; then
   echo "failed"
   exit 1
fi

if [ ! -f input ]; then
   echo "failed: did not get expected output file input"
   exit 1
fi

${DIFF} -q input ${SAMPLE} >/dev/null 2>&1
if [ $? != 0 ]; then
   echo "failed: uncompressed file does not match original sample"
   exit 1
fi

echo "done."

# Close the test
echo ""