#!/usr/bin/expect -f

# like fstest, but does not power down in the middle of the test.
#
#  What I'm looking for here:  If you shut down cleanly, can you
#  expect to avoid the crc errors on mount?

set timeout -1

spawn telnet zaphod 2016
set tel $spawn_id

spawn rst x
expect eof
wait

while {1} {

	set spawn_id $tel

	expect Download

	spawn bootit
	expect eof
	wait

	set spawn_id $tel

	expect "ogin:"
	send "root\r"

	expect "rd:"
	send "brecis\r"

	expect "#"

	send "mount -n -t jffs2 /dev/mtdblock0 /flash\r"
	expect "#"

	send "cd /flash\r"
	expect "#"

#	send "sleep 20\r"
#	expect "#"

	send "checkfs\r"
	expect "Sending Power down"

	send_user "Found Power Down\n"

	set timeout 30

	expect "NEVER FIND THIS"

	set timeout -1

	send_user "sending ctrl-c\n"

	send "\003"

	expect "# "

	send_user "sending \n"

	send "shutdown -h now\r"

}