summaryrefslogtreecommitdiffstats
path: root/tests/unit (follow)
Commit message (Collapse)AuthorAgeFilesLines
* updater: Add ABORT command.Tao Bao2018-07-071-0/+24
| | | | | | | | | | | This will be used for testing purpose only, replacing the previously used "fail", to intentionally abort an update. As we're separating the logic between commands parsing and execution, "abort" needs to be considered as a valid command during the parsing. Test: recovery_unit_test and recovery_component_test on marlin. Change-Id: I47c41c423e62c41cc8515fd92f3c5959be08da02
* tests: Split unit tests out of component/applypatch_test.cpp.Tao Bao2018-07-061-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
* updater: Check the number of args in Command::Parse.Tao Bao2018-06-251-0/+25
| | | | | | | | | Additionally checks for excess args when parsing ERASE, FREE, NEW, STASH and ZERO. Note that the check for MOVE, BSDIFF, IMGDIFF has been covered in Command::ParseTargetInfoAndSourceInfo. Test: Run recovery_unit_test on marlin. Change-Id: Ic8bc9b7a8dcf98f1f8db2e259607564508726857
* updater: Add Command parsing codes.Tao Bao2018-06-251-0/+275
| | | | | | | | The added codes are not used in the updater yet. The switch will happen in subsequent CLs. Test: Run recovery_unit_test and recovery_component_test on marlin. Change-Id: I1ae8a233280f02c2171b43ef028bdccdacb39c59
* tests: Skip ScreenRecoveryUITest on gr_init failure.Tao Bao2018-06-141-1/+38
| | | | | | | | | | | | | | | | | It addresses the ScreenRecoveryUITest failures on gce targets which don't have any graphics backend. Probing for all backend devices in tests could work, but would duplicate codes. This CL relies on the result of gr_init(). As a side effect, it may give false negatives if gr_init() is supposed to work but silently broken. But such issues are beyond ScreenRecoveryUITest's concern, which should be captured by the tests for minui or graphics backends instead. Fixes: 79616356 Test: Run recovery_unit_test on marlin. Test: Run recovery_unit_test on gce. Change-Id: I121aacc61c8a614447509506057ecfd8d86163e4
* ui: join only if joinable.Tao Bao2018-06-061-0/+5
| | | | | | | | The threads in RecoveryUI only get initialized if their Init()s finish successfully. Test: recovery_unit_test on marlin. Change-Id: Ic4b62300a3cbd47887d9f4a90dc26f8a7deab616
* tests: Specify the death test style to avoid flakiness.Tao Bao2018-06-052-0/+5
| | | | | | | | | | | | | | | | | | | As warned below (while running the test), the default death test style (i.e. "fast") doesn't work well in a threaded context, which causes test flakiness (timeout or early exit). [WARNING] external/googletest/googletest/src/gtest-death-test.cc:836:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 3 threads. This CL specifies the death test styles to be "threadsafe" for the following death tests. - RangeSetTest.GetBlockNumber - RangeSetTest.file_range - ScreenRecoveryUITest.LoadAnimation_MissingAnimation Test: mmma -j bootable/recovery Test: Run recovery_unit_test on marlin. Test passes and the above warning is gone. Change-Id: I245bbc09286702d5cb326f878c4391e842b66cc5
* Merge "ui: Use std::thread to create input/progress threads."Tao Bao2018-05-291-2/+10
|\
| * ui: Use std::thread to create input/progress threads.Tao Bao2018-05-221-2/+10
| | | | | | | | | | | | Test: Build and boot into recovery on walleye. Check the long press detection; `Run graphics test`. Change-Id: Ic3e9b0652fc3ff6fb3ad118df5ebb9bb4abda2cd
* | updater: Add Commmand class to manage BBOTA commands.Tao Bao2018-05-261-0/+37
|/ | | | | | | | | | | | Move the commands map parsing out of PerformBlockImageUpdate(), as this can be done more easily by the caller. The goal (not done in this CL) is to decouple command parsing logic from the performers. This allows (a) focusing on the command logic in the performer; and (b) extending BBOTA commands syntax separately. Test: Run recovery_unit_test and recovery_component_test. Change-Id: Ife202398a7660b152d84a3ba17b90f93d19c55f2
* wear_ui: Address a TODO regarding {intro,loop}_frames.Tao Bao2018-05-141-3/+53
| | | | | | | Also add tests for LoadAnimation that cover the change. Test: Run `recovery_unit_test` on marlin. Change-Id: I0380a5cdd0d85d55baecf7759eb647b6a9f3a085
* screen_ui: Fix an issue in RTL locale detection.Tao Bao2018-05-091-1/+1
| | | | | | | | | | | | | | | | The CL in [1] moved android.os.RecoverySystem to send the locale argument in well-formed BCP 47 language tags (e.g. "en-US" instead of "en_US"), with the matching changes to recovery code in [2]. However, the one in ScreenRecoveryUI::SetLocale() was missed, which broke RTL locale detection when using new format. [1] commit 38715228 in platform/frameworks/base [2] commit 2078b22e in platform/bootable/recovery Test: Set the locale to "ar-EG". `Run graphics test` under recovery. Check the progress bar. Test: Run recovery_unit_test on marlin. Change-Id: I7c7f5e0725bfb096109c7192c19f3f008e8e47e3
* tests: Add tests for ScreenRecoveryUI.Tao Bao2018-05-091-0/+167
| | | | | | | | | | | | In order to support that, this CL adds Paths::set_resource_dir() to override the default resource dir ("/res/images/") that's only available under recovery. Note that since there're external modules depending on libminui, it adds a separate function of res_set_resource_dir(), instead of requiring the dependency on libotautil for everyone. Test: mmma -j bootable/recovery Test: Run recovery_unit_test on marlin. Change-Id: I0a7dcf4476808bea9e634eaffc9676f6cbaf92b7
* otautil: Rename dir/sys/thermal utils.Tao Bao2018-05-043-5/+5
| | | | | Test: mmma -j bootable/recovery Change-Id: I32ab98549e91f993364306e4a88dc654221b3869
* Move menu headers/items to std::vector<std::string>.Tao Bao2018-05-031-12/+15
| | | | | | | | | Test: mmma -j bootable/recovery Test: Run recovery_unit_test on marlin. Test: Build and boot into recovery image on angler. Check the UI that shows menu ('View recovery log', 'Wipe data', 'Run locale test'). Test: Start recovery with '--prompt_and_wipe_data'. Check the UI. Change-Id: If8a4209e0bb4ca64f719f9f9465d3b3589a69cdc
* screen_ui: Merge Menu::Start() into its ctor.Tao Bao2018-05-031-21/+7
| | | | | | | | | | | Since we instantiate a Menu object each time for a given set of header/items, we don't have a use case of re-populating an existing Menu with different data (which is what Menu::Start() does). Test: mmma -j bootable/recovery Test: Run recovery_unit_test on marlin. Test: Build and boot into recovery image on angler. Check the UI. Change-Id: Iaa2ba9d406ebd74c015e43198c17c5335b38df53
* Factor out a menu class for screen uiTianjie Xu2018-03-241-0/+198
| | | | | | | | | | | Also consolidate the duplicate codes to draw the menu in ScreenRecoveryUI and WearRecoveryUI. This helps us to support text icons as menu in the future. Bug: 74397117 Test: Check the menu under recovery on bullhead and a wear device. Change-Id: Iba9b646c3828670f0e78a7e07d1a94a44e96bb0b Merged-In: Iba9b646c3828670f0e78a7e07d1a94a44e96bb0b
* Load-balancing update_verifier worker threads.Tao Bao2017-11-091-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this CL, the block verification works were assigned based on the pattern of the ranges, which could lead to unbalanced workloads. This CL adds RangeSet::Split() and moves update_verifier over. a) For the following care_map.txt on walleye: system 20,0,347,348,540,556,32770,33084,98306,98620,163842,164156,229378,229692,294914,295228,524289,524291,524292,524348,529059 vendor 8,0,120,135,32770,32831,94564,98304,98306 Measured the time costs prior to and with this CL with the following script. $ cat test_update_verifier.sh #!/bin/sh adb shell stop adb shell "cp /data/local/tmp/care_map.txt /data/ota_package/" for i in $(seq 1 50) do echo "Iteration: $i" adb shell "bootctl set-active-boot-slot 0" adb shell "echo 3 > /proc/sys/vm/drop_caches" adb shell "time /data/local/tmp/update_verifier" sleep 3 done Without this CL, the average time cost is 5.66s, while with the CL it's reduced to 3.2s. b) For the following care_map.txt, measured the performance on marlin: system 18,0,271,286,457,8350,32770,33022,98306,98558,163842,164094,196609,204800,229378,229630,294914,295166,501547 vendor 10,0,42,44,85,2408,32770,32806,32807,36902,74242 It takes 12.9s and 5.6s without and with the CL respectively. Fixes: 68553827 Test: recovery_unit_test Test: Flash new build and trigger update_verifier. Check the balanced block verification. Change-Id: I5fa4bf09a84e6b9b0975ee5f522724464181333f
* otautil: Remove the aborts in RangeSet::Parse().Tao Bao2017-11-071-14/+64
| | | | | | | | | | | | | | | | | | | We used to CHECK and abort on parsing errors. While it works fine for the updater use case (because recovery starts updater in a forked process and collects the process exit code), it's difficult for other clients to use RangeSet as a library (e.g. update_verifier). This CL switches the aborts to returning empty RangeSet instead. Callers need to check the parsing results explicitly. The CL also separates RangeSet::PushBack() into a function, and moves SortedRangeSet::Clear() into RangeSet. Test: recovery_unit_test Test: Sideload an OTA package with the new updater on angler. Test: Sideload an OTA package with injected range string errors. The updater aborts from the explicit checks. Change-Id: If2b7f6f41dc93af917a21c7877a83e98dc3fd016
* Move rangeset.h and print_sha1.h into otautil.Tao Bao2017-10-111-2/+2
| | | | | | | | | Also drop the "bootable/recovery" path in LOCAL_C_INCLUDES from applypatch modules. Test: lunch aosp_{angler,bullhead,fugu,dragon,sailfish}-userdebug; mmma bootable/recovery Change-Id: Idd602a796894f971ee4f8fa3eafe36c42d9de986
* Move Image/ImageChunk/PatchChunk declaration into header filesTianjie Xu2017-08-191-1/+1
| | | | | | | | | 1. Move the declaration of the Image classes to the header file to make testing easier. 2. Also move rangeset.h to bootable/recovery to allow access in imgdiff. Test: recovery component test Change-Id: I68a863e60a3f2e7ae46ee48f48eb15391f5f4330
* Merge "Add implemention of SortedRangeSet"Tianjie Xu2017-08-011-0/+47
|\
| * Add implemention of SortedRangeSetTianjie Xu2017-08-011-0/+47
| | | | | | | | | | | | | | | | | | This is useful in imgdiff to maintain the block ranges of splitted source image. Bug: 34220646 Test: mma && unit tests pass Change-Id: I6427f2ea50f0e3b0aa3dd01880ec0206679b7429
* | otautil: Clean up dirCreateHierarchy().Tao Bao2017-07-271-21/+11
|/ | | | | | | | | | | | - Changed to std::string based implementation (mostly moved from the former make_parents() in updater/install.cpp); - Removed the timestamp parameter, which is only neeed by file-based OTA; - Changed the type of mode from int to mode_t; - Renamed dirCreateHierarchy() to mkdir_recursively(). Test: recovery_unit_test passes. Test: No external user of dirCreateHierarchy() in code search. Change-Id: I71f8c4b29bab625513bbc3af6d0d1ecdc3a2719a
* otautil: Delete dirUnlinkHierarchy().Tao Bao2017-07-251-32/+0
| | | | | | | | | This function has become obsolete since we've removed file-based OTA support (it was needed by 'delete_recursive' edify function earlier). Test: mmma -j bootable/recovery Test: Code search shows no active user of the function. Change-Id: If6faaa759d4c849b79acba4e6adb82baadc89f7a
* kill package_extract_dirTianjie Xu2017-05-242-228/+0
| | | | | | | It's only used by file-based OTA which has been deprecated for O. Test: mma Change-Id: I439c93155ca94554d827142c99aa6c0845cc7561
* Move sysMapFile and sysReleaseMap into MemMapping class.Tao Bao2017-05-022-38/+27
| | | | | | | Test: recovery_component_test Test: recovery_unit_test Test: Apply an OTA on angler. Change-Id: I7170f03e4ce1fe06184ca1d7bcce0a695f33ac4d
* Change the internal representation in RangeSet.Tao Bao2017-04-031-6/+34
| | | | | | | | | | | | | | 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
* Move parse_range() and range_overlaps() into RangeSet.Tao Bao2017-03-311-0/+84
| | | | | | | | | | | | | | | 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
* Add the missing sr-Latn into png files and rename the png locale headerTianjie Xu2017-03-251-10/+11
| | | | | | | | | | | 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
* Refactor asn1_decoder functions into a class.Tao Bao2017-03-211-217/+180
| | | | | | | Test: mmma bootable/recovery Test: recovery_unit_test passes. Test: recovery_component_test passes. Change-Id: If0bf25993158eaebeedff55ba4f4dd0f6e5f937d
* verify_file: Add constness to a few addresses.Tao Bao2017-03-211-14/+14
| | | | | | | | | | 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
* Add checkers and tests for empty locale in PNG fileTianjie Xu2017-01-191-0/+3
| | | | | | | | | | | match_locale() will return false for empty locale string in the PNG file. Also add a manual test to validate if a PNG file is qualified to use under recovery. Bug: 34054052 Test: recovery_manual_test catches invalid PNG files successfully & Locale_test passed Change-Id: Id7e2136e1d8abf20da15825aa7901effbced8b03
* tests: Add test coverage for DirUtil.Tao Bao2016-12-221-0/+150
| | | | | Test: recovery_unit_test passes. Change-Id: I764c56404c7ccdd57ae5486c946fbc9ac6ae7bc9
* Merge "tests: Replace the O_RDONLY in access(2)."Tao Bao2016-12-221-6/+15
|\
| * tests: Replace the O_RDONLY in access(2).Tao Bao2016-12-221-6/+15
| | | | | | | | | | | | | | | | | | | | | | Although O_RDONLY gives the same value as F_OK (0), it's not the right friend of access(2). Also clean up the temporary files from ZipTest (TemporaryDir doesn't like non-empty directory). Test: recovery_unit_test passes and has no leftover. Change-Id: I66b90e43c0954c89ce08b36b9e2b4e84183b28f5
* | tests: Add testcase for ZipUtil.Tao Bao2016-12-221-0/+191
|/ | | | | Test: recovery_unit_test passes. Change-Id: I8ad364e88aaee31579ed7206aad8e5620518d797
* updater: Fix the wrong return value for package_extract_file().Tao Bao2016-11-151-3/+0
| | | | | | | | | | | | | | | 'bool success = ExtractEntryToFile()' gives opposite result. Fix the issue and add testcases. Change the one-argument version of package_extract_file() to explicitly abort for non-existent zip entry. Note that this is NOT changing the behavior. Prior to this CL, it aborts from Evaluate() function, by giving a general cause code. Now it returns kPackageExtractFileFailure. BUg: 32903624 Test: recovery_component_test works. Change-Id: I7a273e9c0d9aaaf8c472b2c778f7b8d90362c24f
* Move recovery_test.cpp out of unit testTianjie Xu2016-11-081-91/+0
| | | | | | | | Move recovery-refresh/persist tests out because these tests need special steps to run. Also switch the constants to std::string. Test: recovery_manual_test passed on an A/B device Change-Id: I60b3ec6f094044945c3aafc1fae540896a6ddea6
* otautil: Clean up SysUtil.cpp.Tao Bao2016-11-071-0/+140
| | | | | | | | | | Add unit testcases for sysMapFile(). Test: recovery_unit_test passes. Test: Build and use the new recovery image to sideload a package. Test: Build and use the new recovery image to install an update. Change-Id: I77d8f1ea151ab513865d992c256ba93a1fcb51a4
* tests: Fix unit/zip_test.cpp.Tao Bao2016-11-041-59/+50
| | | | | | | | | It's accidentally broken when refactoring the testdata path. Also clean up the testcase a bit by simplying the file reading. Test: recovery_unit_test passes. Change-Id: I592a1cf5a4eb9a7a5f4eecbc6426baeedeb02781
* Replace minzip with libziparchiveTianjie Xu2016-10-181-0/+93
| | | | | | | | | | | Clean up the duplicated codes that handle the zip files in bootable/recovery; and rename the library of the remaining utility functions to libotautil. Test: Update package installed successfully on angler. Bug: 19472796 Change-Id: Iea8962fcf3004473cb0322b6bb3a9ea3ca7f679e
* recovery: drop log/logger.hMark Salyzyn2016-10-041-1/+0
| | | | | | | | | | private/android_logger.h contains all we need. Test: compile Bug: 26552300 Bug: 31289077 Bug: 31456426 Change-Id: I6714d730372dc81f784e7f9dfee8a33848643a5d
* Fix matches_locale functionTianjie Xu2016-04-201-0/+29
| | | | | | | | | matches_locale was expecting input locale string to have at most one underscore; as a result "zh_CN_#Hans" ignores "zh_CN" and matches into "zh". Fix the match function and add unit tests. Bug: 27837319 Change-Id: I4e8a66f91cae6ac2a46b6bf21f670d5ea564c7c8
* recovery: use __android_log_pmsg_file_write for log filesMark Salyzyn2016-03-311-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | (cherry-pick from commit a4f701af93a5a739f34823cde0c493dfbc63537a) - Add call to __android_log_pmsg_file_write for recovery logging. - Add call to refresh pmsg if we reboot back into recovery and then allow overwrite of those logs. - Add a new one-time executable recovery-refresh that refreshes pmsg in post-fs phase of init. We rely on pmsg eventually scrolling off to age the content after recovery-persist has done its job. - Add a new one-time executable recovery-persist that transfers from pmsg to /data/misc/recovery/ directory if /cache is not mounted in post-fs-data phase of init. - Build and appropriately trigger the above two as required if BOARD_CACHEIMAGE_PARTITION_SIZE is undefined. - Add some simple unit tests NB: Test failure is expected on systems that do not deliver either the recovery-persist or recovery-refresh executables, e.g. systems with /cache. Tests also require a timely reboot sequence of test to truly verify, tests provide guidance on stderr to direct. Bug: 27176738 Change-Id: I17bb95980234984f6b2087fd5941b0a3126b706b
* Refactor existing tests to use gtestJed Estep2016-02-041-0/+238
Bug: 26962907 Change-Id: I5f80636af1740badeff7d08193f08e23f4e4fee1