Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: test_utils.cc

Issue 5684002: Add support for bsdiff of file system metadata blocks (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: Addressed code review feedbacks Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« test_utils.h ('K') | « test_utils.h ('k') | utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test_utils.cc
diff --git a/test_utils.cc b/test_utils.cc
index c1bdb48063f43bab01aef4852aa4ed4b262edb42..9d1b5d00dce2f04308f5d3e95298fe03e3ad6503 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -178,6 +178,16 @@ void FillWithData(vector<char>* buffer) {
}
}
+void CreateEmptyExtImageAtPath(const string& path,
+ size_t size,
+ int block_size) {
+ EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s"
+ " seek=%zu bs=1 count=1",
+ path.c_str(), size)));
+ EXPECT_EQ(0, System(StringPrintf("mkfs.ext3 -b %d -F %s",
+ block_size, path.c_str())));
+}
+
void CreateExtImageAtPath(const string& path, vector<string>* out_paths) {
// create 10MiB sparse file
EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s"
@@ -199,7 +209,7 @@ void CreateExtImageAtPath(const string& path, vector<string>* out_paths) {
EXPECT_EQ(0, System(StringPrintf("ln %s/some_dir/test %s/testlink",
kMountPath, kMountPath)));
EXPECT_EQ(0, System(StringPrintf("umount -d %s", kMountPath)));
-
+
if (out_paths) {
out_paths->clear();
out_paths->push_back("");
@@ -263,4 +273,19 @@ void VerifyAllPaths(const string& parent, set<string> expected_paths) {
}
}
+ScopedLoopMounter::ScopedLoopMounter(const std::string& file_path,
+ std::string* mnt_path,
+ unsigned long flags) {
+ EXPECT_TRUE(utils::MakeTempDirectory("/tmp/mnt.XXXXXX", mnt_path));
+ dir_remover_.reset(new ScopedDirRemover(*mnt_path));
+
+ std::string loop_dev = GetUnusedLoopDevice();
+ EXPECT_EQ(0, system(StringPrintf("losetup %s %s", loop_dev.c_str(),
+ file_path.c_str()).c_str()));
+ loop_releaser_.reset(new ScopedLoopbackDeviceReleaser(loop_dev));
+
+ EXPECT_TRUE(utils::MountFilesystem(loop_dev, *mnt_path, flags));
+ unmounter_.reset(new ScopedFilesystemUnmounter(*mnt_path));
+}
+
} // namespace chromeos_update_engine
« test_utils.h ('K') | « test_utils.h ('k') | utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698