summaryrefslogtreecommitdiffstats
path: root/tests/unit/applypatch_test.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-09-23applypatch: Add backup_source parameter to PatchPartition.Tao Bao1-2/+2
And set it to false when installing recovery image via applypatch. We only need to back up the source partition when doing in-place update (e.g. when updating a given partition under recovery). When installing recovery image via applypatch, we won't touch the source partition (i.e. /boot). Removing the backup step also allows dropping the dac_override_allowed permission. Previously it was needed due to the access to /cache. Because applypatch runs as root:root, while /cache is owned by system:cache with 0770. Bug: 68319577 Test: Invoke the code that installs recovery image; check that recovery is installed successfully without denials. Test: recovery_unit_test passes on taimen. Change-Id: I549a770b511762189d6672a2835b6e403d695919
2018-11-15switch to using android-base/file.h instead of android-base/test_utils.hMark Salyzyn1-1/+0
Test: compile Bug: 119313545 Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-08-31applypatch: {Load,Save}FileContents return bool values.Tao Bao1-5/+5
Bug: 110106408 Test: Run recovery_unit_test and recovery_component_test on marlin. Change-Id: Id72e24dd00eb451565d90cff6e049f4f4b844ea2
2018-08-31applypatch: Refactor applypatch().Tao Bao1-56/+65
applypatch() was initially designed for file-based OTA, operating on individual files. It was later extended to allow patching eMMC targets as a whole, in favor of block-based updates. As we have deprecated file-based OTA since Oreo, part of the code in applypatch() has become obsolete. This CL refactors the related functions, by removing the obsolete logic and focusing on eMMC targets. Since this CL substantially changes applypatch APIs, it adds new functions to avoid unintentionally mixing them together. In particular, it removes `applypatch()`, `applypatch_check()`, `applypatch_flash()`, and adds `PatchPartition()`, `PatchPartitionCheck()`, `FlashPartition()` and `CheckPartition()`. It also replaces the old Edify functions `apply_patch()` and `apply_patch_check()` with `patch_partition()` and `patch_partition_check()` respectively. This CL requires matching changes to OTA generation script (in the same topic). Bug: 110106408 Test: Run recovery_unit_test and recovery_component_test on marlin. Test: `m dist` with non-A/B target. Verify /system/bin/install-recovery.sh on device. Test: `m dist` with non-A/B target using BOARD_USES_FULL_RECOVERY_IMAGE. Verify /system/bin/install-recovery.sh on device. Test: Install an incremental OTA with the new updater and scripts. Change-Id: Ia34a90114bb227f4216eb478c22dc98c8194cb7f
2018-08-20tests: Remove {old,new}.file.Tao Bao1-49/+54
They serve the same purpose as {boot,recovery}.img, except that they're not structured to be imgdiff'd. Remove the two files and replace all the uses with {boot,recovery}.img instead. Bug: 110106408 Test: Run recovery_{unit,component}_test on marlin. Change-Id: I8e71187d5b0c142ad932f33717f6fae364b43abc
2018-07-12tests: Clean up the temporary dirs post-run.Tao Bao1-19/+19
TemporaryDir only deletes empty dirs (not done by its dtor because it tries to keep the temporary files available on error exit). Also change FreeCacheTest::MockFreeSpaceChecker to be static. Test: Run recovery_unit_test on marlin. Check /data/local/tmp post-run. Change-Id: I1bd54eb840e3094b4f22ee84c059eec2998773bf
2018-07-12applypatch: Fix the return type of FreeSpaceForFile().Tao Bao1-6/+18
Prior to this CL, FreeSpaceForFile() was returning `size_t`, which may overflow on ILP32 when called on a partition with 4GiB+ free space. Additionally, it was returning static_cast<size_t>(-1) on error, but the caller in freecache.cpp didn't check for that. This CL changes its return type to `int64_t`, and moves the function into freecache.cpp since there's no external caller. Test: Run recovery_unit_test on marlin. Test: Code search shows no external user of FreeSpaceForFile(). Change-Id: I00f501a057726e1f1ab69f367c46c77b30f2d774
2018-07-10applypatch: Restrict applypatch_check to eMMC targets.Tao Bao1-85/+47
Also fix an error-pone behavior in previous code when verifying an eMMC target. As long as it loads the partition content successfully according to the SHAs embedded in the filename, it shouldn't further check against the SHAs given in the second argument. Because the loaded contents relate to a specific partition size. For example: apply_patch_check( "EMMC:/boot.img:src_size:src_hash:tgt_size:tgt_hash", "src_hash"); Assume "/boot.img" already has the desired hash of "tgt_hash", the previous code would give wrong verification result. The issue can be addressed by additionally listing "tgt_hash" as one of the desired SHAs (or by applying this CL). Bug: 110106408 Test: Run recovery_unit_test and recovery_component_test on marlin. Change-Id: I8daafdbecd083f687e24d563ab089caa25667633
2018-07-06tests: Split unit tests out of component/applypatch_test.cpp.Tao Bao1-0/+303
... into unit/applypatch_test.cpp. And rename the file to component/applypatch_modes_test.cpp. Bug: 110106408 Test: Run recovery_unit_test and recovery_component_test on marlin. Change-Id: Ic23c4f054baa2fa0d5e8ea2fcffd22572f1f112e