From 35987d5281a0c2457f8b0b7fbf2fb5c13cd11d1f Mon Sep 17 00:00:00 2001 From: Anouk Van Laer Date: Wed, 17 May 2017 15:49:20 +0100 Subject: [PATCH] Gem5Connection: Correct pull method The pull method used when connecting to gem5 uses the 'm5 writefile'. This only works if the file to pulled in, is in the current working directory on the target. The file therefore might need to be copied on the target, from its original location to the working directory. The previous implemention of this was incorrect and used information about the current working directory on the host. --- devlib/utils/ssh.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index f87746a..f5fedc1 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -442,11 +442,14 @@ class Gem5Connection(TelnetConnection): filename = os.path.basename(source) logger.debug("pull_file {} {}".format(source, filename)) + # writefile needs the file to be copied to be in the current working + # directory so if needed, copy to the working directory # We don't check the exit code here because it is non-zero if the source # and destination are the same. The ls below will cause an error if the # file was not where we expected it to be. - if os.path.dirname(source) != os.getcwd(): - self._gem5_shell("cat '{}' > '{}'".format(source, filename)) + if os.path.isabs(source): + if os.path.dirname(source) != self.execute('pwd',check_exit_code=False): + self._gem5_shell("cat '{}' > '{}'".format(source, filename)) self._gem5_shell("sync") self._gem5_shell("ls -la {}".format(filename)) logger.debug('Finished the copy in the simulator')