The VM harness (tests/vm/) builds and exercises the tools on real Debian and Alpine guests, driving the serial console (no sshd/cloud-init dependency). Results on Debian 12 (glibc 2.36, gcc 12.2): 12/12 checks pass, 0 warnings with -Wall -Wextra, including a real 128M -> 256M resize and the rollback save/restore/reject paths. Results on Alpine 3.20 (musl 1.2.5): the build cannot start. configure stops at "reiserfsprogs requires a method to add printf modifiers" because reiserfscore/prints.c depends on glibc's register_printf_specifier(3) and <printf.h>, which musl does not provide. This is pre-existing and out of scope here; measured at 341 use sites across 20+ files, all routed through reiserfs_warning()/reiserfs_info(). Documented in tests/vm/RESULTS.md. Fix the one real defect the harness surfaced: fsck/semantic_check.c: check_check_regular_file() is called with NULL for new_ih (line 466), so the block that would fill *new_ih is unreachable and check_semantic_pass() never returns RELOCATED through that path. The "case RELOCATED:" arm still reads relocated_ih.ih_key, which gcc 12.2 reports as "may be used uninitialized" (-Wmaybe-uninitialized); gcc 16 does not, because it proves the path dead. Zero-initialise the struct and say why. Verified: 0 warnings on gcc 12.2 after the change, and the Debian battery stays at 12/12.
134 lines
3.7 KiB
Bash
Executable File
134 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Bateria de testes do reiserfsprogs, executada DENTRO do guest.
|
|
# Espera receber o codigo-fonte em $SRC (padrao: /root/rfs).
|
|
#
|
|
# Uso (dentro da VM):
|
|
# SRC=/root/rfs sh run_tests.sh
|
|
set -u
|
|
|
|
SRC=${SRC:-/root/rfs}
|
|
PASS=0
|
|
FAIL=0
|
|
ok() { echo "PASS: $1"; PASS=$((PASS + 1)); }
|
|
bad() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); }
|
|
|
|
cd "$SRC" || { echo "FAIL: $SRC nao existe"; exit 1; }
|
|
|
|
echo "=== ambiente ==="
|
|
uname -srm
|
|
(cc --version 2>/dev/null || echo "sem cc") | head -1
|
|
ldd --version 2>&1 | head -1
|
|
|
|
echo
|
|
echo "=== 1. bootstrap + build com -Wall -Wextra ==="
|
|
make distclean >/dev/null 2>&1
|
|
if ./autogen.sh >/tmp/ag.log 2>&1 && ./configure --enable-warnings >/tmp/cfg.log 2>&1 \
|
|
&& make -j"$(nproc 2>/dev/null || echo 2)" >/tmp/mk.log 2>&1; then
|
|
ok "autogen.sh + configure + make"
|
|
else
|
|
bad "build"
|
|
echo "--- configure ---"; tail -15 /tmp/cfg.log
|
|
echo "--- make ---"; tail -25 /tmp/mk.log
|
|
echo
|
|
echo "RESULTADO: $PASS passaram, $FAIL falharam"
|
|
exit 1
|
|
fi
|
|
|
|
# grep -c retorna 1 quando nao ha ocorrencias; capturar so a primeira linha
|
|
WARN=$(grep -c "warning:" /tmp/mk.log 2>/dev/null | head -1)
|
|
WARN=${WARN:-0}
|
|
if [ "$WARN" = "0" ]; then
|
|
ok "0 warnings com -Wall -Wextra"
|
|
else
|
|
bad "$WARN warnings"
|
|
grep "warning:" /tmp/mk.log | head -10
|
|
fi
|
|
|
|
echo
|
|
echo "=== 2. mkfs ==="
|
|
rm -f /tmp/t.img
|
|
dd if=/dev/zero of=/tmp/t.img bs=1M count=64 status=none 2>/dev/null
|
|
if ./mkreiserfs/mkreiserfs -f -q -l TESTVOL /tmp/t.img >/dev/null 2>&1; then
|
|
ok "mkreiserfs"
|
|
else
|
|
bad "mkreiserfs"
|
|
fi
|
|
|
|
echo
|
|
echo "=== 3. reiserfsck --check ==="
|
|
if ./fsck/reiserfsck --check -f -q -y /tmp/t.img 2>&1 | grep -q "No corruptions found"; then
|
|
ok "reiserfsck --check"
|
|
else
|
|
bad "reiserfsck --check"
|
|
fi
|
|
|
|
echo
|
|
echo "=== 4. debugreiserfs -S ==="
|
|
if ./debugreiserfs/debugreiserfs -S /tmp/t.img 2>&1 | grep -q "Filesystem state: consistent"; then
|
|
ok "debugreiserfs -S"
|
|
else
|
|
bad "debugreiserfs -S"
|
|
fi
|
|
|
|
echo
|
|
echo "=== 5. reiserfstune -l ==="
|
|
if ./tune/reiserfstune -l NEWLABEL -f /tmp/t.img >/dev/null 2>&1; then
|
|
ok "reiserfstune -l"
|
|
else
|
|
bad "reiserfstune -l"
|
|
fi
|
|
|
|
echo
|
|
echo "=== 6. resize 128M -> 256M ==="
|
|
rm -f /tmp/big.img
|
|
dd if=/dev/zero of=/tmp/big.img bs=1M count=128 status=none 2>/dev/null
|
|
./mkreiserfs/mkreiserfs -f -q /tmp/big.img >/dev/null 2>&1
|
|
truncate -s 256M /tmp/big.img
|
|
if ./resize_reiserfs/resize_reiserfs -s +128M -f /tmp/big.img 2>&1 \
|
|
| grep -q "Resizing finished successfully"; then
|
|
ok "resize_reiserfs"
|
|
else
|
|
bad "resize_reiserfs"
|
|
fi
|
|
|
|
echo
|
|
echo "=== 7. fsck pos-resize ==="
|
|
if ./fsck/reiserfsck --check -f -q -y /tmp/big.img 2>&1 | grep -q "No corruptions found"; then
|
|
ok "fsck apos resize"
|
|
else
|
|
bad "fsck apos resize"
|
|
fi
|
|
|
|
echo
|
|
echo "=== 8. rollback (save/restore/reject) ==="
|
|
cp /tmp/t.img /tmp/rb.img
|
|
rm -f /tmp/rb.dat
|
|
./fsck/reiserfsck --fix-fixable -y -q -R /tmp/rb.dat /tmp/rb.img >/dev/null 2>&1
|
|
if [ -f /tmp/rb.dat ]; then
|
|
ok "rollback file criado"
|
|
else
|
|
bad "rollback file nao criado"
|
|
fi
|
|
if ./fsck/reiserfsck --rollback-fsck-changes -y -q -R /tmp/rb.dat /tmp/rb.img 2>&1 \
|
|
| grep -q "blocks restored"; then
|
|
ok "rollback-fsck-changes"
|
|
else
|
|
bad "rollback-fsck-changes"
|
|
fi
|
|
head -c 100 /dev/urandom > /tmp/rollback-invalido.dat
|
|
if ./fsck/reiserfsck --rollback-fsck-changes -y -q -R /tmp/rollback-invalido.dat /tmp/rb.img 2>&1 \
|
|
| grep -q "does not look like a rollback file"; then
|
|
ok "rollback com magic invalida rejeitado"
|
|
else
|
|
bad "rollback com magic invalida aceito"
|
|
fi
|
|
if ./fsck/reiserfsck --rollback-fsck-changes -y -q -R /tmp/nao-existe.dat /tmp/rb.img 2>&1 \
|
|
| grep -q "Cannot stat rollback file"; then
|
|
ok "rollback inexistente rejeitado"
|
|
else
|
|
bad "rollback inexistente aceito"
|
|
fi
|
|
|
|
echo
|
|
echo "RESULTADO: $PASS passaram, $FAIL falharam"
|
|
[ "$FAIL" -eq 0 ] |