AU: Class to perform delta updates.
A class to perform delta updates and the associated unittests. Also,
change the delta diff generator executable to be able to apply a
delta, which is handy for debugging.
TEST=Attached unit test, hand-tested on real build images
BUG=552
Review URL: http://codereview.chromium.org/1718001
diff --git a/test_utils.h b/test_utils.h
index bba3ed1..2a87f49 100644
--- a/test_utils.h
+++ b/test_utils.h
@@ -10,6 +10,7 @@
#include <vector>
#include <gtest/gtest.h>
#include "update_engine/action.h"
+#include "update_engine/subprocess.h"
// These are some handy functions for unittests.
@@ -105,6 +106,23 @@
void VerifyAllPaths(const std::string& parent,
std::set<std::string> expected_paths);
+class ScopedLoopbackDeviceReleaser {
+ public:
+ explicit ScopedLoopbackDeviceReleaser(const std::string& dev) : dev_(dev) {}
+ ~ScopedLoopbackDeviceReleaser() {
+ std::vector<std::string> args;
+ args.push_back("/sbin/losetup");
+ args.push_back("-d");
+ args.push_back(dev_);
+ int return_code = 0;
+ EXPECT_TRUE(Subprocess::SynchronousExec(args, &return_code));
+ EXPECT_EQ(0, return_code);
+ }
+ private:
+ const std::string dev_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedLoopbackDeviceReleaser);
+};
+
// Useful actions for test
class NoneType;