+++ /dev/null
-# Copyright (C) 1988, 1990, 1991, 1992 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-dejagnu@prep.ai.mit.edu
-
-# This file was written by Rob Savoye. (rob@cygnus.com)
-
-#
-# util_test -- run a utility and test the result.
-# Takes four parameters.
-# Parameters:
-# First one is the command line arguments
-# Second one is the file name
-# Third one is the regexp style pattern to match for a PASS,
-# Fourth one is an optional message to be printed. If this
-# a null string "", then the pass/fail messages are not printed.
-# Returns:
-# 1 if the test failed,
-# 0 if the test passes,
-# -1 if there was an internal error.
-#
-proc util_test { args } {
- global verbose
-
- # get the parameters
- set cmd [lindex $args 0]
- verbose "Utility to execute is $cmd" 2
- set cmd_arg [lindex $args 1]
- verbose "Command line arguments are $cmd_arg" 2
- set file [lindex $args 2]
- verbose "The file name to use is $file" 2
- set pattern [lindex $args 3]
- verbose "The pattern to match is \"$pattern\"" 2
-
- if [llength $args]==5 then {
- set message [lindex $args 4]
- } else {
- set message "$arg option"
- }
-
- verbose "Looking to match \"$pattern\"\nMessage is \"$message\"" 1
-
- if ![file exists $file] then {
- error "$file doesn't exist"
- return -1
- }
-
-#
-# run the utility to be tested and analyze the results
-#
- set comp_output [util_start $cmd $cmd_arg $file]
-
- if [regexp "$pattern" $comp_output] then {
- return 0
- }
-
- if [string match "" $comp_output] then {
- return 1
- }
- return 1
-}
-
-# util_start -- run the utility.
-# return NULL or the output
-#
-proc util_start { args } {
- set cmd [lindex $args 0]
- set cmd_arg [lindex $args 1]
- set file [lindex $args 2]
-
- if {[which $cmd] == 0} then {
- error "Can't find $cmd"
- return ""
- }
-
- verbose "Spawning \"$cmd $cmd_arg $file\"" 1
- catch "exec $cmd $cmd_arg $file" comp_output
- if ![string match "" $comp_output] then {
- send_log "$comp_output\n"
- verbose "$comp_output" 1
- }
- return $comp_output
-}
-
-#
-# add some basic error trapping. These mostly catch programming error's
-# within the tests themselves
-#
-expect_before {
- buffer_full { error "Internal buffer is full" }
- "can't open 'nmtest'" { error "Can't open test file" }
-}
-
-