build / build (clang, ) (push) Failing after 7s
build / build (clang, --enable-warnings) (push) Failing after 5s
build / build (gcc, ) (push) Failing after 5s
build / build (gcc, --enable-io-failure-emulation) (push) Failing after 5s
build / build (gcc, --enable-warnings) (push) Failing after 6s
build / out-of-tree (push) Failing after 6s
build / sanitizers (push) Failing after 5s
Clang (22.1.8 on the host, 14.0.6 in the Debian VM) now builds the tree
warning-free with --enable-warnings, in-tree and out-of-tree, with -j, and
the full VM battery passes with CC=clang: 12/12. ASan/UBSan builds run the
real tool paths (mkfs, check, tune, resize, rollback save/restore/reject)
with halt_on_error and report zero errors. Documented in tests/vm/RESULTS.md;
the CI gained clang+warnings, out-of-tree and sanitizer jobs.
Fixes found by this work:
- reiserfscore/Makefile.am: reiserfs_err.c and reiserfs_err.h shared one
recipe. With -j, make runs the recipe once per stale target, so two
compile_et invocations race: one deletes reiserfs_err.c ("no input
files") while another job compiles it. Attached the recipe to
reiserfs_err.c only; reiserfs_err.h merely depends on it. Reproduced
with clang+ASan, stable across 5 clang / 3 asan / 3 gcc parallel builds.
- reiserfscore/Makefile.am: the rule read the source-local
reiserfs_err.et, so VPATH builds could not find it. Use $(srcdir)/.
make distcheck now passes.
- reiserfscore/reiserfslib.c: reiserfs_close() did fsync(fs->fs_dev) after
reiserfs_free() released fs -- a 4-byte heap-use-after-free, flagged
exactly at reiserfslib.c:406/407 by ASan (found by clang+ASan; gcc never
caught it because the freed heap usually still holds the old value).
Moved fsync before the free; reiserfs_flush() has already written
journal and dirty buffers at that point and free_buffers() never
writes, so the ordering preserves durability semantics.
- fsck/semantic_check.c, fsck/semantic_rebuild.c: three %K arguments passed
&tmp_deh->deh2_dir_id where a struct reiserfs_key * is expected. It
printed the right values only because deh2_dir_id sits at offset 4 and
the key is read from the pointer as if dir_id sat at offset 0. Build a
proper local key with set_key_dirid()/set_key_objectid() (the same
idiom debugreiserfs/scan.c already uses). Verified -Waddress-of-packed-
member (clang-only) is gone and output is unchanged.
- reiserfscore/hashes.c: four unreachable *(int *)0 = 0 stores (guarded by
len >= 16/12/8/4 tests that cannot hold after the while (len >= 16)
loop, len <= 15). Removed; clang's -Wnull-dereference goes quiet.
Behavior verified: keyed_hash/yura_hash/r5_hash outputs for 16 inputs
from 0 to 17 bytes are byte-identical before and after.
run_in_vm.sh: propagate CC into the guest, force a remount of /mnt/data
(the host rewrites the backing file under the guest), exclude generated
reiserfs_err.[ch] from the source tar. run_tests.sh: report which compiler
the battery actually used.
135 lines
3.7 KiB
Bash
Executable File
135 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
|
|
echo "CC=${CC:-cc}"
|
|
${CC:-cc} --version 2>/dev/null | head -1 || echo "sem ${CC:-cc}"
|
|
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 ] |