#   Copyright (C) 1997 - 2001 Free Software Foundation, Inc.

#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# Please email any bugs, comments, and/or additions to this file to:
# hamlib-developer@lists.sourceforge.net

set timeout 3
#
# expectations that clean up in case of error. Note that '$test' is
# a purely local variable.
#
# The first of these is used to match any bad responses, and resynchronise
# things by finding a prompt. The second is a timeout error, and shouldn't
# ever be triggered.
#
expect_after {
	-re "\[^\n\r\]*$prompt$" {
		fail "$test (bad match)"
		if { $verbose > 0 } {
			regexp ".*\r\n(\[^\r\n\]+)(\[\r\n\])+$prompt$" \
						$expect_out(buffer) "" output
			send_user "\tUnmatched output: \"$output\"\n"
		}
	}
	timeout {
		fail "$test (timeout)"
	}
}
#
# Here are the tests
#
set test "help"
send "?\n"
expect {
	-re "Commands \\(may not be available for this rig\\):.*$prompt$"	{ pass "$test" }
}

set test "nocmd"
send "\n"
expect {
	-re "\\? for help, q to quit\\..*$prompt$"		{ pass "$test" }
}

set test "info"
send "\\get_info\n"
expect {
	-re "Info:.*$prompt$"		{ pass "$test" }
}
