Added a rudimentary test framework

Tests can be found in 'tests/test_blah.sh'
Tests can be run with 'make test'
This commit is contained in:
Christopher Haster
2017-03-25 17:02:16 -05:00
parent 84a57642e5
commit afa4ad8254
12 changed files with 260 additions and 294 deletions

45
tests/test_format.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
set -eu
echo "=== Formatting tests ==="
rm -rf blocks
echo "--- Basic formatting ---"
./tests/test.py << TEST
lfs_format(&lfs, &bd, &lfs_emubd_ops) => 0;
TEST
echo "--- Invalid superblocks ---"
ln -f -s /dev/null blocks/0
./tests/test.py << TEST
lfs_format(&lfs, &bd, &lfs_emubd_ops) => LFS_ERROR_CORRUPT;
TEST
rm blocks/0
echo "--- Basic mounting ---"
./tests/test.py << TEST
lfs_mount(&lfs, &bd, &lfs_emubd_ops) => 0;
lfs_unmount(&lfs) => 0;
TEST
echo "--- Invalid mount ---"
./tests/test.py << TEST
lfs_format(&lfs, &bd, &lfs_emubd_ops) => 0;
TEST
rm blocks/0 blocks/1
./tests/test.py << TEST
lfs_mount(&lfs, &bd, &lfs_emubd_ops) => LFS_ERROR_CORRUPT;
TEST
echo "--- Valid corrupt mount ---"
./tests/test.py << TEST
lfs_format(&lfs, &bd, &lfs_emubd_ops) => 0;
TEST
rm blocks/0
./tests/test.py << TEST
lfs_mount(&lfs, &bd, &lfs_emubd_ops) => 0;
lfs_unmount(&lfs) => 0;
TEST
echo "--- Results ---"
./tests/stats.py