[PATCH] waf: Allow to add libs per test.

Christian Mauderer christian.mauderer at embedded-brains.de
Wed May 2 09:45:59 UTC 2018


Update #3419.
---
 builder.py    | 11 +++++++----
 libbsd.py     | 33 +++++++++++++++++++++++----------
 waf_libbsd.py |  4 +++-
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/builder.py b/builder.py
index 93363590..c183f7d6 100755
--- a/builder.py
+++ b/builder.py
@@ -495,25 +495,28 @@ class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
 
 class TestFragementComposer(BuildSystemFragmentComposer):
 
-    def __init__(self, testName, fileFragments, runTest = True, netTest = False):
+    def __init__(self, testName, fileFragments, runTest = True, netTest = False, extraLibs = []):
         self.testName = testName
         self.fileFragments = fileFragments
         self.runTest = runTest
         self.netTest = netTest
+        self.extraLibs = extraLibs
 
     def compose(self, path):
         return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
                                                               'run': self.runTest,
-                                                              'net': self.netTest }
+                                                              'net': self.netTest,
+                                                              'libs': self.extraLibs}
 
 class TestIfHeaderComposer(TestFragementComposer):
 
-    def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False):
+    def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False, extraLibs = []):
         if headers is not list:
             headers = [headers]
         self.headers = headers
         super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
-                                                   runTest = runTest, netTest = netTest)
+                                                   runTest = runTest, netTest = netTest,
+                                                   extraLibs = extraLibs)
 
     def compose(self, path):
         r = TestFragementComposer.compose(self, path)
diff --git a/libbsd.py b/libbsd.py
index 586703fd..48bc034a 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -4705,10 +4705,14 @@ class tests(builder.Module):
         self.addTest(mm.generator['test']('arphole', ['test_main'],
                                           runTest = False, netTest = True))
         self.addTest(mm.generator['test']('telnetd01', ['test_main'],
-                                          runTest = False, netTest = True))
+                                          runTest = False, netTest = True,
+                                          extraLibs = ['telnetd']))
         self.addTest(mm.generator['test']('unix01', ['test_main']))
-        self.addTest(mm.generator['test']('ftpd01', ['test_main'], netTest = True))
-        self.addTest(mm.generator['test']('ftpd02', ['test_main']))
+        self.addTest(mm.generator['test']('ftpd01', ['test_main'],
+                                          netTest = True,
+                                          extraLibs = ['ftpd']))
+        self.addTest(mm.generator['test']('ftpd02', ['test_main'],
+                                          extraLibs = ['ftpfs', 'ftpd']))
         self.addTest(mm.generator['test']('ping01', ['test_main'], netTest = True))
         self.addTest(mm.generator['test']('selectpollkqueue01', ['test_main']))
         self.addTest(mm.generator['test']('rwlock01', ['test_main']))
@@ -4729,19 +4733,27 @@ class tests(builder.Module):
         self.addTest(mm.generator['test']('thread01', ['test_main']))
         self.addTest(mm.generator['test']('mutex01', ['test_main']))
         self.addTest(mm.generator['test']('condvar01', ['test_main']))
-        self.addTest(mm.generator['test']('ppp01', ['test_main'], runTest = False))
+        self.addTest(mm.generator['test']('ppp01', ['test_main'], runTest = False,
+                                          extraLibs = ['ftpd', 'telnetd']))
         self.addTest(mm.generator['test']('zerocopy01', ['test_main'],
-                                          runTest = False, netTest = True))
+                                          runTest = False, netTest = True,
+                                          extraLibs = ['telnetd']))
         self.addTest(mm.generator['test']('smp01', ['test_main']))
-        self.addTest(mm.generator['test']('media01', ['test_main'], runTest = False))
+        self.addTest(mm.generator['test']('media01', ['test_main'],
+                                          runTest = False,
+                                          extraLibs = ['ftpd', 'telnetd']))
         self.addTest(mm.generator['test']('vlan01', ['test_main'], netTest = True))
         self.addTest(mm.generator['test']('lagg01', ['test_main'], netTest = True))
         self.addTest(mm.generator['test']('log01', ['test_main']))
         self.addTest(mm.generator['test']('rcconf01', ['test_main']))
-        self.addTest(mm.generator['test']('rcconf02', ['test_main']))
+        self.addTest(mm.generator['test']('rcconf02', ['test_main'],
+                                          extraLibs = ['ftpd', 'telnetd']))
         self.addTest(mm.generator['test']('cdev01', ['test_main', 'test_cdev']))
-        self.addTest(mm.generator['test']('pf01', ['test_main']))
-        self.addTest(mm.generator['test']('pf02', ['test_main'], runTest = False))
+        self.addTest(mm.generator['test']('pf01', ['test_main'],
+                                          extraLibs = ['ftpd', 'telnetd']))
+        self.addTest(mm.generator['test']('pf02', ['test_main'],
+                                          runTest = False,
+                                          extraLibs = ['ftpd', 'telnetd']))
         self.addTest(mm.generator['test']('termios', ['test_main',
                                                       'test_termios_driver',
                                                       'test_termios_utilities']))
@@ -4764,7 +4776,8 @@ class tests(builder.Module):
                                                         '../termios/test_termios_driver',
                                                         '../termios/test_termios_utilities']))
         self.addTest(mm.generator['test-if-header']('debugger01', 'rtems/rtems-debugger.h',
-                                                    ['test_main'], runTest = False, netTest = True))
+                                                    ['test_main'], runTest = False, netTest = True,
+                                                    extraLibs = ['debugger']))
         self.addTest(mm.generator['test']('crypto01', ['test_main']))
 
 def load(mm):
diff --git a/waf_libbsd.py b/waf_libbsd.py
index fd89c394..a1d8ad2b 100644
--- a/waf_libbsd.py
+++ b/waf_libbsd.py
@@ -460,6 +460,7 @@ class Builder(builder.ModuleManager):
         for testName in sorted(tests):
             test = self.data['tests'][testName]['all']
             test_source = []
+            libs = ['bsd', 'm', 'z']
             for cfg in test:
                 build_test = True
                 if cfg != 'default':
@@ -470,6 +471,7 @@ class Builder(builder.ModuleManager):
                 if build_test:
                     test_sources = ['testsuite/%s/%s.c' % (testName, f) \
                                     for f in test[cfg]['files']]
+                    libs = test[cfg]['libs'] + libs
             if build_test:
                 bld.program(target = '%s.exe' % (testName),
                             features = 'cprogram',
@@ -477,5 +479,5 @@ class Builder(builder.ModuleManager):
                             includes = includes,
                             source = test_sources,
                             use = ['bsd'],
-                            lib = ['ftpfs', 'ftpd', 'telnetd', 'bsd', 'm', 'z'],
+                            lib = libs,
                             install_path = None)
-- 
2.13.6



More information about the devel mailing list