diff options
| author | 2019-02-18 01:07:29 -0800 | |
|---|---|---|
| committer | 2019-02-18 01:07:29 -0800 | |
| commit | 48ea00fbd7f7f6673fa3375f9f27f8bf39e9f6c8 (patch) | |
| tree | 4763f7e59b352d7958db2900fd15921acdc902f9 | |
| parent | db40a75199ddfcd367c5b52da0fe714b48efa7b5 (diff) | |
| parent | 917b4d4392eff592c5381a481511a2b5bf703ced (diff) | |
Merge "Fix dumpstate smoke test"
am: 917b4d4392
Change-Id: Idaaf794a1a5bc487cee938c11ee913c147f0ac1a
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 15 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.h | 2 | ||||
| -rw-r--r-- | cmds/dumpstate/tests/dumpstate_smoke_test.cpp | 2 |
3 files changed, 13 insertions, 6 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 9ed89c48f2..dc3faa064f 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -2596,21 +2596,26 @@ Dumpstate::RunStatus Dumpstate::CopyBugreportIfUserConsented() { return Dumpstate::RunStatus::ERROR; } -/* Main entry point for dumpstate binary. */ -int run_main(int argc, char* argv[]) { +Dumpstate::RunStatus Dumpstate::ParseCommandlineAndRun(int argc, char* argv[]) { std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>(); Dumpstate::RunStatus status = options->Initialize(argc, argv); if (status == Dumpstate::RunStatus::OK) { - ds.SetOptions(std::move(options)); + SetOptions(std::move(options)); // When directly running dumpstate binary, the output is not expected to be written // to any external file descriptor. - assert(ds.options_->bugreport_fd.get() == -1); + assert(options_->bugreport_fd.get() == -1); // calling_uid and calling_package are for user consent to share the bugreport with // an app; they are irrelvant here because bugreport is only written to a local // directory, and not shared. - status = ds.Run(-1 /* calling_uid */, "" /* calling_package */); + status = Run(-1 /* calling_uid */, "" /* calling_package */); } + return status; +} + +/* Main entry point for dumpstate binary. */ +int run_main(int argc, char* argv[]) { + Dumpstate::RunStatus status = ds.ParseCommandlineAndRun(argc, argv); switch (status) { case Dumpstate::RunStatus::OK: diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 7fb2f3b2e9..9803f00aa7 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -322,6 +322,8 @@ class Dumpstate { /* Main entry point for running a complete bugreport. */ RunStatus Run(int32_t calling_uid, const std::string& calling_package); + RunStatus ParseCommandlineAndRun(int argc, char* argv[]); + /* Sets runtime options. */ void SetOptions(std::unique_ptr<DumpOptions> options); diff --git a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp index 570c6c9b61..9f99114271 100644 --- a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp +++ b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp @@ -109,7 +109,7 @@ class ZippedBugreportGenerationTest : public Test { ds.listener_name_ = "Smokey"; ds.report_section_ = true; auto start = std::chrono::steady_clock::now(); - run_main(ARRAY_SIZE(argv), argv); + ds.ParseCommandlineAndRun(ARRAY_SIZE(argv), argv); auto end = std::chrono::steady_clock::now(); duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start); } |