File: softlink

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 (197 lines) | stat: -rw-r--r-- 4,526 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/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"
else
   # In autopkgtest mode, the executables are assumed to be installed
   COMPRESS="/usr/bin/compress"
   UNCOMPRESS="/usr/bin/uncompress.real"
   DIFF="/usr/bin/diff"
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 "========================================================================="
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."

# Create a soft link to the input file
echo -n "Creating input file link..."

ln -s input inputlink >/dev/null 2>&1
if [ $? != 0 ]; then
   echo "failed"
   exit 1
fi

echo "done."

# Compress the input file link
# Note: do this before compressing input file, otherwise input file will be gone. :)
echo -n "Compressing the input file link..."

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

if [ ! -f inputlink.Z ]; then
   echo "failed: did not get expected output file inputlink.Z"
   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."

# Create soft links to the compressed file
echo -n "Creating the output file links..."

ln -s input.Z outputlink1.Z >/dev/null 2>&1
if [ $? != 0 ]; then
   echo "failed"
   exit 1
fi

ln -s input.Z outputlink2.Z >/dev/null 2>&1
if [ $? != 0 ]; then
   echo "failed"
   exit 1
fi

echo "done."

# Check that uncompress works on the input file link
echo -n "Checking uncompress behavior for input file link..."

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

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

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

echo "done."

# Check that uncompress works on a link to a compressed file
echo -n "Checking uncompress behavior for link to compressed file..."

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

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

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

echo "done."

# Check that compress -dc works on a link to a compressed file
echo -n "Checking compress -dc behavior for link to compressed file..."

${COMPRESS} -dc outputlink2.Z > result
if [ $? != 0 ]; then
   echo "failed"
   exit 1
fi

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

${DIFF} -q ${SAMPLE} result >/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 ""