#!/bin/bash # # Copyright (C) 2013 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # A test script for paycheck.py and the update_payload.py library. # # This script requires three payload files, along with a metadata signature for # each, and a public key for verifying signatures. Payload include: # # - A full payload for release X (old_full_payload) # # - A full payload for release Y (new_full_payload), where Y > X # # - A delta payload from X to Y (delta_payload) # # The test performs the following: # # - It verifies each payload against its metadata signature, also asserting the # payload type. Another artifact is a human-readable payload report, which # is output to stdout to be inspected by the user. # # - It applies old_full_payload to yield old kernel (old_kern.part) and rootfs # (old_root.part) partitions. # # - It applies delta_payload to old_{kern,root}.part to yield new kernel # (new_delta_kern.part) and rootfs (new_delta_root.part) partitions. # # - It applies new_full_payload to yield reference new kernel # (new_full_kern.part) and rootfs (new_full_root.part) partitions. # # - It compares new_{delta,full}_kern.part and new_{delta,full}_root.part to # 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. Finally, each # paycheck.py execution is timed. # Stop on errors, unset variables. set -e set -u # Temporary image files. OLD_KERN_PART=old_kern.part OLD_ROOT_PART=old_root.part NEW_DELTA_KERN_PART=new_delta_kern.part NEW_DELTA_ROOT_PART=new_delta_root.part NEW_FULL_KERN_PART=new_full_kern.part NEW_FULL_ROOT_PART=new_full_root.part CROS_PARTS="kernel root" log() { echo "$@" >&2 } die() { log "$@" exit 1 } usage_and_exit() { cat >&2 <