From 86e11715819ac183a68aaf1deed6beabb259384b Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Wed, 18 Nov 2020 02:32:42 -0800 Subject: [PATCH] [dvs] Re-add copy_file method to DVS (#1507) I re-added the copy_file method that was removed in a recent refactor. Buildimage tests depend on this method, so subsequent submodule updates will fail. Signed-off-by: Danny Allen --- tests/conftest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 469f5767830a..7e449ad42721 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,6 +9,8 @@ import string import subprocess import sys +import tarfile +import io from typing import Dict, Tuple from datetime import datetime @@ -532,6 +534,17 @@ def runcmd(self, cmd: str) -> Tuple[int, str]: return (exitcode, out) + # used in buildimage tests, do not delete + def copy_file(self, path: str, filename: str) -> None: + tarstr = io.BytesIO() + tar = tarfile.open(fileobj=tarstr, mode="w") + tar.add(filename, os.path.basename(filename)) + tar.close() + + self.ctn.exec_run(f"mkdir -p {path}") + self.ctn.put_archive(path, tarstr.getvalue()) + tarstr.close() + def get_logs(self) -> None: log_dir = os.path.join("log", self.log_path) if self.log_path else "log"