| OLD | NEW |
| 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> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // parent. Also, verifies that no additional paths are present under parent. | 101 // parent. Also, verifies that no additional paths are present under parent. |
| 102 // Also tests properties of various files created by CreateExtImageAtPath(). | 102 // Also tests properties of various files created by CreateExtImageAtPath(). |
| 103 // Intentionally copies expected_paths. | 103 // Intentionally copies expected_paths. |
| 104 void VerifyAllPaths(const std::string& parent, | 104 void VerifyAllPaths(const std::string& parent, |
| 105 std::set<std::string> expected_paths); | 105 std::set<std::string> expected_paths); |
| 106 | 106 |
| 107 class ScopedLoopbackDeviceReleaser { | 107 class ScopedLoopbackDeviceReleaser { |
| 108 public: | 108 public: |
| 109 explicit ScopedLoopbackDeviceReleaser(const std::string& dev) : dev_(dev) {} | 109 explicit ScopedLoopbackDeviceReleaser(const std::string& dev) : dev_(dev) {} |
| 110 ~ScopedLoopbackDeviceReleaser() { | 110 ~ScopedLoopbackDeviceReleaser() { |
| 111 std::vector<std::string> args; | 111 for (int retry = 0; retry < 5; retry++) { |
| 112 args.push_back("/sbin/losetup"); | 112 std::vector<std::string> args; |
| 113 args.push_back("-d"); | 113 args.push_back("/sbin/losetup"); |
| 114 args.push_back(dev_); | 114 args.push_back("-d"); |
| 115 int return_code = 0; | 115 args.push_back(dev_); |
| 116 EXPECT_TRUE(Subprocess::SynchronousExec(args, &return_code)); | 116 int return_code = 0; |
| 117 EXPECT_EQ(0, return_code); | 117 EXPECT_TRUE(Subprocess::SynchronousExec(args, &return_code)); |
| 118 if (return_code == 0) { |
| 119 return; |
| 120 } |
| 121 sleep(1); |
| 122 } |
| 123 ADD_FAILURE(); |
| 118 } | 124 } |
| 119 private: | 125 private: |
| 120 const std::string dev_; | 126 const std::string dev_; |
| 121 DISALLOW_COPY_AND_ASSIGN(ScopedLoopbackDeviceReleaser); | 127 DISALLOW_COPY_AND_ASSIGN(ScopedLoopbackDeviceReleaser); |
| 122 }; | 128 }; |
| 123 | 129 |
| 124 class ScopedTempFile { | 130 class ScopedTempFile { |
| 125 public: | 131 public: |
| 126 ScopedTempFile() { | 132 ScopedTempFile() { |
| 127 EXPECT_TRUE(utils::MakeTempFile("/tmp/update_engine_test_temp_file.XXXXXX", | 133 EXPECT_TRUE(utils::MakeTempFile("/tmp/update_engine_test_temp_file.XXXXXX", |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 static std::string StaticType() { return "ObjectCollectorAction"; } | 207 static std::string StaticType() { return "ObjectCollectorAction"; } |
| 202 std::string Type() const { return StaticType(); } | 208 std::string Type() const { return StaticType(); } |
| 203 const T& object() const { return object_; } | 209 const T& object() const { return object_; } |
| 204 private: | 210 private: |
| 205 T object_; | 211 T object_; |
| 206 }; | 212 }; |
| 207 | 213 |
| 208 } // namespace chromeos_update_engine | 214 } // namespace chromeos_update_engine |
| 209 | 215 |
| 210 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ | 216 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ |
| OLD | NEW |