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

Side by Side Diff: src/platform/update_engine/test_utils.cc

Issue 467051: AU: Use Omaha ID rather than MAC address in delta updater (Closed)
Patch Set: fixes for review Created 11 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
« no previous file with comments | « src/platform/update_engine/test_utils.h ('k') | src/platform/update_engine/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "update_engine/test_utils.h" 5 #include "update_engine/test_utils.h"
6 #include <sys/stat.h> 6 #include <sys/stat.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "chromeos/obsolete_logging.h" 16 #include "chromeos/obsolete_logging.h"
17 17
18 #include "update_engine/file_writer.h" 18 #include "update_engine/file_writer.h"
19 #include "update_engine/filesystem_iterator.h" 19 #include "update_engine/filesystem_iterator.h"
20 #include "update_engine/utils.h" 20 #include "update_engine/utils.h"
21 21
22 using std::set; 22 using std::set;
23 using std::string; 23 using std::string;
24 using std::vector; 24 using std::vector;
25 25
26 namespace chromeos_update_engine { 26 namespace chromeos_update_engine {
27 27
28 bool WriteFile(const char* path, const char* data, int data_len) {
29 DirectFileWriter writer;
30 TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path,
31 O_WRONLY | O_CREAT | O_TRUNC,
32 0666));
33 ScopedFileWriterCloser closer(&writer);
34 TEST_AND_RETURN_FALSE_ERRNO(data_len == writer.Write(data, data_len));
35 return true;
36 }
37
38 bool WriteFileVector(const std::string& path, const std::vector<char>& data) { 28 bool WriteFileVector(const std::string& path, const std::vector<char>& data) {
39 return WriteFile(path.c_str(), &data[0], data.size()); 29 return utils::WriteFile(path.c_str(), &data[0], data.size());
40 } 30 }
41 31
42 bool WriteFileString(const std::string& path, const std::string& data) { 32 bool WriteFileString(const std::string& path, const std::string& data) {
43 return WriteFile(path.c_str(), data.data(), data.size()); 33 return utils::WriteFile(path.c_str(), data.data(), data.size());
44 } 34 }
45 35
46 off_t FileSize(const string& path) { 36 off_t FileSize(const string& path) {
47 struct stat stbuf; 37 struct stat stbuf;
48 int rc = stat(path.c_str(), &stbuf); 38 int rc = stat(path.c_str(), &stbuf);
49 CHECK_EQ(rc, 0); 39 CHECK_EQ(rc, 0);
50 if (rc < 0) 40 if (rc < 0)
51 return rc; 41 return rc;
52 return stbuf.st_size; 42 return stbuf.st_size;
53 } 43 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 EXPECT_TRUE(expected_paths.empty()); 255 EXPECT_TRUE(expected_paths.empty());
266 if (!expected_paths.empty()) { 256 if (!expected_paths.empty()) {
267 for (set<string>::const_iterator it = expected_paths.begin(); 257 for (set<string>::const_iterator it = expected_paths.begin();
268 it != expected_paths.end(); ++it) { 258 it != expected_paths.end(); ++it) {
269 LOG(INFO) << "extra path: " << *it; 259 LOG(INFO) << "extra path: " << *it;
270 } 260 }
271 } 261 }
272 } 262 }
273 263
274 } // namespace chromeos_update_engine 264 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/test_utils.h ('k') | src/platform/update_engine/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698