From 69191f1a24d5bee5826c1e69208940cba5e9792e Mon Sep 17 00:00:00 2001 From: Don Anderson Date: Wed, 8 Jul 2015 13:06:30 -0400 Subject: WT-18899 followup to abstract copying a WT home directory into a function, and create two callers to the function. --- test/suite/helper.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'test/suite/helper.py') diff --git a/test/suite/helper.py b/test/suite/helper.py index cd34811904a..dce5312b966 100644 --- a/test/suite/helper.py +++ b/test/suite/helper.py @@ -27,7 +27,7 @@ # OTHER DEALINGS IN THE SOFTWARE. # -import glob, os, string +import glob, os, shutil, string, subprocess import wiredtiger # python has a filecmp.cmp function, but different versions of python approach @@ -96,6 +96,29 @@ def confirm_empty(self, uri): self.assertEqual(cursor.next(), wiredtiger.WT_NOTFOUND) cursor.close() +# copy a WT home directory +def copy_live_wiredtiger_home(olddir, newdir, aligned=True): + # unaligned copy requires 'dd', which may not be available on Windows + if not aligned and os.name == "nt": + raise AssertionError( + 'copy_live_wiredtiger_home: unaligned copy impossible on Windows') + shutil.rmtree(newdir, ignore_errors=True) + os.mkdir(newdir) + for fname in os.listdir(olddir): + fullname = os.path.join(olddir, fname) + # Skip lock file, on Windows it is locked. + if os.path.isfile(fullname) and "WiredTiger.lock" not in fullname: + # Use a dd command that does not align on a block boundary. + if aligned: + shutil.copy(fullname, newdir) + else: + fullname = os.path.join(olddir, fname) + inpf = 'if=' + fullname + outf = 'of=' + newdir + '/' + fullname + cmd_list = ['dd', inpf, outf, 'bs=300'] + a = subprocess.Popen(cmd_list) + a.wait() + # create a simple_populate or complex_populate key def key_populate(cursor, i): key_format = cursor.key_format -- cgit v1.2.1