aboutsummaryrefslogtreecommitdiff
path: root/testsuite/runtest.libs
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb62281@gmail.com>2018-12-11 22:33:29 +1100
committerBen Elliston <bje@gnu.org>2018-12-11 22:33:29 +1100
commit48fbec72a052b82b14eb96716da6c249d0a673c0 (patch)
tree025d55f827a9a882a352649c19c43a2713aef942 /testsuite/runtest.libs
parent0a5a8a9d3b55cf0bc64d2b5ff4d272a3302a283d (diff)
downloaddejagnu-48fbec72a052b82b14eb96716da6c249d0a673c0.zip
dejagnu-48fbec72a052b82b14eb96716da6c249d0a673c0.tar.gz
dejagnu-48fbec72a052b82b14eb96716da6c249d0a673c0.tar.bz2
* testsuite/runtest.all/libs.exp: Use "testsuite file" command.
* testsuite/runtest.all/load_lib.exp: Likewise. * testsuite/runtest.all/stats.exp: Likewise. * testsuite/runtest.all/stats.exp: Write local init file as "stats-init.exp" for status summary tests. Use --local_init option to runtest to load that file instead of site.exp and move the inner test module to a nested testsuite. * testsuite/runtest.all/stats-sub.exp: Move file from here .. * testsuite/runtest.all/stats/testsuite/stat.test/stats-sub.exp: .. to here. * testsuite/runtest.all/options.exp: Clean up whitespace in file. Wrap lines in test list and move short items to beginning of list. Write local init file as "options-init.exp" for options tests. Use --local_init option with nested runtest to load that file instead of site.exp; also create an empty nested testsuite. Local init file arranges for inner runtest processes to run in a subdirectory in the object tree to eliminate filename clashes. Set tmpdir if not already set and remove entire temporary directory after running options tests. * testsuite/runtest.all/options/testsuite/null.test/null.exp: New. * testsuite/runtest.all/clone_output.test: Move from here .. * testsuite/runtest.libs/clone_output.test: .. to here. * testsuite/runtest.all/config.test: Move from here .. * testsuite/runtest.libs/config.test: .. to here. * testsuite/runtest.all/default_procs.tcl: Move from here .. * testsuite/runtest.libs/default_procs.tcl: .. to here. * testsuite/runtest.all/libs.exp: Move from here .. * testsuite/runtest.libs/libs.exp: .. to here. * testsuite/runtest.all/load_lib.exp: Move from here .. * testsuite/runtest.libs/load_lib.exp: .. to here. * testsuite/runtest.all/remote.test: Move from here .. * testsuite/runtest.libs/remote.test: .. to here. * testsuite/runtest.all/target.test: Move from here .. * testsuite/runtest.libs/target.test: .. to here. * testsuite/runtest.all/testsuite_file.test: Move from here .. * testsuite/runtest.libs/testsuite_file.test: .. to here. * testsuite/runtest.all/topdir/subdir1/subfile1: Move from here .. * testsuite/runtest.libs/topdir/subdir1/subfile1: .. to here. * testsuite/runtest.all/topdir/subdir1/subfile2: Move from here .. * testsuite/runtest.libs/topdir/subdir1/subfile2: .. to here. * testsuite/runtest.all/topdir/subdir1/subsubdir1/subsubfile1: Move from here .. * testsuite/runtest.libs/topdir/subdir1/subsubdir1/subsubfile1: .. to here. * testsuite/runtest.all/topdir/subdir2/subfile2: Move from here .. * testsuite/runtest.libs/topdir/subdir2/subfile2: .. to here. * testsuite/runtest.all/utils.test: Move from here .. * testsuite/runtest.libs/utils.test: .. to here. * testsuite/runtest.libs/utils.test: Update references to "runtest.all". * testsuite/runtest.all/options.exp: Move from here .. * testsuite/runtest.main/options.exp: .. to here. * testsuite/runtest.all/options/testsuite/null.test/null.exp: Move from here .. * testsuite/runtest.main/options/testsuite/null.test/null.exp: .. to here. * testsuite/runtest.all/stats.exp: Move from here .. * testsuite/runtest.main/stats.exp: .. to here. * testsuite/runtest.all/stats/testsuite/stat.test/stats-sub.exp: Move from here .. * testsuite/runtest.main/stats/testsuite/stat.test/stats-sub.exp: .. to here. * Makefile.am (DISTCLEANFILES): Update for testsuite improvements. (TESTSUITE_FILES): Update to reflect testsuite reorganization. * Makefile.in: Regenerate. Signed-off-by: Ben Elliston <bje@gnu.org>
Diffstat (limited to 'testsuite/runtest.libs')
-rw-r--r--testsuite/runtest.libs/clone_output.test67
-rw-r--r--testsuite/runtest.libs/config.test94
-rw-r--r--testsuite/runtest.libs/default_procs.tcl181
-rw-r--r--testsuite/runtest.libs/libs.exp98
-rw-r--r--testsuite/runtest.libs/load_lib.exp45
-rw-r--r--testsuite/runtest.libs/remote.test59
-rw-r--r--testsuite/runtest.libs/target.test98
-rw-r--r--testsuite/runtest.libs/testsuite_file.test213
-rw-r--r--testsuite/runtest.libs/topdir/subdir1/subfile11
-rw-r--r--testsuite/runtest.libs/topdir/subdir1/subfile22
-rw-r--r--testsuite/runtest.libs/topdir/subdir1/subsubdir1/subsubfile12
-rw-r--r--testsuite/runtest.libs/topdir/subdir2/subfile22
-rw-r--r--testsuite/runtest.libs/utils.test219
13 files changed, 1081 insertions, 0 deletions
diff --git a/testsuite/runtest.libs/clone_output.test b/testsuite/runtest.libs/clone_output.test
new file mode 100644
index 0000000..656f308
--- /dev/null
+++ b/testsuite/runtest.libs/clone_output.test
@@ -0,0 +1,67 @@
+# test clone_output -*- Tcl -*-
+
+set srcdir [lindex $argv 0]
+set subdir [lindex $argv 1]
+set objdir [lindex $argv 2]
+
+if [ file exists $objdir/setval.tmp ] {
+ source $objdir/setval.tmp
+} else {
+ puts "ERROR: $objdir/setval.tmp doesn't exist"
+}
+if [ file exists $srcdir/$subdir/default_procs.tcl ] {
+ source $srcdir/$subdir/default_procs.tcl
+} else {
+ puts "ERROR: $srcdir/$subdir/default_procs.tcl doesn't exist"
+}
+if [ file exists $srcdir/../lib/framework.exp] {
+ source $srcdir/../lib/framework.exp
+} else {
+ puts "ERROR: $srcdir/../lib/framework.exp doesn't exist"
+}
+
+set all_flag 0
+global all_flag
+set errno ""
+
+# stuff that shouldn't print anything without all_flag set
+set all_flag 0
+run_tests {
+ { lib_pat_test clone_output {"PASS: Foo"} ""
+ "clone_output(pass) without all_flag set" }
+ { lib_pat_test clone_output {"UNRESOLVED: Foo"} ""
+ "clone_output(unresolved) without all_flag set" }
+ { lib_pat_test clone_output {"UNSUPPORTED: Foo"} ""
+ "clone_output(unsupported) without all_flag set" }
+ { lib_pat_test clone_output {"UNTESTED: Foo"} ""
+ "clone_output(untested) without all_flag set" }
+ { lib_pat_test clone_output {"ERROR: Bar"} "ERROR: Bar"
+ "clone_output(error) without all_flag set" }
+ { lib_pat_test clone_output {"WARNING: Bar"} "WARNING: Bar"
+ "clone_output(warning) without all_flag set" }
+ { lib_pat_test clone_output {"NOTE: Bar"} "NOTE: Bar"
+ "clone_output(note) without all_flag set" }
+}
+
+# tests for all_flag set to 1
+set all_flag 1
+run_tests {
+ { lib_pat_test clone_output {"PASS: Foo"} "PASS: Foo"
+ "clone_output(pass) with all_flag set" }
+ { lib_pat_test clone_output {"XFAIL: Foo"} "XFAIL: Foo"
+ "clone_output(xfail) with all_flag set" }
+ { lib_pat_test clone_output {"UNRESOLVED: Foo"} "UNRESOLVED: Foo"
+ "clone_output(unresolved) with all_flag set" }
+ { lib_pat_test clone_output {"UNSUPPORTED: Foo"} "UNSUPPORTED: Foo"
+ "clone_output(unsupported) with all_flag set" }
+ { lib_pat_test clone_output {"UNTESTED: Foo"} "UNTESTED: Foo"
+ "clone_output(untested) with all_flag set" }
+ { lib_pat_test clone_output {"ERROR: Foo"} "ERROR: Foo"
+ "clone_output(error) with all_flag set" }
+ { lib_pat_test clone_output {"WARNING: Foo"} "WARNING: Foo"
+ "clone_output(warning) with all_flag set" }
+ { lib_pat_test clone_output {"NOTE: Foo"} "NOTE: Foo"
+ "clone_output(note) with all_flag set" }
+}
+
+puts "END clone_output.test"
diff --git a/testsuite/runtest.libs/config.test b/testsuite/runtest.libs/config.test
new file mode 100644
index 0000000..5e0ed82
--- /dev/null
+++ b/testsuite/runtest.libs/config.test
@@ -0,0 +1,94 @@
+# test configuration support -*- Tcl -*-
+
+set srcdir [lindex $argv 0]
+set subdir [lindex $argv 1]
+set objdir [lindex $argv 2]
+
+if [ file exists $objdir/setval.tmp ] {
+ source $objdir/setval.tmp
+} else {
+ puts "ERROR: $objdir/setval.tmp doesn't exist"
+}
+if [ file exists $srcdir/$subdir/default_procs.tcl ] {
+ source $srcdir/$subdir/default_procs.tcl
+} else {
+ puts "ERROR: $srcdir/$subdir/default_procs.tcl doesn't exist"
+}
+if [ file exists $srcdir/../lib/framework.exp] {
+ source $srcdir/../lib/framework.exp
+} else {
+ puts "ERROR: $srcdir/../lib/framework.exp doesn't exist"
+}
+
+set all_flag 1
+
+set host_triplet i586-unknown-linux
+set target_triplet i586-unknown-linux
+set target_cpu i586
+set target_os linux
+set build_triplet i586-unknown-linux
+
+#
+# Tests for a native configuration
+#
+run_tests [subst {
+ { lib_bool_test isbuild {$build_triplet} true
+ "isbuild, native" }
+ { lib_bool_test isbuild {$target_cpu-*-$target_os} true
+ "isbuild, native regexp" }
+ { lib_bool_test isbuild {hppa-ibm-macos} false
+ "isbuild, native bogus config string" }
+
+ { "#" "test default argument for isbuild" }
+ { lib_ret_test isbuild {} $build_triplet
+ "isbuild with no arguments" }
+
+ { "#" "ishost tests" }
+ { lib_bool_test ishost {$host_triplet} true
+ "ishost, native" }
+ { lib_bool_test ishost {$target_cpu-*-$target_os} true
+ "ishost, native regexp" }
+ { lib_bool_test ishost {hppa-ibm-macos} false
+ "ishost, native bogus config string" }
+
+ { "#" "test default argument for ishost" }
+ { lib_ret_test ishost {} $host_triplet
+ "ishost with no arguments" }
+
+ { "#" "istarget tests" }
+ { lib_bool_test istarget {$target_triplet} true
+ "istarget, native" }
+ { lib_bool_test istarget {$target_cpu-*-$target_os} true
+ "istarget, native regexp" }
+ { lib_bool_test istarget {hppa-ibm-macos} false
+ "istarget, native bogus config string" }
+
+ { "#" "test default argument for istarget" }
+ { lib_ret_test istarget {} $target_triplet
+ "istarget with no arguments" }
+}]
+
+run_tests {
+ { lib_bool_test isnative {} true "isnative, native" }
+ { lib_bool_test is3way {} false "is3way, native" }
+}
+
+#
+# Tests for a normal cross configuration
+#
+set target_triplet m68k-unknown-elf
+run_tests {
+ { lib_bool_test isnative {} false "isnative, cross" }
+ { lib_bool_test is3way {} false "is3way, cross" }
+}
+
+#
+# Tests for a canadian cross configuration
+#
+set host_triplet i386-unknown-winnt
+run_tests {
+ { lib_bool_test isnative {} false "isnative, canadian cross" }
+ { lib_bool_test is3way {} true "is3way, canadian cross" }
+}
+
+puts "END config.test"
diff --git a/testsuite/runtest.libs/default_procs.tcl b/testsuite/runtest.libs/default_procs.tcl
new file mode 100644
index 0000000..6537496
--- /dev/null
+++ b/testsuite/runtest.libs/default_procs.tcl
@@ -0,0 +1,181 @@
+set sum_file [open .tmp w]
+set reboot 0
+set errno ""
+
+# this tests a proc for a returned pattern
+proc lib_pat_test { cmd arglist pattern } {
+ puts "CMD(lib_pat_test) is: $cmd $arglist"
+ if { [catch { eval [list $cmd] [lrange $arglist 0 end] } result] == 0 } {
+ puts "RESULT(lib_pat_test) was: \"${result}\"\
+ for pattern \"$pattern\"."
+ return [string match $pattern $result]
+ } else {
+ puts "RESULT(lib_pat_test) was error \"${result}\""
+ return -1
+ }
+}
+
+# this tests a proc for a returned regexp
+proc lib_regexp_test { cmd arglist regexp } {
+ puts "CMD(lib_regexp_test) is: $cmd $arglist"
+ if { [catch { eval [list $cmd] [lrange $arglist 0 end] } result] == 0 } {
+ puts "RESULT(lib_regexp_test) was: \"${result}\"\
+ for regexp \"$regexp\"."
+ return [regexp -- $regexp $result]
+ } else {
+ puts "RESULT(lib_regexp_test) was error \"${result}\""
+ return -1
+ }
+}
+
+# this tests a proc for a returned value
+proc lib_ret_test { cmd arglist val } {
+ puts "CMD(lib_ret_test) is: $cmd $arglist"
+ if { [catch { eval [list $cmd] [lrange $arglist 0 end] } result] == 0 } {
+ puts "RESULT(lib_ret_test) was: $result"
+ return [string equal $result $val]
+ } else {
+ puts "RESULT(lib_ret_test) was error \"${result}\""
+ return -1
+ }
+}
+
+# this tests a proc for an expected boolean result
+proc lib_bool_test { cmd arglist val } {
+ puts "CMD(lib_bool_test) is: $cmd $arglist"
+ if { [catch { eval [list $cmd] [lrange $arglist 0 end] } result] == 0 } {
+ puts "RESULT(lib_bool_test) was: \"$result\" expecting $val."
+ # the "odd" spacing is used to help make the operator grouping clear
+ return [expr { $val ? $result ? 1 : 0 : $result ? 0 : 1 }]
+ } else {
+ puts "RESULT(lib_bool_test) was error \"${result}\""
+ return -1
+ }
+}
+
+# this tests that a proc raises an error matching a pattern
+proc lib_errpat_test { cmd arglist pattern } {
+ puts "CMD(lib_errpat_test) is: $cmd $arglist"
+ if { [catch { eval [list $cmd] [lrange $arglist 0 end] } result] == 1 } {
+ # caught exception code 1 (TCL_ERROR) as expected
+ puts "RESULT(lib_errpat_test) was error\
+ \"${result}\" for pattern \"$pattern\"."
+ if { [string match $pattern $result] } {
+ # the expected error
+ return 1
+ } else {
+ # an unexpected error
+ return -1
+ }
+ } else {
+ # no error -> fail
+ puts "RESULT(lib_errpat_test) was: \"${result}\"\
+ without error; failing."
+ return 0
+ }
+}
+
+# this tests that a proc raises an error matching a regexp
+proc lib_errregexp_test { cmd arglist regexp } {
+ puts "CMD(lib_errregexp_test) is: $cmd $arglist"
+ if { [catch { eval [list $cmd] [lrange $arglist 0 end] } result] == 1 } {
+ # caught exception code 1 (TCL_ERROR) as expected
+ puts "RESULT(lib_errregexp_test) was error\
+ \"${result}\" for regexp \"$regexp\"."
+ if { [regexp -- $regexp $result] } {
+ # the expected error
+ return 1
+ } else {
+ # an unexpected error
+ return -1
+ }
+ } else {
+ # no error -> fail
+ puts "RESULT(lib_errregexp_test) was: \"${result}\"\
+ without error; failing."
+ return 0
+ }
+}
+
+# this tests that a proc raises an error matching an exact string
+proc lib_err_test { cmd arglist val } {
+ puts "CMD(lib_err_test) is: $cmd $arglist"
+ if { [catch { eval [list $cmd] [lrange $arglist 0 end] } result] == 1 } {
+ # caught exception code 1 (TCL_ERROR) as expected
+ puts "RESULT(lib_err_test) was error: $result"
+ if { $result eq $val } {
+ # the expected error
+ return 1
+ } else {
+ # an unexpected error
+ return -1
+ }
+ } else {
+ # no error -> fail
+ puts "RESULT(lib_err_test) was: \"${result}\"\
+ without error; failing."
+ return 0
+ }
+}
+
+#
+# This runs a standard test for a proc. The list is set up as:
+# |test proc|proc being tested|args|pattern|message|
+# test proc is something like lib_pat_test or lib_ret_test.
+#
+proc run_tests { tests } {
+ foreach test $tests {
+ # skip comments in test lists
+ if { [lindex $test 0] eq "#" } { continue }
+ set result [eval [lrange $test 0 3]]
+ switch -- $result {
+ "-1" {
+ puts "ERRORED: [lindex $test 4]"
+ }
+ "1" {
+ puts "PASSED: [lindex $test 4]"
+ }
+ "0" {
+ puts "FAILED: [lindex $test 4]"
+ }
+ default {
+ puts "BAD VALUE: [lindex $test 4]"
+ }
+ }
+ }
+}
+
+proc send_log { args } {
+ # this is just a stub for testing
+}
+
+proc pass { msg } {
+ puts "PASSED: $msg"
+}
+
+proc fail { msg } {
+ puts "FAILED: $msg"
+}
+
+proc perror { msg } {
+ global errno
+ puts "ERRORED: $msg"
+ set errno $msg
+}
+
+proc warning { msg } {
+ global errno
+ puts "WARNED: $msg"
+ set errno $msg
+}
+
+proc untested { msg } {
+ puts "NOTTESTED: $msg"
+}
+
+proc unsupported { msg } {
+ puts "NOTSUPPORTED: $msg"
+}
+proc verbose { args } {
+ puts [lindex $args 0]
+}
diff --git a/testsuite/runtest.libs/libs.exp b/testsuite/runtest.libs/libs.exp
new file mode 100644
index 0000000..7ce63a5
--- /dev/null
+++ b/testsuite/runtest.libs/libs.exp
@@ -0,0 +1,98 @@
+# Copyright (C) 1997-2016, 2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+load_lib libsup.exp
+
+proc process_test { test } {
+ global EXPECT
+
+ verbose -log "Executing test case $test"
+ set text "\[- A-Za-z0-9\,\.\;\"\_\:\'\`\(\)\!\#\=\+\?\&\*]*"
+
+ set timeout 150
+
+ if [file exists $test] {
+ verbose "Processing test $test" 2
+
+ set command "$EXPECT $test\
+ [testsuite file -source -top]\
+ [relative_filename \
+ [testsuite file -source -top]\
+ [testsuite file -source -test]]\
+ [testsuite file -object -top]"
+ spawn -open [open "|$command" r]
+ expect {
+ "No such file or directory" {
+ perror "$test wouldn't run" 0
+ }
+ -re "^\[^\r\n\]*NOTSUPPORTED: $text\[\r\n\]*" {
+ unsupported "[lrange $expect_out(0,string) 1 end]"
+ exp_continue
+ }
+ -re "^\[^\r\n\]*NOTTESTED: $text\[\r\n\]*" {
+ untested "[lrange $expect_out(0,string) 1 end]"
+ exp_continue
+ }
+ -re "^\[^\r\n\]*PASSED: $text\[\r\n\]*" {
+ pass "[lrange $expect_out(0,string) 1 end]"
+ exp_continue
+ }
+ -re "^\[^\r\n\]*FAILED: $text\[\r\n\]*" {
+ fail "[lrange $expect_out(0,string) 1 end]"
+ exp_continue
+ }
+ -re "^\[^\r\n\]*WARNED: $text\[\r\n\]*" {
+ verbose $expect_out(0,string) 2
+ exp_continue
+ }
+ -re "^\[^\r\n\]*ERRORED: $text\[\r\n\]*" {
+ verbose $expect_out(0,string) 2
+ exp_continue
+ }
+ -re "^END \[^.\]+\\.test\[\r\n\]*" {
+ close
+ }
+ -re "^\[^\r\n\]+\[\r\n\]+" {
+ exp_continue
+ }
+ timeout {
+ perror "$test timed out" 0
+ exp_continue
+ }
+ eof {
+ perror "$test exited early" 0
+ }
+ }
+ } else {
+ perror "$test doesn't exist" 0
+ }
+}
+
+if {![info exists EXPECT]} {
+ set EXPECT [findfile $base_dir/../../expect/expect $base_dir/../../expect/expect expect]
+ verbose "EXPECT defaulting to $EXPECT" 2
+}
+
+make_defaults_file [testsuite file -object -top setval.tmp]
+
+foreach i [glob [testsuite file -source -test *.test]] {
+ process_test $i
+}
+
+# Clean up behind ourselves.
+file delete .tmp [testsuite file -object -top setval.tmp]
diff --git a/testsuite/runtest.libs/load_lib.exp b/testsuite/runtest.libs/load_lib.exp
new file mode 100644
index 0000000..21e2824
--- /dev/null
+++ b/testsuite/runtest.libs/load_lib.exp
@@ -0,0 +1,45 @@
+# test load_lib
+
+# Verify that load_lib searches for a lib not only in its default
+# search_dirs but also in the libdirs list of directories.
+
+# load_lib f exits with a failure if it does not find f.
+# Arrange for the testcase to handle this:
+rename exit saved_exit
+proc exit { args } { return [lindex $args 0] }
+
+# The test right below is supposed to fail.
+# Prettify default output by only printing the message in verbose mode.
+rename send_error saved_send_error
+proc send_error { args } {
+ verbose [lindex $args 0] 2
+}
+
+if { [ load_lib "subfile1" ] != 1} {
+ fail "load_lib subfile1 found per default"
+} else {
+ pass "load_lib subfile1 not found per default"
+}
+
+rename send_error ""
+rename saved_send_error send_error
+
+set extradir [testsuite file -source -test "topdir" "subdir1"]
+global libdirs
+lappend libdirs $extradir
+verbose "now added libdirs: $libdirs" 2
+
+# In this testcase, we did not exit 1 from load_lib as per above
+# rename. subfile1 thus is in the loaded_libs LUT and we won't walk
+# the search_dirs again. Use another file for testing the lappend
+# worked.
+
+if { [load_lib "subfile2"] eq ""} {
+ pass "load_lib subfile2 loaded"
+} else {
+ fail "load_lib subfile2 not found"
+}
+
+# cleanup after us
+rename exit ""
+rename saved_exit exit
diff --git a/testsuite/runtest.libs/remote.test b/testsuite/runtest.libs/remote.test
new file mode 100644
index 0000000..78804bd
--- /dev/null
+++ b/testsuite/runtest.libs/remote.test
@@ -0,0 +1,59 @@
+# Test procedures in lib/remote.exp. -*- Tcl -*-
+
+set srcdir [lindex $argv 0]
+set subdir [lindex $argv 1]
+set objdir [lindex $argv 2]
+
+if [ file exists $objdir/setval.tmp ] {
+ source $objdir/setval.tmp
+} else {
+ puts "ERROR: $objdir/setval.tmp doesn't exist"
+}
+if [ file exists $srcdir/$subdir/default_procs.tcl ] {
+ source $srcdir/$subdir/default_procs.tcl
+} else {
+ puts "ERROR: $srcdir/$subdir/default_procs.tcl doesn't exist"
+}
+
+proc load_lib { lib } {
+ global srcdir
+ source $srcdir/../lib/$lib
+}
+
+set file $srcdir/../lib/remote.exp
+if [ file exists $file] {
+ source $file
+} else {
+ puts "ERROR: $file doesn't exist"
+}
+
+global errno ""
+
+#
+# Create a false target config array
+#
+set target_info(idp,name) "idp"
+set target_info(idp,ldflags) "-Tidp.ld"
+set target_info(idp,config) m68k-unknown-aout
+set target_info(idp,cflags) ""
+set target_info(idp,connect) telnet
+set target_info(idp,target) "s12"
+set target_info(idp,serial) "tstty12"
+set target_info(idp,netport) "localhost:23"
+set target_info(idp,baud) "9600"
+# MVME target
+set target_info(mvme,name) "mvme"
+set target_info(mvme,ldflags) "-Tmvme.ld"
+set target_info(mvme,config) m68k-unknown-aout
+set target_info(mvme,cflags) ""
+set target_info(mvme,connect) telnet
+set target_info(mvme,target) "s12"
+set target_info(mvme,serial) "tstty8"
+set target_info(mvme,netport) "localhost:23"
+set target_info(mvme,baud) "9600"
+
+# Test remote open. We try not to use any of the support procs in
+# target.exp to for isolation testing. "target" is the name of the
+# default array setup by the procs in target.exp.
+
+puts "END remote.test"
diff --git a/testsuite/runtest.libs/target.test b/testsuite/runtest.libs/target.test
new file mode 100644
index 0000000..2da4095
--- /dev/null
+++ b/testsuite/runtest.libs/target.test
@@ -0,0 +1,98 @@
+# Test procedures in lib/target.exp. -*- Tcl -*-
+
+set srcdir [lindex $argv 0]
+set subdir [lindex $argv 1]
+set objdir [lindex $argv 2]
+
+if [ file exists $objdir/setval.tmp ] {
+ source $objdir/setval.tmp
+} else {
+ puts "ERROR: $objdir/setval.tmp doesn't exist"
+}
+if [ file exists $srcdir/$subdir/default_procs.tcl ] {
+ source $srcdir/$subdir/default_procs.tcl
+} else {
+ puts "ERROR: $srcdir/$subdir/default_procs.tcl doesn't exist"
+}
+
+proc load_lib { lib } {
+ global srcdir
+ source $srcdir/../lib/$lib
+}
+
+set file $srcdir/../lib/target.exp
+if [ file exists $file] {
+ source $file
+} else {
+ puts "ERROR: $file doesn't exist"
+}
+# we load framework so we can use stuff like is3way
+set file $srcdir/../lib/framework.exp
+if [ file exists $file] {
+ source $file
+} else {
+ puts "ERROR: $file doesn't exist"
+}
+# we load the remote stuff so we can test execute_anywhere
+set file $srcdir/../lib/remote.exp
+if [ file exists $file] {
+ source $file
+} else {
+ puts "ERROR: $file doesn't exist"
+}
+
+#
+# Create a false target config array
+#
+set target_info(idp,name) "idp"
+set target_info(idp,ldflags) "-Tidp.ld"
+set target_info(idp,config) m68k-unknown-aout
+set target_info(idp,cflags) ""
+set target_info(idp,connect) "telnet"
+set target_info(idp,target) "s12"
+set target_info(idp,serial) "tstty12"
+set target_info(idp,netport) "localhost:23"
+set target_info(idp,baud) "9600"
+# MVME target
+set target_info(mvme,name) "mvme"
+set target_info(mvme,ldflags) "-Tmvme.ld"
+set target_info(mvme,config) m68k-unknown-aout
+set target_info(mvme,cflags) ""
+set target_info(mvme,connect) "telnet"
+set target_info(mvme,target) "s12"
+set target_info(mvme,serial) "tstty8"
+set target_info(mvme,netport) "localhost:23"
+set target_info(mvme,baud) "9600"
+
+# test push_config target
+push_config target idp
+if { $target_info(target,name) eq "idp" } {
+ puts "PASSED: push_config target"
+} else {
+ puts "FAILED: push_config target"
+}
+
+# test pop_config target
+pop_config target
+if { ![info exists target_info(target,name)] } {
+ puts "PASSED: pop_config target"
+} else {
+ puts "FAILED: pop_config target"
+}
+
+push_config host idp
+if { $target_info(host,name) eq "idp" } {
+ puts "PASSED: push_config target"
+} else {
+ puts "FAILED: push_config target"
+}
+
+# test pop_config host
+pop_config host
+if { ![info exists target_info(host,name)] } {
+ puts "PASSED: pop_config host"
+} else {
+ puts "FAILED: pop_config host"
+}
+
+puts "END target.test"
diff --git a/testsuite/runtest.libs/testsuite_file.test b/testsuite/runtest.libs/testsuite_file.test
new file mode 100644
index 0000000..fce65b8
--- /dev/null
+++ b/testsuite/runtest.libs/testsuite_file.test
@@ -0,0 +1,213 @@
+# test "testsuite file" API call -*- Tcl -*-
+
+set srcdir [lindex $argv 0]
+set subdir [lindex $argv 1]
+set objdir [lindex $argv 2]
+
+if [ file exists $objdir/setval.tmp ] {
+ source $objdir/setval.tmp
+} else {
+ puts "ERROR: $objdir/setval.tmp doesn't exist"
+}
+if [ file exists $srcdir/$subdir/default_procs.tcl ] {
+ source "$srcdir/$subdir/default_procs.tcl"
+} else {
+ puts "ERROR: $srcdir/$subdir/default_procs.tcl doesn't exist"
+}
+if [ file exists $srcdir/../lib/framework.exp] {
+ source $srcdir/../lib/framework.exp
+} else {
+ puts "ERROR: $srcdir/../lib/framework.exp doesn't exist"
+}
+if [ file exists $srcdir/../lib/utils.exp] {
+ source $srcdir/../lib/utils.exp
+} else {
+ puts "ERROR: $srcdir/../lib/utils.exp doesn't exist"
+}
+
+# basic tests
+
+set testsuitedir /src/foo/testsuite
+set testbuilddir /build/foo/testsuite
+set testdir [file join $testsuitedir foo.all]
+
+run_tests {
+ { "#" "basic syntax errors" }
+ { lib_errpat_test testsuite { file }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file without arguments" }
+ { lib_errpat_test testsuite { file -bogus }
+ "*unrecognized flag -bogus"
+ "testsuite file with bogus flag" }
+ { lib_errpat_test testsuite { file -- }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file without directory level flag, only --" }
+ { lib_errpat_test testsuite { file -source }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file without directory level flag, only -source" }
+ { lib_errpat_test testsuite { file -object }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file without directory level flag, only -object" }
+ { lib_errpat_test testsuite { file -hypothetical }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file without directory level flag, only -hypothetical" }
+ { lib_errpat_test testsuite { file -- foo bar }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file without directory level flag, only -- and names" }
+ { lib_errpat_test testsuite { file foo bar }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file without directory level flag, only names" }
+ { lib_errpat_test testsuite { file -- -top }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file with directory level flag after --" }
+ { lib_errpat_test testsuite { file foo -top }
+ "*testsuite file requires one of *-top*-test*"
+ "testsuite file with directory level flag after name" }
+
+ { "#" "basic variable retrieval" }
+ { lib_ret_test testsuite
+ { file -source -top -hypothetical } "/src/foo/testsuite"
+ "testsuite file -source -top for fixed example" }
+ { lib_ret_test testsuite
+ { file -top -hypothetical } "/src/foo/testsuite"
+ "testsuite file -top defaults to -source" }
+ { lib_ret_test testsuite
+ { file -object -top -hypothetical } "/build/foo/testsuite"
+ "testsuite file -object -top for fixed example" }
+ { lib_ret_test testsuite
+ { file -source -test -hypothetical } "/src/foo/testsuite/foo.all"
+ "testsuite file -source -test for fixed example" }
+ { lib_ret_test testsuite
+ { file -test -hypothetical } "/src/foo/testsuite/foo.all"
+ "testsuite file -test defaults to -source" }
+ { lib_ret_test testsuite
+ { file -object -test -hypothetical } "/build/foo/testsuite/foo.all"
+ "testsuite file -object -test for fixed example" }
+
+ { "#" "append file name elements" }
+ { lib_ret_test testsuite
+ { file -source -top -hypothetical lib foo }
+ "/src/foo/testsuite/lib/foo"
+ "testsuite file -source -top lib foo for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -top -hypothetical lib foo }
+ "/build/foo/testsuite/lib/foo"
+ "testsuite file -object -top lib foo for fixed example" }
+ { lib_ret_test testsuite
+ { file -source -test -hypothetical bar }
+ "/src/foo/testsuite/foo.all/bar"
+ "testsuite file -source -test bar for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -test -hypothetical bar }
+ "/build/foo/testsuite/foo.all/bar"
+ "testsuite file -object -test bar for fixed example" }
+
+ { "#" "-- properly handled" }
+ { lib_ret_test testsuite
+ { file -source -top -hypothetical -- -lib -- foo }
+ "/src/foo/testsuite/-lib/--/foo"
+ "testsuite file -source -top -- -lib -- foo for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -top -hypothetical -- -lib -foo }
+ "/build/foo/testsuite/-lib/-foo"
+ "testsuite file -object -top -- -lib -foo for fixed example" }
+ { lib_ret_test testsuite
+ { file -source -test -hypothetical -- bar -object }
+ "/src/foo/testsuite/foo.all/bar/-object"
+ "testsuite file -source -test -- bar -object for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -test -hypothetical -- -bar }
+ "/build/foo/testsuite/foo.all/-bar"
+ "testsuite file -object -test -- -bar for fixed example" }
+
+ { "#" "apparent command substitutions are safe" }
+ { lib_ret_test testsuite
+ { file -source -top -hypothetical lib foo [bogus] }
+ "/src/foo/testsuite/lib/foo/[bogus]"
+ "testsuite file -source -top foo [bogus] for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -top -hypothetical lib foo [bogus] }
+ "/build/foo/testsuite/lib/foo/[bogus]"
+ "testsuite file -object -top foo [bogus] for fixed example" }
+ { lib_ret_test testsuite
+ { file -source -test -hypothetical bar [bogus] }
+ "/src/foo/testsuite/foo.all/bar/[bogus]"
+ "testsuite file -source -test bar [bogus] for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -test -hypothetical bar [bogus] }
+ "/build/foo/testsuite/foo.all/bar/[bogus]"
+ "testsuite file -object -test bar [bogus] for fixed example" }
+
+ { "#" "apparent variable substitutions are safe" }
+ { lib_ret_test testsuite
+ { file -source -top -hypothetical lib foo $bogus }
+ "/src/foo/testsuite/lib/foo/$bogus"
+ "testsuite file -source -top foo $bogus for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -top -hypothetical lib foo $bogus }
+ "/build/foo/testsuite/lib/foo/$bogus"
+ "testsuite file -object -top foo $bogus for fixed example" }
+ { lib_ret_test testsuite
+ { file -source -test -hypothetical bar $bogus }
+ "/src/foo/testsuite/foo.all/bar/$bogus"
+ "testsuite file -source -test bar $bogus for fixed example" }
+ { lib_ret_test testsuite
+ { file -object -test -hypothetical bar $bogus }
+ "/build/foo/testsuite/foo.all/bar/$bogus"
+ "testsuite file -object -test bar $bogus for fixed example" }
+}
+
+set testsuitedir $srcdir
+set testbuilddir $objdir
+set testdir [file join $srcdir $subdir]
+
+run_tests [subst -nocommands {
+ { lib_ret_test testsuite { file -source -top } $srcdir
+ "testsuite file -source -top" }
+ { lib_ret_test testsuite { file -source -test } $testdir
+ "testsuite file -source -test" }
+ { lib_ret_test testsuite { file -object -top } $objdir
+ "testsuite file -object -top" }
+ { lib_errpat_test testsuite { file -source -test {[bogus]} foo }
+ "directory '*\\\\[bogus\\\\]' does not exist"
+ "testsuite file raises error on bogus source directory" }
+}]
+
+# test object directory creation
+
+if { [file isdirectory [file join $objdir empty-test-dir]] } {
+ file delete -force -- [file join $objdir empty-test-dir]
+}
+if { [file isdirectory [file join $objdir empty-test-dir]] } {
+ perror "[file join $objdir empty-test-dir] exists and cannot be removed"
+}
+
+run_tests [subst {
+ { lib_ret_test testsuite
+ { file -object -top -hypothetical empty-test-dir foo }
+ [file join $objdir empty-test-dir foo]
+ "testsuite file implying hypothetical directory" }
+}]
+
+if { ![file isdirectory [file join $objdir empty-test-dir]] } {
+ puts "PASSED: testsuite file does not create hypothetical implied directory"
+} else {
+ puts "FAILED: testsuite file does not create hypothetical implied directory"
+}
+
+run_tests [subst {
+ { lib_ret_test testsuite
+ { file -object -top empty-test-dir foo }
+ [file join $objdir empty-test-dir foo]
+ "testsuite file implying new object directory" }
+}]
+
+if { [file isdirectory [file join $objdir empty-test-dir]] } {
+ puts "PASSED: testsuite file creates new implied object directory"
+} else {
+ puts "FAILED: testsuite file creates new implied object directory"
+}
+
+file delete -force [file join $objdir empty-test-dir]
+
+puts "END testsuite_file.test"
diff --git a/testsuite/runtest.libs/topdir/subdir1/subfile1 b/testsuite/runtest.libs/topdir/subdir1/subfile1
new file mode 100644
index 0000000..8397fe3
--- /dev/null
+++ b/testsuite/runtest.libs/topdir/subdir1/subfile1
@@ -0,0 +1 @@
+# just so we don't look empty.
diff --git a/testsuite/runtest.libs/topdir/subdir1/subfile2 b/testsuite/runtest.libs/topdir/subdir1/subfile2
new file mode 100644
index 0000000..7d1d836
--- /dev/null
+++ b/testsuite/runtest.libs/topdir/subdir1/subfile2
@@ -0,0 +1,2 @@
+# just so we don't look empty.
+
diff --git a/testsuite/runtest.libs/topdir/subdir1/subsubdir1/subsubfile1 b/testsuite/runtest.libs/topdir/subdir1/subsubdir1/subsubfile1
new file mode 100644
index 0000000..7d1d836
--- /dev/null
+++ b/testsuite/runtest.libs/topdir/subdir1/subsubdir1/subsubfile1
@@ -0,0 +1,2 @@
+# just so we don't look empty.
+
diff --git a/testsuite/runtest.libs/topdir/subdir2/subfile2 b/testsuite/runtest.libs/topdir/subdir2/subfile2
new file mode 100644
index 0000000..7d1d836
--- /dev/null
+++ b/testsuite/runtest.libs/topdir/subdir2/subfile2
@@ -0,0 +1,2 @@
+# just so we don't look empty.
+
diff --git a/testsuite/runtest.libs/utils.test b/testsuite/runtest.libs/utils.test
new file mode 100644
index 0000000..64cfc0a
--- /dev/null
+++ b/testsuite/runtest.libs/utils.test
@@ -0,0 +1,219 @@
+# Test procedures in lib/utils.exp. -*- Tcl -*-
+
+set srcdir [lindex $argv 0]
+set subdir [lindex $argv 1]
+set objdir [lindex $argv 2]
+
+if [ file exists $objdir/setval.tmp ] {
+ source $objdir/setval.tmp
+} else {
+ puts "ERROR: $objdir/setval.tmp doesn't exist"
+}
+if [ file exists $srcdir/$subdir/default_procs.tcl ] {
+ source $srcdir/$subdir/default_procs.tcl
+} else {
+ puts "ERROR: $srcdir$subdir/default_procs.tcl doesn't exist"
+}
+
+set file $srcdir/../lib/utils.exp
+if [ file exists $file] {
+ source $file
+} else {
+ puts "ERROR: $file doesn't exist"
+}
+
+# Test getdirs:
+#
+run_tests [subst {
+ { lib_pat_test getdirs
+ {[file join $srcdir runtest.libs]}
+ [file join $srcdir runtest.libs topdir]
+ "getdirs toplevel, no arguments" }
+ { lib_pat_test getdirs
+ {[file join $srcdir runtest.libs] "top*"}
+ [file join $srcdir runtest.libs topdir]
+ "getdirs toplevel, one subdir" }
+ { lib_pat_test getdirs
+ {[file join $srcdir runtest.libs topdir]}
+ "*topdir*subdir\[12\]*topdir*subdir\[12\]"
+ "getdirs toplevel, two subdirs" }
+ { lib_pat_test getdirs
+ {[file join $srcdir runtest.libs nothere]}
+ ""
+ "getdirs toplevel, non-existent subdir"}
+}]
+
+# Test relative_filename:
+#
+run_tests {
+ { lib_ret_test relative_filename {"/foo/test" "/foo/test/bar/baz"} "bar/baz"
+ "relative_filename, simple prefix" }
+ { lib_ret_test relative_filename {"/foo/test" "/bar/test"} "../../bar/test"
+ "relative_filename, up to top" }
+ { lib_ret_test relative_filename {"/tmp/foo-test" "/tmp/bar/test"} "../bar/test"
+ "relative_filename, up one level" }
+ { lib_ret_test relative_filename {"/tmp/foo-test" "/tmp/foo-test"} ""
+ "relative_filename, same name" }
+}
+
+# Test find:
+#
+run_tests [subst {
+ { lib_pat_test find
+ {[file join $srcdir runtest.libs topdir subdir2] "sub*"}
+ "*/subdir2/subfile2"
+ "find, only one level deep" }
+ { lib_regexp_test find
+ {[file join $srcdir runtest.libs topdir subdir1] "sub*"}
+ ".*/subdir1/subsubdir1/subsubfile1( |$)"
+ "find, two levels deep" }
+}]
+
+# Environment varible utility tests.
+#
+
+if [info exists env(TESTRUN)] {
+ unset env(TESTRUN)
+}
+
+# Test setenv:
+#
+setenv TESTRUN FooBar
+if [info exists env(TESTRUN)] {
+ if { $env(TESTRUN) eq "FooBar" } {
+ pass "setenv, set an environment variable"
+ } else {
+ fail "setenv, set an environment variable"
+ }
+} else {
+ fail "setenv, set an environment variable"
+}
+
+# Test getenv:
+#
+if [info exists env(TESTRUN)] {
+ if { [getenv TESTRUN] eq "FooBar" } {
+ pass "getenv, get an environment variable"
+ } else {
+ fail "getenv, get an environment variable"
+ }
+} else {
+ untested "getenv, get an environment variable"
+}
+
+# Test unsetenv:
+#
+if [info exists env(TESTRUN)] {
+ unsetenv TESTRUN
+ if [info exists env(TESTRUN)] {
+ fail "unsetenv, unset an environment variable"
+ } else {
+ pass "unsetenv, unset an environment variable"
+ }
+} else {
+ untested "unsetenv, unset an environment variable"
+}
+
+# Test 'which' using a relative path.
+#
+if {[which ./config.status] != 0} {
+ pass "which, relative path to config.status"
+} else {
+ fail "which, relative path to config.status"
+}
+
+# Test 'which' using an absolute path.
+#
+if {[which [file join $objdir config.status]] != 0} {
+ pass "which, absolute path to config.status"
+} else {
+ fail "which, absolute path to config.status"
+}
+
+# Test 'which make'.
+#
+if {[which make] != 0} {
+ pass "which, make"
+} else {
+ fail "which, make"
+}
+
+### Do not adjust the comment on the next line. The grep test case
+### depends on it.
+
+# Test grep!
+if {[llength [grep $srcdir/runtest.libs/utils.test "^# Test grep!"]] == 1} {
+ pass "grep, no options"
+} else {
+ fail "grep, no options"
+}
+
+# Test grep with line option.
+set result [grep $srcdir/runtest.libs/utils.test "^# Test grep!" line]
+if {[llength $result] == 1 && [regexp {^\d+ # Test grep!} [lindex $result 0]]} {
+ pass "grep, line option"
+} else {
+ fail "grep, line option"
+}
+
+# Test grep with -n option.
+set result [grep -n $srcdir/runtest.libs/utils.test "^# Test grep!"]
+if {[llength $result] == 1 && [regexp {^\d+ # Test grep!} [lindex $result 0]]} {
+ pass "grep, -n option"
+} else {
+ fail "grep, -n option"
+}
+
+# Test diff proc.
+
+# Setup.
+set f1 [open diff1.txt w]
+set f2 [open diff2.txt w]
+foreach f [list $f1 $f2] {
+ puts $f "Hello world"
+ close $f
+}
+
+# Two identical files; expect 1.
+if {[diff diff1.txt diff2.txt] == 1} {
+ pass "diff, identical files"
+} else {
+ fail "diff, identical files"
+}
+
+# Now remove one file; expect 0.
+file delete diff1.txt
+if {[diff diff1.txt diff2.txt] == 0} {
+ pass "diff, one file missing"
+} else {
+ fail "diff, one file missing"
+}
+
+# diff1.txt differs from diff2.txt; expect -1.
+set f [open diff1.txt w]
+puts $f "Hello Cygnus"
+close $f
+if {[diff diff1.txt diff2.txt] == -1} {
+ pass "diff, different files"
+} else {
+ fail "diff, different files"
+}
+
+# diff teardown.
+file delete -force diff1.txt diff2.txt
+
+
+# Test runtest_file_p.
+
+run_tests {
+ { lib_bool_test runtest_file_p {{foo.exp} foo.c} true
+ "runtest_file_p, bare foo.exp matches foo.c" }
+ { lib_bool_test runtest_file_p {{foo.exp foo.c} foo.c} true
+ "runtest_file_p, foo.exp=foo.c matches foo.c" }
+ { lib_bool_test runtest_file_p {{foo.exp foo.*} foo.c} true
+ "runtest_file_p, foo.exp=foo.* matches foo.c" }
+ { lib_bool_test runtest_file_p {{foo.exp bar.*} foo.c} false
+ "runtest_file_p, foo.exp=bar.* excludes foo.c" }
+}
+
+puts "END utils.test"