Debian Codegraph @

debian/tests/gzipcompatibility

raw
1 #!/bin/sh
2
3 # Make sure $AUTOPKGTEST_TMP is available
4 if [ "${AUTOPKGTEST_TMP}"F = "F" ]; then
5 echo "Error: expected environment variable AUTOPKGTEST_TMP is not set."
6 exit 1
7 fi
8
9 # Make sure $AUTOPKGTEST_ARTIFACTS is available
10 if [ "${AUTOPKGTEST_ARTIFACTS}"F = "F" ]; then
11 echo "Error: expected environment variable AUTOPKGTEST_ARTIFACTS is not set."
12 exit 1
13 fi
14
15 # Determine the test execution mode
16 if [ "${1}"F = "F" ]; then
17 MODE="autopkgtest"
18 elif [ "${1}" = "-r" ]; then
19 MODE="debian/rules"
20 else
21 echo "usage: $0 [-r]\n-r Run in debian/rules mode instead of autopkgtest mode"
22 exit 2
23 fi
24
25 # Determine locations of required tools
26 SOURCE_TREE="${PWD}"
27 if [ "${MODE}" = "debian/rules" ]; then
28 # In debian/rules mode, the executables are assumed to be in the source tree
29 COMPRESS="${PWD}/compress"
30 UNCOMPRESS="${PWD}/compress -d"
31 DIFF="/usr/bin/diff"
32 GZIP="/bin/uncompress"
33 else
34 # In autopkgtest mode, the executables are assumed to be installed
35 COMPRESS="/usr/bin/compress"
36 UNCOMPRESS="/usr/bin/uncompress.real"
37 DIFF="/usr/bin/diff"
38 GZIP="/bin/uncompress"
39 fi
40
41 # Print a test summary
42 echo ""
43 echo "========================================================================="
44 echo "Running ${0} in mode: ${MODE}"
45 echo "========================================================================="
46 echo "SOURCE_TREE..........: ${SOURCE_TREE}"
47 echo "AUTOPKGTEST_TMP......: ${AUTOPKGTEST_TMP}"
48 echo "AUTOPKGTEST_ARTIFACTS: ${AUTOPKGTEST_ARTIFACTS}"
49 echo "COMPRESS.............: ${COMPRESS}"
50 echo "UNCOMPRESS...........: ${UNCOMPRESS}"
51 echo "DIFF.................: ${DIFF}"
52 echo "GZIP.................: ${GZIP}"
53 echo "========================================================================="
54 echo ""
55
56 # Always run tests from within $AUTOPKGTEST_TMP
57 cd ${AUTOPKGTEST_TMP}
58
59 # Create an input file
60 echo -n "Creating input file..."
61 SAMPLE=${SOURCE_TREE}/debian/tests/data/sample.txt
62
63 cp ${SAMPLE} input >/dev/null 2>&1
64 if [ $? != 0 ]; then
65 echo "failed"
66 exit 1
67 fi
68
69 echo "done."
70
71 # Compress the input file
72 echo -n "Compressing the input file..."
73
74 ${COMPRESS} input >/dev/null 2>&1
75 if [ $? != 0 ]; then
76 echo "failed"
77 exit 1
78 fi
79
80 if [ ! -f input.Z ]; then
81 echo "failed: did not get expected output file input.Z"
82 exit 1
83 fi
84
85 echo "done."
86
87 # Check for compatibility by uncompressing the input file with the gzip uncompress
88 echo -n "Checking for compatibility with gzip..."
89
90 ${GZIP} input.Z >/dev/null 2>&1
91 if [ $? != 0 ]; then
92 echo "failed"
93 exit 1
94 fi
95
96 if [ ! -f input ]; then
97 echo "failed: did not get expected output file input"
98 exit 1
99 fi
100
101 ${DIFF} -q input ${SAMPLE} >/dev/null 2>&1
102 if [ $? != 0 ]; then
103 echo "failed: uncompressed file does not match original sample"
104 exit 1
105 fi
106
107 echo "done."
108
109 # Close the test
110 echo ""
111