summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/2tb_disk/exfat.img.tar.xzbin0 -> 13368 bytes
-rw-r--r--tests/bad_bitmap/exfat.img.tar.xzbin0 -> 4056 bytes
-rw-r--r--tests/bad_dentries/exfat.img.tar.xzbin0 -> 9628 bytes
-rw-r--r--tests/bad_dentries2/exfat.img.tar.xzbin0 -> 9724 bytes
-rw-r--r--tests/bad_file_size/exfat.img.tar.xzbin0 -> 4052 bytes
-rw-r--r--tests/bad_first_clu/exfat.img.tar.xzbin0 -> 3232 bytes
-rw-r--r--tests/bad_num_chain/config1
-rw-r--r--tests/bad_num_chain/exfat.img.tar.xzbin0 -> 4064 bytes
-rw-r--r--tests/bad_root/exfat.img.tar.xzbin0 -> 4528 bytes
-rw-r--r--tests/bs_bad_csum/exfat.img.tar.xzbin0 -> 3036 bytes
-rw-r--r--tests/de_bad_csum/exfat.img.tar.xzbin0 -> 3196 bytes
-rw-r--r--tests/duplicate_clu/exfat.img.tar.xzbin0 -> 4048 bytes
-rw-r--r--tests/duplicated_name/exfat.img.tar.xzbin0 -> 3940 bytes
-rw-r--r--tests/file_invalid_clus/exfat.img.tar.xzbin0 -> 3392 bytes
-rw-r--r--tests/invalid_name/exfat.img.tar.xzbin0 -> 4444 bytes
-rw-r--r--tests/large_file_invalid_clus/exfat.img.tar.xzbin0 -> 17280 bytes
-rw-r--r--tests/loop_chain/config1
-rw-r--r--tests/loop_chain/exfat.img.tar.xzbin0 -> 4052 bytes
-rw-r--r--tests/rename_dot_entry/exfat.img.tar.xzbin0 -> 7336 bytes
-rwxr-xr-xtests/test_fsck.sh88
20 files changed, 90 insertions, 0 deletions
diff --git a/tests/2tb_disk/exfat.img.tar.xz b/tests/2tb_disk/exfat.img.tar.xz
new file mode 100644
index 0000000..f979bde
--- /dev/null
+++ b/tests/2tb_disk/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bad_bitmap/exfat.img.tar.xz b/tests/bad_bitmap/exfat.img.tar.xz
new file mode 100644
index 0000000..df09d10
--- /dev/null
+++ b/tests/bad_bitmap/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bad_dentries/exfat.img.tar.xz b/tests/bad_dentries/exfat.img.tar.xz
new file mode 100644
index 0000000..32643ca
--- /dev/null
+++ b/tests/bad_dentries/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bad_dentries2/exfat.img.tar.xz b/tests/bad_dentries2/exfat.img.tar.xz
new file mode 100644
index 0000000..f266741
--- /dev/null
+++ b/tests/bad_dentries2/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bad_file_size/exfat.img.tar.xz b/tests/bad_file_size/exfat.img.tar.xz
new file mode 100644
index 0000000..df7ff14
--- /dev/null
+++ b/tests/bad_file_size/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bad_first_clu/exfat.img.tar.xz b/tests/bad_first_clu/exfat.img.tar.xz
new file mode 100644
index 0000000..3dc29ec
--- /dev/null
+++ b/tests/bad_first_clu/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bad_num_chain/config b/tests/bad_num_chain/config
new file mode 100644
index 0000000..f62cec1
--- /dev/null
+++ b/tests/bad_num_chain/config
@@ -0,0 +1 @@
+#OPTS: -s
diff --git a/tests/bad_num_chain/exfat.img.tar.xz b/tests/bad_num_chain/exfat.img.tar.xz
new file mode 100644
index 0000000..68b8605
--- /dev/null
+++ b/tests/bad_num_chain/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bad_root/exfat.img.tar.xz b/tests/bad_root/exfat.img.tar.xz
new file mode 100644
index 0000000..de0066f
--- /dev/null
+++ b/tests/bad_root/exfat.img.tar.xz
Binary files differ
diff --git a/tests/bs_bad_csum/exfat.img.tar.xz b/tests/bs_bad_csum/exfat.img.tar.xz
new file mode 100644
index 0000000..cbcc5c0
--- /dev/null
+++ b/tests/bs_bad_csum/exfat.img.tar.xz
Binary files differ
diff --git a/tests/de_bad_csum/exfat.img.tar.xz b/tests/de_bad_csum/exfat.img.tar.xz
new file mode 100644
index 0000000..f753e82
--- /dev/null
+++ b/tests/de_bad_csum/exfat.img.tar.xz
Binary files differ
diff --git a/tests/duplicate_clu/exfat.img.tar.xz b/tests/duplicate_clu/exfat.img.tar.xz
new file mode 100644
index 0000000..bf3fdd8
--- /dev/null
+++ b/tests/duplicate_clu/exfat.img.tar.xz
Binary files differ
diff --git a/tests/duplicated_name/exfat.img.tar.xz b/tests/duplicated_name/exfat.img.tar.xz
new file mode 100644
index 0000000..ceb046f
--- /dev/null
+++ b/tests/duplicated_name/exfat.img.tar.xz
Binary files differ
diff --git a/tests/file_invalid_clus/exfat.img.tar.xz b/tests/file_invalid_clus/exfat.img.tar.xz
new file mode 100644
index 0000000..830edf2
--- /dev/null
+++ b/tests/file_invalid_clus/exfat.img.tar.xz
Binary files differ
diff --git a/tests/invalid_name/exfat.img.tar.xz b/tests/invalid_name/exfat.img.tar.xz
new file mode 100644
index 0000000..d274028
--- /dev/null
+++ b/tests/invalid_name/exfat.img.tar.xz
Binary files differ
diff --git a/tests/large_file_invalid_clus/exfat.img.tar.xz b/tests/large_file_invalid_clus/exfat.img.tar.xz
new file mode 100644
index 0000000..5e3dbef
--- /dev/null
+++ b/tests/large_file_invalid_clus/exfat.img.tar.xz
Binary files differ
diff --git a/tests/loop_chain/config b/tests/loop_chain/config
new file mode 100644
index 0000000..f62cec1
--- /dev/null
+++ b/tests/loop_chain/config
@@ -0,0 +1 @@
+#OPTS: -s
diff --git a/tests/loop_chain/exfat.img.tar.xz b/tests/loop_chain/exfat.img.tar.xz
new file mode 100644
index 0000000..c863cdd
--- /dev/null
+++ b/tests/loop_chain/exfat.img.tar.xz
Binary files differ
diff --git a/tests/rename_dot_entry/exfat.img.tar.xz b/tests/rename_dot_entry/exfat.img.tar.xz
new file mode 100644
index 0000000..6e50a72
--- /dev/null
+++ b/tests/rename_dot_entry/exfat.img.tar.xz
Binary files differ
diff --git a/tests/test_fsck.sh b/tests/test_fsck.sh
new file mode 100755
index 0000000..678b331
--- /dev/null
+++ b/tests/test_fsck.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+
+TESTCASE_DIR=$1
+NEED_LOOPDEV=$2
+IMAGE_FILE=exfat.img
+FSCK_PROG=${FSCK1:-"fsck.exfat"}
+FSCK_PROG_2=${FSCK2:-"fsck.exfat"}
+FSCK_OPTS="-y -s"
+PASS_COUNT=0
+
+cleanup() {
+ echo ""
+ echo "Passed ${PASS_COUNT} of ${TEST_COUNT}"
+ if [ ${PASS_COUNT} -ne ${TEST_COUNT} ]; then
+ exit 1
+ else
+ exit 0
+ fi
+}
+
+if [ $# -eq 0 ]; then
+ TESTCASE_DIRS=$(find . -mindepth 1 -maxdepth 1 -type d)
+ TEST_COUNT=$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)
+else
+ TESTCASE_DIRS=$@
+ TEST_COUNT=$#
+fi
+
+for TESTCASE_DIR in $TESTCASE_DIRS; do
+ if [ ! -e "${TESTCASE_DIR}/${IMAGE_FILE}.tar.xz" ]; then
+ TEST_COUNT=$((TEST_COUNT - 1))
+ continue
+ fi
+
+ echo "Running ${TESTCASE_DIR}"
+ echo "-----------------------------------"
+
+ # Set up image file as loop device
+ tar -C . -xf "${TESTCASE_DIR}/${IMAGE_FILE}.tar.xz"
+ if [ $NEED_LOOPDEV ]; then
+ DEV_FILE=$(losetup -f "${IMAGE_FILE}" --show)
+ else
+ DEV_FILE=$IMAGE_FILE
+ fi
+
+ # Run fsck to detect corruptions
+ $FSCK_PROG "$DEV_FILE" | grep -q "ERROR:\|corrupted"
+ if [ $? -ne 0 ]; then
+ echo ""
+ echo "Failed to detect corruption for ${TESTCASE_DIR}"
+ if [ $NEED_LOOPDEV ]; then
+ losetup -d "${DEV_FILE}"
+ fi
+ cleanup
+ fi
+
+ # Run fsck for repair
+ $FSCK_PROG $FSCK_OPTS "$DEV_FILE"
+ if [ $? -ne 1 ] && [ $? -ne 0 ]; then
+ echo ""
+ echo "Failed to repair ${TESTCASE_DIR}"
+ if [ $NEED_LOOPDEV ]; then
+ losetup -d "${DEV_FILE}"
+ fi
+ cleanup
+ fi
+
+ echo ""
+ # Run fsck again
+ $FSCK_PROG_2 "$DEV_FILE"
+ if [ $? -ne 0 ]; then
+ echo ""
+ echo "Failed, corrupted ${TESTCASE_DIR}"
+ if [ $NEED_LOOPDEV ]; then
+ losetup -d "${DEV_FILE}"
+ fi
+ cleanup
+ fi
+
+ echo ""
+ echo "Passed ${TESTCASE_DIR}"
+ PASS_COUNT=$((PASS_COUNT + 1))
+
+ if [ $NEED_LOOPDEV ]; then
+ losetup -d "${DEV_FILE}"
+ fi
+done
+cleanup