diff options
author | Kevin Jeon <kevinjeon@google.com> | 2023-07-27 11:36:41 -0400 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-08-04 02:08:07 +0000 |
commit | 9d635641929acf81f6b4972dd19c35ee8dd8a89e (patch) | |
tree | 4ca73cf88363044b22577a034bb13ea434a3c5cd | |
parent | 3f83737e64ad89fb13db3d39fe57d4bbb7d641b4 (diff) | |
download | native-9d635641929acf81f6b4972dd19c35ee8dd8a89e.tar.gz |
Add sysprop for identifying strict-run bugreports
This change adds 'dumpstate.strict_run', which sets stricter timeouts on
flaky sections. The default value for this property is 'true'.
Test: Build, wipe, and flash, then verify that:
1) the strict-run log is emitted when taking a bug report
2) manually running 'setprop dumpstate.strict_run false' results in
the strict-run log not being emitted in the next bug report
Bug: 283326935
(cherry picked from https://android-review.googlesource.com/q/commit:fa64e6412bd607e198a199b39cc18024e6e99105)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2a5a1a92dfdf911e095a0298a1b4f81905d9efec)
Merged-In: Ic40b235f710b2858ec8ca463a8f6a796d9e6c98e
Change-Id: Ic40b235f710b2858ec8ca463a8f6a796d9e6c98e
-rw-r--r-- | cmds/dumpstate/DumpstateUtil.cpp | 9 | ||||
-rw-r--r-- | cmds/dumpstate/DumpstateUtil.h | 8 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 18 |
3 files changed, 31 insertions, 4 deletions
diff --git a/cmds/dumpstate/DumpstateUtil.cpp b/cmds/dumpstate/DumpstateUtil.cpp index aa42541a66..615701ccc1 100644 --- a/cmds/dumpstate/DumpstateUtil.cpp +++ b/cmds/dumpstate/DumpstateUtil.cpp @@ -207,6 +207,7 @@ std::string PropertiesHelper::build_type_ = ""; int PropertiesHelper::dry_run_ = -1; int PropertiesHelper::unroot_ = -1; int PropertiesHelper::parallel_run_ = -1; +int PropertiesHelper::strict_run_ = -1; bool PropertiesHelper::IsUserBuild() { if (build_type_.empty()) { @@ -237,6 +238,14 @@ bool PropertiesHelper::IsParallelRun() { return parallel_run_ == 1; } +bool PropertiesHelper::IsStrictRun() { + if (strict_run_ == -1) { + // Defaults to using stricter timeouts. + strict_run_ = android::base::GetBoolProperty("dumpstate.strict_run", true) ? 1 : 0; + } + return strict_run_ == 1; +} + int DumpFileToFd(int out_fd, const std::string& title, const std::string& path) { android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC))); if (fd.get() < 0) { diff --git a/cmds/dumpstate/DumpstateUtil.h b/cmds/dumpstate/DumpstateUtil.h index b00c46e0db..9e955e3c04 100644 --- a/cmds/dumpstate/DumpstateUtil.h +++ b/cmds/dumpstate/DumpstateUtil.h @@ -193,11 +193,19 @@ class PropertiesHelper { */ static bool IsParallelRun(); + /* + * Strict-run mode is determined by the `dumpstate.strict_run` sysprop which + * will default to true. This results in shortened timeouts for flaky + * sections. + */ + static bool IsStrictRun(); + private: static std::string build_type_; static int dry_run_; static int unroot_; static int parallel_run_; + static int strict_run_; }; /* diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 8a337569c4..e93b46c666 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -822,9 +822,12 @@ void Dumpstate::PrintHeader() const { RunCommandToFd(STDOUT_FILENO, "", {"uptime", "-p"}, CommandOptions::WithTimeout(1).Always().Build()); printf("Bugreport format version: %s\n", version_.c_str()); - printf("Dumpstate info: id=%d pid=%d dry_run=%d parallel_run=%d args=%s bugreport_mode=%s\n", - id_, pid_, PropertiesHelper::IsDryRun(), PropertiesHelper::IsParallelRun(), - options_->args.c_str(), options_->bugreport_mode_string.c_str()); + printf( + "Dumpstate info: id=%d pid=%d dry_run=%d parallel_run=%d strict_run=%d args=%s " + "bugreport_mode=%s\n", + id_, pid_, PropertiesHelper::IsDryRun(), PropertiesHelper::IsParallelRun(), + PropertiesHelper::IsStrictRun(), options_->args.c_str(), + options_->bugreport_mode_string.c_str()); printf("\n"); } @@ -1046,7 +1049,8 @@ static void DumpIncidentReport() { MYLOGE("Could not open %s to dump incident report.\n", path.c_str()); return; } - RunCommandToFd(fd, "", {"incident", "-u"}, CommandOptions::WithTimeout(20).Build()); + RunCommandToFd(fd, "", {"incident", "-u"}, + CommandOptions::WithTimeout(PropertiesHelper::IsStrictRun() ? 20 : 120).Build()); bool empty = 0 == lseek(fd, 0, SEEK_END); if (!empty) { // Use a different name from "incident.proto" @@ -3127,6 +3131,12 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n"); } + if (PropertiesHelper::IsStrictRun()) { + MYLOGI( + "Running on strict-run mode, which has shorter timeouts " + "(to disable, call 'setprop dumpstate.strict_run false')\n"); + } + MYLOGI("dumpstate info: id=%d, args='%s', bugreport_mode= %s bugreport format version: %s\n", id_, options_->args.c_str(), options_->bugreport_mode_string.c_str(), version_.c_str()); |