summaryrefslogtreecommitdiff
path: root/common/subprocess_unittest.cc
AgeCommit message (Collapse)Author
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-09-16Fix remaining styling and compiling issuesAmin Hassani
Bug: 163153182 Test: FEATURES=test emerge-reef update_engine Change-Id: I12d95920946fee1866f721783f16795c1ad4c2d9
2020-07-28Reduce wait time in SubprocessTest.CancelTestQijiang Fan
With AsynchronousSignalHandler switching to base::FileDescriptorWatcher, there's no more IOTask under the MessageLoop. Thus MessageLoopRunUntil will block until the timeout task (unless there's some other task being posted). It was designed to call the callback to check whether it should stop for every posted task run. But now IOTask is gone, and no other task is posted, it will wait until timeout. On Chrome OS, 120s timeout doesn't appear a problem. But on AOSP, it looks the test is failing timeout. Test: mma && unittest SubprocessTest.CancelTest finish quickly. Change-Id: I8bbc5f0371dfe344e6173ff1a81444813affe808
2020-07-23Update UE to remove MessageLoop::current()->WatchFileDescriptor.Tianjie
MessageLoop::current()->WatchFileDescriptor is deprecated. And UE should remove usages of it. Test: mma && unittest Change-Id: Ib1ef2e6b6a38ad2a8d07b78bcd72fdb3b7f82226
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
2019-11-24update_engine: Get rid of WatchFileDescriptor.Qijiang Fan
The API is removed in the next libchrome uprev to r576297. This CL replaces the use by new API base::FileDescriptorWatcher. BUG=chromium:909719 TEST=Build locally. Ran cros_run_unit_tests. Change-Id: I318b35b2d00742955f6877c4e36624e4c672827b Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1924097 Tested-by: Qijiang Fan <fqj@google.com> Reviewed-by: Amin Hassani <ahassani@chromium.org> Commit-Queue: Qijiang Fan <fqj@google.com>
2019-11-07update_engine: pipe stderr individually in SycnronousExecAmin Hassani
Currently, SyncronousExec pipes stderr to stdout which is fine but not ideal. Specially we have an issue with vpd_get_value script that exits with 0 even with underlying failures. This is problematic, because we get the combined stdout/stderr of the command and since the exit code is 0 we assume the output is correct. Then, we create the XML request based on this output but with stderr combined (too much junk) as the value of an XML attribute. This causes update failure. Fortunately, vpd_get_value correctly separates its children's stderr and stdout. So as long as we don't combine both stdout and stderr into one stream, this error wil not happen again anymore. Also a few other nitpicks in this CL: - Constructing the command for shutdown using simpler syntax. - Logging the command before running it for all external subprocess runs. BUG=chromium:1010306 TEST=sudo FEATURES=test emerge update_engine Change-Id: Ia620afed814e4fe9ba24b1a0ad01680481c6ba7c Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1901886 Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Andrew Lassalle <lassalle@chromium.org> Reviewed-by: Jae Hoon Kim <kimjae@chromium.org> Commit-Queue: Amin Hassani <ahassani@chromium.org>
2019-01-16update_engine: Run clang-format on common/Amin Hassani
BUG=none TEST=unittest Change-Id: Icdaf5017e03a197bc576f08f4b8dcdd00cff217c Reviewed-on: https://chromium-review.googlesource.com/1407541 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Sen Jiang <senj@chromium.org>
2018-11-21Revert "Partially Revert 2b9d241"Hidehiko Abe
This reverts commit 71818c8409812c5a08124627c19aa8ea0625a72e. This patch was created because the upstream update_engine was using the new version of libchrome and the Chrome OS one was not. Now that we are upreving libchrome on Chrome OS we can revert this. BUG=b:37434548 TEST=Build CQ-DEPEND=CL:1240033 Change-Id: I98b7d124212087292500701782de08b3d3ecc559 Reviewed-on: https://chromium-review.googlesource.com/1239818 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Hidehiko Abe <hidehiko@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>
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-07-26Revert "update_engine: Update libchrome APIS to r456626."Luis Hector Chavez
This reverts commit 663ff4b30b9f629a130ef6d357d462b897d4071e. Reason for revert: Broke the mac_sdk Exempt-From-Owner-Approval: Fixing mac_sdk Change-Id: I8184ec58e74d62dca0deafb39340d4bd36bf40e0
2017-07-26update_engine: Update libchrome APIS to r456626.Jay Civelli
The new libchrome has been ported from Chromium and some APIs have changed. Make necessary changes at call sites. Change-Id: I8c3cea4510774c813a5d8fb10240918b5736884e
2017-05-31update_engine: clean up sleep process in SubprocessTest.CancelTestBen Chan
SubprocessTest.CancelTest terminates a 'sh' process, which is put into sleep by executing `sleep 60`. Upon receiving SIGTERM, the 'sleep' process isn't reaped and thus becomes orphaned. As a remedy, this CL modifies the shell command to trap SIGTERM and kill the 'sleep' process upon receiving SIGTERM. BUG=chromium:678643 TEST=Verified that no orphaned 'sleep' process is left after running SubprocessTest.CancelTest. Reviewed-on: https://chromium-review.googlesource.com/427059 Commit-Ready: Ben Chan <benchan@chromium.org> Tested-by: Ben Chan <benchan@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> (cherry picked from commit efb56850475b27ab9197c6010a3f3910b078cdc2) Change-Id: I7a94b317b524c6de81e94a1f01c29aeb9b3de85c
2016-07-28Fix clang-tidy performance warnings in update_engine.Chih-Hung Hsieh
* Use const reference type for parameters, local variables, and for-loop index variables to avoid unnecessary copy. * Convert some for-loops to for-rang loops. Bug: 30407689 Bug: 30413223 Bug: 30413862 Change-Id: I78996b3f799639fc57ced45e110807625be7dcce Test: build with WITH_TIDY=1
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-04-08Fix PipeClosedWhenNotRedirectedTest.Alex Deymo
When checking for a file descriptor open on the child, we now execute a simple test program that just runs fstat on that file descriptor. This is more reliable than calling sh on different platforms. Bug: 26955860 TEST=Ran unittests on edison-eng and Chromium OS. Change-Id: I5d5d87095564159df1a75e78b0aed29c16bc7eb8
2016-04-05Revert "Make transition to "postinstall" domain explicit."Alex Deymo
This reverts commit 20e3960e245f6dfa57fa5c9124b0fd33e679f723. Bug: 28008031 Change-Id: If5fcb949dee91779bea465793ec2b333d27a704e
2016-04-05Make transition to "postinstall" domain explicit.Alex Deymo
When running the postinstall program, we were relying on the automatic transition between update_engine domain and postinstall, which required postinstall_file to be an entrypoint for such domain. This patch makes the transition explicit by calling setexeccon(3). Bug: 28008031 TEST=make dist; Deployed an update to edison-eng: postinstall runs as "postinstall" domain. Change-Id: I27d404886841e0bd39589f0274eaaf98929eeac9
2016-04-04Subprocess: Close all unused file descriptors.Alex Deymo
This patch extends Subprocess::ExecFlags() method with a list of file descriptors that should be kept open on the child process and mapped to a pipe() in the parent. The remaining file descriptors will be closed. Bug: 27880754 TEST=Added unittests for this functionality. Change-Id: Id96fb6a72f7805a0bfacfbc85422dc7d44750d93
2016-02-19Fix Subprocess unittests.Alex Deymo
TEST=/data/nativetest/update_engine_unittests/update_engine_unittests --gtest_filter=SubprocessTest.* Change-Id: Ib4ed3768f81f1c1f476eb832df3b5e1aa80c8814
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-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