OLD | NEW |
---|---|
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 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 171 |
172 void FillWithData(vector<char>* buffer) { | 172 void FillWithData(vector<char>* buffer) { |
173 size_t input_counter = 0; | 173 size_t input_counter = 0; |
174 for (vector<char>::iterator it = buffer->begin(); it != buffer->end(); ++it) { | 174 for (vector<char>::iterator it = buffer->begin(); it != buffer->end(); ++it) { |
175 *it = kRandomString[input_counter]; | 175 *it = kRandomString[input_counter]; |
176 input_counter++; | 176 input_counter++; |
177 input_counter %= sizeof(kRandomString); | 177 input_counter %= sizeof(kRandomString); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 void CreateEmptyExtImageAtPath(const string& path, | |
182 size_t size, | |
183 int block_size) { | |
184 EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s" | |
185 " seek=%Zu bs=1 count=1", | |
petkov
2010/12/10 00:46:55
what's %Zu?
thieule
2010/12/14 23:11:21
Looks like %Zu is outdated and the proper format i
| |
186 path.c_str(), size))); | |
187 EXPECT_EQ(0, System(StringPrintf("mkfs.ext3 -b %d -F %s", | |
petkov
2010/12/10 00:46:55
we use ext2 now, right?
thieule
2010/12/14 23:11:21
This is a little bit more involved than just here.
| |
188 block_size, path.c_str()))); | |
189 } | |
190 | |
181 void CreateExtImageAtPath(const string& path, vector<string>* out_paths) { | 191 void CreateExtImageAtPath(const string& path, vector<string>* out_paths) { |
182 // create 10MiB sparse file | 192 // create 10MiB sparse file |
183 EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s" | 193 EXPECT_EQ(0, System(StringPrintf("dd if=/dev/zero of=%s" |
184 " seek=10485759 bs=1 count=1", | 194 " seek=10485759 bs=1 count=1", |
185 path.c_str()))); | 195 path.c_str()))); |
186 EXPECT_EQ(0, System(StringPrintf("mkfs.ext3 -b 4096 -F %s", path.c_str()))); | 196 EXPECT_EQ(0, System(StringPrintf("mkfs.ext3 -b 4096 -F %s", path.c_str()))); |
187 EXPECT_EQ(0, System(StringPrintf("mkdir -p %s", kMountPath))); | 197 EXPECT_EQ(0, System(StringPrintf("mkdir -p %s", kMountPath))); |
188 EXPECT_EQ(0, System(StringPrintf("mount -o loop %s %s", path.c_str(), | 198 EXPECT_EQ(0, System(StringPrintf("mount -o loop %s %s", path.c_str(), |
189 kMountPath))); | 199 kMountPath))); |
190 EXPECT_EQ(0, System(StringPrintf("echo hi > %s/hi", kMountPath))); | 200 EXPECT_EQ(0, System(StringPrintf("echo hi > %s/hi", kMountPath))); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 EXPECT_TRUE(expected_paths.empty()); | 267 EXPECT_TRUE(expected_paths.empty()); |
258 if (!expected_paths.empty()) { | 268 if (!expected_paths.empty()) { |
259 for (set<string>::const_iterator it = expected_paths.begin(); | 269 for (set<string>::const_iterator it = expected_paths.begin(); |
260 it != expected_paths.end(); ++it) { | 270 it != expected_paths.end(); ++it) { |
261 LOG(INFO) << "extra path: " << *it; | 271 LOG(INFO) << "extra path: " << *it; |
262 } | 272 } |
263 } | 273 } |
264 } | 274 } |
265 | 275 |
266 } // namespace chromeos_update_engine | 276 } // namespace chromeos_update_engine |
OLD | NEW |