Support running tests with `--tmp-dir` on a filesystem different from /tmp.
os.rename withs only within a single FS whereas shutil.move works accross
different filesystems.
Type: improvement
Signed-off-by: Dmitry Valter <d-valter@yandex-team.ru>
Change-Id: I5371f5d75386bd2b82a75b3e6c1f2c850bc62356
vpp_api_trace_log = "%s/%s" % (self.tempdir, api_trace)
self.logger.info(self.vapi.ppcli("api trace save %s" % api_trace))
self.logger.info("Moving %s to %s\n" % (tmp_api_trace, vpp_api_trace_log))
- os.rename(tmp_api_trace, vpp_api_trace_log)
+ shutil.move(tmp_api_trace, vpp_api_trace_log)
except VppTransportSocketIOError:
self.logger.debug(
"VppTransportSocketIOError: Vpp dead. Cannot log show commands."
from asfframework import VppTestCase, VppTestRunner
from vpp_papi import VppEnum
import json
+import shutil
class TestJsonApiTrace(VppTestCase):
tmp_api_trace = "/tmp/%s" % fname
fpath = "%s/%s" % (self.tempdir, fname)
self.vapi.cli("api trace save-json {}".format(fname))
- os.rename(tmp_api_trace, fpath)
+ shutil.move(tmp_api_trace, fpath)
with open(fpath, encoding="utf-8") as f:
s = f.read()
trace = json.loads(s)
vpp_api_trace_log = "%s/%s" % (self.tempdir, api_trace)
self.logger.info(self.vapi.ppcli("api trace save %s" % api_trace))
self.logger.info("Moving %s to %s\n" % (tmp_api_trace, vpp_api_trace_log))
- os.rename(tmp_api_trace, vpp_api_trace_log)
+ shutil.move(tmp_api_trace, vpp_api_trace_log)
except VppTransportSocketIOError:
self.logger.debug(
"VppTransportSocketIOError: Vpp dead. Cannot log show commands."
import os
+import shutil
import socket
from socket import inet_pton, inet_ntop
import struct
filename,
)
self.test.logger.debug("Renaming %s->%s" % (path, name))
- os.rename(path, name)
+ shutil.move(path, name)
except OSError:
self.test.logger.debug("OSError: Could not rename %s %s" % (path, filename))