# Commands covered: test traceback facility
#
# This file contains a collection of tests for one or more of the Expect
# command capabilities.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1997 Mitel, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: $Header: /disk/3/CVSROOT/Mitel/expect/win/tests/crash.test,v 1.2 1998/09/17 21:21:48 chaffee Exp $

if {[string compare test [info procs test]] == 1} then {source defs}

catch {unset a}
catch {unset x}

# Expected output:

#Backtrace for testcrash.exe
#-------------------------------------
#testcrash.exe 00401013	crash+13
#testcrash.exe 0040103e	subroutine4+17
#testcrash.exe 00401062	subroutine3+17
#testcrash.exe 00401086	subroutine2+17
#testcrash.exe 004010aa	subroutine1+17
#testcrash.exe 004010c9	main+12
#testcrash.exe 00401dfc	mainCRTStartup+FC
#kernel32.dbg 77f1afc1	GetProcessPriorityBoost+117


# Note: this test will fail if testcrash.exe was not compiled with
# debugging enabled.

# XXX: This test is not yet correct or working.

test crash-1.0 {subprocess crash tests} {
    if [catch {
	# spawn tclsh80.exe crash.tcl
	spawn ../testcrash.exe

	if {0} {

	expect {
	    "Backtrace for" {} {set ok 1}
	    timeout {error "Unexpected timeout 1"}
	    eof     {error "Unexpected eof 1"}
	}
	expect {
	    "	crash" {} {set ok 1}
	    timeout {error "Unexpected timeout 2"}
	    eof     {error "Unexpected eof 2"}
	}
	expect {
	    "	subroutine4" {} {set ok 1}
	    timeout {error "Unexpected timeout 3"}
	    eof     {error "Unexpected eof 3"}
	}
	expect {
	    "	subroutine3" {} {set ok 1}
	    timeout {error "Unexpected timeout 4"}
	    eof     {error "Unexpected eof 4"}
	}
	expect {
	    "	subroutine2" {} {set ok 1}
	    timeout {error "Unexpected timeout 5"}
	    eof     {error "Unexpected eof 5"}
	}
	expect {
	    "	subroutine1" {} {set ok 1}
	    timeout {error "Unexpected timeout 6"}
	    eof     {error "Unexpected eof 6"}
	}
	}
	catch { kill }
	catch { close }
	catch { wait }
    } msg] {set msg} else {set ok 1}
} {1}
