| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 <glib.h> | 5 #include <glib.h> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> |
| 7 #include <vector> | 8 #include <vector> |
| 8 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
| 9 #include "update_engine/filesystem_copier_action.h" | 10 #include "update_engine/filesystem_copier_action.h" |
| 10 #include "update_engine/filesystem_iterator.h" | 11 #include "update_engine/filesystem_iterator.h" |
| 11 #include "update_engine/omaha_hash_calculator.h" | 12 #include "update_engine/omaha_hash_calculator.h" |
| 12 #include "update_engine/test_utils.h" | 13 #include "update_engine/test_utils.h" |
| 13 #include "update_engine/utils.h" | 14 #include "update_engine/utils.h" |
| 14 | 15 |
| 15 using std::set; | 16 using std::set; |
| 17 using std::string; |
| 16 using std::vector; | 18 using std::vector; |
| 17 | 19 |
| 18 namespace chromeos_update_engine { | 20 namespace chromeos_update_engine { |
| 19 | 21 |
| 20 class FilesystemCopierActionTest : public ::testing::Test { | 22 class FilesystemCopierActionTest : public ::testing::Test { |
| 21 protected: | 23 protected: |
| 22 void DoTest(bool double_copy, bool run_out_of_space); | 24 void DoTest(bool double_copy, bool run_out_of_space); |
| 23 string TestDir() { return "./FilesystemCopierActionTestDir"; } | 25 string TestDir() { return "./FilesystemCopierActionTestDir"; } |
| 24 void SetUp() { | 26 void SetUp() { |
| 25 System(string("mkdir -p ") + TestDir()); | 27 System(string("mkdir -p ") + TestDir()); |
| 26 } | 28 } |
| 27 void TearDown() { | 29 void TearDown() { |
| 28 System(string("rm -rf ") + TestDir()); | 30 System(string("rm -rf ") + TestDir()); |
| 29 } | 31 } |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 class FilesystemCopierActionTestDelegate : public ActionProcessorDelegate { | 34 class FilesystemCopierActionTestDelegate : public ActionProcessorDelegate { |
| 33 public: | 35 public: |
| 34 FilesystemCopierActionTestDelegate() : ran_(false), success_(false) {} | 36 FilesystemCopierActionTestDelegate() : ran_(false), success_(false) {} |
| 35 void ProcessingDone(const ActionProcessor* processor) { | 37 void ProcessingDone(const ActionProcessor* processor, bool success) { |
| 36 g_main_loop_quit(loop_); | 38 g_main_loop_quit(loop_); |
| 37 } | 39 } |
| 38 void ActionCompleted(ActionProcessor* processor, | 40 void ActionCompleted(ActionProcessor* processor, |
| 39 AbstractAction* action, | 41 AbstractAction* action, |
| 40 bool success) { | 42 bool success) { |
| 41 if (action->Type() == FilesystemCopierAction::StaticType()) { | 43 if (action->Type() == FilesystemCopierAction::StaticType()) { |
| 42 ran_ = true; | 44 ran_ = true; |
| 43 success_ = success; | 45 success_ = success; |
| 44 } | 46 } |
| 45 } | 47 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 ASSERT_EQ(0, getuid()); | 266 ASSERT_EQ(0, getuid()); |
| 265 DoTest(true, false); | 267 DoTest(true, false); |
| 266 } | 268 } |
| 267 | 269 |
| 268 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) { | 270 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) { |
| 269 ASSERT_EQ(0, getuid()); | 271 ASSERT_EQ(0, getuid()); |
| 270 DoTest(false, true); | 272 DoTest(false, true); |
| 271 } | 273 } |
| 272 | 274 |
| 273 } // namespace chromeos_update_engine | 275 } // namespace chromeos_update_engine |
| OLD | NEW |