diff options
author | 2020-03-05 09:46:45 -0800 | |
---|---|---|
committer | 2020-03-05 09:51:10 -0800 | |
commit | 31dac35341bc86c892313e8b88f06f7713465e57 (patch) | |
tree | 236d155fb8f5a6c6df67afa95022fcc14d269246 | |
parent | d6dad7afc088fd5efeedf2cfb701ea531afd1816 (diff) |
dumpsys: '-l' works for 0/1 services.
Currently, if there are only 0/1 services registered and list is called,
no output will be produced.
Bug: hit me while testing vndservicemanager, since this may not register
anything
Test: dumpsys_test
Change-Id: I8e16376eb99c5758d53ff0b5f01b32fd21e6b119
-rw-r--r-- | cmds/dumpsys/dumpsys.cpp | 2 | ||||
-rw-r--r-- | cmds/dumpsys/tests/dumpsys_test.cpp | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/cmds/dumpsys/dumpsys.cpp b/cmds/dumpsys/dumpsys.cpp index a427c8dd68..1327cfd155 100644 --- a/cmds/dumpsys/dumpsys.cpp +++ b/cmds/dumpsys/dumpsys.cpp @@ -230,7 +230,7 @@ int Dumpsys::main(int argc, char* const argv[]) { } const size_t N = services.size(); - if (N > 1) { + if (N > 1 || showListOnly) { // first print a list of the current services std::cout << "Currently running services:" << std::endl; diff --git a/cmds/dumpsys/tests/dumpsys_test.cpp b/cmds/dumpsys/tests/dumpsys_test.cpp index b9395ba4e2..3467898f3e 100644 --- a/cmds/dumpsys/tests/dumpsys_test.cpp +++ b/cmds/dumpsys/tests/dumpsys_test.cpp @@ -206,10 +206,7 @@ class DumpsysTest : public Test { } void AssertRunningServices(const std::vector<std::string>& services) { - std::string expected; - if (services.size() > 1) { - expected.append("Currently running services:\n"); - } + std::string expected = "Currently running services:\n"; for (const std::string& service : services) { expected.append(" ").append(service).append("\n"); } @@ -263,6 +260,21 @@ TEST_F(DumpsysTest, ListAllServices) { AssertRunningServices({"Locksmith", "Valet"}); } +TEST_F(DumpsysTest, ListServicesOneRegistered) { + ExpectListServices({"Locksmith"}); + ExpectCheckService("Locksmith"); + + CallMain({"-l"}); + + AssertRunningServices({"Locksmith"}); +} + +TEST_F(DumpsysTest, ListServicesEmpty) { + CallMain({"-l"}); + + AssertRunningServices({}); +} + // Tests 'dumpsys -l' when a service is not running TEST_F(DumpsysTest, ListRunningServices) { ExpectListServices({"Locksmith", "Valet"}); |