This repository has been archived by the owner on Sep 15, 2021. It is now read-only.
forked from Parchive/par2cmdline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
PeterBClements
committed
May 26, 2015
1 parent
dd9c4e6
commit 1c54ef1
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/sh | ||
|
||
cd tests || { echo "ERROR: Could not change to tests directory" ; exit 1; } >&2 | ||
tests=../../$srcdir/tests | ||
|
||
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 | ||
|
||
banner="Creating 1024 byte test data file" | ||
dashes=`echo "$banner" | sed s/./-/g` | ||
|
||
echo $dashes | ||
echo $banner | ||
echo $dashes | ||
|
||
dd if=/dev/urandom of=datafile bs=1024 count=1 || { echo "ERROR: Unable to create test data file" ; exit 1; } >&2 | ||
ls -l | ||
|
||
banner="Creating PAR 2.0 recovery data (block size 200)" | ||
dashes=`echo "$banner" | sed s/./-/g` | ||
|
||
echo $dashes | ||
echo $banner | ||
echo $dashes | ||
|
||
../../par2 c -s200 -c1 recovery datafile > ../$testname.log || { echo "ERROR: Creating PAR 2.0 data failed" ; exit 1; } >&2 | ||
ls -l | ||
|
||
banner="Damaging data file (trim first 100 bytes)" | ||
dashes=`echo "$banner" | sed s/./-/g` | ||
|
||
echo $dashes | ||
echo $banner | ||
echo $dashes | ||
|
||
mv datafile datafile.orig | ||
dd if=datafile.orig of=datafile bs=100 skip=1 || { echo "ERROR: Unable to create damaged data file" ; exit 1; } >&2 | ||
rm datafile.orig | ||
ls -l | ||
|
||
banner="Repairing using PAR 2.0 data (with skip leaway 99 - should fail)" | ||
dashes=`echo "$banner" | sed s/./-/g` | ||
|
||
echo $dashes | ||
echo $banner | ||
echo $dashes | ||
|
||
../../par2 r -S99 -vv recovery.par2 > ../$testname.log && { echo "ERROR: Repair should not be possible with skip leaway set to 99" ; exit 1; } >&2 | ||
ls -l | ||
|
||
banner="Repairing using PAR 2.0 data (with skip leaway 100 - should succeed)" | ||
dashes=`echo "$banner" | sed s/./-/g` | ||
|
||
echo $dashes | ||
echo $banner | ||
echo $dashes | ||
|
||
../../par2 r -S100 -vv recovery.par2 > ../$testname.log || { echo "ERROR: Repair should be possible with skip leaway set to 100" ; exit 1; } >&2 | ||
ls -l | ||
|
||
cd .. | ||
rm -rf run$testname | ||
|
||
exit 0; | ||
|