Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: src/platform/update_engine/postinstall_runner_action_unittest.cc

Issue 1881001: AU: Many minor cleanup changes (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <sys/stat.h> 5 #include <sys/stat.h>
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include <gtest/gtest.h> 10 #include <gtest/gtest.h>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 fclose(find_dev_cmd); 103 fclose(find_dev_cmd);
104 104
105 // strip trailing newline on dev 105 // strip trailing newline on dev
106 if (dev[strlen(dev) - 1] == '\n') 106 if (dev[strlen(dev) - 1] == '\n')
107 dev[strlen(dev) - 1] = '\0'; 107 dev[strlen(dev) - 1] = '\0';
108 108
109 if (do_losetup) 109 if (do_losetup)
110 ASSERT_EQ(0, System(string("losetup ") + dev + " " + cwd + "/image.dat")); 110 ASSERT_EQ(0, System(string("losetup ") + dev + " " + cwd + "/image.dat"));
111 111
112 ActionProcessor processor; 112 ActionProcessor processor;
113 ObjectFeederAction<string> feeder_action; 113 ObjectFeederAction<InstallPlan> feeder_action;
114 feeder_action.set_obj(dev); 114 InstallPlan install_plan;
115 PostinstallRunnerAction runner_action; 115 install_plan.install_path = dev;
116 feeder_action.set_obj(install_plan);
117 PostinstallRunnerAction runner_action(true);
116 BondActions(&feeder_action, &runner_action); 118 BondActions(&feeder_action, &runner_action);
117 ObjectCollectorAction<string> collector_action; 119 ObjectCollectorAction<InstallPlan> collector_action;
118 BondActions(&runner_action, &collector_action); 120 BondActions(&runner_action, &collector_action);
119 PostinstActionProcessorDelegate delegate; 121 PostinstActionProcessorDelegate delegate;
120 processor.EnqueueAction(&feeder_action); 122 processor.EnqueueAction(&feeder_action);
121 processor.EnqueueAction(&runner_action); 123 processor.EnqueueAction(&runner_action);
122 processor.EnqueueAction(&collector_action); 124 processor.EnqueueAction(&collector_action);
123 processor.set_delegate(&delegate); 125 processor.set_delegate(&delegate);
124 processor.StartProcessing(); 126 processor.StartProcessing();
125 ASSERT_FALSE(processor.IsRunning()) 127 ASSERT_FALSE(processor.IsRunning())
126 << "Update test to handle non-asynch actions"; 128 << "Update test to handle non-asynch actions";
127 129
128 EXPECT_TRUE(delegate.success_set_); 130 EXPECT_TRUE(delegate.success_set_);
129 EXPECT_EQ(do_losetup && !do_err_script, delegate.success_); 131 EXPECT_EQ(do_losetup && !do_err_script, delegate.success_);
130 EXPECT_EQ(do_losetup && !do_err_script, !collector_action.object().empty()); 132 EXPECT_EQ(do_losetup && !do_err_script,
133 !collector_action.object().install_path.empty());
131 if (do_losetup && !do_err_script) { 134 if (do_losetup && !do_err_script) {
132 EXPECT_EQ(dev, collector_action.object()); 135 EXPECT_TRUE(install_plan == collector_action.object());
133 } 136 }
134 137
135 struct stat stbuf; 138 struct stat stbuf;
136 int rc = lstat((string(cwd) + "/postinst_called").c_str(), &stbuf); 139 int rc = lstat((string(cwd) + "/postinst_called").c_str(), &stbuf);
137 if (do_losetup && !do_err_script) 140 if (do_losetup && !do_err_script)
138 ASSERT_EQ(0, rc); 141 ASSERT_EQ(0, rc);
139 else 142 else
140 ASSERT_LT(rc, 0); 143 ASSERT_LT(rc, 0);
141 144
142 if (do_losetup) 145 if (do_losetup)
143 ASSERT_EQ(0, System(string("losetup -d ") + dev)); 146 ASSERT_EQ(0, System(string("losetup -d ") + dev));
144 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/postinst_called")); 147 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/postinst_called"));
145 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/image.dat")); 148 ASSERT_EQ(0, System(string("rm -f ") + cwd + "/image.dat"));
146 } 149 }
147 150
148 // Death tests don't seem to be working on Hardy 151 // Death tests don't seem to be working on Hardy
149 TEST_F(PostinstallRunnerActionTest, DISABLED_RunAsRootDeathTest) { 152 TEST_F(PostinstallRunnerActionTest, DISABLED_RunAsRootDeathTest) {
150 ASSERT_EQ(0, getuid()); 153 ASSERT_EQ(0, getuid());
151 PostinstallRunnerAction runner_action; 154 PostinstallRunnerAction runner_action(true);
152 ASSERT_DEATH({ runner_action.TerminateProcessing(); }, 155 ASSERT_DEATH({ runner_action.TerminateProcessing(); },
153 "postinstall_runner_action.h:.*] Check failed"); 156 "postinstall_runner_action.h:.*] Check failed");
154 } 157 }
155 158
156 } // namespace chromeos_update_engine 159 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/postinstall_runner_action.cc ('k') | src/platform/update_engine/set_bootable_flag_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698