diff mbox series

[v2] ext4: add test case 061 for ext3 to ext4 conversion

Message ID 20250220081748.185731-1-bxue@redhat.com (mailing list archive)
State New
Headers show
Series [v2] ext4: add test case 061 for ext3 to ext4 conversion | expand

Commit Message

Boyang Xue Feb. 20, 2025, 8:14 a.m. UTC
Signed-off-by: Boyang Xue <bxue@redhat.com>
---
v1->v2:
 - fix mount check in _cleanup()

 tests/ext4/061     | 63 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/ext4/061.out | 17 +++++++++++++
 2 files changed, 80 insertions(+)
 create mode 100755 tests/ext4/061
 create mode 100644 tests/ext4/061.out
diff mbox series

Patch

diff --git a/tests/ext4/061 b/tests/ext4/061
new file mode 100755
index 00000000..785aecbc
--- /dev/null
+++ b/tests/ext4/061
@@ -0,0 +1,63 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat Inc.  All Rights Reserved.
+#
+# FS QA Test 061
+#
+# Test conversion from ext3 to ext4 filesystem with various mount options
+#
+. ./common/preamble
+_begin_fstest auto
+
+# Import common functions.
+. ./common/filter
+
+_supported_fs ext3 ext4
+
+_require_scratch
+
+MOUNT_OPTS_LIST=(
+    ""
+    "noatime"
+    "data=journal"
+    "data=writeback"
+)
+
+_cleanup()
+{
+    if mount | grep -q "$SCRATCH_DEV" > /dev/null 2>&1; then
+        $UMOUNT_PROG "$SCRATCH_DEV" || _fail "_cleanup: umount failed"
+    fi
+}
+
+
+fill_fs() {
+    echo "Filling filesystem..."
+    while true; do
+        dd if=/dev/urandom of="${SCRATCH_MNT}/file$(date +%s)" bs=1M count=4 \
+> /dev/null 2>&1 || _fail "dd failed"
+        df -h ${SCRATCH_MNT} | awk 'NR==2 {print $5}' | grep -q '[9][0-9]%' \
+&& break
+    done
+    echo "Filesystem almost full."
+}
+
+for mount_opt in "${MOUNT_OPTS_LIST[@]}"; do
+    echo "Starting test with mount options: '$mount_opt'"
+    mkfs.ext3 -F "$SCRATCH_DEV" 1g >> $seqres.full 2>&1 \
+|| _fail "mkfs.ext3 failed"
+    mount -t ext3 -o "$mount_opt" "$SCRATCH_DEV" "$SCRATCH_MNT" \
+ >> $seqres.full 2>&1 || _fail "mount ext3 failed"
+    fill_fs
+    umount "$SCRATCH_MNT" >> $seqres.full 2>&1 || _fail "umount ext3 failed"
+    tune2fs -O extents,uninit_bg,dir_index "$SCRATCH_DEV" \
+>> $seqres.full 2>&1 || _fail "tune2fs failed"
+    e2fsck -f -y "$SCRATCH_DEV" >> $seqres.full 2>&1 || _fail "e2fsck failed"
+    mount -t ext4 "$SCRATCH_DEV" "$SCRATCH_MNT" >> $seqres.full 2>&1 \
+|| _fail "mount ext4 failed"
+    umount "$SCRATCH_MNT" >> $seqres.full 2>&1 || _fail "umount ext3 failed"
+    echo "Test with mount options: '$mount_opt' completed successfully."
+done
+
+status=0
+exit
diff --git a/tests/ext4/061.out b/tests/ext4/061.out
new file mode 100644
index 00000000..ed2997a0
--- /dev/null
+++ b/tests/ext4/061.out
@@ -0,0 +1,17 @@ 
+QA output created by 061
+Starting test with mount options: ''
+Filling filesystem...
+Filesystem almost full.
+Test with mount options: '' completed successfully.
+Starting test with mount options: 'noatime'
+Filling filesystem...
+Filesystem almost full.
+Test with mount options: 'noatime' completed successfully.
+Starting test with mount options: 'data=journal'
+Filling filesystem...
+Filesystem almost full.
+Test with mount options: 'data=journal' completed successfully.
+Starting test with mount options: 'data=writeback'
+Filling filesystem...
+Filesystem almost full.
+Test with mount options: 'data=writeback' completed successfully.