update_payload: Allow check for given metadata size

Allow passing metadata size to check_update_payload so we can verify the
metadata size in omaha equals to the one in the payload.

BUG=chromium:820243
TEST=run paycheck.py with both valid and invalid metadata sizes reports as expected
TEST=unittests

Change-Id: Ib41ce77af77636fffec6752201c363e7fbbf868d
Reviewed-on: https://chromium-review.googlesource.com/955679
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
diff --git a/scripts/paycheck.py b/scripts/paycheck.py
index 96b1032..0050f5b 100755
--- a/scripts/paycheck.py
+++ b/scripts/paycheck.py
@@ -89,6 +89,9 @@
                                 'validation'))
   check_args.add_argument('-m', '--meta-sig', metavar='FILE',
                           help='verify metadata against its signature')
+  check_args.add_argument('-s', '--metadata-size', metavar='NUM', default=0,
+                          help='the metadata size to verify with the one in'
+                          ' payload')
   check_args.add_argument('-p', '--root-part-size', metavar='NUM',
                           default=0, type=int,
                           help='override rootfs partition size auto-inference')
@@ -128,7 +131,8 @@
   args.check = (args.check or args.report or args.assert_type or
                 args.block_size or args.allow_unhashed or
                 args.disabled_tests or args.meta_sig or args.key or
-                args.root_part_size or args.kern_part_size)
+                args.root_part_size or args.kern_part_size or
+                args.metadata_size)
 
   # Check the arguments, enforce payload type accordingly.
   if (args.src_kern is None) != (args.src_root is None):
@@ -202,6 +206,7 @@
           payload.Check(
               pubkey_file_name=args.key,
               metadata_sig_file=metadata_sig_file,
+              metadata_size=int(args.metadata_size),
               report_out_file=report_file,
               assert_type=args.assert_type,
               block_size=int(args.block_size),