Hi Gao Xiang and linux-erofs team,

The repository currently lacks any automated smoke or integration tests.

This patch adds a simple, self-contained bash script (tests/smoke.sh)
that verifies the primary userspace workflow:

- mkfs.erofs image creation (uncompressed)
- fsck.erofs integrity check
- erofsfuse FUSE mount
- Basic content verification
- Clean unmount and full cleanup

The script:
- Checks for required binaries upfront with a helpful error message
- Fails fast with clear diagnostics
- Uses trap for cleanup on exit or failure
- Exits non-zero on failure

Happy to expand it (e.g., add compressed image variant, error
injection, or CI integration).

Thanks for considering!

Best regards,
Aayushmaan Chakraborty
GitHub: https://github.com/Aayushmaan-24/erofs-utils/tree/add-basic-smoke-test

---

>From 5dabe68b8c58e5d8b5541822446f7e27e816d6a1 Mon Sep 17 00:00:00 2001
From: Aayushmaan <[email protected]>
Date: Wed, 4 Mar 2026 18:49:53 +0530
Subject: [PATCH] tests: add basic smoke/integration test script

Verifies core userspace workflow: mkfs.erofs image creation,
fsck.erofs integrity check, erofsfuse mount, content verification,
and automatic cleanup.
Script includes:
- Binary existence checks
- Fail-fast error handling
- Trap-based cleanup on exit
- Tested locally on Debian-based Chromebook (Crostini)
No existing tests were present in the repository.
---
 tests/smoke.sh | 115 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100755 tests/smoke.sh

diff --git a/tests/smoke.sh b/tests/smoke.sh
new file mode 100755
index 0000000..43f70f5
--- /dev/null
+++ b/tests/smoke.sh
@@ -0,0 +1,115 @@
+#!/usr/bin/env bash
+#
+# Basic smoke test for erofs-utils
+# Tests: mkfs.erofs → fsck.erofs → erofsfuse mount → content
verification → unmount
+#
+# Usage: ./tests/smoke.sh
+#        Must be run from the root of the built erofs-utils tree
+#
+# Exits with 0 on success, non-zero on failure
+
+set -euo pipefail
+IFS=$'\n\t'
+
+echo "=== Starting EROFS smoke test ==="
+
+# ====================
+# Setup
+# ====================
+
+SRC_DIR="smoke_test_src_$$    "
+IMAGE_FILE="smoke_test.img"
+MOUNT_POINT="smoke_test_mnt_    $$"
+
+MKFS_BIN="./mkfs/mkfs.erofs"
+FSCK_BIN="./fsck/fsck.erofs"
+FUSE_BIN="./fuse/erofsfuse"
+
+if [[ ! -x "$MKFS_BIN" || ! -x "$FSCK_BIN" || ! -x "$FUSE_BIN" ]]; then
+    echo "ERROR: Required binaries not found (expected: $MKFS_BIN,
$FSCK_BIN, $FUSE_BIN)."
+    echo "       Make sure you have built erofs-utils first, for example:"
+    echo "         ./autogen.sh"
+    echo "         ./configure --enable-lz4 --enable-lzma
--enable-fuse --with-libzstd"
+    echo "         make -j$(nproc)"
+    exit 1
+fi
+
+mkdir -p "$SRC_DIR" "$MOUNT_POINT"
+
+# Create some test files
+echo "Hello from EROFS smoke test!" > "$SRC_DIR/hello.txt"
+echo "This is a second file."      > "$SRC_DIR/second.txt"
+mkdir "$SRC_DIR/subdir"
+echo "Nested file content"         > "$SRC_DIR/subdir/nested.txt"
+
+echo "[OK] Test files created in $SRC_DIR"
+
+# ====================
+# Create image (uncompressed)
+# ====================
+
+echo "Creating EROFS image (uncompressed)..."
+"$MKFS_BIN" "$IMAGE_FILE" "$SRC_DIR/"
+
+if [[ ! -f "$IMAGE_FILE" ]]; then
+    echo "ERROR: mkfs.erofs failed to create $IMAGE_FILE"
+    exit 1
+fi
+
+echo "[OK] Image created: $IMAGE_FILE"
+
+# ====================
+# Verify with fsck
+# ====================
+
+echo "Running fsck on image..."
+"$FSCK_BIN" "$IMAGE_FILE"
+
+# fsck.erofs usually prints stats or "No errors found" on clean images
+# We just check exit code here
+echo "[OK] fsck completed (exit code $?)"
+
+# ====================
+# Mount via FUSE and verify contents
+# ====================
+
+echo "Mounting image via erofsfuse..."
+"$FUSE_BIN" "$IMAGE_FILE" "$MOUNT_POINT/"
+
+# Give FUSE a moment to settle
+sleep 1
+
+# Basic existence checks
+if [[ ! -f "$MOUNT_POINT/hello.txt" ]]; then
+    echo "FAIL: hello.txt not visible after mount"
+    fusermount -u "$MOUNT_POINT" 2>/dev/null || true
+    exit 1
+fi
+
+if ! grep -q "Hello from EROFS" "$MOUNT_POINT/hello.txt"; then
+    echo "FAIL: Content mismatch in hello.txt"
+    fusermount -u "$MOUNT_POINT" 2>/dev/null || true
+    exit 1
+fi
+
+if [[ ! -f "$MOUNT_POINT/subdir/nested.txt" ]]; then
+    echo "FAIL: subdir/nested.txt not visible"
+    fusermount -u "$MOUNT_POINT" 2>/dev/null || true
+    exit 1
+fi
+
+echo "[OK] Mount successful and files verified"
+
+# ====================
+# Cleanup
+# ====================
+
+echo "Unmounting..."
+fusermount -u "$MOUNT_POINT" 2>/dev/null || sudo fusermount -u
"$MOUNT_POINT" || {
+    echo "Warning: unmount failed, continuing cleanup..."
+}
+
+rm -rf "$SRC_DIR" "$MOUNT_POINT" "$IMAGE_FILE"
+
+echo "=== Smoke test PASSED ==="
+exit 0
--
2.39.5

Reply via email to