systemc: Make verify.py recognize a DEPS file in test dirs.
authorGabe Black <gabeblack@google.com>
Thu, 22 Nov 2018 00:59:32 +0000 (16:59 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 29 Nov 2018 01:21:06 +0000 (01:21 +0000)
This file lists additional files beyond the sources that the test
relies on, like files it uses when running.

Change-Id: Ifc4958b26eed08689e0e72bd87f84388dbcf1898
Reviewed-on: https://gem5-review.googlesource.com/c/14516
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/tests/SConscript

index 0ecd6ad4ad5e38e9b14534299eceb8e6beb2dbba..745061020b2c5781dc67d8077b5971f56f75c0a4 100644 (file)
@@ -44,6 +44,7 @@ if env['USE_SYSTEMC']:
             self.reldir = os.path.relpath(dirname, src)
             self.target = os.path.join(self.reldir, name)
             self.sources = []
+            self.deps = []
 
             self.compile_only = False
 
@@ -58,13 +59,16 @@ if env['USE_SYSTEMC']:
             return {
                 'name' : self.name,
                 'path' : self.reldir,
-                'compile_only' : self.compile_only
+                'compile_only' : self.compile_only,
+                'deps' : self.deps
             }
 
     test_dir = Dir('.')
     class SystemCTestBin(Executable):
         def __init__(self, test):
             super(SystemCTestBin, self).__init__(test.target, *test.sources)
+            self.reldir = test.reldir
+            self.test_deps = test.deps
 
         @classmethod
         def declare_all(cls, env):
@@ -95,7 +99,11 @@ if env['USE_SYSTEMC']:
                     self.path(env).dir.abspath)
             env.Append(LINKFLAGS=Split('-z origin'))
             env.Append(RPATH=env.Literal(os.path.join('\\$$ORIGIN', relpath)))
-            return super(SystemCTestBin, self).declare(env, objs)
+            test_bin = super(SystemCTestBin, self).declare(env, objs)
+            test_dir = self.dir.Dir(self.reldir)
+            for dep in self.test_deps:
+                env.Depends(test_bin, test_dir.File(dep))
+            return test_bin
 
     tests = []
     def new_test(dirname, name):
@@ -118,6 +126,15 @@ if env['USE_SYSTEMC']:
             if not cpps:
                 return
 
+            def get_entries(fname):
+                with open(os.path.join(dirname, fname)) as content:
+                    lines = content.readlines
+                    # Get rid of leading and trailing whitespace.
+                    lines = map(lambda x: x.strip(), content.readlines())
+                    # Get rid of blank lines.
+                    lines = filter(lambda x: x, lines)
+                    return lines
+
             # If there's only one source file, then that files name is the test
             # name, and it's the source for that test.
             if len(cpps) == 1:
@@ -140,18 +157,15 @@ if env['USE_SYSTEMC']:
                 f = fs[0]
 
                 test = new_test(dirname, os.path.splitext(f)[0])
-                with open(os.path.join(dirname, f)) as content:
-                    lines = content.readlines
-                    # Get rid of leading and trailing whitespace.
-                    lines = map(lambda x: x.strip(), content.readlines())
-                    # Get rid of blank lines.
-                    lines = filter(lambda x: x, lines)
-                    # Add all the sources to this test.
-                    test.add_sources(lines)
+                # Add all the sources to this test.
+                test.add_sources(get_entries(f))
 
             if 'COMPILE' in names:
                 test.compile_only = True
 
+            if 'DEPS' in names:
+                test.deps = get_entries('DEPS')
+
         subdir_src = Dir('.').srcdir.Dir(subdir)
         os.path.walk(str(subdir_src), visitor, None)