File: test-003

package info (click to toggle)
bar 1.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 928 kB
  • sloc: ansic: 4,381; sh: 3,334; makefile: 264
file content (60 lines) | stat: -rwxr-xr-x 1,257 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

src_file="./test-file-003.1.bin"
tmp_file="./test-file-003.incomplete.bin"
dst_file="./test-file-003.2.bin"

if [ ! -c /dev/random ]; then
	echo "*** NOTICE: Skipping test -- no /dev/random found"
	exit 0
fi

if [ ! -f "${src_file}" ]; then
	echo "- Creating test file (this may take a while...)"
	dd \
		if=/dev/random \
		of=${tmp_file} \
		bs=1024 \
		count=1024 \
		2> /dev/null
	if [ "$?" -ne 0 ]; then
		echo "*** ERROR: Failed to create test file"
		echo "           Test inconclusive"
		exit 1
	fi
	mv ${tmp_file} ${src_file}
	if [ "$?" -ne 0 ]; then
		echo "*** ERROR: Failed to create test file"
		echo "           Test inconclusive"
		rm -f ${tmp_file}
		exit 1
	fi
else
	echo "- Using existing test file: ${src_file}..."
fi

echo "- Copying file..."
cp ${src_file} ${dst_file}
if [ "$?" -ne 0 ]; then
	echo "*** ERROR: Unable to copy file"
	echo "           Test inconclusive"
	exit 1
fi

echo "- Copying file through bar..."
./bar -if ${src_file} -of ${dst_file} 2> /dev/null
if [ "$?" -ne 0 ]; then
	echo "*** ERROR: bar failed"
	exit 1
fi

echo "- Comparing file against copy..."
cmp ${src_file} ${dst_file} > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
	echo "*** ERROR: Files differ"
	exit 1
fi

rm -f ${src_file} ${dst_file}
exit 0