Skip to content

Commit

Permalink
tests: some modification of test_fsck.sh
Browse files Browse the repository at this point in the history
Add '-s' option to fsck option, And
remove comparision between repaired image
and expected image in test_fsck.sh

Signed-off-by: Hyunchul Lee <[email protected]>
  • Loading branch information
hclee committed Sep 1, 2022
1 parent 2d1d874 commit a3da451
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
Binary file removed tests/file_invalid_clus/exfat.img.expected.xz
Binary file not shown.
Binary file removed tests/large_file_invalid_clus/exfat.img.expected.xz
Binary file not shown.
27 changes: 9 additions & 18 deletions tests/test_fsck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ TESTCASE_DIR=$1
NEED_LOOPDEV=$2
IMAGE_FILE=exfat.img
FSCK_PROG=fsck.exfat
FSCK_OPTS=-y
FSCK_PROG_2=fsck.exfat
FSCK_OPTS="-y -s"
PASS_COUNT=0

cleanup() {
echo ""
echo "Passed ${PASS_COUNT} of ${TEST_COUNT}"
exit
if [ ${PASS_COUNT} -ne ${TEST_COUNT} ]; then
exit 1
else
exit 0
fi
}

if [ $# -eq 0 ]; then
Expand Down Expand Up @@ -40,7 +45,7 @@ for TESTCASE_DIR in $TESTCASE_DIRS; do

# Run fsck for repair
$FSCK_PROG $FSCK_OPTS "$DEV_FILE"
if [ $? -ne 1 ]; then
if [ $? -ne 1 ] && [ $? -ne 0 ]; then
echo ""
echo "Failed to repair ${TESTCASE_DIR}"
if [ $NEED_LOOPDEV ]; then
Expand All @@ -51,7 +56,7 @@ for TESTCASE_DIR in $TESTCASE_DIRS; do

echo ""
# Run fsck again
$FSCK_PROG -n "$DEV_FILE"
$FSCK_PROG_2 "$DEV_FILE"
if [ $? -ne 0 ]; then
echo ""
echo "Failed, corrupted ${TESTCASE_DIR}"
Expand All @@ -61,20 +66,6 @@ for TESTCASE_DIR in $TESTCASE_DIRS; do
cleanup
fi

if [ -e "${TESTCASE_DIR}/exfat.img.expected.xz" ]; then
EXPECTED_FILE=${IMAGE_FILE}.expected
unxz -cfk "${TESTCASE_DIR}/${EXPECTED_FILE}.xz" > "${EXPECTED_FILE}"
diff <(xxd "${IMAGE_FILE}") <(xxd "${EXPECTED_FILE}")
if [ $? -ne 0 ]; then
echo ""
echo "Failed ${TESTCASE_DIR}"
if [ $NEED_LOOPDEV ]; then
losetup -d "${DEV_FILE}"
fi
cleanup
fi
fi

echo ""
echo "Passed ${TESTCASE_DIR}"
PASS_COUNT=$((PASS_COUNT + 1))
Expand Down

0 comments on commit a3da451

Please sign in to comment.