-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build scripts changed to support FreeBSD. File size check
implemented for input files. Fixed error that caused data corruption in the last few bytes of bannerless images of certain sizes. Added and expanded code comments all around.
- Loading branch information
Showing
7 changed files
with
108 additions
and
38 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 |
---|---|---|
|
@@ -3,7 +3,8 @@ doc-pak | |
s2png | ||
*.deb | ||
*.png | ||
python github flavored markdown.py | ||
pymd.py | ||
README.html | ||
s2png.o | ||
rc4.o | ||
core | ||
|
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
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
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
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
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
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 |
---|---|---|
@@ -1,26 +1,61 @@ | ||
#!/bin/sh | ||
# Test s2png encoding and decoding operations, as well as encryption, for | ||
# causing data corruption. | ||
|
||
runtests() { | ||
opstest() { | ||
testfile=$1 | ||
|
||
./s2png $testfile -s -o $testfile.png || echo File encoding failed. | ||
./s2png $testfile.png -o $testfile.out || echo File decoding failed. | ||
./s2png -s -o $testfile.png $testfile || echo File encoding failed. | ||
./s2png -o $testfile.out $testfile.png || echo File decoding failed. | ||
|
||
./s2png $testfile -s -o $testfile.png -b "Hello" -p password || echo File encryption failed. | ||
./s2png $testfile.png -o $testfile.out2 -p password || echo File decryption failed. | ||
./s2png -s -o $testfile.png -b "Hello" -p password $testfile || echo File encryption failed. | ||
./s2png -o $testfile.out2 -p password $testfile.png || echo File decryption failed. | ||
|
||
diff $testfile $testfile.out || echo Basic test failed. | ||
diff $testfile $testfile.out2 || echo Encryption test failed. | ||
|
||
rm $testfile.png $testfile.out $testfile.out2 | ||
} | ||
|
||
sizetest() { | ||
n=$1 | ||
testfile=$2 | ||
encoded=$3 | ||
decoded=$4 | ||
|
||
dd bs=$1 count=1 if=/dev/urandom of=$testfile 2> /dev/null | ||
./s2png -e -o $encoded -b "" -w 10 $testfile | ||
./s2png -d -o $decoded $encoded | ||
diff $testfile $decoded | ||
if [ $? != 0 ]; then | ||
echo Corruption at file size $n. | ||
identify a.png | ||
fi | ||
} | ||
|
||
echo Running basic operations tests. | ||
|
||
# Test for data corruption with an 0xFFFF pattern. | ||
echo -n -e \\0377\\0377\\0377\\0377\\0377\\0377\\0377\\0377 > test.bin | ||
runtests test.bin | ||
opstest test.bin | ||
rm test.bin | ||
|
||
# Test for data corruption with random data. | ||
dd if=/dev/urandom of=test.bin count=2k | ||
runtests test.bin | ||
opstest test.bin | ||
rm test.bin | ||
|
||
echo Running integrity tests for bannerless images. | ||
|
||
# Test for data corruption by file size pixel. | ||
t1=$(mktemp -t s2pngXXXXX) | ||
t2=$(mktemp -t s2pngXXXXX) | ||
t3=$(mktemp -t s2pngXXXXX) | ||
i=10 | ||
while [ $i -le 256 ]; do | ||
sizetest $i $t1 $t2 $t3 | ||
i=`expr $i + 1` | ||
done | ||
rm $t1 $t2 $t3 | ||
|
||
echo Tests done. |