Commit graph

162 commits

Author SHA1 Message Date
Tao Bao
c6bb44e9bf Merge "Add tests for update_binary_command()." am: 44f61b4ce5 am: 1fc109bdc7
am: d218dca8f9

Change-Id: Ib8520d3249f3c131be5008324c52e4b94cf8426d
2017-04-19 01:52:22 +00:00
Tao Bao
bc4b1fe4c4 Add tests for update_binary_command().
Expose update_binary_command() through private/install.h for testing
purpose.

Also make minor clean-ups to install.cpp: a) adding more verbose logging
on ExtractToMemory failures; b) update_binary_command() taking
std::string instead of const char*; c) moving a few macro and global
constants into update_binary_command().

Bug: 37300957
Test: recovery_component_test on marlin
Test: Build new recovery and adb sideload on angler and sailfish.
Change-Id: Ib2d9068af3fee038f01c90940ccaeb0a7da374fc
2017-04-17 20:44:37 -07:00
Tao Bao
1d866050eb Verify the package compatibility with libvintf.
verify_package_compatibility() is added to parse the compatibility entry
(compatibility.zip) in a given OTA package. If entry is present, the
information is sent to libvintf to check the compatibility.

This CL doesn't actually call libvintf, since the API there is not
available yet.

Bug: 36597505
Test: Doesn't break the install with existing packages (i.e. w/o the
      compatibility entry).
Test: recovery_component_test
Change-Id: I3903ffa5f6ba33a5c0d761602ade6290c6752596
(cherry picked from commit 62e0bc7586)
2017-04-12 22:46:09 -07:00
Tao Bao
33ebf7bea4 Verify the package compatibility with libvintf.
am: 62e0bc7586

Change-Id: I35383abfd52766070df0de00013ec743dea190c7
2017-04-13 00:16:19 +00:00
Tao Bao
62e0bc7586 Verify the package compatibility with libvintf.
verify_package_compatibility() is added to parse the compatibility entry
(compatibility.zip) in a given OTA package. If entry is present, the
information is sent to libvintf to check the compatibility.

This CL doesn't actually call libvintf, since the API there is not
available yet.

Bug: 36597505
Test: Doesn't break the install with existing packages (i.e. w/o the
      compatibility entry).
Test: recovery_component_test
Change-Id: I3903ffa5f6ba33a5c0d761602ade6290c6752596
2017-04-12 14:52:00 -07:00
Tianjie Xu
3bd7aaf871 Merge "Abort the update if there's not enough new data" am: b4b0c49c48 am: bc66528cb9
am: 955c5ebece

Change-Id: I65b6699cc653192b3b8cbcb88093abd1a0e44ba1
2017-04-10 18:32:54 +00:00
Tianjie Xu
3a8d98dd90 Abort the update if there's not enough new data
Right now the update stuck in a deadlock if there's less new data than
expection. Add some checkers and abort the update if such case happens.
Also add a corresponding test.

Bug: 36787146
Test: update aborts correctly on bullhead && recovery_component_test passes
Change-Id: I914e4a2a4cf157b99ef2fc65bd21c6981e38ca47
2017-04-07 17:19:46 -07:00
Tao Bao
8ce8affee8 Merge "tests: Use get_bootloader_message_blk_device() to find /misc." am: 3cd630a5a8 am: cc630bdde1
am: f25cd871cc

Change-Id: I7ee75869ea3b80548c25e5f96d0906c1e8d88862
2017-04-05 15:51:36 +00:00
Tao Bao
ad87d9dc78 tests: Use get_bootloader_message_blk_device() to find /misc.
Since commit fb00d82f32 has added
get_bootloader_message_blk_device() as an API, switch the tests-local
implementation to it.

Test: recovery_component_test on angler.
Test: recovery_component_test on a local build that doesn't have /misc.
Change-Id: I4f5f542cb9ef58292c587a677da73d8822db7262
2017-04-04 20:35:10 -07:00
Tao Bao
b126a2cd9a Merge "Change the internal representation in RangeSet." am: 7ffa8be41d am: 2e12242b7a
am: 7f4e5d55f4

Change-Id: Ie48c858013808b1ccbe19b68e236b6bf18471da8
2017-04-04 21:57:57 +00:00
Tao Bao
bf5b77dbf7 Change the internal representation in RangeSet.
This CL makes the following changes to RangeSet:
 - Uses std::pair<size_t, size_t> to represent a Range;
 - Uses std::vector<Range> to represent a RangeSet;
 - Provides const iterators (forward and reverse);
 - Provides const accessor;
 - 'blocks()' returns the number of blocks (formerly 'size');
 - 'size()' returns the number of Range's (formerly 'count').

Test: recovery_unit_test
Test: Apply an incremental update with the new updater.
Change-Id: Ia1fbb343370a152e1f7aa050cf914c2da09b1396
2017-04-03 09:22:48 -07:00
Tao Bao
1980075fa9 Merge "Move parse_range() and range_overlaps() into RangeSet." am: 8fab8f97b7 am: 74c4da4c01
am: 3cf1113021

Change-Id: I297d6d7d5bb266cddc11e76216e064ea3ad1529e
2017-03-31 19:30:25 +00:00
Tao Bao
8f23757ad4 Move parse_range() and range_overlaps() into RangeSet.
Also move RangeSet into a header file to make it testable, and add unit
tests.

In RangeSet::Parse() (the former parse_range()), use libbase logging to
do assertions. This has the same effect as the previous
exit(EXIT_FAILURE) to terminate the updater process and abort an update.
The difference lies in the exit status code (i.e. WEXITSTATUS(status) in
install.cpp), which changes from 1 (i.e. EXIT_FAILURE) to 0.

Test: recovery_unit_test
Test: Apply an incremental update with the new updater.
Change-Id: Ie8393c78b0d8ae0fd5f0ca0646d871308d71fff0
2017-03-31 00:04:56 -07:00
Tao Bao
25546af375 Merge "tests: Remove LOCAL_ADDITIONAL_DEPENDENCIES." am: 3f0a3a2b1d am: b648a8781f
am: 4d6f904a88

Change-Id: Ib0e503efca67d3abcb964c5c9cc6bf6c60d0a0fc
2017-03-30 17:57:21 +00:00
Dan Shi
c0e6475f68 Merge "Add test config to minadbd_test" am: df1a585504 am: b8f33fdf5f
am: 57bb313b1e

Change-Id: I3e9aaedf23d1f3bfbeac9c7afee97993fa14422e
2017-03-30 15:49:43 +00:00
Tao Bao
31b6bc5ced tests: Remove LOCAL_ADDITIONAL_DEPENDENCIES.
Per the comment in build/make/core/base_rules.mk:
  Ninja has an implicit dependency on the command being run, and kati will
  regenerate the ninja manifest if any read makefile changes, so there is no
  need to have dependencies on makefiles.

Test: mmma bootable/recovery
Change-Id: I27b97df10d40f39ad966be70b33811175a665439
2017-03-30 08:43:47 -07:00
Treehugger Robot
df1a585504 Merge "Add test config to minadbd_test" 2017-03-30 15:39:21 +00:00
Dan Shi
7368316de1 Add test config to minadbd_test
Design doc:
Generalized Suites & the Unification of APCT & CTS Workflows Design/Roadmap
https://docs.google.com/document/d/1eabK3srlBLouMiBMrNP3xJPiRRdcoCquNxC8gBWPvx8/edit#heading=h.78vup5eivwzo

Details about test configs changes are tracked in doc
https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit#

Bug: 35882476
Test: local test
Change-Id: I51e1b410536469d254ae7a353bc61a7df06c8324
2017-03-28 22:13:38 -07:00
Tao Bao
8fdce9ab99 resolve merge conflicts of 39ef2d7f to oc-dev-plus-aosp
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I59d27cec1ef2c6befe824848cdc9ef3b0a0dc586
2017-03-28 17:58:31 -07:00
Tao Bao
3f2d35522a Merge "tests: Construct two bad packages at runtime for VerifierTest." 2017-03-29 00:37:05 +00:00
Tao Bao
20e4e73caa Merge "tests: Add a test for --wipe_ab into UncryptTest." am: 7b0cda5b37 am: c6df7d2937
am: 62a4e5ca98

Change-Id: I87b66da50364c0effdfdd5dbe8a7d0496152e68b
2017-03-28 22:34:39 +00:00
Tianjie Xu
0a599567ce Merge "Add the missing sr-Latn into png files and rename the png locale header" am: 713d915636 am: dc235b5ab9
am: 5ec12126f0

Change-Id: Ia6b861c91958d3be23a4a7456d6d5d8e4a1607c8
(cherry picked from commit 9166f66eee)
2017-03-28 22:23:40 +00:00
Tao Bao
7b0cda5b37 Merge "tests: Add a test for --wipe_ab into UncryptTest." 2017-03-28 22:12:35 +00:00
Tianjie Xu
9166f66eee Merge "Add the missing sr-Latn into png files and rename the png locale header" am: 713d915636 am: dc235b5ab9
am: 5ec12126f0

Change-Id: Ia6b861c91958d3be23a4a7456d6d5d8e4a1607c8
2017-03-28 20:11:15 +00:00
Tianjie Xu
713d915636 Merge "Add the missing sr-Latn into png files and rename the png locale header" 2017-03-28 19:42:54 +00:00
Tao Bao
e003a97668 Merge changes from topic 'sinkfn' am: 34df98ee6d am: 862b7e8523
am: a2015e0d86

Change-Id: I55bd4c762033cbfd68b019c3fad861ff9b954450
2017-03-28 19:21:34 +00:00
Tao Bao
b5f84ef1c3 applypatch: Change the ssize_t length parameters to size_t. am: f7eb760fe7 am: d4d9ef3941
am: 52569ce2ed

Change-Id: Ifeeb537d59d93acac445a0c748e4180a9704fcfb
2017-03-28 19:21:31 +00:00
Tao Bao
bdc8c1a264 tests: Add a test for --wipe_ab into UncryptTest.
Also factor out the common parts in {setup,clear}_bcb into a separate
function.

Test: recovery_component_test
Change-Id: I7b95cced925c8135e020dcb791ca2425d4f28449
2017-03-28 10:55:02 -07:00
Tao Bao
c0e1c46a70 applypatch: Let Apply{BSDiff,Image}Patch accept std::function.
Test: mmma bootable/recovery system/update_engine
Test: recovery_component_test
Change-Id: I93c2caa87bf94a53509bb37f98f2c02bcadb6f5c
2017-03-28 10:14:53 -07:00
Tao Bao
f7eb760fe7 applypatch: Change the ssize_t length parameters to size_t.
Mostly for applypatch family APIs like ApplyBSDiffPatch() and
ApplyImagePatch(). Changing to size_t doesn't indicate they would
necessarily work with very large size_t (e.g. > ssize_t), just
similar to write(2). But otherwise accepting negative length doesn't
make much sense.

Also change the return type of SinkFn from ssize_t to size_t. Callers
tell a successful sink by comparing the number of written bytes against
the desired value. Negative return values like -1 are not needed. This
also makes it consistent with bsdiff::bspatch interface.

Test: recovery_component_test
Test: Apply an incremental with the new updater.
Change-Id: I7ff1615203a5c9854134f75d019e266f4ea6e714
2017-03-28 10:13:38 -07:00
Tao Bao
217d9f9859 tests: Construct two bad packages at runtime for VerifierTest.
For the BadPackage tests from VerifierTest: one alters the footer, and
the other alters the metadata. Move the two tests to be based on
otasigned_v3.zip (they're based on otasigned_v1.zip previously). Also
construct the testdata files dynamically (to save the space and for
better readability).

Test: recovery_component_test
Change-Id: I7604d563f8b4fa0c55fec8730c063384158e3abc
2017-03-27 16:10:11 -07:00
Tao Bao
056e2da679 tests: Construct signature-boundary.zip at runtime.
Test: Observe the same failure with recovery_component_test ("signature
      start: 65535 is larger than comment size: 0").
Change-Id: I98c357b5df2fa4caa9d8eed63af2e945ed99f18a
2017-03-26 23:34:13 -07:00
Tao Bao
e55215ffd5 Merge "applypatch: Drop the support for patching non-EMMC targets." am: b4c4f8c494 am: 351f69e64a
am: dcbabd5932

Change-Id: Ia8ff537f0c503fec5602ae6ad6677c8b427d0806
2017-03-26 18:08:40 +00:00
Tao Bao
b4c4f8c494 Merge "applypatch: Drop the support for patching non-EMMC targets." 2017-03-26 18:00:20 +00:00
Tianjie Xu
2078b22e41 Add the missing sr-Latn into png files and rename the png locale header
Switch the locale header in the png files from Locale.toString() to
Locale.toLanguageTag(). For example, en_US --> en-us and sr__#Latn
--> sr-Latn. Also clean up recovery a bit to expect the new locale
format.

Bug: 35215015
Test: sr-Latn shows correctly under graphic tests && recovery tests pass
Change-Id: Ic62bab7756cdc6e5f98f26076f7c2dd046f811db
2017-03-24 16:54:52 -07:00
Tao Bao
951a61b9a8 Merge "updater: Fix the broken case for apply_patch_check()." am: 9f2062657d am: 923d41ccd5
am: 47ee8fa42a

Change-Id: I24a2b7776779a61f786fae0cbe5dd9569250ff7b
2017-03-23 17:15:42 +00:00
Tao Bao
db56eb073e updater: Fix the broken case for apply_patch_check().
It's valid to provide only 1 argument to apply_patch_check(). We
shouldn't fail the argument parsing.

Bug: 36541737
Test: recovery_component_test passes.
Test: recovery_component_test captures the failure without the fix.
Test: The previously failed update applies successfully.
Change-Id: Iee4c54ed33b877fc4885945b085341ec5c64f663
2017-03-23 06:52:45 -07:00
Tianjie Xu
5e1a2dc522 Merge "Remove malloc in edify functions" am: 1ea869b0c6 am: 137d85333e
am: eb0623b14b

Change-Id: I7c48105d9259b1713e8be5fb2c50ef8d6a92c993
2017-03-23 00:45:51 +00:00
Tianjie Xu
c444732540 Remove malloc in edify functions
And switch them to std::vector & std::unique_ptr

Bug: 32117870
Test: recovery tests passed on sailfish
Change-Id: I5a45951c4bdf895be311d6d760e52e7a1b0798c3
2017-03-22 14:20:57 -07:00
Tao Bao
a309fec8af Merge "Refactor asn1_decoder functions into a class." am: ea3d0b923d am: d7846b7303
am: 6e30101834

Change-Id: I4ac855fe7b33e4b1141c601045ecf79a681c60cf
2017-03-22 17:11:14 +00:00
Tao Bao
861c53c6c5 Refactor asn1_decoder functions into a class.
Test: mmma bootable/recovery
Test: recovery_unit_test passes.
Test: recovery_component_test passes.
Change-Id: If0bf25993158eaebeedff55ba4f4dd0f6e5f937d
2017-03-21 15:17:43 -07:00
Tao Bao
9d9f310f4e Merge "verify_file: Add constness to a few addresses." am: 5b2bf90e13 am: 43bd2c8414
am: 1c456cd3a5

Change-Id: I6d423a2fe19727e0d41b083a4020be30ae9400fb
2017-03-21 19:16:39 +00:00
Tao Bao
76fdb2419b verify_file: Add constness to a few addresses.
We should not touch any data while verifying packages (or parsing the
in-memory ASN.1 structures).

Test: mmma bootable/recovery
Test: recovery_component_test passes.
Test: recovery_unit_test passes.
Change-Id: Ie990662c6451ec066a1807b3081c9296afbdb0bf
2017-03-20 22:13:56 -07:00
Tao Bao
e44af82043 Merge "Add testcases for load_keys()." am: 110102f37e am: 43f5ad6e90
am: 60ea643afb

Change-Id: I2246094d0db184726cae34d7b916c127512ad6d2
2017-03-20 19:36:05 +00:00
Tao Bao
110102f37e Merge "Add testcases for load_keys()." 2017-03-20 19:24:23 +00:00
Tao Bao
b7d07f7b1e Merge "Remove the dead #include's in verifier.cpp." am: 64d25024b9 am: b2617e882e
am: cc3f3c3d1c

Change-Id: Ib78b586044938d9ec41cabfb07e8a274cc7d4d73
2017-03-20 16:32:24 +00:00
Tao Bao
3116ce4651 Add testcases for load_keys().
Test: recovery_component_test passes.
Change-Id: I6276b59981c87c50736d69d4af7647c8ed892965
2017-03-18 14:16:21 -07:00
Tao Bao
d7bf82eb53 Remove the dead #include's in verifier.cpp.
A follow-up to commit 5e535014dd.
Also clean up Android.mk, since libverifier no longer needs anything
from libminui.

Test: mmma bootable/recovery
Test: recovery_component_test passes.
Change-Id: I1c11e4bbeef67ca34a2054debf1f5b280d509217
2017-03-18 09:28:42 -07:00
Tao Bao
90d3f20c99 Merge "Drop the dependency on 'ui' in verify_file()." 2017-03-18 14:16:16 +00:00
Tao Bao
2b83f36355 Merge "Drop the dependency on 'ui' in verify_file()." 2017-03-17 23:41:45 +00:00