| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium 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 #include <glib.h> | 5 #include <glib.h> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "update_engine/filesystem_copier_action.h" | 11 #include "update_engine/filesystem_copier_action.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 TEST_F(FilesystemCopierActionTest, FullUpdateTest) { | 226 TEST_F(FilesystemCopierActionTest, FullUpdateTest) { |
| 227 ActionProcessor processor; | 227 ActionProcessor processor; |
| 228 FilesystemCopierActionTest2Delegate delegate; | 228 FilesystemCopierActionTest2Delegate delegate; |
| 229 | 229 |
| 230 processor.set_delegate(&delegate); | 230 processor.set_delegate(&delegate); |
| 231 | 231 |
| 232 ObjectFeederAction<InstallPlan> feeder_action; | 232 ObjectFeederAction<InstallPlan> feeder_action; |
| 233 const char* kUrl = "http://some/url"; | 233 const char* kUrl = "http://some/url"; |
| 234 InstallPlan install_plan(true, kUrl, 0, "", "", ""); | 234 InstallPlan install_plan(true, false, kUrl, 0, "", "", ""); |
| 235 feeder_action.set_obj(install_plan); | 235 feeder_action.set_obj(install_plan); |
| 236 FilesystemCopierAction copier_action(false); | 236 FilesystemCopierAction copier_action(false); |
| 237 ObjectCollectorAction<InstallPlan> collector_action; | 237 ObjectCollectorAction<InstallPlan> collector_action; |
| 238 | 238 |
| 239 BondActions(&feeder_action, &copier_action); | 239 BondActions(&feeder_action, &copier_action); |
| 240 BondActions(&copier_action, &collector_action); | 240 BondActions(&copier_action, &collector_action); |
| 241 | 241 |
| 242 processor.EnqueueAction(&feeder_action); | 242 processor.EnqueueAction(&feeder_action); |
| 243 processor.EnqueueAction(&copier_action); | 243 processor.EnqueueAction(&copier_action); |
| 244 processor.EnqueueAction(&collector_action); | 244 processor.EnqueueAction(&collector_action); |
| 245 processor.StartProcessing(); | 245 processor.StartProcessing(); |
| 246 EXPECT_FALSE(processor.IsRunning()); | 246 EXPECT_FALSE(processor.IsRunning()); |
| 247 EXPECT_TRUE(delegate.ran_); | 247 EXPECT_TRUE(delegate.ran_); |
| 248 EXPECT_EQ(kActionCodeSuccess, delegate.code_); | 248 EXPECT_EQ(kActionCodeSuccess, delegate.code_); |
| 249 EXPECT_EQ(kUrl, collector_action.object().download_url); | 249 EXPECT_EQ(kUrl, collector_action.object().download_url); |
| 250 } | 250 } |
| 251 | 251 |
| 252 TEST_F(FilesystemCopierActionTest, NonExistentDriveTest) { | 252 TEST_F(FilesystemCopierActionTest, NonExistentDriveTest) { |
| 253 ActionProcessor processor; | 253 ActionProcessor processor; |
| 254 FilesystemCopierActionTest2Delegate delegate; | 254 FilesystemCopierActionTest2Delegate delegate; |
| 255 | 255 |
| 256 processor.set_delegate(&delegate); | 256 processor.set_delegate(&delegate); |
| 257 | 257 |
| 258 ObjectFeederAction<InstallPlan> feeder_action; | 258 ObjectFeederAction<InstallPlan> feeder_action; |
| 259 InstallPlan install_plan(false, "", 0, "", "/no/such/file", "/no/such/file"); | 259 InstallPlan install_plan(false, |
| 260 false, |
| 261 "", |
| 262 0, |
| 263 "", |
| 264 "/no/such/file", |
| 265 "/no/such/file"); |
| 260 feeder_action.set_obj(install_plan); | 266 feeder_action.set_obj(install_plan); |
| 261 FilesystemCopierAction copier_action(false); | 267 FilesystemCopierAction copier_action(false); |
| 262 ObjectCollectorAction<InstallPlan> collector_action; | 268 ObjectCollectorAction<InstallPlan> collector_action; |
| 263 | 269 |
| 264 BondActions(&copier_action, &collector_action); | 270 BondActions(&copier_action, &collector_action); |
| 265 | 271 |
| 266 processor.EnqueueAction(&feeder_action); | 272 processor.EnqueueAction(&feeder_action); |
| 267 processor.EnqueueAction(&copier_action); | 273 processor.EnqueueAction(&copier_action); |
| 268 processor.EnqueueAction(&collector_action); | 274 processor.EnqueueAction(&collector_action); |
| 269 processor.StartProcessing(); | 275 processor.StartProcessing(); |
| 270 EXPECT_FALSE(processor.IsRunning()); | 276 EXPECT_FALSE(processor.IsRunning()); |
| 271 EXPECT_TRUE(delegate.ran_); | 277 EXPECT_TRUE(delegate.ran_); |
| 272 EXPECT_EQ(kActionCodeError, delegate.code_); | 278 EXPECT_EQ(kActionCodeError, delegate.code_); |
| 273 } | 279 } |
| 274 | 280 |
| 275 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) { | 281 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) { |
| 276 ASSERT_EQ(0, getuid()); | 282 ASSERT_EQ(0, getuid()); |
| 277 DoTest(true, false, false); | 283 DoTest(true, false, false); |
| 278 } | 284 } |
| 279 | 285 |
| 280 TEST_F(FilesystemCopierActionTest, RunAsRootTerminateEarlyTest) { | 286 TEST_F(FilesystemCopierActionTest, RunAsRootTerminateEarlyTest) { |
| 281 ASSERT_EQ(0, getuid()); | 287 ASSERT_EQ(0, getuid()); |
| 282 DoTest(false, true, false); | 288 DoTest(false, true, false); |
| 283 } | 289 } |
| 284 | 290 |
| 285 } // namespace chromeos_update_engine | 291 } // namespace chromeos_update_engine |
| OLD | NEW |