diff --git a/tests/image.bash b/tests/image.bash index 44c3874..8fc0ab2 100755 --- a/tests/image.bash +++ b/tests/image.bash @@ -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 diff --git a/tests/run.exp b/tests/run.exp index 4b2a501..857af5f 100755 --- a/tests/run.exp +++ b/tests/run.exp @@ -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 { @@ -66,6 +105,7 @@ expect { send "sync\r" } } + expect "pi@raspberrypi:~$ " send "sudo shutdown -h 5s\r"