Files
lgcosta 5a7382185b
build / build (clang, ) (push) Failing after 6s
build / build (gcc, ) (push) Failing after 6s
build / build (gcc, --enable-io-failure-emulation) (push) Failing after 6s
build / build (gcc, --enable-warnings) (push) Failing after 5s
Add a libvirt/KVM test environment and fix the gcc-12 warning it found
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.
2026-11-12 00:11:31 -03:00

51 lines
1.7 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>
# Requer: guestcmd.py (mesmo diretorio), mkisofs, libvirt.
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' \
.
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.$$
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 =="
"$HERE/guestcmd.py" "$DOMAIN" '
set -e
mkdir -p /mnt/data
mountpoint -q /mnt/data || mount -o ro /dev/vdb /mnt/data
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 sh /root/run_tests.sh
' 900