| 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 |
else |
| 33 |
# In autopkgtest mode, the executables are assumed to be installed |
| 34 |
COMPRESS="/usr/bin/compress" |
| 35 |
UNCOMPRESS="/usr/bin/uncompress.real" |
| 36 |
DIFF="/usr/bin/diff" |
| 37 |
fi |
| 38 |
|
| 39 |
# Print a test summary |
| 40 |
echo "" |
| 41 |
echo "=========================================================================" |
| 42 |
echo "Running ${0} in mode: ${MODE}" |
| 43 |
echo "=========================================================================" |
| 44 |
echo "SOURCE_TREE..........: ${SOURCE_TREE}" |
| 45 |
echo "AUTOPKGTEST_TMP......: ${AUTOPKGTEST_TMP}" |
| 46 |
echo "AUTOPKGTEST_ARTIFACTS: ${AUTOPKGTEST_ARTIFACTS}" |
| 47 |
echo "COMPRESS.............: ${COMPRESS}" |
| 48 |
echo "UNCOMPRESS...........: ${UNCOMPRESS}" |
| 49 |
echo "DIFF.................: ${DIFF}" |
| 50 |
echo "=========================================================================" |
| 51 |
echo "" |
| 52 |
|
| 53 |
# Always run tests from within $AUTOPKGTEST_TMP |
| 54 |
cd ${AUTOPKGTEST_TMP} |
| 55 |
|
| 56 |
# Create an input file |
| 57 |
echo -n "Creating input file..." |
| 58 |
SAMPLE=${SOURCE_TREE}/debian/tests/data/sample.txt |
| 59 |
|
| 60 |
cp ${SAMPLE} input >/dev/null 2>&1 |
| 61 |
if [ $? != 0 ]; then |
| 62 |
echo "failed" |
| 63 |
exit 1 |
| 64 |
fi |
| 65 |
|
| 66 |
echo "done." |
| 67 |
|
| 68 |
# Create a soft link to the input file |
| 69 |
echo -n "Creating input file link..." |
| 70 |
|
| 71 |
ln -s input inputlink >/dev/null 2>&1 |
| 72 |
if [ $? != 0 ]; then |
| 73 |
echo "failed" |
| 74 |
exit 1 |
| 75 |
fi |
| 76 |
|
| 77 |
echo "done." |
| 78 |
|
| 79 |
# Compress the input file link |
| 80 |
# Note: do this before compressing input file, otherwise input file will be gone. :) |
| 81 |
echo -n "Compressing the input file link..." |
| 82 |
|
| 83 |
${COMPRESS} inputlink >/dev/null 2>&1 |
| 84 |
if [ $? != 0 ]; then |
| 85 |
echo "failed" |
| 86 |
exit 1 |
| 87 |
fi |
| 88 |
|
| 89 |
if [ ! -f inputlink.Z ]; then |
| 90 |
echo "failed: did not get expected output file inputlink.Z" |
| 91 |
exit 1 |
| 92 |
fi |
| 93 |
|
| 94 |
echo "done." |
| 95 |
|
| 96 |
# Compress the input file |
| 97 |
echo -n "Compressing the input file..." |
| 98 |
|
| 99 |
${COMPRESS} input >/dev/null 2>&1 |
| 100 |
if [ $? != 0 ]; then |
| 101 |
echo "failed" |
| 102 |
exit 1 |
| 103 |
fi |
| 104 |
|
| 105 |
if [ ! -f input.Z ]; then |
| 106 |
echo "failed: did not get expected output file input.Z" |
| 107 |
exit 1 |
| 108 |
fi |
| 109 |
|
| 110 |
echo "done." |
| 111 |
|
| 112 |
# Create soft links to the compressed file |
| 113 |
echo -n "Creating the output file links..." |
| 114 |
|
| 115 |
ln -s input.Z outputlink1.Z >/dev/null 2>&1 |
| 116 |
if [ $? != 0 ]; then |
| 117 |
echo "failed" |
| 118 |
exit 1 |
| 119 |
fi |
| 120 |
|
| 121 |
ln -s input.Z outputlink2.Z >/dev/null 2>&1 |
| 122 |
if [ $? != 0 ]; then |
| 123 |
echo "failed" |
| 124 |
exit 1 |
| 125 |
fi |
| 126 |
|
| 127 |
echo "done." |
| 128 |
|
| 129 |
# Check that uncompress works on the input file link |
| 130 |
echo -n "Checking uncompress behavior for input file link..." |
| 131 |
|
| 132 |
${UNCOMPRESS} inputlink.Z >/dev/null 2>&1 |
| 133 |
if [ $? != 0 ]; then |
| 134 |
echo "failed" |
| 135 |
exit 1 |
| 136 |
fi |
| 137 |
|
| 138 |
if [ ! -f inputlink ]; then |
| 139 |
echo "failed: did not get expected output file inputlink" |
| 140 |
exit 1 |
| 141 |
fi |
| 142 |
|
| 143 |
${DIFF} -q ${SAMPLE} inputlink >/dev/null 2>&1 |
| 144 |
if [ $? != 0 ]; then |
| 145 |
echo "failed: uncompressed file does not match original sample" |
| 146 |
exit 1 |
| 147 |
fi |
| 148 |
|
| 149 |
echo "done." |
| 150 |
|
| 151 |
# Check that uncompress works on a link to a compressed file |
| 152 |
echo -n "Checking uncompress behavior for link to compressed file..." |
| 153 |
|
| 154 |
${UNCOMPRESS} outputlink1.Z >/dev/null 2>&1 |
| 155 |
if [ $? != 0 ]; then |
| 156 |
echo "failed" |
| 157 |
exit 1 |
| 158 |
fi |
| 159 |
|
| 160 |
if [ ! -f outputlink1 ]; then |
| 161 |
echo "failed: did not get expected output file input" |
| 162 |
exit 1 |
| 163 |
fi |
| 164 |
|
| 165 |
${DIFF} -q ${SAMPLE} outputlink1 >/dev/null 2>&1 |
| 166 |
if [ $? != 0 ]; then |
| 167 |
echo "failed: uncompressed file does not match original sample" |
| 168 |
exit 1 |
| 169 |
fi |
| 170 |
|
| 171 |
echo "done." |
| 172 |
|
| 173 |
# Check that compress -dc works on a link to a compressed file |
| 174 |
echo -n "Checking compress -dc behavior for link to compressed file..." |
| 175 |
|
| 176 |
${COMPRESS} -dc outputlink2.Z > result |
| 177 |
if [ $? != 0 ]; then |
| 178 |
echo "failed" |
| 179 |
exit 1 |
| 180 |
fi |
| 181 |
|
| 182 |
if [ ! -f result ]; then |
| 183 |
echo "failed: did not get expected output file input" |
| 184 |
exit 1 |
| 185 |
fi |
| 186 |
|
| 187 |
${DIFF} -q ${SAMPLE} result >/dev/null 2>&1 |
| 188 |
if [ $? != 0 ]; then |
| 189 |
echo "failed: uncompressed file does not match original sample" |
| 190 |
exit 1 |
| 191 |
fi |
| 192 |
|
| 193 |
echo "done." |
| 194 |
|
| 195 |
# Close the test |
| 196 |
echo "" |
| 197 |
|