(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: Ben Elliston <bje@gnu.org>
+2013-06-17 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
+
+ * 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.
+
2013-06-15 Ben Elliston <bje@gnu.org>
* configure.ac: If DEJAGNU is unset, set it to /dev/null.
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 \
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 \
@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
load.
@end table
+The global variable @code{libdirs}, handled
+as a list, is appended to the default fixed paths built
+into DejaGnu.
+
+@strong{Additional search directories for load_lib}
+
+@example
+# 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
+@end example
+
@node Procedures For Remote Communication, connprocs, Core Internal Procedures, Builtin Procedures
@subsection Procedures For Remote Communication
<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
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>
# 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)]} {
}
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
}
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"
--- /dev/null
+# 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