Files
football/tests/system/boot_test.bats
Charles N Wyble ab49d1f98b refactor: remove versioning from ISO filename
ISO now always named knel-football-secure.iso (no v1.0.0 suffix).
Updated all references in code, docs, and tests.

💘 Generated with Crush

Assisted-by: GLM-4.7 via Crush <crush@charm.land>
2026-02-17 15:44:09 -05:00

92 lines
2.4 KiB
Bash

#!/usr/bin/env bats
# KNEL-Football System Tests - VM Boot Verification
# These tests verify the ISO boots correctly and runtime behavior
# Copyright © 2026 Known Element Enterprises LLC
# License: GNU Affero General Public License v3.0 only
# These tests require:
# - User in libvirt group
# - libvirtd service running
# - ISO present in output/
# - run.sh test:iso commands available
# Setup - check prerequisites
setup() {
# Skip all tests if not in libvirt group
if ! groups | grep -q libvirt 2>/dev/null; then
skip "User not in libvirt group - logout/login required"
fi
# Skip if virsh not available
if ! command -v virsh &> /dev/null; then
skip "virsh not available - install libvirt"
fi
# Skip if ISO not present
if [[ ! -f "output/knel-football-secure.iso" ]]; then
skip "ISO not built - run ./run.sh iso"
fi
}
# Test: Verify libvirt is available
@test "libvirt service is running" {
run systemctl is-active libvirtd
[ "$status" -eq 0 ]
}
# Test: Verify user can access libvirt
@test "user can access libvirt" {
run virsh list
[ "$status" -eq 0 ]
}
# Test: Verify ISO file exists
@test "ISO file exists in output directory" {
[ -f "output/knel-football-secure.iso" ]
}
# Test: Verify ISO file size is reasonable (>100MB)
@test "ISO file size is reasonable" {
local iso_size
iso_size=$(stat -c%s "output/knel-football-secure.iso" 2>/dev/null || echo 0)
[ "$iso_size" -gt 104857600 ] # 100 MB
}
# Test: Verify ISO has valid checksums
@test "ISO has SHA256 checksum file" {
[ -f "output/knel-football-secure.iso.sha256" ]
}
@test "ISO SHA256 checksum is valid" {
cd output
run sha256sum -c knel-football-secure.iso.sha256
[ "$status" -eq 0 ]
}
@test "ISO has MD5 checksum file" {
[ -f "output/knel-football-secure.iso.md5" ]
}
@test "ISO MD5 checksum is valid" {
cd output
run md5sum -c knel-football-secure.iso.md5
[ "$status" -eq 0 ]
}
# Test: Verify run.sh has VM testing commands
@test "run.sh has test:iso commands" {
[[ "$("./run.sh" help 2>&1)" == *"test:iso"* ]]
}
@test "run.sh test:iso check runs" {
run ./run.sh test:iso check
# Should pass if all prerequisites are met
[ "$status" -eq 0 ] || [ "$status" -eq 1 ] # 1 means missing prereqs (acceptable)
}
@test "run.sh test:iso help shows usage" {
run ./run.sh test:iso
[ "$status" -eq 0 ]
[[ "$output" == *"Usage:"* ]] || [[ "$output" == *"test:iso"* ]]
}