Files
reiserfsprogs/tests/vm/run_in_vm.sh
T
lgcosta 7b5421ce49
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
Support clang builds; fix the defects clang and its sanitizers exposed
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.
2026-11-12 08:51:29 -03:00

58 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# Envia o codigo-fonte e o script de teste para dentro de uma VM e executa.
#
# Uso: run_in_vm.sh <dominio>
# CC=clang run_in_vm.sh rfs-debian # build no guest com clang
# Requer: guestcmd.py (mesmo diretorio), mkisofs, libvirt, sudo (loop mount).
set -e
DOMAIN=${1:?uso: run_in_vm.sh <dominio>}
HERE=$(cd "$(dirname "$0")" && pwd)
REPO=$(cd "$HERE/../.." && pwd)
WORK=${WORK:-/var/tmp/vmtest}
echo "== empacotando o codigo-fonte =="
tar czf "$WORK/rfs-src.tar.gz" -C "$REPO" \
--exclude=.git --exclude='*.o' --exclude='*.lo' --exclude='*.la' \
--exclude='.libs' --exclude=build-aux --exclude=m4 \
--exclude=autom4te.cache --exclude=config.h --exclude=config.log \
--exclude=config.status --exclude=libtool \
--exclude='Makefile' --exclude='Makefile.in' --exclude=configure \
--exclude=aclocal.m4 --exclude='*.8' --exclude=stamp-h1 \
--exclude='reiserfscore/reiserfs_err.c' \
--exclude='reiserfscore/reiserfs_err.h' \
.
echo "== montando o disco de dados =="
rm -rf /tmp/vmdata.$$ && mkdir -p /tmp/vmdata.$$
sudo mount -o loop "$WORK/data.img" /tmp/vmdata.$$
sudo cp "$WORK/rfs-src.tar.gz" "$HERE/run_tests.sh" /tmp/vmdata.$$
sync
sudo umount /tmp/vmdata.$$ && rmdir /tmp/vmdata.$$
echo "== transferindo para $DOMAIN =="
ATTACH=/tmp/vdb.$$.xml
cat > "$ATTACH" <<EOF
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='$WORK/data.img'/>
<target dev='vdb' bus='virtio'/>
</disk>
EOF
virsh attach-device "$DOMAIN" "$ATTACH" --live >/dev/null 2>&1 || true
rm -f "$ATTACH"
echo "== extraindo e rodando os testes ${CC:+com CC=$CC} =="
"$HERE/guestcmd.py" "$DOMAIN" "
set -e
mkdir -p /mnt/data
# remount forcado: o host trocou o conteudo do disco por baixo do guest
umount /mnt/data 2>/dev/null || true
mount -o ro /dev/vdb /mnt/data
rm -rf /root/rfs
mkdir -p /root/rfs
tar xzf /mnt/data/rfs-src.tar.gz -C /root/rfs
cp /mnt/data/run_tests.sh /root/run_tests.sh
chmod +x /root/run_tests.sh
SRC=/root/rfs ${CC:+CC=$CC }sh /root/run_tests.sh
" 1800