Files
football/tests/unit/run_comprehensive_test.bats
reachableceo 94abcfffda fix: resolve 11 test failures, clean up stale files, add NVMe build cache
Test Fixes:
- Fixed grep regex matching `test:iso)` instead of `iso|iso:demo)` by
  using `grep -F` for literal string matching in 3 test files
- Increased grep context from -A 5 to -A 15 for FDE reference tests
  since FDE mention is 9+ lines into the iso command block

Stale Files:
- Deleted test-iso.sh (merged into run.sh in Session 4)
- Deleted verify.sh (orphaned, never referenced anywhere)

Documentation:
- Fixed stale test file references in COMPLIANCE.md
- Updated TEST-COVERAGE.md to remove "delegates to test-iso.sh"
- Added JOURNAL.md entry with full audit findings
- Updated STATUS.md timestamp

NVMe Build Cache (from previous session, was uncommitted):
- Added Docker volume `knel-football-cache` for build caching
- Added `clean:cache` and `cache` commands to run.sh
- Cache preserves bootstrap + package downloads between builds

Test Results: 786 pass, 0 fail, 16 VM skip

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
2026-05-07 07:51:56 -05:00

320 lines
8.8 KiB
Bash

#!/usr/bin/env bats
# KNEL-Football Unit Tests - run.sh Main Entry Point
# Reference: PRD.md FR-010 (ISO Build Process)
# Copyright © 2026 Known Element Enterprises LLC
# License: GNU Affero General Public License v3.0 only
# =============================================================================
# File Existence and Basic Properties
# =============================================================================
@test "run.sh exists" {
[ -f "/workspace/run.sh" ]
}
@test "run.sh is executable" {
[ -x "/workspace/run.sh" ]
}
@test "run.sh is a valid bash script" {
run bash -n /workspace/run.sh
[ "$status" -eq 0 ]
}
@test "run.sh uses strict mode" {
grep -q "set -euo pipefail" /workspace/run.sh
}
# =============================================================================
# Script Structure and Configuration
# =============================================================================
@test "run.sh defines SCRIPT_DIR variable" {
grep -q "SCRIPT_DIR=" /workspace/run.sh
}
@test "run.sh defines DOCKER_IMAGE variable" {
grep -q "DOCKER_IMAGE=" /workspace/run.sh
}
@test "run.sh defines OUTPUT_DIR variable" {
grep -q "OUTPUT_DIR=" /workspace/run.sh
}
@test "run.sh defines BUILD_DIR variable" {
grep -q "BUILD_DIR=" /workspace/run.sh
}
@test "run.sh defines BUILD_LOG variable" {
grep -q "BUILD_LOG=" /workspace/run.sh
}
# =============================================================================
# Logging Functions
# =============================================================================
@test "run.sh defines log_info function" {
grep -q "log_info()" /workspace/run.sh
}
@test "run.sh defines log_warn function" {
grep -q "log_warn()" /workspace/run.sh
}
@test "run.sh defines log_error function" {
grep -q "log_error()" /workspace/run.sh
}
# =============================================================================
# Build Commands
# =============================================================================
@test "run.sh has build command" {
grep -q 'build)' /workspace/run.sh
}
@test "run.sh has iso command" {
grep -q 'iso)' /workspace/run.sh
}
@test "run.sh has monitor command" {
grep -q 'monitor)' /workspace/run.sh
}
@test "run.sh has clean command" {
grep -q 'clean)' /workspace/run.sh
}
# =============================================================================
# Test Commands
# =============================================================================
@test "run.sh has test command" {
grep -q 'test)' /workspace/run.sh
}
@test "run.sh has test:unit command" {
grep -q 'test:unit)' /workspace/run.sh
}
@test "run.sh has test:integration command" {
grep -q 'test:integration)' /workspace/run.sh
}
@test "run.sh has test:security command" {
grep -q 'test:security)' /workspace/run.sh
}
@test "run.sh has test:system command" {
grep -q 'test:system)' /workspace/run.sh
}
@test "run.sh has lint command" {
grep -q 'lint)' /workspace/run.sh
}
# =============================================================================
# VM Testing Commands
# =============================================================================
@test "run.sh has test:iso command" {
grep -q 'test:iso)' /workspace/run.sh
}
@test "run.sh defines vm_check_prerequisites function" {
grep -q "vm_check_prerequisites()" /workspace/run.sh
}
@test "run.sh defines vm_create function" {
grep -q "vm_create()" /workspace/run.sh
}
@test "run.sh defines vm_console function" {
grep -q "vm_console()" /workspace/run.sh
}
@test "run.sh defines vm_status function" {
grep -q "vm_status()" /workspace/run.sh
}
@test "run.sh defines vm_destroy function" {
grep -q "vm_destroy()" /workspace/run.sh
}
@test "run.sh defines vm_is_running function" {
grep -q "vm_is_running()" /workspace/run.sh
}
# =============================================================================
# Help and Usage
# =============================================================================
@test "run.sh has help command" {
grep -qE 'help\|\*\)|\*\)|help\)' /workspace/run.sh
}
@test "run.sh has usage function" {
grep -q "usage()" /workspace/run.sh
}
@test "run.sh usage shows available commands" {
run bash /workspace/run.sh help
[ "$status" -eq 1 ] # usage() exits with 1
[[ "$output" == *"build"* ]]
[[ "$output" == *"test"* ]]
[[ "$output" == *"iso"* ]]
}
@test "run.sh help mentions Docker" {
run bash /workspace/run.sh help
[[ "$output" == *"docker"* ]] || [[ "$output" == *"Docker"* ]]
}
@test "run.sh help mentions test commands" {
run bash /workspace/run.sh help
[[ "$output" == *"test:unit"* ]]
[[ "$output" == *"test:integration"* ]]
[[ "$output" == *"test:security"* ]]
}
# =============================================================================
# Docker Integration
# =============================================================================
@test "run.sh iso command uses Docker" {
grep -A 50 -F 'iso|iso:demo)' /workspace/run.sh | grep -q "docker run"
}
@test "run.sh test command uses Docker" {
grep -A 10 'test)' /workspace/run.sh | grep -q "docker run"
}
@test "run.sh mounts workspace as read-only in Docker" {
grep -q "/workspace:ro" /workspace/run.sh
}
@test "run.sh uses correct Docker image name" {
grep -q "knel-football-dev" /workspace/run.sh
}
# =============================================================================
# Build Configuration
# =============================================================================
@test "run.sh configures live-build for Debian trixie" {
grep -q "\-\-distribution trixie" /workspace/run.sh
}
@test "run.sh configures live-build for AMD64" {
grep -q "\-\-architectures amd64" /workspace/run.sh
}
@test "run.sh configures live-build for ISO hybrid" {
grep -q "\-\-binary-images iso-hybrid" /workspace/run.sh
}
@test "run.sh sets correct ISO application name" {
grep -q "KNEL-Football Secure OS" /workspace/run.sh
}
@test "run.sh enables Debian installer" {
grep -q "\-\-debian-installer" /workspace/run.sh
}
# =============================================================================
# Checksum Generation
# =============================================================================
@test "run.sh generates SHA256 checksums" {
grep -q "sha256sum" /workspace/run.sh
}
@test "run.sh generates MD5 checksums" {
grep -q "md5sum" /workspace/run.sh
}
# =============================================================================
# VM Configuration
# =============================================================================
@test "run.sh defines VM name" {
grep -q 'VM_NAME=' /workspace/run.sh
}
@test "run.sh defines VM RAM size" {
grep -q 'VM_RAM=' /workspace/run.sh
}
@test "run.sh defines VM CPU count" {
grep -q 'VM_CPUS=' /workspace/run.sh
}
@test "run.sh defines VM disk size" {
grep -q 'VM_DISK_SIZE=' /workspace/run.sh
}
@test "run.sh uses system libvirt URI" {
grep -q 'qemu:///system' /workspace/run.sh
}
# =============================================================================
# Main Entry Point
# =============================================================================
@test "run.sh has main function" {
grep -q "main()" /workspace/run.sh
}
@test "run.sh calls main with arguments" {
grep -q 'main "\$@"' /workspace/run.sh
}
@test "run.sh uses case statement for command dispatch" {
grep -q "case.*command" /workspace/run.sh
}
# =============================================================================
# Shell Compatibility
# =============================================================================
@test "run.sh shebang is bash" {
head -1 /workspace/run.sh | grep -q "#!/bin/bash"
}
@test "run.sh handles missing arguments gracefully" {
run bash /workspace/run.sh
[ "$status" -eq 1 ] # Should show usage and exit 1
}
# =============================================================================
# Host FDE Requirements (FR-011)
# =============================================================================
@test "run.sh has check_host_fde function" {
grep -q "check_host_fde()" /workspace/run.sh
}
@test "run.sh checks for LUKS devices" {
grep -q "lsblk.*crypt" /workspace/run.sh || grep -q "CRYPT-LUKS" /workspace/run.sh
}
@test "run.sh checks /etc/crypttab" {
grep -q "/etc/crypttab" /workspace/run.sh
}
@test "run.sh checks root filesystem encryption" {
grep -q "findmnt" /workspace/run.sh || grep -q "dm-crypt" /workspace/run.sh
}
@test "run.sh iso command references host FDE" {
grep -A 15 -F 'iso|iso:demo)' /workspace/run.sh | grep -qi "fde\|encryption"
}
@test "run.sh provides clear FDE error message" {
grep -q "SECURITY REQUIREMENT VIOLATION" /workspace/run.sh
}
@test "run.sh provides FDE setup guidance" {
grep -q "encrypted LVM" /workspace/run.sh || grep -q "Full Disk Encryption" /workspace/run.sh
}