update_payload: remove block tracer
block tracing was useful for minor version 1 with move operations (before having
A/B updates). But, we do not create that operation anymore and we are in the
process of moving to major version 2. So this needs to go
BUG=chromium:794404
TEST=unit tests
Change-Id: I56d24ef81e8f37c481669d47e5878eb3a321131f
Reviewed-on: https://chromium-review.googlesource.com/888546
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 7f0b9a3..3233292 100755
--- a/scripts/paycheck.py
+++ b/scripts/paycheck.py
@@ -100,24 +100,11 @@
apply_args.add_argument('--src_root', metavar='FILE',
help='source root partition file')
- trace_args = parser.add_argument_group('Block tracing')
- trace_args.add_argument('-b', '--root-block', metavar='BLOCK', type=int,
- help='trace the origin for a rootfs block')
- trace_args.add_argument('-B', '--kern-block', metavar='BLOCK', type=int,
- help='trace the origin for a kernel block')
- trace_args.add_argument('-s', '--skip', metavar='NUM', default='0', type=int,
- help='skip first NUM occurrences of traced block')
-
parser.add_argument('payload', metavar='PAYLOAD', help='the payload file')
# Parse command-line arguments.
args = parser.parse_args(argv)
- # Ensure consistent use of block tracing options.
- do_block_trace = not (args.root_block is None and args.kern_block is None)
- if args.skip and not do_block_trace:
- parser.error('--skip must be used with either --root-block or --kern-block')
-
# There are several options that imply --check.
args.check = (args.check or args.report or args.assert_type or
args.block_size or args.allow_unhashed or
@@ -144,10 +131,7 @@
else:
args.assert_type = _TYPE_FULL
else:
- # Not applying payload; if block tracing not requested either, do an
- # integrity check.
- if not do_block_trace:
- args.check = True
+ # Not applying payload.
if args.extract_bsdiff:
parser.error('--extract-bsdiff can only be used when applying payloads')
if args.bspatch_path:
@@ -209,12 +193,6 @@
if do_close_report_file:
report_file.close()
- # Trace blocks.
- if args.root_block is not None:
- payload.TraceBlock(args.root_block, args.skip, sys.stdout, False)
- if args.kern_block is not None:
- payload.TraceBlock(args.kern_block, args.skip, sys.stdout, True)
-
# Apply payload.
if args.dst_root or args.dst_kern:
dargs = {'bsdiff_in_place': not args.extract_bsdiff}
diff --git a/scripts/test_paycheck.sh b/scripts/test_paycheck.sh
index 92f7de2..7b96f5d 100755
--- a/scripts/test_paycheck.sh
+++ b/scripts/test_paycheck.sh
@@ -21,9 +21,6 @@
# payload type. Another artifact is a human-readable payload report, which
# is output to stdout to be inspected by the user.
#
-# - It performs a random block trace on the delta payload (both kernel and
-# rootfs blocks), dumping the traces to stdout for the user to inspect.
-#
# - It applies old_full_payload to yield old kernel (old_kern.part) and rootfs
# (old_root.part) partitions.
#
@@ -37,11 +34,9 @@
# ensure that they are binary identical.
#
# If all steps have completed successfully we know with high certainty that
-# paycheck.py (and hence update_payload.py) correctly parses both full and
-# delta payloads, and applies them to yield the expected result. We also know
-# that tracing works, to the extent it does not crash. Manual inspection of
-# payload reports and block traces will improve this our confidence and are
-# strongly encouraged. Finally, each paycheck.py execution is timed.
+# paycheck.py (and hence update_payload.py) correctly parses both full and delta
+# payloads, and applies them to yield the expected result. Finally, each
+# paycheck.py execution is timed.
# Stop on errors, unset variables.
@@ -80,18 +75,6 @@
time ${paycheck} -t ${payload_type} ${payload_file}
}
-trace_kern_block() {
- payload_file=$1
- block=$2
- time ${paycheck} -B ${block} ${payload_file}
-}
-
-trace_root_block() {
- payload_file=$1
- block=$2
- time ${paycheck} -b ${block} ${payload_file}
-}
-
apply_full_payload() {
payload_file=$1
dst_kern_part="$2/$3"
@@ -137,15 +120,6 @@
check_payload "${delta_payload}" delta
log "Done"
- # Trace a random block between 0-1024 on all payloads.
- block=$((RANDOM * 1024 / 32767))
- log "Tracing a random block (${block}) in full/delta payloads..."
- trace_kern_block "${new_full_payload}" ${block}
- trace_root_block "${new_full_payload}" ${block}
- trace_kern_block "${delta_payload}" ${block}
- trace_root_block "${delta_payload}" ${block}
- log "Done"
-
# Apply full/delta payloads and verify results are identical.
tmpdir="$(mktemp -d --tmpdir test_paycheck.XXXXXXXX)"
log "Initiating application of payloads at $tmpdir"
diff --git a/scripts/update_payload/block_tracer.py b/scripts/update_payload/block_tracer.py
deleted file mode 100644
index 5caf7e3..0000000
--- a/scripts/update_payload/block_tracer.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Tracing block data source through a Chrome OS update payload.
-
-This module is used internally by the main Payload class for tracing block
-content through an update payload. This is a useful feature in debugging
-payload applying functionality in this package. The interface for invoking the
-tracer is as follows:
-
- tracer = PayloadBlockTracer(payload)
- tracer.Run(...)
-
-"""
-
-from __future__ import print_function
-
-from update_payload import common
-
-
-#
-# Payload block tracing.
-#
-class PayloadBlockTracer(object):
- """Tracing the origin of block data through update instructions.
-
- This is a short-lived object whose purpose is to isolate the logic used for
- tracing the origin of destination partition blocks.
-
- """
-
- def __init__(self, payload):
- assert payload.is_init, 'uninitialized update payload'
- self.payload = payload
-
- @staticmethod
- def _TraceBlock(block, skip, trace_out_file, operations, base_name):
- """Trace the origin of a given block through a sequence of operations.
-
- This method tries to map the given dest block to the corresponding source
- block from which its content originates in the course of an update. It
- further tries to trace transitive origins through MOVE operations. It is
- rather efficient, doing the actual tracing by means of a single reverse
- sweep through the operation sequence. It dumps a log of operations and
- source blocks responsible for the data in the given dest block to the
- provided output file.
-
- Args:
- block: the block number to trace
- skip: number of initial transitive origins to ignore
- trace_out_file: a file object to dump the trace to
- operations: the sequence of operations
- base_name: name of the operation sequence
- """
- # Traverse operations backwards.
- for op, op_name in common.OperationIter(operations, base_name,
- reverse=True):
- total_block_offset = 0
- found = False
-
- # Is the traced block mentioned in the dest extents?
- for dst_ex, dst_ex_name in common.ExtentIter(op.dst_extents,
- op_name + '.dst_extents'):
- if (block >= dst_ex.start_block
- and block < dst_ex.start_block + dst_ex.num_blocks):
- if skip:
- skip -= 1
- else:
- total_block_offset += block - dst_ex.start_block
- trace_out_file.write(
- '%d: %s: found %s (total block offset: %d)\n' %
- (block, dst_ex_name, common.FormatExtent(dst_ex),
- total_block_offset))
- found = True
- break
-
- total_block_offset += dst_ex.num_blocks
-
- if found:
- # Don't trace further, unless it's a MOVE.
- if op.type != common.OpType.MOVE:
- break
-
- # For MOVE, find corresponding source block and keep tracing.
- for src_ex, src_ex_name in common.ExtentIter(op.src_extents,
- op_name + '.src_extents'):
- if total_block_offset < src_ex.num_blocks:
- block = src_ex.start_block + total_block_offset
- trace_out_file.write(
- '%s: mapped to %s (%d)\n' %
- (src_ex_name, common.FormatExtent(src_ex), block))
- break
-
- total_block_offset -= src_ex.num_blocks
-
- def Run(self, block, skip, trace_out_file, is_kernel):
- """Block tracer entry point, invoking the actual search.
-
- Args:
- block: the block number whose origin to trace
- skip: the number of first origin mappings to skip
- trace_out_file: file object to dump the trace to
- is_kernel: trace through kernel (True) or rootfs (False) operations
- """
- if is_kernel:
- operations = self.payload.manifest.kernel_install_operations
- base_name = 'kernel_install_operations'
- else:
- operations = self.payload.manifest.install_operations
- base_name = 'install_operations'
-
- self._TraceBlock(block, skip, trace_out_file, operations, base_name)
diff --git a/scripts/update_payload/payload.py b/scripts/update_payload/payload.py
index 8e50c1f..7733a4a 100644
--- a/scripts/update_payload/payload.py
+++ b/scripts/update_payload/payload.py
@@ -10,7 +10,6 @@
import struct
from update_payload import applier
-from update_payload import block_tracer
from update_payload import checker
from update_payload import common
from update_payload import update_metadata_pb2
@@ -318,23 +317,3 @@
helper.Run(new_kernel_part, new_rootfs_part,
old_kernel_part=old_kernel_part,
old_rootfs_part=old_rootfs_part)
-
- def TraceBlock(self, block, skip, trace_out_file, is_kernel):
- """Traces the origin(s) of a given dest partition block.
-
- The tracing tries to find origins transitively, when possible (it currently
- only works for move operations, where the mapping of src/dst is
- one-to-one). It will dump a list of operations and source blocks
- responsible for the data in the given dest block.
-
- Args:
- block: the block number whose origin to trace
- skip: the number of first origin mappings to skip
- trace_out_file: file object to dump the trace to
- is_kernel: trace through kernel (True) or rootfs (False) operations
- """
- self._AssertInit()
-
- # Create a short-lived payload block tracer object and run it.
- helper = block_tracer.PayloadBlockTracer(self)
- helper.Run(block, skip, trace_out_file, is_kernel)