From 0151cc01a4f5b10ee3fe12d4ac107e05075a5a5c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 26 Aug 2024 12:36:09 +0200 Subject: Merging upstream version 1.2.5. Signed-off-by: Daniel Baumann --- tests/2tb_disk/exfat.img.tar.xz | Bin 0 -> 13368 bytes tests/bad_bitmap/exfat.img.tar.xz | Bin 0 -> 4056 bytes tests/bad_dentries/exfat.img.tar.xz | Bin 0 -> 9628 bytes tests/bad_dentries2/exfat.img.tar.xz | Bin 0 -> 9724 bytes tests/bad_file_size/exfat.img.tar.xz | Bin 0 -> 4052 bytes tests/bad_first_clu/exfat.img.tar.xz | Bin 0 -> 3232 bytes tests/bad_num_chain/config | 1 + tests/bad_num_chain/exfat.img.tar.xz | Bin 0 -> 4064 bytes tests/bad_root/exfat.img.tar.xz | Bin 0 -> 4528 bytes tests/bs_bad_csum/exfat.img.tar.xz | Bin 0 -> 3036 bytes tests/de_bad_csum/exfat.img.tar.xz | Bin 0 -> 3196 bytes tests/duplicate_clu/exfat.img.tar.xz | Bin 0 -> 4048 bytes tests/duplicated_name/exfat.img.tar.xz | Bin 0 -> 3940 bytes tests/file_invalid_clus/exfat.img.tar.xz | Bin 0 -> 3392 bytes tests/invalid_name/exfat.img.tar.xz | Bin 0 -> 4444 bytes tests/large_file_invalid_clus/exfat.img.tar.xz | Bin 0 -> 17280 bytes tests/loop_chain/config | 1 + tests/loop_chain/exfat.img.tar.xz | Bin 0 -> 4052 bytes tests/rename_dot_entry/exfat.img.tar.xz | Bin 0 -> 7336 bytes tests/test_fsck.sh | 88 +++++++++++++++++++++++++ 20 files changed, 90 insertions(+) create mode 100644 tests/2tb_disk/exfat.img.tar.xz create mode 100644 tests/bad_bitmap/exfat.img.tar.xz create mode 100644 tests/bad_dentries/exfat.img.tar.xz create mode 100644 tests/bad_dentries2/exfat.img.tar.xz create mode 100644 tests/bad_file_size/exfat.img.tar.xz create mode 100644 tests/bad_first_clu/exfat.img.tar.xz create mode 100644 tests/bad_num_chain/config create mode 100644 tests/bad_num_chain/exfat.img.tar.xz create mode 100644 tests/bad_root/exfat.img.tar.xz create mode 100644 tests/bs_bad_csum/exfat.img.tar.xz create mode 100644 tests/de_bad_csum/exfat.img.tar.xz create mode 100644 tests/duplicate_clu/exfat.img.tar.xz create mode 100644 tests/duplicated_name/exfat.img.tar.xz create mode 100644 tests/file_invalid_clus/exfat.img.tar.xz create mode 100644 tests/invalid_name/exfat.img.tar.xz create mode 100644 tests/large_file_invalid_clus/exfat.img.tar.xz create mode 100644 tests/loop_chain/config create mode 100644 tests/loop_chain/exfat.img.tar.xz create mode 100644 tests/rename_dot_entry/exfat.img.tar.xz create mode 100755 tests/test_fsck.sh (limited to 'tests') 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 Binary files /dev/null and b/tests/2tb_disk/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bad_bitmap/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bad_dentries/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bad_dentries2/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bad_file_size/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bad_first_clu/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bad_num_chain/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bad_root/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/bs_bad_csum/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/de_bad_csum/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/duplicate_clu/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/duplicated_name/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/file_invalid_clus/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/invalid_name/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/large_file_invalid_clus/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/loop_chain/exfat.img.tar.xz 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 Binary files /dev/null and b/tests/rename_dot_entry/exfat.img.tar.xz 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 -- cgit v1.2.3