Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/32123 )

Change subject: scons: Make src/systemc/tests/SConscript python 3 compatible.
......................................................................

scons: Make src/systemc/tests/SConscript python 3 compatible.

The os.path.walk method was removed in python 3. Replace it with os.walk
which is available in both python 2 and 3.

Change-Id: I7919b6a2063c65bc3619927aa4514d8d6d1b2038
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32123
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/systemc/tests/SConscript
1 file changed, 17 insertions(+), 17 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/systemc/tests/SConscript b/src/systemc/tests/SConscript
index e791059..cf50514 100644
--- a/src/systemc/tests/SConscript
+++ b/src/systemc/tests/SConscript
@@ -31,6 +31,7 @@

     from gem5_scons import Transform

+    import os
     import os.path
     import json

@@ -75,7 +76,7 @@
             # Turn off extra warnings and Werror for the tests.
             to_remove = ['-Wall', '-Wundef', '-Wextra', '-Werror']
             env['CCFLAGS'] = \
-                filter(lambda f: f not in to_remove, env['CCFLAGS'])
+                list(filter(lambda f: f not in to_remove, env['CCFLAGS']))

             env.Append(CPPPATH=test_dir.Dir('include'))

@@ -112,26 +113,28 @@


     def scan_dir_for_tests(subdir):
-        def visitor(arg, dirname, names):
+        subdir_src = Dir('.').srcdir.Dir(subdir)
+        for root, dirs, files in os.walk(str(subdir_src)):
# If there's a 'DONTRUN' file in this directory, skip it and any
             # child directories.
-            if 'DONTRUN' in names:
-                del names[:]
+            if 'DONTRUN' in files:
+                del dirs[:]
                 return

-            endswith = lambda sfx: filter(lambda n: n.endswith(sfx), names)
+            endswith = lambda sfx: list(filter(
+                        lambda n: n.endswith(sfx), files))

             cpps = endswith('.cpp')
             if not cpps:
-                return
+                continue

             def get_entries(fname):
-                with open(os.path.join(dirname, fname)) as content:
+                with open(os.path.join(root, 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)
+                    lines = list(filter(lambda x: x, lines))
                     return lines

# If there's only one source file, then that files name is the test
@@ -139,7 +142,7 @@
             if len(cpps) == 1:
                 cpp = cpps[0]

-                test = new_test(dirname, os.path.splitext(cpp)[0])
+                test = new_test(root, os.path.splitext(cpp)[0])
                 test.add_source(cpp)

# Otherwise, expect there to be a file that ends in .f. That files
@@ -149,25 +152,22 @@
                 fs = endswith('.f')
                 if len(fs) != 1:
                     print("In %s, expected 1 *.f file, but found %d.",
-                          dirname, len(fs))
+                          root, len(fs))
                     for f in fs:
-                        print(os.path.join(dirname, f))
+                        print(os.path.join(root, f))
                     return
                 f = fs[0]

-                test = new_test(dirname, os.path.splitext(f)[0])
+                test = new_test(root, os.path.splitext(f)[0])
                 # Add all the sources to this test.
                 test.add_sources(get_entries(f))

-            if 'COMPILE' in names:
+            if 'COMPILE' in files:
                 test.compile_only = True

-            if 'DEPS' in names:
+            if 'DEPS' in files:
                 test.deps = get_entries('DEPS')

-        subdir_src = Dir('.').srcdir.Dir(subdir)
-        os.path.walk(str(subdir_src), visitor, None)
-
     scan_dir_for_tests('systemc')
     scan_dir_for_tests('tlm')


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/32123
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7919b6a2063c65bc3619927aa4514d8d6d1b2038
Gerrit-Change-Number: 32123
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to