[Xorp-cvs] SF.net SVN: xorp:[11587] trunk/xorp/site_scons/site_tools/autotest.py

bms_fbsd at users.sourceforge.net bms_fbsd at users.sourceforge.net
Thu Nov 26 13:34:55 PST 2009


Revision: 11587
          http://xorp.svn.sourceforge.net/xorp/?rev=11587&view=rev
Author:   bms_fbsd
Date:     2009-11-26 21:34:54 +0000 (Thu, 26 Nov 2009)

Log Message:
-----------
Add support for running regression tests in a shared library world.
With this change, 'scons check shared=true' runs to completion.

Note: ORIGIN support is not yet enabled. The shared library paths
are hardcoded to the $BUILDDIR. This hard-coding happens in the ELF
.dynamic section (specifically the DT_RPATH entry) of each compiled test
program.

The rtld RPATH feature needs an expanded (i.e. non-SCons) path name,
as the SCons builders pass it directly to the linker.
This path changes if we install all .so into a $libdir (new XORP layout),
or if we install them into a subdir of the destination tree for each
subsystem (current XORP layout).

For tests, we want RPATH directories to be passed either as absolute
paths rooted at $BUILDDIR, or relative to the executable (../../subdir)
if using ORIGIN.

If we use rtld's ORIGIN feature to let it find our .so using
a path relative to where the Program is installed, we need
to turn each $BUILDDIR in $RPATH into a path relative to the Program.
This requires SCons is run under Python 2.6 or later, as os.path.relpath()
is used to determine the relative path for ORIGIN.

Modified Paths:
--------------
    trunk/xorp/site_scons/site_tools/autotest.py

Modified: trunk/xorp/site_scons/site_tools/autotest.py
===================================================================
--- trunk/xorp/site_scons/site_tools/autotest.py	2009-11-26 21:30:28 UTC (rev 11586)
+++ trunk/xorp/site_scons/site_tools/autotest.py	2009-11-26 21:34:54 UTC (rev 11587)
@@ -60,10 +60,36 @@
     # get the c and cxx flags to process.
     ccflags   = Split( multiget([kwargs, env], 'CCFLAGS' ))
     cxxflags  = Split( multiget([kwargs, env], 'CXXFLAGS'))
+    libpath  = Split( multiget([kwargs, env], 'LIBPATH'))
+    rpath  = Split( multiget([kwargs, env], 'RPATH'))
+    linkflags  = Split( multiget([kwargs, env], 'LINKFLAGS'))
 
+    myrpath = rpath
+
+    # For a test, take the our passed in LIBPATH, expand it, and prepend
+    # to our passed in RPATH, so that tests can build using shared
+    # libraries, even though they are not installed.
+    if env.has_key('SHAREDLIBS'):
+        # Figure out our absolute BUILDDIR path. If we're not using
+        # ORIGIN, then the test can be run
+        my_rpath_base = Dir(env['BUILDDIR']).abspath
+        # If ORIGIN is enabled, figure out our test's path relative
+        # to the BUILDDIR, and pass that to the linker in RPATH.
+        # XXX: Perhaps we should set '-z origin' at the top level?
+        #if env['use_rtld_origin']:
+        #    env.PrependUnique( LINKFLAGS = Split('-z origin') )
+        #    my_rpath_base = os.path.relpath(my_rpath_base, Dir('.').abspath)
+        # Expand the RPATH according to destdir layout.
+        myrpath += [ x.replace('$BUILDDIR', my_rpath_base) for x in libpath ]
+
     # fill the flags into kwargs
     kwargs["CXXFLAGS"] = cxxflags
     kwargs["CCFLAGS"]  = ccflags
+    kwargs["LIBPATH"]  = libpath
+    kwargs["RPATH"]  = myrpath
+    kwargs["LINKFLAGS"]  = linkflags
+
+    # build the test program
     test = env.Program(target, source = source, **kwargs)
 
     # FIXME: Skip this step if we are cross-compiling (don't run the runner).
@@ -73,6 +99,7 @@
         runner = env.Action(test[0].abspath)
     env.Alias(env['AUTOTEST_TARGET'], test, runner)
     env.AlwaysBuild(env['AUTOTEST_TARGET'])
+
     return test
 
 def generate(env, **kwargs):


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Xorp-cvs mailing list