systemc: Make verify.py recognize a DEPS file in test dirs.

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>
diff --git a/src/systemc/tests/SConscript b/src/systemc/tests/SConscript
index 0ecd6ad..7450610 100644
--- a/src/systemc/tests/SConscript
+++ b/src/systemc/tests/SConscript
@@ -44,6 +44,7 @@
             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 @@
             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 @@
                     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 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 @@
                 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)