[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] runtest.exp: add libdirs list for load_lib()
From: |
Bernhard Reutner-Fischer |
Subject: |
[PATCH 6/6] runtest.exp: add libdirs list for load_lib() |
Date: |
Fri, 14 Jun 2013 09:03:12 +0200 |
Add a user-settable global variable libdirs that is appended to the
built-in list of paths to search for libs.
Motivation:
GCC's libgomp wants to load .exp files from ../gcc/testsuite/lib.
Previously GCC used to have a helper proc that had to first load all
dependent .exp manually and then, again manually, the desired .exp.
All these workarounds (essentially the whole load_gcc_lib) can be removed
now -- once GCC can require a dejagnu version that contains this,
obviuosly.
2013-06-13 Bernhard Reutner-Fischer <address@hidden>
* runtest.exp (libdirs): New global variable.
(load_lib): Append libdirs to search_and_load_files directories.
* doc/ref.xml (load_lib): Document global variable libdirs.
* doc/dejagnu.texi: Regenerate.
* testsuite/runtest.all/load_lib.exp: New testcase.
* Makefile.am (TESTSUITE_FILES): Add new testcase.
* Makefile.in: Regenerate.
Signed-off-by: Bernhard Reutner-Fischer <address@hidden>
---
Makefile.am | 1 +
Makefile.in | 1 +
doc/dejagnu.texi | 17 +++++++++++++-
doc/ref.xml | 15 +++++++++++-
runtest.exp | 11 ++++++---
testsuite/runtest.all/load_lib.exp | 44 ++++++++++++++++++++++++++++++++++++
6 files changed, 84 insertions(+), 5 deletions(-)
create mode 100644 testsuite/runtest.all/load_lib.exp
diff --git a/Makefile.am b/Makefile.am
index 79e38d3..1b9fc5b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -232,6 +232,7 @@ TESTSUITE_FILES = \
testsuite/runtest.all/clone_output.test \
testsuite/runtest.all/config.test \
testsuite/runtest.all/default_procs.tcl \
+ testsuite/runtest.all/load_lib.exp \
testsuite/config/default.exp \
testsuite/lib/libsup.exp \
testsuite/lib/util-defs.exp \
diff --git a/Makefile.in b/Makefile.in
index 58d1f0e..974e89a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -477,6 +477,7 @@ TESTSUITE_FILES = \
testsuite/runtest.all/clone_output.test \
testsuite/runtest.all/config.test \
testsuite/runtest.all/default_procs.tcl \
+ testsuite/runtest.all/load_lib.exp \
testsuite/config/default.exp \
testsuite/lib/libsup.exp \
testsuite/lib/util-defs.exp \
diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index f53291d..9e6c606 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -4257,7 +4257,8 @@ to print string without a trailing newline. Use the
optional
@node load_lib procedure, , verbose procedure, Core Internal Procedures
@subsubsection Load_lib Procedure
-Loads a DejaGnu library file by searching a fixed path built
+Loads a DejaGnu library file by searching the default fixed paths
+built
into DejaGnu. If DejaGnu has been installed, it looks in a path
starting with the installed library directory. If you are running
DejaGnu directly from a source directory, without first running
@@ -4279,6 +4280,20 @@ The name of the DejaGnu library file to
load.
@end table
+The global variable @code{libdirs}, handled
+as a list, is appended to the default fixed paths built
+into DejaGnu.
+
address@hidden search directories for load_lib}
+
address@hidden
+# append a non-standard search path
+ global libdirs
+ lappend libdirs $srcdir/../../gcc/testsuite/lib
+ # now loading $srcdir/../../gcc/testsuite/lib/foo.exp works
+ load_lib foo.exp
address@hidden example
+
@node Procedures For Remote Communication, connprocs, Core Internal
Procedures, Builtin Procedures
@subsection Procedures For Remote Communication
diff --git a/doc/ref.xml b/doc/ref.xml
index b366207..18ae3bc 100644
--- a/doc/ref.xml
+++ b/doc/ref.xml
@@ -1015,7 +1015,8 @@
<sect4 id="loadlib" xreflabel="load_lib procedure">
<title>Load_lib Procedure</title>
- <para>Loads a &dj; library file by searching a fixed path built
+ <para>Loads a &dj; library file by searching the default fixed paths
+ built
into &dj;. If &dj; has been installed, it looks in a path
starting with the installed library directory. If you are running
&dj; directly from a source directory, without first running
@@ -1038,6 +1039,18 @@
load.</para></listitem>
</varlistentry>
</variablelist>
+ <para>The global variable <parameter>libdirs</parameter>, handled
+ as a list, is appended to the default fixed paths built
+ into &dj;.</para>
+ <example>
+ <title>Additional search directories for
<function>load_lib</function></title>
+ <programlisting># append a non-standard search path
+ global libdirs
+ lappend libdirs $srcdir/../../gcc/testsuite/lib
+ # now loading $srcdir/../../gcc/testsuite/lib/foo.exp works
+ load_lib foo.exp</programlisting>
+ </example>
+
</sect4>
</sect3>
diff --git a/runtest.exp b/runtest.exp
index 78da782..bd39dd8 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -589,7 +589,7 @@ proc lookfor_file { dir name } {
# source tree, (up one or two levels), then in the current dir.
#
proc load_lib { file } {
- global verbose libdir srcdir base_dir execpath tool
+ global verbose libdir libdirs srcdir base_dir execpath tool
global loaded_libs
if {[info exists loaded_libs($file)]} {
@@ -597,8 +597,11 @@ proc load_lib { file } {
}
set loaded_libs($file) ""
-
- if { [search_and_load_file "library file" $file [list ../lib $libdir
$libdir/lib [file dirname [file dirname $srcdir]]/dejagnu/lib $srcdir/lib
$execpath/lib . [file dirname [file dirname [file dirname
$srcdir]]]/dejagnu/lib]] == 0 } {
+ set search_dirs [list ../lib $libdir $libdir/lib [file dirname [file
dirname $srcdir]]/dejagnu/lib $srcdir/lib $execpath/lib . [file dirname [file
dirname [file dirname $srcdir]]]/dejagnu/lib]
+ if {[info exists libdirs]} {
+ lappend search_dirs $libdirs
+ }
+ if { [search_and_load_file "library file" $file $search_dirs ] == 0 } {
send_error "ERROR: Couldn't find library file $file.\n"
exit 1
}
@@ -652,6 +655,8 @@ set libdir [file dirname $execpath]/dejagnu
if {[info exists env(DEJAGNULIBS)]} {
set libdir $env(DEJAGNULIBS)
}
+# list of extra search directories used by load_lib to look for libs
+set libdirs {}
verbose "Using $libdir to find libraries"
diff --git a/testsuite/runtest.all/load_lib.exp
b/testsuite/runtest.all/load_lib.exp
new file mode 100644
index 0000000..55a3a07
--- /dev/null
+++ b/testsuite/runtest.all/load_lib.exp
@@ -0,0 +1,44 @@
+# test load_lib
+
+# Verify that load_lib searches for a lib not only in it's 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 [file join $srcdir $subdir "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"] == ""} {
+ pass "load_lib subfile2 loaded"
+} else {
+ fail "load_lib subfile2 not found"
+}
+
+# cleanup after us
+rename exit ""
+rename saved_exit exit
--
1.7.10.4
- [PATCH 0/6] add libdirs for load_lib extra search dirs; cleanups, Bernhard Reutner-Fischer, 2013/06/14
- [PATCH 1/6] doc: Add missing space before &dj; in user.xml, Bernhard Reutner-Fischer, 2013/06/14
- [PATCH 2/6] .gitignore: Ignore some more generated files, Bernhard Reutner-Fischer, 2013/06/14
- [PATCH 5/6] doc: Fix typos, Bernhard Reutner-Fischer, 2013/06/14
- [PATCH 4/6] doc: Fix table, Bernhard Reutner-Fischer, 2013/06/14
- [PATCH 3/6] doc: Fix some misplaced para, Bernhard Reutner-Fischer, 2013/06/14
- [PATCH 6/6] runtest.exp: add libdirs list for load_lib(),
Bernhard Reutner-Fischer <=