| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 EXPECT_EQ(0, System(StringPrintf("echo hello > %s/hello", kMountPath))); | 201 EXPECT_EQ(0, System(StringPrintf("echo hello > %s/hello", kMountPath))); |
| 202 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir", kMountPath))); | 202 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir", kMountPath))); |
| 203 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/empty_dir", kMountPath))); | 203 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/empty_dir", kMountPath))); |
| 204 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/mnt", kMountPath))); | 204 EXPECT_EQ(0, System(StringPrintf("mkdir %s/some_dir/mnt", kMountPath))); |
| 205 EXPECT_EQ(0, System(StringPrintf("echo T > %s/some_dir/test", kMountPath))); | 205 EXPECT_EQ(0, System(StringPrintf("echo T > %s/some_dir/test", kMountPath))); |
| 206 EXPECT_EQ(0, System(StringPrintf("mkfifo %s/some_dir/fifo", kMountPath))); | 206 EXPECT_EQ(0, System(StringPrintf("mkfifo %s/some_dir/fifo", kMountPath))); |
| 207 EXPECT_EQ(0, System(StringPrintf("mknod %s/cdev c 2 3", kMountPath))); | 207 EXPECT_EQ(0, System(StringPrintf("mknod %s/cdev c 2 3", kMountPath))); |
| 208 EXPECT_EQ(0, System(StringPrintf("ln -s /some/target %s/sym", kMountPath))); | 208 EXPECT_EQ(0, System(StringPrintf("ln -s /some/target %s/sym", kMountPath))); |
| 209 EXPECT_EQ(0, System(StringPrintf("ln %s/some_dir/test %s/testlink", | 209 EXPECT_EQ(0, System(StringPrintf("ln %s/some_dir/test %s/testlink", |
| 210 kMountPath, kMountPath))); | 210 kMountPath, kMountPath))); |
| 211 EXPECT_EQ(0, System(StringPrintf("echo T > %s/srchardlink0", kMountPath))); |
| 212 EXPECT_EQ(0, System(StringPrintf("ln %s/srchardlink0 %s/srchardlink1", |
| 213 kMountPath, kMountPath))); |
| 211 EXPECT_EQ(0, System(StringPrintf("umount -d %s", kMountPath))); | 214 EXPECT_EQ(0, System(StringPrintf("umount -d %s", kMountPath))); |
| 212 | 215 |
| 213 if (out_paths) { | 216 if (out_paths) { |
| 214 out_paths->clear(); | 217 out_paths->clear(); |
| 215 out_paths->push_back(""); | 218 out_paths->push_back(""); |
| 216 out_paths->push_back("/hi"); | 219 out_paths->push_back("/hi"); |
| 217 out_paths->push_back("/hello"); | 220 out_paths->push_back("/hello"); |
| 218 out_paths->push_back("/some_dir"); | 221 out_paths->push_back("/some_dir"); |
| 219 out_paths->push_back("/some_dir/empty_dir"); | 222 out_paths->push_back("/some_dir/empty_dir"); |
| 220 out_paths->push_back("/some_dir/mnt"); | 223 out_paths->push_back("/some_dir/mnt"); |
| 221 out_paths->push_back("/some_dir/test"); | 224 out_paths->push_back("/some_dir/test"); |
| 222 out_paths->push_back("/some_dir/fifo"); | 225 out_paths->push_back("/some_dir/fifo"); |
| 223 out_paths->push_back("/cdev"); | 226 out_paths->push_back("/cdev"); |
| 224 out_paths->push_back("/testlink"); | 227 out_paths->push_back("/testlink"); |
| 225 out_paths->push_back("/sym"); | 228 out_paths->push_back("/sym"); |
| 229 out_paths->push_back("/srchardlink0"); |
| 230 out_paths->push_back("/srchardlink1"); |
| 226 out_paths->push_back("/lost+found"); | 231 out_paths->push_back("/lost+found"); |
| 227 } | 232 } |
| 228 } | 233 } |
| 229 | 234 |
| 230 void VerifyAllPaths(const string& parent, set<string> expected_paths) { | 235 void VerifyAllPaths(const string& parent, set<string> expected_paths) { |
| 231 FilesystemIterator iter(parent, set<string>()); | 236 FilesystemIterator iter(parent, set<string>()); |
| 232 ino_t test_ino = 0; | 237 ino_t test_ino = 0; |
| 233 ino_t testlink_ino = 0; | 238 ino_t testlink_ino = 0; |
| 234 while (!iter.IsEnd()) { | 239 while (!iter.IsEnd()) { |
| 235 string path = iter.GetFullPath(); | 240 string path = iter.GetFullPath(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 std::string loop_dev = GetUnusedLoopDevice(); | 287 std::string loop_dev = GetUnusedLoopDevice(); |
| 283 EXPECT_EQ(0, system(StringPrintf("losetup %s %s", loop_dev.c_str(), | 288 EXPECT_EQ(0, system(StringPrintf("losetup %s %s", loop_dev.c_str(), |
| 284 file_path.c_str()).c_str())); | 289 file_path.c_str()).c_str())); |
| 285 loop_releaser_.reset(new ScopedLoopbackDeviceReleaser(loop_dev)); | 290 loop_releaser_.reset(new ScopedLoopbackDeviceReleaser(loop_dev)); |
| 286 | 291 |
| 287 EXPECT_TRUE(utils::MountFilesystem(loop_dev, *mnt_path, flags)); | 292 EXPECT_TRUE(utils::MountFilesystem(loop_dev, *mnt_path, flags)); |
| 288 unmounter_.reset(new ScopedFilesystemUnmounter(*mnt_path)); | 293 unmounter_.reset(new ScopedFilesystemUnmounter(*mnt_path)); |
| 289 } | 294 } |
| 290 | 295 |
| 291 } // namespace chromeos_update_engine | 296 } // namespace chromeos_update_engine |
| OLD | NEW |