Update engine should use the release channel policy if it exists.
The release channel (aka update track) can be specified by a device
policy. When this is the case, the update engine should use the
value specified by the policy instead of the value specified in
/etc/lsb-release.
BUG=chromium-os:17015
TEST=Added two new tests:
- Added test that OmahaRequestParams uses the release channel passed
in to it when the value is valid, and otherwise uses /etc/lsb-release.
- Added test that the update engine correctly picks up the release
channel that's specified by the policy.
Change-Id: I2fe03712220bb3286476b12cd1f1b330ad006d7c
Reviewed-on: http://gerrit.chromium.org/gerrit/5072
Tested-by: Patrick Dubroy <dubroy@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
diff --git a/omaha_request_params_unittest.cc b/omaha_request_params_unittest.cc
index 458f582..d59afcd 100644
--- a/omaha_request_params_unittest.cc
+++ b/omaha_request_params_unittest.cc
@@ -47,7 +47,7 @@
bool OmahaRequestDeviceParamsTest::DoTest(OmahaRequestParams* out,
const string& app_version,
const string& omaha_url) {
- bool success = params_.Init(app_version, omaha_url);
+ bool success = params_.Init(app_version, omaha_url, "");
if (out)
*out = params_;
return success;
@@ -326,7 +326,7 @@
OmahaRequestDeviceParams params;
params.set_root(string("./") + kTestDir);
params.SetLockDown(false);
- EXPECT_TRUE(params.Init("", ""));
+ EXPECT_TRUE(params.Init("", "", ""));
params.SetTrack("zootrack");
}
OmahaRequestParams out;
@@ -351,7 +351,7 @@
OmahaRequestDeviceParams params;
params.set_root(string("./") + kTestDir);
params.SetLockDown(false);
- EXPECT_TRUE(params.Init("", ""));
+ EXPECT_TRUE(params.Init("", "", ""));
params.SetTrack("zootrack");
}
OmahaRequestParams out;
@@ -372,7 +372,7 @@
OmahaRequestDeviceParams params;
params.set_root(string("./") + kTestDir);
params.SetLockDown(true);
- EXPECT_TRUE(params.Init("", ""));
+ EXPECT_TRUE(params.Init("", "", ""));
params.SetTrack("zootrack");
}
OmahaRequestParams out;
@@ -421,6 +421,28 @@
EXPECT_EQ("http://www.google.com", out.update_url);
}
+TEST_F(OmahaRequestDeviceParamsTest, ChannelSpecified) {
+ ASSERT_TRUE(WriteFileString(
+ kTestDir + "/etc/lsb-release",
+ "CHROMEOS_RELEASE_BOARD=arm-generic\n"
+ "CHROMEOS_RELEASE_FOO=bar\n"
+ "CHROMEOS_RELEASE_VERSION=0.2.2.3\n"
+ "CHROMEOS_RELEASE_TRACK=dev-channel\n"
+ "CHROMEOS_AUSERVER=http://www.google.com"));
+ params_.SetLockDown(true);
+ // Passed-in value for release channel should be used.
+ params_.Init("", "", "beta-channel");
+ EXPECT_EQ("beta-channel", params_.app_track);
+
+ // When passed-in value is invalid, value from lsb-release should be used.
+ params_.Init("", "", "foo-channel");
+ EXPECT_EQ("dev-channel", params_.app_track);
+
+ // When passed-in value is empty, value from lsb-release should be used.
+ params_.Init("", "", "");
+ EXPECT_EQ("dev-channel", params_.app_track);
+}
+
TEST_F(OmahaRequestDeviceParamsTest, ShouldLockDownTest) {
EXPECT_FALSE(params_.ShouldLockDown());
}