init
This commit is contained in:
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
if {$argc != 3} {
|
||||
puts stderr "usage: network.exp RUNNER DISK MODE"
|
||||
exit 2
|
||||
}
|
||||
set runner [file normalize [lindex $argv 0]]
|
||||
set disk [file normalize [lindex $argv 1]]
|
||||
set mode [lindex $argv 2]
|
||||
if {$mode ni {first verify}} {
|
||||
puts stderr "invalid network mode: $mode"
|
||||
exit 2
|
||||
}
|
||||
set timeout 90
|
||||
set acceptance_name "network"
|
||||
source [file join [file dirname [info script]] harness.exp]
|
||||
proc poweroff {} {
|
||||
sendline {kill -TERM 1}
|
||||
await "cheesed: received poweroff request" "the poweroff request"
|
||||
await "Stopping network" "the network shutdown"
|
||||
await "cheesed: root filesystem remounted read-only" "the read-only remount"
|
||||
expect {
|
||||
eof {
|
||||
set result [wait]
|
||||
if {[lindex $result 3] != 0} {
|
||||
fail "QEMU exited unsuccessfully"
|
||||
}
|
||||
}
|
||||
timeout { fail "QEMU did not power off" }
|
||||
}
|
||||
}
|
||||
|
||||
acceptance_log
|
||||
set env(MOUSE_BOOT_MODE) disk
|
||||
set env(MOUSE_DISK_IMAGE) $disk
|
||||
set env(MOUSE_NETWORK) 1
|
||||
set env(MOUSE_KERNEL_ARGS) "console=ttyS0 root=PARTUUID=4d4f5553-4500-4000-8000-000000000002 rootfstype=btrfs rw rootwait init=/sbin/cheesed mouse.autologin=1 panic=-1"
|
||||
spawn -noecho $runner
|
||||
|
||||
await "Starting network" "the network service"
|
||||
await "mouse login: root (automatic login)" "the test login"
|
||||
await "cheesed: service graph started; cgroup supervision active" "the completed service graph"
|
||||
send -- "\r"
|
||||
prompt
|
||||
|
||||
sendline {sh -c 'test -s /run/mouse-network.ready && grep -q eth0 /proc/net/route && grep -q 00000000 /proc/net/route && grep -q "^nameserver " /etc/resolv.conf'; echo LEASE_$?}
|
||||
await "LEASE_0\r" "the DHCP route and resolver state"
|
||||
prompt
|
||||
sendline {nc -z -w 5 1.1.1.1 80; echo IP_$?}
|
||||
await "IP_0\r" "the IP endpoint"
|
||||
prompt
|
||||
sendline {nc -z -w 5 example.com 80; echo DNS_$?}
|
||||
await "DNS_0\r" "the DNS endpoint"
|
||||
prompt
|
||||
sendline {service network status; echo STATUS_$?}
|
||||
await "network running" "accurate service status"
|
||||
await "STATUS_0\r" "the service status exit code"
|
||||
prompt
|
||||
sendline {service network restart}
|
||||
await "Stopping network" "runtime network stop"
|
||||
await "Starting network" "runtime network restart"
|
||||
prompt
|
||||
sendline {sh -c 'test -s /run/mouse-network.ready'; echo RESTART_$?}
|
||||
await "RESTART_0\r" "the renewed lease"
|
||||
prompt
|
||||
|
||||
if {$mode eq "first"} {
|
||||
sendline {sed 's/metric 100/metric 200/' /etc/dhcpcd.conf >/run/dhcpcd.conf.new && mv /run/dhcpcd.conf.new /etc/dhcpcd.conf; echo POLICY_$?}
|
||||
await "POLICY_0\r" "the persistent policy update"
|
||||
prompt
|
||||
} else {
|
||||
sendline {sh -c 'grep -q "^metric 200$" /etc/dhcpcd.conf && grep -q "eth0.*200" /proc/net/route'; echo PERSIST_$?}
|
||||
await "PERSIST_0\r" "the persisted route metric"
|
||||
prompt
|
||||
}
|
||||
poweroff
|
||||
puts "$mode network acceptance passed"
|
||||
Reference in New Issue
Block a user