Add and enforce MinorVersion in Payload Manifest.

The MinorVersion is also set to 0 for Full payloads, and to 1 for
DeltaPayloads (for now). If the field is not set, it defaults to 0.

The default is important, since Full payloads will be generated without this
value set in production because older payload generators will be used for
Full payloads for some time to come.

If an unexpected MinorVersion is received, we will refuse to process it, and
send an kErrorCodeUnsupportedMinorPayloadVersion error result.

Add unittests to delta_performer_unittests to unittest the ValidateManifest
method (never individually tested before).

BUG=chromium:322564
TEST=Unittests

Change-Id: Icbd2ebeb739431905497e79edb4b99629c8d6f7f
Reviewed-on: https://chromium-review.googlesource.com/177823
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
diff --git a/delta_diff_generator.cc b/delta_diff_generator.cc
index 2df0de9..8d70749 100644
--- a/delta_diff_generator.cc
+++ b/delta_diff_generator.cc
@@ -28,6 +28,7 @@
 
 #include "update_engine/bzip.h"
 #include "update_engine/cycle_breaker.h"
+#include "update_engine/delta_performer.h"
 #include "update_engine/extent_mapper.h"
 #include "update_engine/extent_ranges.h"
 #include "update_engine/file_writer.h"
@@ -1440,6 +1441,9 @@
 
   LOG(INFO) << "Reading files...";
 
+  // Create empty protobuf Manifest object
+  DeltaArchiveManifest manifest;
+
   vector<DeltaArchiveManifest_InstallOperation> kernel_ops;
 
   vector<Vertex::Index> final_order;
@@ -1511,6 +1515,10 @@
                                               &data_file_size,
                                               &final_order,
                                               scratch_vertex));
+
+      // Set the minor version for this payload.
+      LOG(INFO) << "Adding Delta Minor Version.";
+      manifest.set_minor_version(DeltaPerformer::kSupportedMinorPayloadVersion);
     } else {
       // Full update
       off_t new_image_size =
@@ -1525,12 +1533,13 @@
                                                      kBlockSize,
                                                      &kernel_ops,
                                                      &final_order));
+
+      // Set the minor version for this payload.
+      LOG(INFO) << "Adding Full Minor Version.";
+      manifest.set_minor_version(DeltaPerformer::kFullPayloadMinorVersion);
     }
   }
 
-  // Convert to protobuf Manifest object
-  DeltaArchiveManifest manifest;
-
   if (old_image_info)
     *(manifest.mutable_old_image_info()) = *old_image_info;