This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master in repository sanlock.
commit 7cc926179bff32f2830dc1f9ab0c2a297a47117b Author: Nir Soffer nirsof@gmail.com AuthorDate: Wed Apr 29 02:01:14 2020 +0300
tests: Test handling paths with colons
"sanlock direct dump" supports now escaped colons in path. Add a test to verify this behaviour. Unfortunately, "sanlock direct init" does not support that yet.
Signed-off-by: Nir Soffer nsoffer@redhat.com --- tests/direct_test.py | 24 ++++++++++++++++++++++++ tests/util.py | 5 +++-- 2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/tests/direct_test.py b/tests/direct_test.py index bc66526..a7ad014 100644 --- a/tests/direct_test.py +++ b/tests/direct_test.py @@ -10,6 +10,7 @@ Test sanlock direct options. from __future__ import absolute_import
import io +import os import struct
from . import constants @@ -113,3 +114,26 @@ def test_dump_resources_start_before(tmpdir): ['04194304', 'ls_name', 'res_4', '0000000000', '0000', '0000', '0'], ['05242880', 'ls_name', 'res_5', '0000000000', '0000', '0000', '0'], ] + + +def test_path_with_colon(tmpdir): + path = str(tmpdir.mkdir("with:colon").join("resources")) + size = 8 * MiB + util.create_file(path, size) + + # sanlock direct init does not support escaped colons in path. + dirname, filename = os.path.split(path) + res = "ls_name:res_0:%s:0M" % filename + util.sanlock("direct", "init", "-r", res, cwd=dirname) + + # sanlock direct dump supports escaped colons in path. + escaped_path = path.replace(":", "\:") + dump = "%s:0:8M" % escaped_path + out = util.sanlock("direct", "dump", dump) + + lines = out.decode("utf-8").splitlines() + resources = [line.split() for line in lines] + assert resources == [ + ['offset', 'lockspace', 'resource', 'timestamp', 'own', 'gen', 'lver'], + ['00000000', 'ls_name', 'res_0', '0000000000', '0000', '0000', '0'], + ] diff --git a/tests/util.py b/tests/util.py index 12f2702..df36ebb 100644 --- a/tests/util.py +++ b/tests/util.py @@ -82,14 +82,15 @@ def wait_for_daemon(timeout): s.close()
-def sanlock(*args): +def sanlock(*args, cwd=None): """ Run sanlock returning the process stdout, or raising util.CommandError on failures. """ cmd = [SANLOCK] cmd.extend(args) - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd) out, err = p.communicate() if p.returncode: raise CommandError(cmd, p.returncode, out, err)
sanlock-devel@lists.fedorahosted.org