#
# $Id: unix.exp,v 1.3 2000/02/07 23:51:13 tlyu Exp $
#

set kill /bin/kill
set sleep /bin/sleep
set kinit $KINIT
set kdestroy $KDESTROY

set hostname [exec hostname]

proc rpc_test_version {} {
	global CLIENT
	global SERVER

	clone_output "$CLIENT version <unknown>"
	clone_output "$SERVER version <unknown>"
}

proc rpc_test_load {} {
	#
}

# rpc_test_exit -- clean up and exit
proc rpc_test_exit {} {
	global server_id
	global server_pid
	global server_started
	global kill

 	if {[catch {
		expect {
			-i $server_id
			eof { 
				fail "server exited!"
				verbose $expect_out(buffer) 1
			}
			timeout { pass "server survived" }
		}
	} tmp]} {
		fail "server exited! (expect failed)"
	}
}

#
# rpc_test_start -- start the rpc_test server running
#
proc rpc_test_start { } {
 	global SERVER PROT
	global server_id
	global server_pid
	global server_started
	global env

	set env(KRB5_KTNAME) FILE:$env(RPC_TEST_SRVTAB)

 	verbose "% $SERVER" 1
	set server_pid [spawn $SERVER $PROT]
	set server_id $spawn_id

	unset env(KRB5_KTNAME)

	set timeout 30

	expect {
		"running" { }
		eof { 
			send_error "server exited!"
			verbose $expect_out(buffer) 1
		}
		timeout { 
			send_error "server didn't start in $timeout seconds"
			verbose $expect_out(buffer) 1
		}
	}

}

rpc_test_start
