update_engine: Detect supported minor version from conf file.

If the delta minor version is not given as a command line argument, the
payload generator will look for the minor version in
etc/update_engine.conf in the old image.

BUG=chromium:455493
TEST=`FEATURES=test emerge-link update_engine`
CQ-DEPEND=CL:249956

Change-Id: I0f8e3f3c05432169770f2e8e283e8f1fb363def3
Reviewed-on: https://chromium-review.googlesource.com/249955
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Allie Wood <alliewood@chromium.org>
Tested-by: Allie Wood <alliewood@chromium.org>
diff --git a/utils_unittest.cc b/utils_unittest.cc
index ce65c50..2ac95cb 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -15,6 +15,7 @@
 
 #include <base/files/file_path.h>
 #include <base/files/file_util.h>
+#include <base/files/scoped_temp_dir.h>
 #include <base/strings/string_util.h>
 #include <base/strings/stringprintf.h>
 #include <gtest/gtest.h>
@@ -771,6 +772,23 @@
                                      NetworkTethering::kUnknown));
 }
 
+TEST(UtilsTest, GetMinorVersion) {
+  // Test GetMinorVersion by verifying that it parses the conf file and returns
+  // the correct value.
+  string contents = "PAYLOAD_MINOR_VERSION=1\n";
+  uint32_t minor_version;
+
+  base::ScopedTempDir temp_dir;
+  ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+
+  base::FilePath temp_file("update_engine.conf");
+  base::FilePath filepath = temp_dir.path().Append(temp_file);
+
+  ASSERT_TRUE(test_utils::WriteFileString(filepath.value(), contents.c_str()));
+  ASSERT_TRUE(utils::GetMinorVersion(filepath, &minor_version));
+  ASSERT_EQ(minor_version, 1);
+}
+
 static bool BoolMacroTestHelper() {
   int i = 1;
   unsigned int ui = 1;