File size: 4,061 Bytes
433dc73 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | #!/usr/bin/env python3
"""
Test runner for Phase 3:
Checks NetworkManager status, verifies installed packages, ensures internet connectivity,
and completes the backports kernel installation and vyron-hwinfo setup.
"""
import os, sys, time, subprocess, select
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
DIST_DIR = os.path.join(ROOT_DIR, "dist")
BUILD_DIR = os.path.join(ROOT_DIR, "build")
DISK_IMAGE = os.path.join(DIST_DIR, "VyronOS-Disk.qcow2")
LOG_PATH = os.path.join(BUILD_DIR, "phase3-transition-serial.log")
OVMF_CODE = "/opt/homebrew/share/qemu/edk2-x86_64-code.fd"
cmd = [
"/opt/homebrew/bin/qemu-system-x86_64",
"-name", "VyronOS-Phase3Run",
"-m", "2048",
"-smp", "2",
"-drive", f"if=pflash,format=raw,readonly=on,file={OVMF_CODE}",
"-drive", f"file={DISK_IMAGE},format=qcow2,file.locking=off",
"-netdev", "user,id=net0,hostname=vyron-os",
"-device", "virtio-net-pci,netdev=net0",
"-display", "none",
"-serial", "stdio"
]
print(">>> Booting VyronOS in QEMU to complete Phase 3 transition...")
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0)
os.set_blocking(proc.stdout.fileno(), False)
buffer = ""
full_output = []
login_sent = False
pass_sent = False
script_sent = False
start = time.time()
commands = '''
cat << 'EOF' > /tmp/p3_complete.sh
#!/bin/bash
echo "=== 1. CHECKING NETWORKMANAGER ==="
systemctl status NetworkManager --no-pager || true
nmcli device status || true
nmcli connection show || true
echo "=== 2. WAITING FOR NETWORK CONNECTIVITY ==="
for i in {1..20}; do
if ping -c 1 1.1.1.1 >/dev/null 2>&1; then
echo "Internet reachable! (attempt $i)"
break
fi
sleep 1
done
ip -4 addr show ens3 || true
ip route show || true
ping -c 2 1.1.1.1 || true
ping -c 2 debian.org || true
echo "=== 3. VERIFYING INSTALLED DIAGNOSTICS ==="
which ps lspci lsusb ethtool iw rfkill nmcli || true
ps -ef | head -n 10 || true
lspci || true
lsusb || true
echo "=== 4. INSTALLING BACKPORTS KERNEL WITH RETRY ==="
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y -t bookworm-backports linux-image-amd64 || true
echo "=== 5. CHECKING INSTALLED KERNELS IN BOOT ==="
ls -lh /boot/vmlinuz* /boot/initrd.img* || true
echo "=== PHASE 3 STEP 1 COMPLETE ==="
sync
poweroff
EOF
chmod +x /tmp/p3_complete.sh
sudo bash /tmp/p3_complete.sh
'''
try:
while time.time() - start < 360:
r, _, _ = select.select([proc.stdout.fileno()], [], [], 0.1)
if r:
chunk = os.read(proc.stdout.fileno(), 4096).decode("utf-8", errors="replace")
if not chunk and proc.poll() is not None:
break
full_output.append(chunk)
sys.stdout.write(chunk)
sys.stdout.flush()
buffer += chunk
if ("login:" in buffer or "vyron-os login:" in buffer) and not login_sent:
time.sleep(0.3)
proc.stdin.write(b"vyron\n")
proc.stdin.flush()
login_sent = True
if "Password:" in buffer and login_sent and not pass_sent:
time.sleep(0.3)
proc.stdin.write(b"vyron\n")
proc.stdin.flush()
pass_sent = True
if "vyron@vyron-os:~$" in buffer and pass_sent and not script_sent:
script_sent = True
print("\n>>> Logged in. Dispatching commands...")
time.sleep(0.5)
proc.stdin.write(f"{commands.strip()}\n".encode("utf-8"))
proc.stdin.flush()
if "ACPI: PM: Preparing to enter system sleep state S5" in buffer or "reboot: Power down" in buffer:
break
else:
if proc.poll() is not None:
break
finally:
try:
proc.wait(timeout=10)
except:
proc.kill()
with open(LOG_PATH, "w") as f:
f.write("".join(full_output))
print("\n>>> Phase 3 runner finished.")
|