From 0e0d40a8a3e26b454d20fef51f5411d3231c123f Mon Sep 17 00:00:00 2001 From: Christopher Hoffman Date: Mon, 6 Jan 2025 14:44:49 +0000 Subject: [PATCH] teuthology: Add tests for seek and sync in write_file Signed-off-by: Christopher Hoffman --- teuthology/orchestra/test/test_remote.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/teuthology/orchestra/test/test_remote.py b/teuthology/orchestra/test/test_remote.py index a953835e7..ef9fb4406 100644 --- a/teuthology/orchestra/test/test_remote.py +++ b/teuthology/orchestra/test/test_remote.py @@ -220,3 +220,15 @@ def test_is_container(self): rem2 = remote.Remote(name='jdoe@xyzzy.example.com', ssh=self.m_ssh) rem2._runner = m_run assert not rem2.is_container + + @patch("teuthology.orchestra.remote.Remote.run") + def test_write_file(self, m_run): + file = "fakefile" + contents = "fakecontents" + rem = remote.Remote(name='jdoe@xyzzy.example.com', ssh=self.m_ssh) + + remote.Remote.write_file(rem, file, contents, bs=1, offset=1024) + m_run.assert_called_with(args=f"set -ex\ndd of={file} bs=1 seek=1024", stdin=contents, quiet=True) + + remote.Remote.write_file(rem, file, contents, sync=True) + m_run.assert_called_with(args=f"set -ex\ndd of={file} conv=sync", stdin=contents, quiet=True)