paycheck: Allow payloads with no operations.

Due to a fix to the delta generator (CL:246670) we may actually end up
with delta payloads that contain no operations (e.g. a delta from an
image to itself). This is a good thing and we want paycheck to not rule
out trivial deltas such as these.

BUG=chromium:453659
TEST=Empty delta verification passes

Change-Id: I461f48bba743a5b96b77aa3f55697ffc5cb8ea0e
Reviewed-on: https://chromium-review.googlesource.com/246673
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/host/lib/update_payload/checker.py b/host/lib/update_payload/checker.py
index c2e348f..d7d86c0 100644
--- a/host/lib/update_payload/checker.py
+++ b/host/lib/update_payload/checker.py
@@ -593,11 +593,6 @@
           'New rootfs content (%d) exceed partition size (%d).' %
           (self.new_rootfs_fs_size, rootfs_part_size))
 
-    # Check: Payload must contain at least one operation.
-    if not(len(manifest.install_operations) or
-           len(manifest.kernel_install_operations)):
-      raise error.PayloadError('Payload contains no operations.')
-
   def _CheckLength(self, length, total_blocks, op_name, length_name):
     """Checks whether a length matches the space designated in extents.
 
diff --git a/host/lib/update_payload/checker_unittest.py b/host/lib/update_payload/checker_unittest.py
index 9ca5a64..c099e2a 100755
--- a/host/lib/update_payload/checker_unittest.py
+++ b/host/lib/update_payload/checker_unittest.py
@@ -395,9 +395,9 @@
 
   def DoCheckManifestTest(self, fail_mismatched_block_size, fail_bad_sigs,
                           fail_mismatched_oki_ori, fail_bad_oki, fail_bad_ori,
-                          fail_bad_nki, fail_bad_nri, fail_missing_ops,
-                          fail_old_kernel_fs_size, fail_old_rootfs_fs_size,
-                          fail_new_kernel_fs_size, fail_new_rootfs_fs_size):
+                          fail_bad_nki, fail_bad_nri, fail_old_kernel_fs_size,
+                          fail_old_rootfs_fs_size, fail_new_kernel_fs_size,
+                          fail_new_rootfs_fs_size):
     """Parametric testing of _CheckManifest().
 
     Args:
@@ -408,7 +408,6 @@
       fail_bad_ori: Tamper with old rootfs info.
       fail_bad_nki: Tamper with new kernel info.
       fail_bad_nri: Tamper with new rootfs info.
-      fail_missing_ops: Simulate a manifest without any operations.
       fail_old_kernel_fs_size: Make old kernel fs size too big.
       fail_old_rootfs_fs_size: Make old rootfs fs size too big.
       fail_new_kernel_fs_size: Make new kernel fs size too big.
@@ -426,13 +425,12 @@
       payload_gen.SetBlockSize(test_utils.KiB(4))
 
     # Add some operations.
-    if not fail_missing_ops:
-      payload_gen.AddOperation(False, common.OpType.MOVE,
-                               src_extents=[(0, 16), (16, 497)],
-                               dst_extents=[(16, 496), (0, 16)])
-      payload_gen.AddOperation(True, common.OpType.MOVE,
-                               src_extents=[(0, 8), (8, 8)],
-                               dst_extents=[(8, 8), (0, 8)])
+    payload_gen.AddOperation(False, common.OpType.MOVE,
+                             src_extents=[(0, 16), (16, 497)],
+                             dst_extents=[(16, 496), (0, 16)])
+    payload_gen.AddOperation(True, common.OpType.MOVE,
+                             src_extents=[(0, 8), (8, 8)],
+                             dst_extents=[(8, 8), (0, 8)])
 
     # Set an invalid signatures block (offset but no size), if required.
     if fail_bad_sigs:
@@ -477,9 +475,9 @@
 
     should_fail = (fail_mismatched_block_size or fail_bad_sigs or
                    fail_mismatched_oki_ori or fail_bad_oki or fail_bad_ori or
-                   fail_bad_nki or fail_bad_nri or fail_missing_ops or
-                   fail_old_kernel_fs_size or fail_old_rootfs_fs_size or
-                   fail_new_kernel_fs_size or fail_new_rootfs_fs_size)
+                   fail_bad_nki or fail_bad_nri or fail_old_kernel_fs_size or
+                   fail_old_rootfs_fs_size or fail_new_kernel_fs_size or
+                   fail_new_rootfs_fs_size)
     if should_fail:
       self.assertRaises(update_payload.PayloadError,
                         payload_checker._CheckManifest, report,
@@ -1173,7 +1171,6 @@
                       'fail_bad_ori': (True, False),
                       'fail_bad_nki': (True, False),
                       'fail_bad_nri': (True, False),
-                      'fail_missing_ops': (True, False),
                       'fail_old_kernel_fs_size': (True, False),
                       'fail_old_rootfs_fs_size': (True, False),
                       'fail_new_kernel_fs_size': (True, False),