Skip to content

Commit

Permalink
Add tests for reboot
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Dec 5, 2024
1 parent 0faf294 commit 7fb4fa6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/image.bash
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if [[ $1 == "setup" ]]; then
qemu-img resize -f raw "$3" 4G
echo ", +" | sfdisk -N 2 "$3"
imageFile "mount" "$3"
sed -i -e "s|DATESED|$(date)|" tests/run.exp
sed -i -e "s|DATESED|$(date)|g" tests/run.exp
rsync -avr --exclude="*.img" --exclude="*.sig" --exclude="tests/fs" --exclude="tests/dtb" --exclude="tests/kernel" ./ tests/fs/opt/zram-config
systemd-nspawn --directory="tests/fs" /opt/zram-config/tests/install-packages.bash
echo "set enable-bracketed-paste off" >> tests/fs/etc/inputrc # Prevents weird character output
Expand Down
42 changes: 41 additions & 1 deletion tests/run.exp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,46 @@ expect {
}
}
expect "pi@raspberrypi:~$ "
send "sudo /opt/zram-config/uninstall.bash\r"
send "sudo shutdown -r 5s\r"

spawn qemu-system-aarch64 -machine "raspi3b" -cpu arm1176 -m 1G -drive "format=raw,file=raspios.img" -dtb "./custom.dtb" -kernel "./tests/kernel/kernel8.img" -append "loglevel=0 quiet console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 fsck.repair=yes rootwait init=/sbin/init" -nographic -serial mon:stdio
# Login process
expect {
"raspberrypi login: " {
send "$loginUser\r"
exp_continue
}
"Password: " {
send "$loginPassword\r"
exp_continue
}
"pi@raspberrypi:~$ " {
send "sudo date -s \"DATESED\"\r"
}
"Login incorrect" {
exit 1
}
}
expect "pi@raspberrypi:~$ "
send "if ! [[ -f /var/log/test.txt ]]; then echo Failed; fi\r"
expect {
"Failed" {
set retval 1
exp_continue
}
"pi@raspberrypi:~$ " {
send "/opt/zram-config/tests/test-zram-devices.bash\r"
}
}
expect {
-re "Test failed:.*$" {
set retval 1
exp_continue
}
"pi@raspberrypi:~$ " {
send "sudo /opt/zram-config/uninstall.bash\r"
}
}
expect "pi@raspberrypi:~$ "
send "/opt/zram-config/tests/test-zram-devices.bash removal\r"
expect {
Expand All @@ -66,6 +105,7 @@ expect {
send "sync\r"
}
}

expect "pi@raspberrypi:~$ "
send "sudo shutdown -h 5s\r"

Expand Down

0 comments on commit 7fb4fa6

Please sign in to comment.