Commit graph

217 commits

Author SHA1 Message Date
Tianjie Xu
c89d1e7e2a Turn on -Wall for recovery modules
Turn on -Wall for all modules. Also remove the obsolete file_cmp() in
apply_patch test and now() in wear_ui.

The only exception is lib_edify due to the unused functions in the
intermediate cpp files generated from the lex files. It will be handled
in a seperate CL.

Bug: 64939312
Test: mma, unit tests pass
Change-Id: Ic53f76b60b6401ab20db3d98130d674c08e3702f
2017-08-28 21:56:33 -07:00
Tianjie Xu
7379a5290d Merge "Allow comparison against multi serial nums for A/B package" am: 3810046a55 am: e8b02d68e5
am: 968ebdeefd

Change-Id: I21de76c870001cb5faf145d5f39f8fb2cfa58a66
2017-08-22 23:23:07 +00:00
Tianjie Xu
3810046a55 Merge "Allow comparison against multi serial nums for A/B package" 2017-08-22 22:40:47 +00:00
Tianjie Xu
69b9649e9b Allow comparison against multi serial nums for A/B package
The metadata file now can have multiple serial numbers in the format:
serialno=serialno1|serialno2|serialno3 ...
Verifier will pass the check if the device serial number matches any of
these numbers.

Bug: 64802465
Test: Create a metadata file with 1000 numbers and sideload in sailfish.
      The checker detects both match and mismatch cases.

Change-Id: I3f12b75e15f4179df260778e37f4563d65db0fa8
2017-08-22 12:05:52 -07:00
Tao Bao
2357b0c745 Merge "tests: Add a test to cover legacy care_map.txt handling." am: 6eb23c594c am: dbe9da5331
am: 0148a6f9ab

Change-Id: Id568b7cb5043c444f88032368be57a6f128a44c7
2017-07-24 18:32:01 +00:00
Tao Bao
dbe9da5331 Merge "tests: Add a test to cover legacy care_map.txt handling."
am: 6eb23c594c

Change-Id: Iaad43cb44f4c406e4c07c9399e70e96cbaa4db7b
2017-07-24 18:27:00 +00:00
Tao Bao
c319613e06 tests: Add a test to cover legacy care_map.txt handling.
This is to cover the code added by commit
5a1dee01df, where an O update_verifier
should not reject N care_map.txt.

Bug: 63544345
Test: recovery_component_test passes on marlin.
Change-Id: Ia944e16cba3cc635098b3ffd92842d725b570fec
2017-07-24 09:34:06 -07:00
Tianjie Xu
512283a751 Merge "Fix a case when brotli writer fails to write last few blocks of data" am: e45c8f0057 am: 80acaab52f
am: 75ff0107c8

Change-Id: Ieab5e6e412704599e873c7497d1c0de42453e642
2017-07-21 22:46:00 +00:00
Tianjie Xu
80acaab52f Merge "Fix a case when brotli writer fails to write last few blocks of data"
am: e45c8f0057

Change-Id: I337e8ec26f59a5245ab299080d7251331823e2da
2017-07-21 21:04:17 +00:00
Tianjie Xu
e45c8f0057 Merge "Fix a case when brotli writer fails to write last few blocks of data" 2017-07-21 20:59:24 +00:00
Tianjie Xu
6ed175d541 Fix a case when brotli writer fails to write last few blocks of data
receive_new_data may exit too early if the zip processor has sent all
the raw data. As a result, the last few 'new' commands will fail even
though the brotli decoder has more output in its buffer.

Restruct the code so that 'NewThreadInfo' owns the decoder state solely;
and receive_brotli_new_data is responsible for the decompression.

Also reduce the test data size to 100 blocks to avoid the test timeout.

Bug: 63802629
Test: recovery_component_test. on bullhead, apply full updates with and
w/o brotli compressed entries, apply an incremental update.

Change-Id: I9442f2536b74e48dbf7eeb062a8539c82c6dab47
2017-07-21 11:44:00 -07:00
Tianjie Xu
f2a279adb5 Merge "Fix the android-cloexec-* warnings in bootable/recovery" am: 94a8ea1797 am: 6d8827e0d3
am: 96b5bb9601

Change-Id: I55911c112a34797d7c7098e5e325145667b46715
2017-07-19 23:12:20 +00:00
Tianjie Xu
6d8827e0d3 Merge "Fix the android-cloexec-* warnings in bootable/recovery"
am: 94a8ea1797

Change-Id: I57ae57bab58f603540654bb24df9facca9a7d625
2017-07-19 23:06:50 +00:00
Tianjie Xu
de6735e80c Fix the android-cloexec-* warnings in bootable/recovery
Add the O_CLOEXEC or 'e' accordingly.

Bug: 63510015
Test: recovery tests pass
Change-Id: I7094bcc6af22c9687eb535116b2ca6a59178b303
2017-07-19 12:17:41 -07:00
Tianjie Xu
9f8fd32d95 Merge "Add support to decompress brotli compressed new data" am: 918e6ea1b2 am: 43bdf6cad6
am: 8375ebee37

Change-Id: I3eea508486f48d316644b68278f42976ffd4698d
2017-07-10 22:47:10 +00:00
Tianjie Xu
43bdf6cad6 Merge "Add support to decompress brotli compressed new data"
am: 918e6ea1b2

Change-Id: I4fd9cea71716ad1574ecb4bb7f612bc8734711c5
2017-07-10 22:33:37 +00:00
Tianjie Xu
107a34f9fc Add support to decompress brotli compressed new data
Add a new writer that can decode the brotli-compressed system/vendor
new data stored in the OTA zip.

Brotli generally gives better compression rate at the cost of slightly
increased time consumption. The patch.dat is already compressed
by BZ; so there's no point to further compress it.

For the given 1.9G bullhead system image:
Size: 875M -> 787M; ~10% reduction of package size.
Time: 147s -> 153s; ~4% increase of the block_image_update execution time.
(I guess I/O takes much longer time than decompression.)

Also it takes 4 minutes to compress the system image on my local
machine, 3 more minutes than zip.

Test: recovery tests pass && apply a full OTA with brotli compressed
system/vendor.new.dat on bullhead

Change-Id: I232335ebf662a9c55579ca073ad45265700a621e
2017-07-07 16:08:18 -07:00
Tianjie Xu
79c1562dc9 Merge "Fix a rare failure for imgdiff when random data equals gzip header" am: b87a166a16 am: 8542502f1f
am: 233f4b0b4b

Change-Id: If7e81b8e794f34d374d385eb5603353cdfec524f
2017-07-07 18:11:59 +00:00
Tianjie Xu
8542502f1f Merge "Fix a rare failure for imgdiff when random data equals gzip header"
am: b87a166a16

Change-Id: Ic3c7d102cc7a2b992c699add012076a4bda549c6
2017-07-07 17:52:26 +00:00
Tianjie Xu
14ebc1e5ae Fix a rare failure for imgdiff when random data equals gzip header
In a rare case, a random chunk will pass both the gzip header check
and the inflation process; but fail the uncompressed length check in the
footer. This leads to a imgdiff failure. So, we should treat this chunk
as 'normal' instead of 'inflated' while generating the patch.

Bug: 63334984
Test: imgdiff generates patch successfully on previous failing images.
Change-Id: Ice84f22d3653bce9756bda91e70528c0d2f264a0
2017-07-06 16:49:11 -07:00
Tianjie Xu
617b702104 Merge "Remove the obsolete package_extract_dir() test" am: e916cca8a9 am: af913974a5
am: e002d96194

Change-Id: If4887683362c1a00ee20b0d6e447d70bff442c28
2017-06-23 04:58:26 +00:00
Tianjie Xu
e002d96194 Merge "Remove the obsolete package_extract_dir() test" am: e916cca8a9
am: af913974a5

Change-Id: I6afcdb92726231325a7d2e8171e3e2b1b3b940e0
2017-06-23 04:53:56 +00:00
Tianjie Xu
e916cca8a9 Merge "Remove the obsolete package_extract_dir() test" 2017-06-23 04:46:14 +00:00
Tianjie Xu
bb7e005a79 Remove the obsolete package_extract_dir() test
package_extract_dir() was removed in go/aog/402383, and the
corresponding UpdaterTest should be removed as well.

Bug: 62918308
Test: mma && code search
Change-Id: Ibe9c473a5d41d2fa4d26abca5684e71b104891b0
2017-06-22 17:35:06 -07:00
David Zeuthen
0f6a109f14 Merge "update_verifier: Support AVB." am: e248e434ea am: 1f108dae49
am: b0c38f1cce

Change-Id: If4e8be8b8277143cad9447a487a674e39ba5a832
2017-06-22 19:56:37 +00:00
David Zeuthen
b0c38f1cce Merge "update_verifier: Support AVB." am: e248e434ea
am: 1f108dae49

Change-Id: I85544f829783fade5e91cfa1d48013047056924d
2017-06-22 19:26:10 +00:00
David Zeuthen
8ed9738b62 update_verifier: Support AVB.
When using AVB, PRODUCT_SUPPORTS_VERITY is not set so check for
BOARD_ENABLE_AVB as well. Also AVB sets up the root filesystem as
'vroot' so map that to 'system' since this is what is
expected. Managed to test at least that the code is at least compiled
in:

 $ fastboot --set-active=_a
 Setting current slot to 'a'...
 OKAY [  0.023s]
 finished. total time: 0.023s

 $ fastboot reboot
 rebooting...

 finished. total time: 0.050s

 $ adb wait-for-device

 $ adb logcat |grep update_verifier
 03-04 05:28:56.773   630   630 I /system/bin/update_verifier: Started with arg 1: nonencrypted
 03-04 05:28:56.776   630   630 I /system/bin/update_verifier: Booting slot 0: isSlotMarkedSuccessful=0
 03-04 05:28:56.776   630   630 W /system/bin/update_verifier: Failed to open /data/ota_package/care_map.txt: No such file or directory
 03-04 05:28:56.788   630   630 I /system/bin/update_verifier: Marked slot 0 as booted successfully.
 03-04 05:28:56.788   630   630 I /system/bin/update_verifier: Leaving update_verifier.

Bug: None
Test: Manually tested on device using AVB bootloader.
Change-Id: I13c0fe1cc5d0f397e36f5e62fcc05c8dfee5fd85
2017-05-24 14:14:11 -04:00
Tianjie Xu
f158a7d29e Merge "Print SHA1 of the patch if bsdiff fails with data error" am: 1f9808bd48 am: 8f68accc9d am: 1562f41348
am: 0abe9860d8

Change-Id: Id8d4e4b369f30a33a37ca1895d5dd36eb2bf8aff
2017-05-18 22:25:55 +00:00
Tianjie Xu
0abe9860d8 Merge "Print SHA1 of the patch if bsdiff fails with data error" am: 1f9808bd48 am: 8f68accc9d
am: 1562f41348

Change-Id: I7b605673eb3cee6a615459ca9fe2fc00c532ed9d
2017-05-18 22:20:55 +00:00
Tianjie Xu
ce5fa5e538 Print SHA1 of the patch if bsdiff fails with data error
This will help us to identify the patch corruption.

Meanwhile fix a wrong size parameter passed to bspatch.
(patch->data.size() into patch->data.size() - patch_offset).

Also remove the only usage of "ApplyBSDiffPatchMem()" and inline its
Sink function for simplicity.

Bug: 37855643
Test: Prints SHA1 for corrupted patch in imgdiff_test.
Change-Id: Ibf2db8c08b0ded1409bb7c91a3547a6bf99c601d
2017-05-16 12:39:14 -07:00
Tao Bao
4deb2fb1bd Merge "Add a binary path param to update_binary_command()." am: 197304aada am: f648b5c9fc am: f49c57643d
am: 460e47adfc

Change-Id: I34b789b29f019f730d6c8a7e3a96384a056c1d4a
2017-05-09 00:28:00 +00:00
Tao Bao
460e47adfc Merge "Add a binary path param to update_binary_command()." am: 197304aada am: f648b5c9fc
am: f49c57643d

Change-Id: Iea3496ad9cbcd8389ade9effa7072198cf33a5c3
2017-05-09 00:22:30 +00:00
Tao Bao
00d5757186 Add a binary path param to update_binary_command().
This allows writing native tests for non-A/B update_binary_command().
Prior to this CL, it was extracting the updater to a hard-coded
location (/tmp/update_binary) that's not available under the test
environment.

Test: recovery_component_test on angler and marlin respectively.
Test: Sideload OTA packages on angler and marlin respectively.
Change-Id: I78b9cc211d90c0a16a84e94e339b65759300e2a8
2017-05-08 12:16:45 -07:00
Tao Bao
ab1e70647f Merge "fuse_sideload: Change the minimal block size to 4096." am: 4e8e56eaea am: 53b98de866 am: 6bea344d7e
am: bfca876038

Change-Id: I5d1fa644a867b523553127c8bde92000f4cb539a
2017-05-04 00:11:51 +00:00
Tao Bao
bfca876038 Merge "fuse_sideload: Change the minimal block size to 4096." am: 4e8e56eaea am: 53b98de866
am: 6bea344d7e

Change-Id: If7e905a7630ee8cf142752695272afb8e76c28cb
2017-05-04 00:06:38 +00:00
Tao Bao
4e8e56eaea Merge "fuse_sideload: Change the minimal block size to 4096." 2017-05-03 23:52:34 +00:00
Tao Bao
a616f0d476 Merge "Move sysMapFile and sysReleaseMap into MemMapping class." am: fe7eecff4c am: 08d9ede8f2 am: b3eeb817ab
am: 586377d1f3

Change-Id: I4d2cac061fbf6ac34e9e5125ebd5294dbc33e4ef
2017-05-02 23:54:02 +00:00
Tao Bao
586377d1f3 Merge "Move sysMapFile and sysReleaseMap into MemMapping class." am: fe7eecff4c am: 08d9ede8f2
am: b3eeb817ab

Change-Id: I1bcf86cbbc495bf5df92dc53e01be39e7c623255
2017-05-02 23:51:32 +00:00
Tao Bao
ed13819a0d fuse_sideload: Change the minimal block size to 4096.
run_fuse_sideload() is passing the block size as the max_read
option, so it will only handle a request that involves at most two
blocks at a time. However, the minimal allowed value was set to 1024
prior to this CL, which is inconsistent with the kernel code
(fs/fuse/inode.c) that sets it to the greater of 4096 and the passed-in
max_read option. This would fail the calls with a block size / max_read
less than 4096 due to the wrongly computed block indices.

Note that we didn't observe real issue in practice, because we have been
using 64 KiB block sizes for both of adb and sdcard sideload calls. The
issue only shows up in my local CL (to come later) that uses 1024 block
size in run_fuse_sideload() tests.

Test: recovery_component_test
Test: adb sideload with the new recovery image on angler
Change-Id: Id9f0cfea13d0d193dcb7cd41a1553a23739545f2
2017-05-02 15:56:22 -07:00
Tao Bao
b656a154ea Move sysMapFile and sysReleaseMap into MemMapping class.
Test: recovery_component_test
Test: recovery_unit_test
Test: Apply an OTA on angler.
Change-Id: I7170f03e4ce1fe06184ca1d7bcce0a695f33ac4d
2017-05-01 21:51:54 -07:00
Tao Bao
598679cbad Merge "Separate libupdate_verifier module and add testcases." am: c99bb23955 am: d8c078d2c6 am: c7410924a3
am: 322d866ec8

Change-Id: I58bf1596f7247866e0d9e76c1c7a5ddc1d58024a
2017-04-27 21:41:28 +00:00
Tao Bao
322d866ec8 Merge "Separate libupdate_verifier module and add testcases." am: c99bb23955 am: d8c078d2c6
am: c7410924a3

Change-Id: I452f0a1b5c0377f985294d37d59a19d1272be50d
2017-04-27 21:32:30 +00:00
Tao Bao
83b0780ddd Separate libupdate_verifier module and add testcases.
Enable -Wall and expose verify_image() for testing purpose.

Test: mmma bootable/recovery
Test: recovery_component_test
Change-Id: I1ee1db2a775bafdc1112e25a1bc7194d8d6aee4f
2017-04-27 08:57:23 -07:00
Tao Bao
afd224bf3b Merge "applypatch: Remove the obsolete support for "applypatch -s"." am: d5ae4253c1 am: 22b1fa7d61 am: 7ee4b7dd84
am: 41dc284309

Change-Id: If092d5a6d97e31bef4d2ec19478061c8df4ad792
2017-04-26 17:29:46 +00:00
Tao Bao
41dc284309 Merge "applypatch: Remove the obsolete support for "applypatch -s"." am: d5ae4253c1 am: 22b1fa7d61
am: 7ee4b7dd84

Change-Id: I9f372c9b371f28b70ec6832e66053d3aee5b7c8e
2017-04-26 17:07:44 +00:00
Tao Bao
8ab28082b7 applypatch: Remove the obsolete support for "applypatch -s".
The SpaceMode (applypatch -s) was used in amend script (cupcake) only,
which has been removed since commit
9ce2ebf5d300eba5f6086583b0941ef68a3e4b42 (platform/build). The later
(and current) edify script uses apply_patch_space().

Note that other modes (PatchMode, CheckMode) of applypatch executable
are mostly used by install-recovery.sh script.

Test: No active user of "applypatch -s".
Test: recovery_component_test
Change-Id: I1d689b7fedd3884077e88ed1d6c22f7a2198859d
2017-04-25 21:23:12 -07:00
Tao Bao
f5cb2a11df Merge "Add more tests for verify_package_compatibility()." am: a9dd77fa84 am: 5f85d07e87 am: 54f8988cfe
am: 7b2957ed25

Change-Id: Ia1dbea19d1975348a7dfdcaf803ebb6bf4b99a0a
2017-04-24 19:38:41 +00:00
Tao Bao
4983412270 Merge "tests: Remove obsolete classes in applypatch_test." am: f17aa960db am: 8a3325dc8a am: f4a8d0bba6
am: b35fb1cf7b

Change-Id: Iba385b5435dc8aa4393821f8a72c92c477685f51
2017-04-24 19:38:29 +00:00
Tao Bao
7b2957ed25 Merge "Add more tests for verify_package_compatibility()." am: a9dd77fa84 am: 5f85d07e87
am: 54f8988cfe

Change-Id: I389ced1ec0e90e90e5fbde74f1b0ab5449310ab7
2017-04-24 19:01:28 +00:00
Tao Bao
b35fb1cf7b Merge "tests: Remove obsolete classes in applypatch_test." am: f17aa960db am: 8a3325dc8a
am: f4a8d0bba6

Change-Id: If68b3e47fa75a5d5f2041bdda8a8f4cb84c8880c
2017-04-24 19:01:14 +00:00
Tao Bao
a9dd77fa84 Merge "Add more tests for verify_package_compatibility()." 2017-04-24 18:08:55 +00:00
Tao Bao
0a3e4dca58 tests: Remove obsolete classes in applypatch_test.
ApplyPatchFullTest and ApplyPatchDoubleCacheTest were used for defining
testcases for file-based OTA. The testcases have already been removed by
commit 40e144dae8. This CL removes the
obsolete class defnitions.

Bug: 37559618
Test: recovery_component_test on angler and marlin respectively.
Change-Id: I3f4f1dfc8580cf010365e671de256f68bbc0d99a
2017-04-21 09:52:27 -07:00
Tao Bao
f2784b6a43 Add more tests for verify_package_compatibility().
This now covers the actual calls to libvintf, and asserts we're getting
identical results through verify_package_compatibility() and by calling
libvintf directly.

We were missing the coverage and introduced the double free bug (fixed
by commit f978278995).

Bug: 37413730
Test: recovery_component_test passes.
Test: recovery_component_test fails w/o commit
      f978278995.
Change-Id: If5195ea1c583fd7c440a1de289da82145e80e23c
2017-04-19 17:10:34 -07:00
Tao Bao
0ae77823f4 Merge "Add tests for read_metadata_from_package()." am: e888d45950 am: c08c055ce0 am: 7b9b77f445
am: 67045afa85

Change-Id: I449c52d75ee821293e57878eda5b95782912d429
2017-04-19 19:03:23 +00:00
Tao Bao
67045afa85 Merge "Add tests for read_metadata_from_package()." am: e888d45950 am: c08c055ce0
am: 7b9b77f445

Change-Id: I9e3563e052ce1b993981af29c8af9fd4ab4f3516
2017-04-19 18:58:52 +00:00
Tao Bao
8a7afcc6ed Add tests for read_metadata_from_package().
Test: recovery_component_test
Change-Id: I672a6a4f101c72e82b9f25f165dccd1c9520627b
2017-04-18 22:07:44 -07:00
Tao Bao
9c5ae7445f Merge "Add tests for update_binary_command()." am: 44f61b4ce5 am: 1fc109bdc7 am: d218dca8f9
am: c6bb44e9bf

Change-Id: I42f53d3d48caf913fa8d4ba2eba475e20c8b65f9
2017-04-19 01:54:22 +00:00
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
a6004b6dcb Verify the package compatibility with libvintf. am: 62e0bc7586
am: 33ebf7bea4

Change-Id: I9799279177b4b0c98b6a198a7544da224cda72b0
2017-04-13 00:26:50 +00: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
3cdd467f17 Merge "Abort the update if there's not enough new data" am: b4b0c49c48 am: bc66528cb9 am: 955c5ebece
am: 3bd7aaf871

Change-Id: I015ba8d71c6aea95647b01b4c61a7c28d153fbda
2017-04-10 18:37:25 +00: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
58847a109a Merge "tests: Use get_bootloader_message_blk_device() to find /misc." am: 3cd630a5a8 am: cc630bdde1 am: f25cd871cc
am: 8ce8affee8

Change-Id: I6501442dc37ef8db52a0bcd75c0475636f157d52
2017-04-05 15:54:07 +00: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
28b79f797c Fix the bad merge (duplicate tests).
Test: mmma bootable/recovery
Change-Id: I909164fed84fb17a7e1cb2427cb88208a69dc052
2017-03-28 19:07:12 -07:00
Tao Bao
fa617cdf97 resolve merge conflicts of 39ef2d7f to oc-dev-plus-aosp
am: 8fdce9ab99

Change-Id: Ifcd2c3236d337216adabb5bb810befd33f05f44c
2017-03-29 01:14:51 +00: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
dcf94dd14c Merge "tests: Add a test for --wipe_ab into UncryptTest." am: 7b0cda5b37 am: c6df7d2937 am: 62a4e5ca98
am: 20e4e73caa

Change-Id: Ib58d2e7843c6cbe75695b83651e3dcd2f9d94f9a
2017-03-28 22:39:39 +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
Tao Bao
7b0cda5b37 Merge "tests: Add a test for --wipe_ab into UncryptTest." 2017-03-28 22:12:35 +00:00
Tao Bao
2eb5d10846 Merge "tests: Construct two bad packages at runtime for VerifierTest." 2017-03-28 21:18:13 +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
7e61c6a862 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
(cherry picked from commit 217d9f9859)
2017-03-27 16:13:01 -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
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
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
3116ce4651 Add testcases for load_keys().
Test: recovery_component_test passes.
Change-Id: I6276b59981c87c50736d69d4af7647c8ed892965
2017-03-18 14:16:21 -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
Tao Bao
7b22c92ac1 Drop the dependency on 'ui' in verify_file().
verify_file() has a dependency on the global variable of 'ui' for
posting the verification progress, which requires the users of
libverifier to provide a UI instance.

This CL adds an optional argument to verify_file() so that it can
post the progress through the provided callback function. As a result,
we can drop the MockUI class in verifier_test.cpp.

Test: recovery_component_test passes.
Test: verify_file() posts progress update when installing an OTA.
Change-Id: I8b87d0f0d99777ea755d33d6dbbe2b6d44243bf1
(cherry picked from commit 5e535014dd)
2017-03-17 14:14:07 -07:00
Tao Bao
5e535014dd Drop the dependency on 'ui' in verify_file().
verify_file() has a dependency on the global variable of 'ui' for
posting the verification progress, which requires the users of
libverifier to provide a UI instance.

This CL adds an optional argument to verify_file() so that it can
post the progress through the provided callback function. As a result,
we can drop the MockUI class in verifier_test.cpp.

Test: recovery_component_test passes.
Test: verify_file() posts progress update when installing an OTA.
Change-Id: I8b87d0f0d99777ea755d33d6dbbe2b6d44243bf1
2017-03-17 14:07:12 -07:00
Tianjie Xu
c76805952e Merge "Add a test to perform block_image_update" am: 881b08ecd2 am: 5c06706d51
am: 640fc1d338

Change-Id: If611a8023bb5411ac2a1063411d0030121ce0de2
2017-03-17 18:34:31 +00:00
Tianjie Xu
881b08ecd2 Merge "Add a test to perform block_image_update" 2017-03-17 18:22:11 +00:00
Tianjie Xu
56ebe620a2 Add a test to perform block_image_update
Add the following tests:
stash src
bspatch stashed_src tgt
free stashed_src
(expected a successful update)

stash src
free stashed_src
fail_the_update
(expected stashed_src freed)

Bug: 36242722
Test: Test identified unfreed stashes correctly.
Change-Id: I5a136e8dc31774367972fbfe8c63cbc1ddb3a113
2017-03-16 23:06:37 -07:00