OLD | NEW |
1 // Copyright (c) 2009 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 #include <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 #include <glib.h> | 7 #include <glib.h> |
8 #include <pthread.h> | 8 #include <pthread.h> |
9 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
10 #include "update_engine/download_action.h" | 10 #include "update_engine/download_action.h" |
11 #include "update_engine/install_action.h" | 11 #include "update_engine/install_action.h" |
(...skipping 21 matching lines...) Expand all Loading... |
33 namespace { | 33 namespace { |
34 const char* kTestDir = "/tmp/update_engine-integration-test"; | 34 const char* kTestDir = "/tmp/update_engine-integration-test"; |
35 | 35 |
36 class IntegrationTestProcessorDelegate : public ActionProcessorDelegate { | 36 class IntegrationTestProcessorDelegate : public ActionProcessorDelegate { |
37 public: | 37 public: |
38 IntegrationTestProcessorDelegate() | 38 IntegrationTestProcessorDelegate() |
39 : loop_(NULL), processing_done_called_(false) {} | 39 : loop_(NULL), processing_done_called_(false) {} |
40 virtual ~IntegrationTestProcessorDelegate() { | 40 virtual ~IntegrationTestProcessorDelegate() { |
41 EXPECT_TRUE(processing_done_called_); | 41 EXPECT_TRUE(processing_done_called_); |
42 } | 42 } |
43 virtual void ProcessingDone(const ActionProcessor* processor, bool success) { | 43 virtual void ProcessingDone(const ActionProcessor* processor, |
| 44 ActionExitCode code) { |
44 processing_done_called_ = true; | 45 processing_done_called_ = true; |
45 g_main_loop_quit(loop_); | 46 g_main_loop_quit(loop_); |
46 } | 47 } |
47 | 48 |
48 virtual void ActionCompleted(ActionProcessor* processor, | 49 virtual void ActionCompleted(ActionProcessor* processor, |
49 AbstractAction* action, | 50 AbstractAction* action, |
50 bool success) { | 51 ActionExitCode code) { |
51 // make sure actions always succeed | 52 // make sure actions always succeed |
52 EXPECT_TRUE(success); | 53 EXPECT_EQ(kActionCodeSuccess, code); |
53 | 54 |
54 // Swap in the device path for PostinstallRunnerAction with a loop device | 55 // Swap in the device path for PostinstallRunnerAction with a loop device |
55 if (action->Type() == InstallAction::StaticType()) { | 56 if (action->Type() == InstallAction::StaticType()) { |
56 InstallAction* install_action = static_cast<InstallAction*>(action); | 57 InstallAction* install_action = static_cast<InstallAction*>(action); |
57 old_dev_ = install_action->GetOutputObject(); | 58 old_dev_ = install_action->GetOutputObject(); |
58 string dev = GetUnusedLoopDevice(); | 59 string dev = GetUnusedLoopDevice(); |
59 string cmd = string("losetup ") + dev + " " + kTestDir + "/dev2"; | 60 string cmd = string("losetup ") + dev + " " + kTestDir + "/dev2"; |
60 EXPECT_EQ(0, system(cmd.c_str())); | 61 EXPECT_EQ(0, system(cmd.c_str())); |
61 install_action->SetOutputObject(dev); | 62 install_action->SetOutputObject(dev); |
62 } else if (action->Type() == PostinstallRunnerAction::StaticType()) { | 63 } else if (action->Type() == PostinstallRunnerAction::StaticType()) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 "/tmp/update_engine_test_postinst_out.txt", | 184 "/tmp/update_engine_test_postinst_out.txt", |
184 &file_data)); | 185 &file_data)); |
185 EXPECT_EQ("POSTINST_DONE\n", file_data); | 186 EXPECT_EQ("POSTINST_DONE\n", file_data); |
186 | 187 |
187 // cleanup | 188 // cleanup |
188 ASSERT_EQ(0, System(string("rm -rf ") + kTestDir)); | 189 ASSERT_EQ(0, System(string("rm -rf ") + kTestDir)); |
189 ASSERT_EQ(0, system("rm -f /tmp/update_engine_test_postinst_out.txt")); | 190 ASSERT_EQ(0, system("rm -f /tmp/update_engine_test_postinst_out.txt")); |
190 } | 191 } |
191 | 192 |
192 } // namespace chromeos_update_engine | 193 } // namespace chromeos_update_engine |
OLD | NEW |