diff options
author | 2018-01-05 13:15:49 -0800 | |
---|---|---|
committer | 2018-01-05 13:15:49 -0800 | |
commit | 20cf5036c1f373c1acfbb95295f118b7ff6c2227 (patch) | |
tree | b170bcce3339241f716cafff57f933345a7a3f34 /cmds/dumpstate/dumpstate.cpp | |
parent | cdd574e12df39e0921a4b2f3f34955f49b9a3d40 (diff) |
Add bugreport section progress reporter
- Allow dumpstatelisteners to monitor section size and duration and errors while the
bugreport is generated. Data will be used to write smoke tests for bugreport.
- Refactor main function to allow test to call dumpstate main function. Required until
bugreport api is completed
- Restore stdout and stderr fds before exiting dumpstate
Bug: 70154685
Test: mmm -j56 frameworks/native/cmds/dumpstate && \
adb sync data && \
adb shell /data/nativetest64/dumpstate_test/dumpstate_test && \
printf "\n\n#### ALL TESTS PASSED ####\n"
Change-Id: I7e0938baf6e055f14dce2348d0fe99f261870bf1
Diffstat (limited to 'cmds/dumpstate/dumpstate.cpp')
-rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 143192eba0..eb9079b0f1 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -1545,7 +1545,8 @@ static void Vibrate(int duration_ms) { // clang-format on } -int main(int argc, char *argv[]) { +/** Main entry point for dumpstate. */ +int run_main(int argc, char* argv[]) { int do_add_date = 0; int do_zip_file = 0; int do_vibrate = 1; @@ -1558,6 +1559,8 @@ int main(int argc, char *argv[]) { bool show_header_only = false; bool do_start_service = false; bool telephony_only = false; + int dup_stdout_fd; + int dup_stderr_fd; /* set as high priority, and protect from OOM killer */ setpriority(PRIO_PROCESS, 0, -20); @@ -1829,11 +1832,13 @@ int main(int argc, char *argv[]) { } if (is_redirecting) { + TEMP_FAILURE_RETRY(dup_stderr_fd = dup(fileno(stderr))); redirect_to_file(stderr, const_cast<char*>(ds.log_path_.c_str())); if (chown(ds.log_path_.c_str(), AID_SHELL, AID_SHELL)) { MYLOGE("Unable to change ownership of dumpstate log file %s: %s\n", ds.log_path_.c_str(), strerror(errno)); } + TEMP_FAILURE_RETRY(dup_stdout_fd = dup(fileno(stdout))); /* TODO: rather than generating a text file now and zipping it later, it would be more efficient to redirect stdout to the zip entry directly, but the libziparchive doesn't support that option yet. */ @@ -1907,7 +1912,7 @@ int main(int argc, char *argv[]) { /* close output if needed */ if (is_redirecting) { - fclose(stdout); + TEMP_FAILURE_RETRY(dup2(dup_stdout_fd, fileno(stdout))); } /* rename or zip the (now complete) .tmp file to its final location */ @@ -2038,7 +2043,7 @@ int main(int argc, char *argv[]) { MYLOGI("done (id %d)\n", ds.id_); if (is_redirecting) { - fclose(stderr); + TEMP_FAILURE_RETRY(dup2(dup_stderr_fd, fileno(stderr))); } if (use_control_socket && ds.control_socket_fd_ != -1) { |