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

Side by Side Diff: test_utils.h

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: Forgot newly added metadata processing files. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11
12 #include <base/scoped_ptr.h>
13 #include <base/string_util.h>
petkov 2010/12/15 18:40:32 do you need this header file here? can it be moved
thieule 2010/12/15 19:57:01 Done.
11 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
12 #include "base/scoped_ptr.h" 15
13 #include "update_engine/action.h" 16 #include "update_engine/action.h"
14 #include "update_engine/subprocess.h" 17 #include "update_engine/subprocess.h"
15 #include "update_engine/utils.h" 18 #include "update_engine/utils.h"
16 19
17 // These are some handy functions for unittests. 20 // These are some handy functions for unittests.
18 21
19 namespace chromeos_update_engine { 22 namespace chromeos_update_engine {
20 23
21 // Writes the data passed to path. The file at path will be overwritten if it 24 // Writes the data passed to path. The file at path will be overwritten if it
22 // exists. Returns true on success, false otherwise. 25 // exists. Returns true on success, false otherwise.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 0xe8, 0x05, 0x08, 0xa1, 0x45, 0x70, 0x5b, 0x8c, 88 0xe8, 0x05, 0x08, 0xa1, 0x45, 0x70, 0x5b, 0x8c,
86 0x39, 0x28, 0xab, 0xe9, 0x6b, 0x51, 0xd2, 0xcb, 89 0x39, 0x28, 0xab, 0xe9, 0x6b, 0x51, 0xd2, 0xcb,
87 0x30, 0x04, 0xea, 0x7d, 0x2f, 0x6e, 0x6c, 0x3b, 90 0x30, 0x04, 0xea, 0x7d, 0x2f, 0x6e, 0x6c, 0x3b,
88 0x5f, 0x82, 0xd9, 0x5b, 0x89, 0x37, 0x65, 0x65, 91 0x5f, 0x82, 0xd9, 0x5b, 0x89, 0x37, 0x65, 0x65,
89 0xbe, 0x9f, 0xa3, 0x5d 92 0xbe, 0x9f, 0xa3, 0x5d
90 }; 93 };
91 94
92 const char* const kMountPath = "/tmp/UpdateEngineTests_mnt"; 95 const char* const kMountPath = "/tmp/UpdateEngineTests_mnt";
93 } // namespace {} 96 } // namespace {}
94 97
98 // Creates an empty ext image.
99 void CreateEmptyExtImageAtPath(const std::string& path,
100 size_t size,
101 int block_size);
102
95 // Creates an ext image with some files in it. The paths creates are 103 // Creates an ext image with some files in it. The paths creates are
96 // returned in out_paths. 104 // returned in out_paths.
97 void CreateExtImageAtPath(const std::string& path, 105 void CreateExtImageAtPath(const std::string& path,
98 std::vector<std::string>* out_paths); 106 std::vector<std::string>* out_paths);
99 107
100 // Verifies that for each path in paths, it exists in the filesystem under 108 // Verifies that for each path in paths, it exists in the filesystem under
101 // parent. Also, verifies that no additional paths are present under parent. 109 // parent. Also, verifies that no additional paths are present under parent.
102 // Also tests properties of various files created by CreateExtImageAtPath(). 110 // Also tests properties of various files created by CreateExtImageAtPath().
103 // Intentionally copies expected_paths. 111 // Intentionally copies expected_paths.
104 void VerifyAllPaths(const std::string& parent, 112 void VerifyAllPaths(const std::string& parent,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 212 }
205 this->processor_->ActionComplete(this, kActionCodeSuccess); 213 this->processor_->ActionComplete(this, kActionCodeSuccess);
206 } 214 }
207 static std::string StaticType() { return "ObjectCollectorAction"; } 215 static std::string StaticType() { return "ObjectCollectorAction"; }
208 std::string Type() const { return StaticType(); } 216 std::string Type() const { return StaticType(); }
209 const T& object() const { return object_; } 217 const T& object() const { return object_; }
210 private: 218 private:
211 T object_; 219 T object_;
212 }; 220 };
213 221
222 class ScopedLoopMounter {
223 public:
224 explicit ScopedLoopMounter(const std::string& file_path,
225 std::string* mnt_path,
226 unsigned long flags);
227
228 private:
229 // These objects must be destructed in the following order:
230 // ScopedFilesystemUnmounter (the file system must be unmounted first)
231 // ScopedLoopbackDeviceReleaser (then the loop device can be deleted)
232 // ScopedDirRemover (then the mount point can be deleted)
233 scoped_ptr<ScopedDirRemover> dir_remover_;
234 scoped_ptr<ScopedLoopbackDeviceReleaser> loop_releaser_;
235 scoped_ptr<ScopedFilesystemUnmounter> unmounter_;
236 };
237
214 } // namespace chromeos_update_engine 238 } // namespace chromeos_update_engine
215 239
216 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ 240 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698