summaryrefslogtreecommitdiff
path: root/payload_consumer/postinstall_runner_action_unittest.cc
AgeCommit message (Collapse)Author
2021-05-05Rename postinstall_mount_device to readonly_target_pathKelvin Zhang
When postinstall_mount_device is initially introduced, it's only intended to be used by postinstall action, hence the name. Now we plan to use it for fs verification purpose as well, rename for better clarity. Test: th Change-Id: Iff996f2f513bb44694e39d758a69851793b9a565
2021-03-30Allow /postinstall files to have custom contextsAlex Light
We were mounting /postinstall with a 'context=...' option. This forces all files within /postinstall to have a single selinux context, limiting the possible granularity of our policies. Here we change it to simply default to the 'postinstall_file' context for the 'system' partition but allow individual files to have their own custom contexts defined by /system/sepolicy. Other partitions retain the single 'postinstall_file' context. The sample_images were updated to manually add a selinux label for testing FS contexts. Test: Manual OTA of blueline Test: atest update_engine_unittests Bug: 181182967 Change-Id: I0b8c2b2228fa08afecb64da9c276737eb9ae3631 Merged-In: I0b8c2b2228fa08afecb64da9c276737eb9ae3631
2020-12-07Mock a /postinstall dir at test timeKelvin Zhang
Bug: 172696594 Test: treehugger Change-Id: Ib6264569d090dc61fc9ded5f833e3841ec16a8dd
2020-11-23Do not map dynamic partitions on VABC devicesKelvin Zhang
With VABC, we no longer need to map all partitions before reading/writing, so don't try to map them. 1. modify GetPartitionDevice to return empty path for target partitions on VABC 2. Add a separate GetMountableTargetDevice for obtaining a mountable device path, specifically for postinstall Test: treehugger Change-Id: Ib1f608914fc49c677ce7389140ca79b028171191
2020-11-03update_engine: Create cros vs. aosp boundary clearAmin Hassani
Its time to make the boundary between Chrome OS and Android code more clear. This CL moves all CrOS only code to "chromeos" directory and the same for Android (in "android" directory). This way we would easily know which code is uses in which project and can keep the code cleaner and more maintainable. One big remaining problem is download_action* files. It seems like DownloadAction class does a lot of things that chrome OS needs and it depends on a lot of Chrome OS stuff, but Android is also using thie Action in a way that circumvent the Chrome OS stuff. For example Android checks for SystemState to be nullptr to not do things. This is really fragile and needs to change. Probably Android Team has to implement their own DownloadAction of some sort and not re use the Chrome OS one in a very fragile way. Removed a few android files that have not been used anywhere. Changed some clang-format and lint issues in order to pass preupload. BUG=b:171829801 TEST=cros_workon_make --board reef --test update_engine Change-Id: I3fff1d4a100a065a5c1484a845241b5521614d9f Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2508965 Tested-by: Amin Hassani <ahassani@chromium.org> Auto-Submit: Amin Hassani <ahassani@chromium.org> Reviewed-by: Jae Hoon Kim <kimjae@chromium.org> Reviewed-by: Tianjie Xu <xunchang@google.com> Reviewed-by: Kelvin Zhang <zhangkelvin@google.com> Commit-Queue: Amin Hassani <ahassani@chromium.org>
2020-10-23update_engine: remove usages of base::MessageLoop.Qijiang Fan
It's replaced by base::SingleThreadTaskExecutor. BUG=chromium:1094927 TEST=unittest Change-Id: I281063564037a2ccf1b93d00253180a0000abd09 Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2474955 Commit-Queue: Qijiang Fan <fqj@google.com> Tested-by: Qijiang Fan <fqj@google.com> Reviewed-by: Amin Hassani <ahassani@chromium.org>
2020-07-29Update language to comply with Android's inclusive language guidanceSaint Chou
See https://source.android.com/setup/contribute/respectful-code for reference #inclusivefixit Bug: 161896447 Change-Id: Icb9e2fca7e27a2ee81380897134deae6c4a24053 Test: NA (Comment only)
2020-07-06Merge remote-tracking branch 'aosp/upstream-master' into mergeTianjie
It's a merge from chrome OS with some reverts. 1. the fd watcher change, because the libbrillo version isn't compatible in aosp. commit 6955bcc4ffe4cc9d62a88186b9a7e75d095a7897 commit 493fecb3f48c8478fd3ef244d631d857730dd14d 2. two libcurl unittest. Because the RunOnce() of the fake message loop seems to have different behavior in aosp. commit d3d84218cafbc1a95e7d6bbb775b495d1bebf4d2 Put preprocessor guards to use the old code in aosp. And we can switch to the new code in the other path after adopting the new libbrillo & libchrome. Test: unit tests pass, apply an OTA Change-Id: Id613599834b0f44f92841dbeae6303601db5490d
2020-01-14Allow update_engine to skip post-installTianjie Xu
The postinstall steps take long time to finish, even though most of them are optional. Therefore, reuse the flag run_post_install in InstallPlan to allow skipping optional postinstalls. Bug: 136185424 Test: cancel the update during post-install, apply again with the header "RUN_POST_INSTALL=0", check the optional post-installs are skipped Change-Id: Ic5ab89b079dfd547714fd3d1664e044900f9eebe
2019-09-17update_engine: AddressSanitizer PostinstallerRunnerAction RunAsRoot leak fixJae Hoon Kim
The reason why this change is required is because of |FileDescriptorWatcher::Controller| within |PostinstallRunnerAction|. If the delay is too short (previously 10ms) it was possible for the posted task within the |FileDescriptorWatcher::Controller| to be present after that of the task which stops the processor. In order to mitigate this issue, the process of stopping the processor should be a |PostDelayedTask()| instead of a direct call in stopping the processor to ensure the processor stops after |Watcher::StartWatching()| happens. Within |FileDescriptorWatcher::Controller| it states: "If the MessageLoopForIO is deleted before Watcher::StartWatching() runs, |watcher_| is leaked." BUG=chromium:989749 TEST=FEATURES="nostrip" ./build_packages --board amd64-generic --withdebugsymbols TEST=FEATURES="test nostrip -splitdebug" USE="asan debug" CFLAGS="-g -O2" CXXFLAGS="-g -O2" emerge-amd64-generic update_engine TEST=sudo cat /build/amd64-generic/tmp/portage/chromeos-base/update_engine-9999/temp/asan_logs/asan.10 | asan_symbolize.py -s /build/amd64-generic -d > /tmp/asan.log Change-Id: I88f0a86686830553fea150d0188b2851753c2f94 Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1796613 Tested-by: Jae Hoon Kim <kimjae@chromium.org> Reviewed-by: Amin Hassani <ahassani@chromium.org> Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
2019-04-24update_engine: Place enterprise rollback save marker fileZentaro Kavanagh
- There are now two types of rollback. One that does a full powerwash and one that save some system state. - When an enterprise rollback powerwash is scheduled, place a marker file to tell the shutdown process to save data before rebooting. - This lets rollback preserve additional data over a powerwash that can be restored later. - Change a few places that were using is_rollback to save_rollback_data to be explicit. BUG=chromium:955463 TEST=unittests Change-Id: I9f18319e711e425a6e712dd319e03bcc6ddd0a1b Reviewed-on: https://chromium-review.googlesource.com/1414030 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zentaro Kavanagh <zentaro@chromium.org> Reviewed-by: Amin Hassani <ahassani@chromium.org>
2019-01-22update_engine: Add support for enterprise rollback powerwashZentaro Kavanagh
- Adds the additional flag "rollback" to the powerwash file - This flag allows additional data to be preserved over a powerwash - Adds tests BUG=chromium:881341 TEST=unittests Change-Id: I4487f4de856ea8d2d0255e8de4cd1ba0762a8e53 Reviewed-on: https://chromium-review.googlesource.com/1412683 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zentaro Kavanagh <zentaro@chromium.org> Reviewed-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Sen Jiang <senj@chromium.org>
2019-01-10Remove unused functions in test_utils.Sen Jiang
Also cleaned up unused includes. Test: mma Change-Id: I8e19648f4d866615de9ae5abeb29d8c8b8f37b36
2018-08-13Merge remote-tracking branch 'aosp/upstream-master' into aosp/master.Sen Jiang
The following change is reverted because aosp has newer libchrome. 71818c84 Partially Revert 2b9d241 Added stub override for ReportInternalErrorCode(). Fixed RunPosinstallAction typo. Bug: 112326236 Test: update_engine_unittests Change-Id: Ieaae0eef425cbb1278067a48aa19b14ed056317a
2018-07-25update_engine: Pass Action ownership to ActionProcessorAmin Hassani
Currently, an object that uses an ActionProcessor for processing one or more actions has to own the Actions. This is problematic, because if we want to create an action on the fly and use an ActionProcessor to perform it, we have to own the Action until it is finished. Furthermore, if someone forget to own the action, there will be memory leaks because ActionProcessor does not delete the Action. This patch passes the ownership of the Actions to the ActionProcessor through unique pointers. If an object wants to have access to the Action, it can get it when ActionComplete() is called. BUG=chromium:807976 TEST=unittests TEST=cros flash TEST=precq Change-Id: I28f7e9fd3425f17cc51b4db4a4abc130a7d6ef8f Reviewed-on: https://chromium-review.googlesource.com/1065113 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Xiaochu Liu <xiaochu@chromium.org>
2018-05-14update_engine: Process Omaha response for rollback imagesMarton Hunyady
Omaha returns whether the image returned is a rollback in the _rollback="true" argument. If this is set, the client has to check whether it's OK to apply the rollback image (policy is specifically requesting a rollback and verified boot will accept the image based on its kernel and firmware key versions). In addition to this, the device has to do a safe powerwash if the image is a rollback. (We're not supporting rollbacks with partial or no powerwash yet.) We're also setting the rollback_happened preference to avoid force updates happening before the policy is available again. Chromium CL adding the error code: http://crrev.com/c/1047866 BUG=chromium:840432 TEST='cros_run_unit_tests --board=caroline --packages update_engine' Change-Id: I1436ca96211b2a8523e78bf83602ef8b6b525570 Reviewed-on: https://chromium-review.googlesource.com/1047610 Commit-Ready: Marton Hunyady <hunyadym@chromium.org> Tested-by: Marton Hunyady <hunyadym@chromium.org> Reviewed-by: Amin Hassani <ahassani@chromium.org>
2018-03-19Partially Revert 2b9d241Amin Hassani
2b9d2417722cd4052b0e22494886f93c5b4ef042 update_engine: Update libchrome APIS to r456626. The above commit changes the libchrome API used in update_engine to r456626. But the libchrome has not been upreved fully in the CrOS yet with the exception of some changes represented in UE like CL:882543. So, now we need to revert the changes partially untill the libchrome is updated. BUG=chromium:815356 TEST=unittests, precq Change-Id: If2207f0672c7b9f6dab84e676d9fb8423a047372 Reviewed-on: https://chromium-review.googlesource.com/965266 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org> Reviewed-by: Sen Jiang <senj@chromium.org>
2018-01-11Merge remote-tracking branch 'goog/upstream-master'.Sen Jiang
The following commits were reverted: 840703a Fix update over cellular network on guest account eaad5d0 Do not merge to AOSP: Fixes the link to brillo-clang-format in CrOS 740efad Reboot even if a system update is not available. Fixed a few sign compare warnings. Had to ifdef out 2 SquashfsFilesystemTest because it depends on unsquashfs -m. Test: update_engine_unittests Change-Id: I6f4ca5003e78c76064ec60d0797505d8c18d00bf Merged-In: I6f4ca5003e78c76064ec60d0797505d8c18d00bf
2017-12-18update_engine: Update libchrome APIS to r456626.Hidehiko Abe
The new libchrome has been ported from Chromium and some APIs have changed. Make necessary changes at call sites. BUG=chromium:724678 CQ-DEPEND=CL:480928 Test: Build. Change-Id: I01b70da87521d0884ed21acbd7ed3e0ff1e94357 Merged-In: I4dbaea4a2a19031375a8bf2415645a4f226dab57
2017-09-21update_engine: Replace vector<Extent> with RepeatedPtrField<Extent>Amin Hassani
This patch removes references to vector<Extent> and replaces them with RepeatedPtrField in payload_consumer. Extent itself is a protobuf item and it makes sense to use google::protobuf::RepeatedPtrField instead of vector because then we won't have any extra copy to vector. We can directly use the list of extents given in the payload protobuf. Also removed references to vector in files which did not use vector. BUG=chromium:766397 TEST=FEATURES="test" emerge-amd64-generic update_engine Change-Id: I1f12332ff4d6303c1e4b7470bb87bf934acdf81a Reviewed-on: https://chromium-review.googlesource.com/672006 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org>
2016-07-27update_engine: Update libchrome APIs to r405848Luis Hector Chavez
The new libchrome has been ported from Chromium and some APIs have changed. Make necessary changes at call sites. Notable changes from libchrome: - base::Bind() now explicitly disallows captures in lambdas (which was never allowed in the style guide), so lambdas should now be written in a way that take the captures as parameters. Bug: 29104761 Test: All tests in update_engine_unittest pass on dragonboard-eng build Change-Id: Iec04c126630fd876114076e3cb10cf917c8817b0
2016-06-10Add a few more unittest for parsing global_progress.Alex Deymo
Postinstall program can occasionally return garbage instead of a fraction. Add two more test cases. Bug: None TEST=unittests still pass. Change-Id: Ia444acada78eaa124c618b68d3f0880b2348c8f6
2016-06-09Implement powerwash on Android.Alex Deymo
Powerwash, the name for the equivalent of a factory reset or /data wipe, can be triggered in Android by writing the desired command to the recovery command file and rebooting into recovery. This patch moves the powerwash scheduling/canceling logic to the HardwareInterface and implements it on Android. Bug: 28700985 TEST=Called update_engine_client passing POWERWASH=1, BCB is stored up to offset 832. Change-Id: If737fd4b9b3e2ed9bce709b3b59f22e9f0a3dc9a
2016-04-13Remove utils::MakeTempDirectory().Sen Jiang
In favor of base::ScopedTempDir, except for PostinstallRunnerAction, where the temp directory needs to be removed for every partition. ScopedDirRemover is also removed because it's no longer used. Test: ./update_engine_unittests Test: cros_workon_make update_engine --test Bug: 26955860 Change-Id: I954e6e892aff0cf9f8434a77408dc3c9eb64c1b5
2016-04-12Remove postinstall unittests root check.Alex Deymo
Not all the postinstall tests need to be runned as root. Remove the global check. Bug: None TEST=FEATURES=test emerge-link update_engine Change-Id: I269e413a26ec84022448e64b34a5ee795b5a6e31
2016-04-04Parse postinstall program progress updates.Alex Deymo
In Android postinstall is expected to take a long time in common cases. This patch allows the postinstall program to report back to the updater a progress indication, which will then be forwarded to all the clients listening. These progress updates are part of the FINALIZING status. Bug: 27880754 TEST=Added unittests. Deployed an update to an edison-eng and post-install reported progress back with the postinstall_example. Change-Id: I35f96b92f090219c54cca48d8ab07c54cf8b4ab1
2016-03-23Fix unittest key path in Brillo.Sen Jiang
The unittests weren't able to find the keys if it's not run from the update_engine_unittests directory. Test: /data/nativetest/update_engine_unittests/update_engine_unittests Bug: 26955860 Change-Id: I4c189cca2714986d3d2b2669b54a5dff9a488964
2016-03-12Implement susped, resume and cancel for the Postinstall action.Alex Deymo
This patch sends SIGSTOP/SIGCONT to the running postinstall program to suspend/resume the child process, and SIGKILL when cancelling it. Bug: 27272144 TEST=Added unittest to check the signal being sent. Change-Id: Iebe9bd34448ad1d0a5340c82e1fd839ff8c69dd2
2016-03-12Rework postinstall unittests to pass on Android.Alex Deymo
Postinstall unittests were creating and mounting an image on each test run. This patch adds several test scripts to one of the pre-generated images and uses that image during postinstall testing instead. To workaround problems with mount/umount of loop devices on Android, this patch rewrites the `losetup` logic to make the appropriate syscalls and create the loop device with mknod if it doesn't exists. The tests require some extra SELinux policies to run in enforcing mode. Bug: 26955860 TEST=Ran all Postinstall unittests. Change-Id: I47a56b80b97596bc65ffe30cbc8118f05faff0ae
2016-02-29Parse postinstall parameters from the payload metadata.Alex Deymo
Payload v2 includes a description of the post-install command it should run, while in payload v1 we use the default values. This patch mounts the partition on the new top-level directory called /postinstall that should already be created. Bug: 27177071 TEST=FEATURES=test emerge-link update_engine Change-Id: Iaedf3b01e5e1ad57c68bd316b4b6e79cbab35bb6
2016-02-17Build unittests in Brillo.Alex Deymo
Many unittests do not pass for simple reasons that will be addressed later. This CL includes all the changes to make the unittests build. In particular, the generated DBus mocks, required to build several unittests are now included here. The dbus-constants.h files were moved to the system_api repo, so they can be removed from here. The unittest build is only enabled for Brillo targets, since non-Brillo targets don't even build DBus. Bug: 26955860 TEST=`mmma` on edison-eng (and aosp_arm-eng). Change-Id: Ib38241f0a6eb99b1d60d72db6bcfd125d38e3fad
2015-11-25Remove SystemState from post-install step.Alex Deymo
The post-install action only requires to mark the new slot as ready, for which it was including a reference to the whole SystemState. This patch removes said dependency replacing it for just the BootControlInterface. Bug: 25773375 TEST=FEATURES=test emerge-link update_engine; mma Change-Id: I814d47c138c7565e9a80f316f25e124adb0d9c4e
2015-11-12Split payload application code into a subdirectory.Alex Deymo
This patch splits from the main libupdate_engine code the part that is strictly used to download and apply a payload into a new static library, moving the code to subdirectories. The new library is divided in two subdirectories: common/ and payload_consumer/, and should not depend on other update_engine files outside those two subdirectories. The main difference between those two is that the common/ tools are more generic and not tied to the payload consumer process, but otherwise they are both compiled together. There are still dependencies from the new libpayload_consumer library into the main directory files and DBus generated files. Those will be addressed in follow up CLs. Bug: 25197634 Test: FEATURES=test emerge-link update_engine; `mm` on Brillo. Change-Id: Id8d0204ea573627e6e26ca9ea17b9592ca95bc23