Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f02564e1 authored by Nandana Dutt's avatar Nandana Dutt
Browse files

Fix dumpstate smoke test

run_main exits when finished, which is suitable if we want to run
assertions on bugreport file. Instead call an intermediate function.

Test: adb shell /data/nativetest64/dumpstate_smoke_test/dumpstate_smoke_test
Change-Id: I43708325dcaaf8f0f1ca59f181c216bfb25d28bf
parent e55a64f1
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -2586,22 +2586,27 @@ Dumpstate::RunStatus Dumpstate::CopyBugreportIfUserConsented() {
    return Dumpstate::RunStatus::ERROR;
    return Dumpstate::RunStatus::ERROR;
}
}


/* Main entry point for dumpstate binary. */
Dumpstate::RunStatus Dumpstate::ParseCommandlineAndRun(int argc, char* argv[]) {
int run_main(int argc, char* argv[]) {
    std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
    std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
    Dumpstate::RunStatus status = options->Initialize(argc, argv);
    Dumpstate::RunStatus status = options->Initialize(argc, argv);
    if (status == Dumpstate::RunStatus::OK) {
    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
        // When directly running dumpstate binary, the output is not expected to be written
        // to any external file descriptor.
        // 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
        // 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
        // an app; they are irrelvant here because bugreport is only written to a local
        // directory, and not shared.
        // 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) {
    switch (status) {
        case Dumpstate::RunStatus::OK:
        case Dumpstate::RunStatus::OK:
            exit(0);
            exit(0);
+2 −0
Original line number Original line Diff line number Diff line
@@ -322,6 +322,8 @@ class Dumpstate {
    /* Main entry point for running a complete bugreport. */
    /* Main entry point for running a complete bugreport. */
    RunStatus Run(int32_t calling_uid, const std::string& calling_package);
    RunStatus Run(int32_t calling_uid, const std::string& calling_package);


    RunStatus ParseCommandlineAndRun(int argc, char* argv[]);

    /* Sets runtime options. */
    /* Sets runtime options. */
    void SetOptions(std::unique_ptr<DumpOptions> options);
    void SetOptions(std::unique_ptr<DumpOptions> options);


+1 −1
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ class ZippedBugreportGenerationTest : public Test {
        ds.listener_name_ = "Smokey";
        ds.listener_name_ = "Smokey";
        ds.report_section_ = true;
        ds.report_section_ = true;
        auto start = std::chrono::steady_clock::now();
        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();
        auto end = std::chrono::steady_clock::now();
        duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
        duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
    }
    }