Debian Codegraph @

debian/tests/roundtrip

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 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 # Compress the input file
69 echo -n "Compressing the input file..."
70
71 ${COMPRESS} input >/dev/null 2>&1
72 if [ $? != 0 ]; then
73 echo "failed"
74 exit 1
75 fi
76
77 if [ ! -f input.Z ]; then
78 echo "failed: did not get expected output file input.Z"
79 exit 1
80 fi
81
82 echo "done."
83
84 # Check that uncompress works
85 echo -n "Checking uncompress behavior..."
86
87 ${UNCOMPRESS} input.Z >/dev/null 2>&1
88 if [ $? != 0 ]; then
89 echo "failed"
90 exit 1
91 fi
92
93 if [ ! -f input ]; then
94 echo "failed: did not get expected output file input"
95 exit 1
96 fi
97
98 ${DIFF} -q ${SAMPLE} input >/dev/null 2>&1
99 if [ $? != 0 ]; then
100 echo "failed: uncompressed file does not match original sample"
101 exit 1
102 fi
103
104 echo "done."
105
106 # Close the test
107 echo ""
108