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

Side by Side Diff: src/platform/update_engine/omaha_request_prep_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 <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 #include <gtest/gtest.h> 7 #include <gtest/gtest.h>
8 #include "update_engine/install_plan.h" 8 #include "update_engine/install_plan.h"
9 #include "update_engine/omaha_request_prep_action.h" 9 #include "update_engine/omaha_request_prep_action.h"
10 #include "update_engine/test_utils.h" 10 #include "update_engine/test_utils.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 } // namespace {} 105 } // namespace {}
106 106
107 TEST_F(OmahaRequestPrepActionTest, SimpleTest) { 107 TEST_F(OmahaRequestPrepActionTest, SimpleTest) {
108 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc")); 108 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc"));
109 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + 109 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir +
110 utils::kStatefulPartition + "/etc")); 110 utils::kStatefulPartition + "/etc"));
111 { 111 {
112 ASSERT_TRUE(WriteFileString( 112 ASSERT_TRUE(WriteFileString(
113 kTestDir + "/etc/lsb-release", 113 kTestDir + "/etc/lsb-release",
114 "GOOGLE_FOO=bar\nGOOGLE_RELEASE=0.2.2.3\nGOOGLE_TRACK=footrack")); 114 "CHROMEOS_RELEASE_FOO=bar\n"
115 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n"
116 "CHROMEOS_RELEASE_TRACK=footrack"));
115 UpdateCheckParams out; 117 UpdateCheckParams out;
116 EXPECT_TRUE(DoTest(false, &out)); 118 EXPECT_TRUE(DoTest(false, &out));
117 EXPECT_TRUE(IsValidGuid(out.machine_id)) << "id: " << out.machine_id; 119 EXPECT_TRUE(IsValidGuid(out.machine_id)) << "id: " << out.machine_id;
118 // for now we're just using the machine id here 120 // for now we're just using the machine id here
119 EXPECT_TRUE(IsValidGuid(out.user_id)) << "id: " << out.user_id; 121 EXPECT_TRUE(IsValidGuid(out.user_id)) << "id: " << out.user_id;
120 EXPECT_EQ("Chrome OS", out.os_platform); 122 EXPECT_EQ("Chrome OS", out.os_platform);
121 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp); 123 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
122 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id); 124 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id);
123 EXPECT_EQ("0.2.2.3", out.app_version); 125 EXPECT_EQ("0.2.2.3", out.app_version);
124 EXPECT_EQ("en-US", out.app_lang); 126 EXPECT_EQ("en-US", out.app_lang);
125 EXPECT_EQ("footrack", out.app_track); 127 EXPECT_EQ("footrack", out.app_track);
126 } 128 }
127 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir)); 129 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir));
128 } 130 }
129 131
130 TEST_F(OmahaRequestPrepActionTest, MissingTrackTest) { 132 TEST_F(OmahaRequestPrepActionTest, MissingTrackTest) {
131 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc")); 133 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc"));
132 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + 134 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir +
133 utils::kStatefulPartition + "/etc")); 135 utils::kStatefulPartition + "/etc"));
134 { 136 {
135 ASSERT_TRUE(WriteFileString( 137 ASSERT_TRUE(WriteFileString(
136 kTestDir + "/etc/lsb-release", 138 kTestDir + "/etc/lsb-release",
137 "GOOGLE_FOO=bar\nGOOGLE_RELEASE=0.2.2.3\nGOOGLE_TRXCK=footrack")); 139 "CHROMEOS_RELEASE_FOO=bar\n"
140 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n"
141 "CHROMEOS_RELEASE_TRXCK=footrack"));
138 UpdateCheckParams out; 142 UpdateCheckParams out;
139 EXPECT_TRUE(DoTest(false, &out)); 143 EXPECT_TRUE(DoTest(false, &out));
140 EXPECT_TRUE(IsValidGuid(out.machine_id)); 144 EXPECT_TRUE(IsValidGuid(out.machine_id));
141 // for now we're just using the machine id here 145 // for now we're just using the machine id here
142 EXPECT_TRUE(IsValidGuid(out.user_id)); 146 EXPECT_TRUE(IsValidGuid(out.user_id));
143 EXPECT_EQ("Chrome OS", out.os_platform); 147 EXPECT_EQ("Chrome OS", out.os_platform);
144 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp); 148 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
145 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id); 149 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id);
146 EXPECT_EQ("0.2.2.3", out.app_version); 150 EXPECT_EQ("0.2.2.3", out.app_version);
147 EXPECT_EQ("en-US", out.app_lang); 151 EXPECT_EQ("en-US", out.app_lang);
148 EXPECT_EQ("", out.app_track); 152 EXPECT_EQ("", out.app_track);
149 } 153 }
150 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir)); 154 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir));
151 } 155 }
152 156
153 TEST_F(OmahaRequestPrepActionTest, ConfusingReleaseTest) { 157 TEST_F(OmahaRequestPrepActionTest, ConfusingReleaseTest) {
154 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc")); 158 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc"));
155 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + 159 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir +
156 utils::kStatefulPartition + "/etc")); 160 utils::kStatefulPartition + "/etc"));
157 { 161 {
158 ASSERT_TRUE(WriteFileString( 162 ASSERT_TRUE(WriteFileString(
159 kTestDir + "/etc/lsb-release", 163 kTestDir + "/etc/lsb-release",
160 "GOOGLE_FOO=GOOGLE_RELEASE=1.2.3.4\n" 164 "CHROMEOS_RELEASE_FOO=CHROMEOS_RELEASE_VERSION=1.2.3.4\n"
161 "GOOGLE_RELEASE=0.2.2.3\nGOOGLE_TRXCK=footrack")); 165 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n"
166 "CHROMEOS_RELEASE_TRXCK=footrack"));
162 UpdateCheckParams out; 167 UpdateCheckParams out;
163 EXPECT_TRUE(DoTest(false, &out)); 168 EXPECT_TRUE(DoTest(false, &out));
164 EXPECT_TRUE(IsValidGuid(out.machine_id)) << out.machine_id; 169 EXPECT_TRUE(IsValidGuid(out.machine_id)) << out.machine_id;
165 // for now we're just using the machine id here 170 // for now we're just using the machine id here
166 EXPECT_TRUE(IsValidGuid(out.user_id)); 171 EXPECT_TRUE(IsValidGuid(out.user_id));
167 EXPECT_EQ("Chrome OS", out.os_platform); 172 EXPECT_EQ("Chrome OS", out.os_platform);
168 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp); 173 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
169 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id); 174 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id);
170 EXPECT_EQ("0.2.2.3", out.app_version); 175 EXPECT_EQ("0.2.2.3", out.app_version);
171 EXPECT_EQ("en-US", out.app_lang); 176 EXPECT_EQ("en-US", out.app_lang);
172 EXPECT_EQ("", out.app_track); 177 EXPECT_EQ("", out.app_track);
173 } 178 }
174 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir)); 179 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir));
175 } 180 }
176 181
177 TEST_F(OmahaRequestPrepActionTest, MachineIdPersistsTest) { 182 TEST_F(OmahaRequestPrepActionTest, MachineIdPersistsTest) {
178 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc")); 183 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + "/etc"));
179 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir + 184 ASSERT_EQ(0, System(string("mkdir -p ") + kTestDir +
180 utils::kStatefulPartition + "/etc")); 185 utils::kStatefulPartition + "/etc"));
181 ASSERT_TRUE(WriteFileString( 186 ASSERT_TRUE(WriteFileString(
182 kTestDir + "/etc/lsb-release", 187 kTestDir + "/etc/lsb-release",
183 "GOOGLE_FOO=GOOGLE_RELEASE=1.2.3.4\n" 188 "CHROMEOS_RELEASE_FOO=CHROMEOS_RELEASE_VERSION=1.2.3.4\n"
184 "GOOGLE_RELEASE=0.2.2.3\nGOOGLE_TRXCK=footrack")); 189 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n"
190 "CHROMEOS_RELEASE_TRXCK=footrack"));
185 UpdateCheckParams out1; 191 UpdateCheckParams out1;
186 EXPECT_TRUE(DoTest(false, &out1)); 192 EXPECT_TRUE(DoTest(false, &out1));
187 string machine_id; 193 string machine_id;
188 EXPECT_TRUE(utils::ReadFileToString( 194 EXPECT_TRUE(utils::ReadFileToString(
189 kTestDir + 195 kTestDir +
190 utils::kStatefulPartition + "/etc/omaha_id", 196 utils::kStatefulPartition + "/etc/omaha_id",
191 &machine_id)); 197 &machine_id));
192 EXPECT_EQ(machine_id, out1.machine_id); 198 EXPECT_EQ(machine_id, out1.machine_id);
193 UpdateCheckParams out2; 199 UpdateCheckParams out2;
194 EXPECT_TRUE(DoTest(false, &out2)); 200 EXPECT_TRUE(DoTest(false, &out2));
195 EXPECT_EQ(machine_id, out2.machine_id); 201 EXPECT_EQ(machine_id, out2.machine_id);
196 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir)); 202 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir));
197 } 203 }
198 204
199 } // namespace chromeos_update_engine 205 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/omaha_request_prep_action.cc ('k') | src/platform/update_engine/postinstall_runner_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698