#!/usr/bin/env herodo
// Test: Device Configuration via VMBuilder
// Tests that devices can be correctly configured through VMBuilder methods

print("=== Test: Device Configuration via VMBuilder ===");

// Test 1: VM with disk devices
print("\n[TEST 1] VM with disk devices");
let vm1 = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cmdline("console=ttyS0")
    .cpus(2)
    .memory(1024)
    .virtio_blk("/tmp/disk1.img", false)
    .build();

print("✓ VM with read-write disk created");

let vm2 = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cpus(2)
    .memory(1024)
    .virtio_blk("/tmp/disk2.img", true)
    .build();

print("✓ VM with read-only disk created");

// Test 2: VM with network devices
print("\n[TEST 2] VM with network devices");
let vm3 = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cpus(2)
    .memory(1024)
    .virtio_net("tap0")
    .build();

print("✓ VM with TAP network device created");

let vm4 = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cpus(2)
    .memory(1024)
    .virtio_net("tap1")
    .build();

print("✓ VM with second TAP network device created");

// Test 3: VM with filesystem device
print("\n[TEST 3] VM with filesystem device");
let vm5 = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cpus(2)
    .memory(1024)
    .virtio_fs("myfs", "/tmp/vhost-fs.sock")
    .build();

print("✓ VM with filesystem device created");

// Test 4: VM with multiple devices
print("\n[TEST 4] VM with multiple devices");
let vm6 = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cpus(4)
    .memory(2048)
    .virtio_blk("/tmp/disk1.img", false)
    .virtio_blk("/tmp/disk2.img", true)
    .virtio_net("tap0")
    .build();

print("✓ VM with multiple devices created");

// Test 5: Multiple VMs with different device configurations
print("\n[TEST 5] Multiple VMs with different devices");
let vms = [];
let i = 0;
while i < 3 {
    let vm = VMBuilder()
        .kernel("/tmp/test-kernel")
        .cpus(2)
        .memory(1024)
        .virtio_blk("/tmp/disk_" + i + ".img", false)
        .build();
    vms.push(vm);
    i += 1;
}
print("  ✓ Created " + vms.len() + " VMs with different disk devices");

// Test 6: VM with various device paths
print("\n[TEST 6] VM with various device paths");
let vm_abs = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cpus(2)
    .memory(1024)
    .virtio_blk("/absolute/path/disk.img", false)
    .build();
print("  ✓ VM with absolute path device");

let vm_rel = VMBuilder()
    .kernel("/tmp/test-kernel")
    .cpus(2)
    .memory(1024)
    .virtio_blk("relative/path/disk.img", true)
    .build();
print("  ✓ VM with relative path device");

print("\n=== All Device Configuration tests passed! ===");
