summaryrefslogtreecommitdiff
path: root/test/bbackupd/testbbackupd.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-12-24 23:21:43 +0000
committerChris Wilson <chris+github@qwirx.com>2015-12-24 23:21:43 +0000
commitaa0b05629ee0f61cd5c6b7b473699758f848b5d2 (patch)
tree03f7b1f0a67a88ac70e3e3ee372405f5f333d3a3 /test/bbackupd/testbbackupd.cpp
parent482d628ec0070f11d4ca5a4ad1b5e00323e18563 (diff)
Use 7za to extract tgz files on Windows, as there's no (reliable) tar command.
Diffstat (limited to 'test/bbackupd/testbbackupd.cpp')
-rw-r--r--test/bbackupd/testbbackupd.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index f99ffcb4..4302fb69 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -331,11 +331,20 @@ bool unpack_files(const std::string& archive_file,
BOX_INFO("Unpacking test fixture archive into " << destination_dir
<< ": " << archive_file);
-#ifdef WIN32
+#ifdef _MSC_VER // No tar, use 7zip.
+ // 7za only extracts the tgz file to a tar file, which we have to extract in a
+ // separate step.
+ std::string cmd = std::string("7za x testfiles/") + archive_file + ".tgz -aos "
+ "-otestfiles >nul:";
+ TEST_LINE_OR(::system(cmd.c_str()) == 0, cmd, return false);
+
+ cmd = std::string("7za x testfiles/") + archive_file + ".tar -aos "
+ "-o" + destination_dir + " -x!.\\TestDir1\\symlink? >nul:";
+#elif defined WIN32 // Cygwin + MinGW, we can use real tar.
std::string cmd("tar xz");
cmd += tar_options + " -f testfiles/" + archive_file + ".tgz " +
"-C " + destination_dir;
-#else
+#else // Unixish, but Solaris tar doesn't like decompressing gzip files.
std::string cmd("gzip -d < testfiles/");
cmd += archive_file + ".tgz | ( cd " + destination_dir + " && tar xf" +
tar_options + " -)";