encfs/tests/test_corruption.sh
Jakob Unterwurzacher 8bda1c8a46 tests: Add integration tests
Add a simple cli-based test infrastructure with a few tests
to prepare future code changes.
Note that these cannot be run on Travis CI as it does not support
FUSE.

Expected output:

	$ tests/run.sh
	1 Running unit tests: OK
	*** running test_corruption.sh
	2 Reading file: OK
	3 Reading corrupted file: OK
	4 Reading file with MAC: OK
	5 Corruption with MAC returns IO error: OK
	*** running test_file_expansion.sh
	6 Creating files of different sizes: : OK
	7 Growing file: OK
	8 Internal modification: OK
	*** All tests OK
2014-10-17 19:41:21 +02:00

32 lines
571 B
Bash

fresh_mount default.xml
cd $SCRATCH
dd if=/dev/urandom of=foo bs=1M count=1 2> /dev/null
A=$(md5 foo)
cp foo $UPPER
cd $UPPER
test_begin "Reading file"
B=$(md5 foo)
test $A = $B
test_ok
test_begin "Reading corrupted file"
echo DEADBEEF >> $LOWER/$(ls $LOWER)
B=$(md5 foo)
test $A != $B
test_ok
fresh_mount mac.xml
cd $SCRATCH
cp foo $UPPER
cd $UPPER
test_begin "Reading file with MAC"
B=$(md5 foo)
test $A = $B
test_ok
test_begin "Corruption with MAC returns IO error"
echo DEADBEEF >> $LOWER/$(ls $LOWER)
md5 foo 2>&1 | grep "Input/output error" > /dev/null
test_ok