libchromeos: void OsReleaseReader.Load()
Previously OsReleaseReader returned a bool, which meant that code that
called load wanted to CHECK the return values and possibly log warning
messages, etc. This was unecessary since OsReleaseReader.Load never
returns false.
TEST=unittests
BUG=none
Change-Id: I7064c6a788897b5d5c687d6c9c5f4e03d4ca21a7
Reviewed-on: https://chromium-review.googlesource.com/223990
Reviewed-by: Bertrand Simonnet <bsimonnet@google.com>
Commit-Queue: Nathan Bullock <nathanbullock@google.com>
Tested-by: Nathan Bullock <nathanbullock@google.com>
diff --git a/chromeos/osrelease_reader.cc b/chromeos/osrelease_reader.cc
index e6129fe..92a86f3 100644
--- a/chromeos/osrelease_reader.cc
+++ b/chromeos/osrelease_reader.cc
@@ -11,8 +11,8 @@
namespace chromeos {
-bool OsReleaseReader::Load() {
- return Load(base::FilePath("/"));
+void OsReleaseReader::Load() {
+ Load(base::FilePath("/"));
}
bool OsReleaseReader::GetString(const std::string& key,
@@ -21,11 +21,11 @@
return store_.GetString(key, value);
}
-bool OsReleaseReader::LoadTestingOnly(const base::FilePath& root_dir) {
- return Load(root_dir);
+void OsReleaseReader::LoadTestingOnly(const base::FilePath& root_dir) {
+ Load(root_dir);
}
-bool OsReleaseReader::Load(const base::FilePath& root_dir) {
+void OsReleaseReader::Load(const base::FilePath& root_dir) {
base::FilePath osrelease = root_dir.Append("etc").Append("os-release");
if (!store_.Load(osrelease)) {
// /etc/os-release might not be present (cros deploying a new configuration
@@ -52,7 +52,6 @@
store_.SetString(path.BaseName().value(), content);
}
initialized_ = true;
- return true;
}
} // namespace chromeos
diff --git a/chromeos/osrelease_reader.h b/chromeos/osrelease_reader.h
index 8e8c4d0..93db457 100644
--- a/chromeos/osrelease_reader.h
+++ b/chromeos/osrelease_reader.h
@@ -24,15 +24,14 @@
// Loads the key=value pairs from either /etc/os-release.d/<KEY> or
// /etc/os-release.
- // Returns false on errors.
- bool Load();
+ void Load();
// Same as the private Load method.
// This need to be public so that services can use it in testing mode (for
// autotest tests for example).
// This should not be used in production so suffix it with TestingOnly to
// make it obvious.
- bool LoadTestingOnly(const base::FilePath& root_dir);
+ void LoadTestingOnly(const base::FilePath& root_dir);
// Getter for the given key. Returns whether the key was found on the store.
bool GetString(const std::string& key, std::string* value) const;
@@ -44,8 +43,8 @@
// os-release can be lazily loaded if need be.
bool initialized_;
- // Load the data from a given root_dir. Return false on errors.
- CHROMEOS_PRIVATE bool Load(const base::FilePath& root_dir);
+ // Load the data from a given root_dir.
+ CHROMEOS_PRIVATE void Load(const base::FilePath& root_dir);
DISALLOW_COPY_AND_ASSIGN(OsReleaseReader);
};
diff --git a/chromeos/osrelease_reader_unittest.cc b/chromeos/osrelease_reader_unittest.cc
index 92bfde6..a7f99da 100644
--- a/chromeos/osrelease_reader_unittest.cc
+++ b/chromeos/osrelease_reader_unittest.cc
@@ -28,12 +28,12 @@
};
TEST_F(OsReleaseReaderTest, MissingOsReleaseTest) {
- ASSERT_TRUE(store_.LoadTestingOnly(temp_dir_.path()));
+ store_.LoadTestingOnly(temp_dir_.path());
}
TEST_F(OsReleaseReaderTest, MissingOsReleaseDTest) {
base::DeleteFile(osreleased_, true);
- ASSERT_TRUE(store_.LoadTestingOnly(temp_dir_.path()));
+ store_.LoadTestingOnly(temp_dir_.path());
}
TEST_F(OsReleaseReaderTest, CompleteTest) {
@@ -46,7 +46,7 @@
base::WriteFile(osreleased_.Append("GREETINGS"), ola.data(), ola.size());
base::WriteFile(osrelease_, osreleasecontent.data(), osreleasecontent.size());
- ASSERT_TRUE(store_.LoadTestingOnly(temp_dir_.path()));
+ store_.LoadTestingOnly(temp_dir_.path());
string test_key_value;
ASSERT_TRUE(store_.GetString("TEST_KEY", &test_key_value));
@@ -81,7 +81,7 @@
bonjour.data(),
bonjour.size());
- ASSERT_TRUE(store_.LoadTestingOnly(temp_dir_.path()));
+ store_.LoadTestingOnly(temp_dir_.path());
string hello_value;
string bonjour_value;