diff options
author | Ben Elliston <bje@gnu.org> | 2004-02-06 23:51:47 +0000 |
---|---|---|
committer | Ben Elliston <bje@gnu.org> | 2004-02-06 23:51:47 +0000 |
commit | 9b15dbbaf29172e804b722a64f60f6f0a4f2b5b6 (patch) | |
tree | 30e80dbee2c51763b4933730bf35a32ca4d36a75 /testsuite/lib/util-defs.exp | |
parent | a4a23f8e4eb5bcf4bd7e61aca783c74ceb250c56 (diff) | |
download | dejagnu-9b15dbbaf29172e804b722a64f60f6f0a4f2b5b6.zip dejagnu-9b15dbbaf29172e804b722a64f60f6f0a4f2b5b6.tar.gz dejagnu-9b15dbbaf29172e804b722a64f60f6f0a4f2b5b6.tar.bz2 |
* util-defs.exp only exists to support testing lib/utils.exp, so move
it to the testsuite/lib directory and out of users' sight.
* lib/util-defs.exp: Move from here ..
* testsuite/lib/util-defs.exp: .. to here.
* Makefile.am (EXTRA_DIST): Remove lib/util-defs.exp.
* Makefile.in: Regenerate.
* testsuite/Makefile.am (EXTRA_DIST): Add lib/util-defs.exp.
* testsuite/Makefile.in: Regenerate.
* doc/ref.sgml (File Map): Remove util-defs.exp.
* packaging/pkg/prototype: Update file list.
Diffstat (limited to 'testsuite/lib/util-defs.exp')
-rw-r--r-- | testsuite/lib/util-defs.exp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/testsuite/lib/util-defs.exp b/testsuite/lib/util-defs.exp new file mode 100644 index 0000000..0865861 --- /dev/null +++ b/testsuite/lib/util-defs.exp @@ -0,0 +1,102 @@ +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +# 2001, 2002, 2003 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu 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. +# +# DejaGnu 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 DejaGnu; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file was written by Rob Savoye. (rob@welcomehome.org) + +note "Hello!" +# +# Run a utility and test the result. +# +# Parameters: +# First one is the command +# Second one is command arguments +# Third one is the file name +# Fourth one is the regexp style pattern to match for a PASS +# +# 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 [info exists file] { + if ![string match "" $file] { + if ![file exists $file] { + perror "$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] + + verbose "Output is \"$comp_output\"" 2 + verbose "Pattern is \"$pattern\"" 2 + + if [regexp "$pattern" $comp_output] { + verbose "Pattern matches." 2 + return 0 + } + + verbose "Pattern does not match." 2 + return 1 +} + +# +# Run the utility +# +# Return NULL or the output. +# + +proc util_start { args } { + global verbose + set cmd [lindex $args 0] + set cmd_arg [lindex $args 1] + set file [lindex $args 2] + + if {[which $cmd] == 0} { + perror "Can't find $cmd" + return "" + } + + if { $verbose > 0 } { + verbose "Spawning \"$cmd $cmd_arg $file\"" + } else { + send_log "Spawning \"$cmd $cmd_arg $file\"\n" + } + catch "exec $cmd $cmd_arg $file" comp_output + if ![string match "" $comp_output] { + send_log "$comp_output\n" + } + return $comp_output +} |