File: test-004

package info (click to toggle)
bar 1.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 928 kB
  • sloc: ansic: 4,381; sh: 3,334; makefile: 264
file content (94 lines) | stat: -rwxr-xr-x 2,291 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
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
#!/bin/sh

src_file="./test-file-004.bin"
tmp_file="./test-file-004.incomplete.bin"
dst_file_1="./test-file-004.1.bin"
dst_file_2="./test-file-004.2.bin"

echo
echo "NOTICE: This test takes a very long time."
echo

if [ ! -f "${src_file}" ]; then
	echo "- Creating main test file (this may take a while...)"
	(cd / \
		&& tar -cf - \
			./usr/X* \
			./usr/bin \
			./usr/doc \
			./usr/include \
			./usr/info \
			./usr/lib \
			./usr/sbin \
			./usr/share \
			./usr/src \
			./bin \
			./etc \
			./lib \
			./opt \
			./sbin \
			./var \
			2> /dev/null
		) | dd of=${tmp_file} 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"
		exit 1
		rm -f ${tmp_file}
		exit 1
	fi
fi
for buffer_size in 1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1m 2m; do
	for block_size in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 30 31 32 33 34 63 \
		64 65 127 128 129 255 256 257 500 501 502 503 504 505 506 507 508 509 510 \
		511 512 513 514 515 516 517 518 519 520 1024 2048 3096;\
	do
		for block_count in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 30 31 32 33 34 63 \
		64 65 127 128 129 255 256 257 500 501 502 503 504 505 506 507 508 509 510 \
		511 512 513 514 515 516 517 518 519 520 1024 2048 3096;\
		do
			rm -f ${dst_file_1} 2> /dev/null
			rm -f ${dst_file_2} 2> /dev/null
			dd \
				if=${src_file} \
				bs=${block_size} \
				count=${block_count} \
				of=${dst_file_1} \
				2> /dev/null
			if [ "$?" -ne 0 ]; then
				echo "*** ERROR: Could not create test subfile"
				echo "           Test inconclusive"
				exit 1
			fi
			dd \
				if=${dst_file_1} \
				2> /dev/null \
				| ./bar \
					-s ${block_count}b \
					-of ${dst_file_2} \
					-bl ${block_size} \
					-bs ${buffer_size} \
					2> /dev/null \
					#
			if [ "$?" -ne 0 ]; then
				echo "ERROR: bar failed"
				exit 1
			fi
			cmp ${dst_file_1} ${dst_file_2}
			if [ "$?" -ne 0 ]; then
				echo "ERROR: Files differ"
				echo "    Buffer Size: ${buffer_size}"
				echo "     Block Size: ${block_size}"
				echo "    Block Count: ${block_count}"
				exit 1
			fi
		done
	done
done
rm ${dst_file_1} ${dst_file_2}