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

91 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
# Prepara o ambiente de VMs: imagens, seed e maquinas virtuais.
# Requer: libvirt (qemu:///session), virt-install, qemu-img, mkisofs.
set -e
HERE=$(cd "$(dirname "$0")" && pwd)
WORK=${WORK:-/var/tmp/vmtest}
CONN=qemu:///session
mkdir -p "$WORK"
cd "$WORK"
fetch() {
url=$1; out=$2
[ -s "$out" ] && { echo " $out ja existe"; return; }
echo " baixando $out"
curl -fsSL -o "$out.part" "$url"
mv "$out.part" "$out"
}
echo "== imagens =="
fetch https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2 debian.qcow2
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/cloud/nocloud_alpine-3.20.3-x86_64-bios-cloudinit-r0.qcow2 alpine.qcow2
echo "== redimensionando =="
for img in debian.qcow2 alpine.qcow2; do
size=$(qemu-img info --output=json "$img" | grep -oP '"virtual-size":\s*\K[0-9]+')
if [ "${size:-0}" -lt 8589934592 ]; then
qemu-img resize "$img" 8G
else
echo " $img ja tem 8G"
fi
done
echo "== disco de dados (fontes + script de teste) =="
if [ ! -s data.img ]; then
dd if=/dev/zero of=data.img bs=1M count=8 status=none
mkfs.ext4 -q -F data.img
fi
echo "== seed cloud-init =="
cat > user-data <<'EOF'
#cloud-config
hostname: rfs-test
ssh_pwauth: true
disable_root: false
users:
- name: root
lock_passwd: false
plain_text_passwd: rfstest
chpasswd:
expire: false
EOF
cat > meta-data <<'EOF'
instance-id: rfs-test-1
local-hostname: rfs-test
EOF
cat > network-config <<'EOF'
version: 2
ethernets:
eth0:
dhcp4: true
EOF
rm -f seed.iso
mkisofs -output seed.iso -volid cidata -joliet -rock \
user-data meta-data network-config >/dev/null 2>&1
echo "== definindo VMs =="
define_vm() {
name=$1; img=$2; variant=$3; mem=$4
if virsh -c "$CONN" dominfo "$name" >/dev/null 2>&1; then
echo " $name ja existe"
return
fi
virt-install -c "$CONN" \
--name "$name" \
--memory "$mem" --vcpus 2 \
--disk "path=$WORK/$img,format=qcow2,bus=virtio" \
--disk "path=$WORK/seed.iso,device=cdrom" \
--os-variant "$variant" \
--network user,model=virtio \
--graphics none --console pty \
--import --noautoconsole >/dev/null
echo " criada: $name"
}
define_vm rfs-debian debian.qcow2 debian12 2048
define_vm rfs-alpine alpine.qcow2 alpinelinux3.20 1024
echo
echo "Pronto. Use tests/vm/run_in_vm.sh <vm> para testar."