File: test5rk

package info (click to toggle)
par2cmdline 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,204 kB
  • sloc: cpp: 14,330; sh: 6,457; makefile: 204
file content (96 lines) | stat: -rwxr-xr-x 3,232 bytes parent folder | download
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
#!/bin/sh
# This is a copy of test5 but using "-rk" instead of "-r100".
# (This increases redundancy, but I'm missing system knowledge
# to refactor the test core).

# Couldn't we move the stuff common for all tests and maybe some
# helper functions to a utility file and source it? For example:
#   source testfuncs.sh

execdir="$PWD"

# valgrind tests memory usage.
# wine allow for windows testing on linux
if [ -n "${PARVALGRINDOPTS+set}" ]
then
    PARBINARY="valgrind $PARVALGRINDOPTS $execdir/par2"
elif [ "`which wine`" != "" ] && [ -f "$execdir/par2.exe" ]
then
    PARBINARY="wine $execdir/par2.exe"
else
    PARBINARY="$execdir/par2"
fi


if [ -z "$srcdir" ] || [ "." = "$srcdir" ]; then
  srcdir="$PWD"
  TESTDATA="$srcdir/tests"
else
  srcdir="$PWD/$srcdir"
  TESTDATA="$srcdir/tests"
fi

TESTROOT="$PWD"

testname=$(basename $0)
rm -f "$testname.log"
rm -rf "run$testname"

mkdir "run$testname" && cd "run$testname" || { echo "ERROR: Could not change to test directory" ; exit 1; } >&2

tar -xzf "$TESTDATA/flatdata.tar.gz" || { echo "ERROR: Could not extract data test files" ; exit 1; } >&2

banner="Creating 100% PAR 2.0 recovery data"
dashes=`echo "$banner" | sed s/./-/g`

echo $dashes
echo $banner
echo $dashes

# About the "magic -rk1302":
# par2 c -r100 creates PAR2 files of in sum 1302436 bytes, so do
# we approximately (-rk1302).
# To also test ISSUE-80 (https://github.com/Parchive/par2cmdline/issues/80)
# we also use "-n2".
$PARBINARY c -rk1302 -b190 -n2 -a newtest test-*.data || { echo "ERROR: Creating PAR 2.0 data failed" ; exit 1; } >&2

# Checking whether "-n2" worked by creating two newtest.vol*.par2 files
# (and also tolerate newtest.VOL*.PAR2 as seen on Windows)
test "$(ls newtest.[Vv][Oo][Ll]*.[Pp][Aa][Rr]2 | wc -l)" -eq 2 || { echo "ERROR: File count option -n2 did not work." ; exit 1; } >&2

# Why not simply "mv"?
#    for f in test-*.data; do mv "$f" "$f.orig"; done
# Would save the cp, the rm and keep file date (may help debug).
cp test-0.data test-0.data.orig
cp test-1.data test-1.data.orig
cp test-2.data test-2.data.orig
cp test-3.data test-3.data.orig
cp test-4.data test-4.data.orig
cp test-5.data test-5.data.orig
cp test-6.data test-6.data.orig
cp test-7.data test-7.data.orig
cp test-8.data test-8.data.orig
cp test-9.data test-9.data.orig

rm -f test-*.data

test -e test-0.data && { echo "ERROR: File deletion did not work." ; exit 1; } >&2

banner="Repairing 100% loss using PAR 2.0 data"
dashes=`echo "$banner" | sed s/./-/g`

echo $dashes
echo $banner
echo $dashes

rm -f test-*.data

$PARBINARY r newtest.par2 || { echo "ERROR: Full Repair using PAR 2.0 failed" ; exit 1; } >&2

#    for f in test-*.data; do cmp "$f" "$f.orig" || { echo XXX; exit 1; }; done
cmp -s test-0.data test-0.data.orig && cmp -s test-1.data test-1.data.orig && cmp -s test-2.data test-2.data.orig && cmp -s test-3.data test-3.data.orig && cmp -s test-4.data test-4.data.orig && cmp -s test-5.data test-5.data.orig && cmp -s test-6.data test-6.data.orig && cmp -s test-7.data test-7.data.orig && cmp -s test-8.data test-8.data.orig && cmp -s test-9.data test-9.data.orig || { echo "ERROR: Repaired files do not match originals" ; exit 1 ; } >&2

cd "$TESTROOT"
rm -rf "run$testname"

exit 0