Jason Lowe-Power has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/19528 )

Change subject: ext: Fix tmpfiles in testlib
......................................................................

ext: Fix tmpfiles in testlib

Previously, the testlib would generate and not clean up 100s of
temporary files in /tmp. This puts all of the tempfiles in the same
directory to make sure they are cleaned up on a successful test.

Change-Id: If4dcd93ab4b5df556c046753266a71365d1388c1
Signed-off-by: Jason Lowe-Power <ja...@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19528
Reviewed-by: Bobby R. Bruce <bbr...@ucdavis.edu>
Reviewed-by: Nikos Nikoleris <nikos.nikole...@arm.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M ext/testlib/helper.py
1 file changed, 6 insertions(+), 6 deletions(-)

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



diff --git a/ext/testlib/helper.py b/ext/testlib/helper.py
index 18256ea..ac49e46 100644
--- a/ext/testlib/helper.py
+++ b/ext/testlib/helper.py
@@ -390,13 +390,13 @@
     os.chown(target, st[stat.ST_UID], st[stat.ST_GID])


-def _filter_file_inplace(fname, filters):
+def _filter_file_inplace(fname, dir, filters):
     '''
Filter the given file writing filtered lines out to a temporary file, then
     copy that tempfile back into the original file.
     '''
     reenter = False
-    (_, tfname) = tempfile.mkstemp(text=True)
+    (_, tfname) = tempfile.mkstemp(dir=dir, text=True)
     with open(tfname, 'w') as tempfile_:
         for line in _filter_file(fname, filters):
             tempfile_.write(line)
@@ -414,11 +414,11 @@
     if not os.path.exists(out_file):
         raise OSError("%s doesn't exist in output directory" % out_file)

-    _filter_file_inplace(out_file, ignore_regexes)
-    _filter_file_inplace(ref_file, ignore_regexes)
+ _filter_file_inplace(out_file, os.path.dirname(out_file), ignore_regexes) + _filter_file_inplace(ref_file, os.path.dirname(out_file), ignore_regexes)

     #try :
-    (_, tfname) = tempfile.mkstemp(text=True)
+ (_, tfname) = tempfile.mkstemp(dir=os.path.dirname(out_file), text=True)
     with open(tfname, 'r+') as tempfile_:
         try:
log_call(logger, ['diff', out_file, ref_file], stdout=tempfile_)
@@ -457,4 +457,4 @@

     @staticmethod
     def timestamp():
-        return time.time()
\ No newline at end of file
+        return time.time()

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/19528
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: If4dcd93ab4b5df556c046753266a71365d1388c1
Gerrit-Change-Number: 19528
Gerrit-PatchSet: 9
Gerrit-Owner: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to