summaryrefslogtreecommitdiff
path: root/cmds/dumpsys/tests/dumpsys_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/dumpsys/tests/dumpsys_test.cpp')
-rw-r--r--cmds/dumpsys/tests/dumpsys_test.cpp63
1 files changed, 4 insertions, 59 deletions
diff --git a/cmds/dumpsys/tests/dumpsys_test.cpp b/cmds/dumpsys/tests/dumpsys_test.cpp
index c9d2dbb883..b9395ba4e2 100644
--- a/cmds/dumpsys/tests/dumpsys_test.cpp
+++ b/cmds/dumpsys/tests/dumpsys_test.cpp
@@ -16,15 +16,12 @@
#include "../dumpsys.h"
-#include <regex>
#include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <android-base/file.h>
-#include <binder/Binder.h>
-#include <binder/ProcessState.h>
#include <serviceutils/PriorityDumper.h>
#include <utils/String16.h>
#include <utils/String8.h>
@@ -58,8 +55,6 @@ class ServiceManagerMock : public IServiceManager {
MOCK_METHOD1(listServices, Vector<String16>(int));
MOCK_METHOD1(waitForService, sp<IBinder>(const String16&));
MOCK_METHOD1(isDeclared, bool(const String16&));
- MOCK_METHOD1(getDeclaredInstances, Vector<String16>(const String16&));
- MOCK_METHOD1(updatableViaApex, std::optional<String16>(const String16&));
protected:
MOCK_METHOD0(onAsBinder, IBinder*());
};
@@ -211,7 +206,10 @@ class DumpsysTest : public Test {
}
void AssertRunningServices(const std::vector<std::string>& services) {
- std::string expected = "Currently running services:\n";
+ std::string expected;
+ if (services.size() > 1) {
+ expected.append("Currently running services:\n");
+ }
for (const std::string& service : services) {
expected.append(" ").append(service).append("\n");
}
@@ -226,10 +224,6 @@ class DumpsysTest : public Test {
EXPECT_THAT(stdout_, HasSubstr(expected));
}
- void AssertOutputFormat(const std::string format) {
- EXPECT_THAT(stdout_, testing::MatchesRegex(format));
- }
-
void AssertDumped(const std::string& service, const std::string& dump) {
EXPECT_THAT(stdout_, HasSubstr("DUMP OF SERVICE " + service + ":\n" + dump));
EXPECT_THAT(stdout_, HasSubstr("was the duration of dumpsys " + service + ", ending at: "));
@@ -269,21 +263,6 @@ 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"});
@@ -582,30 +561,6 @@ TEST_F(DumpsysTest, ListServiceWithPid) {
AssertOutput(std::to_string(getpid()) + "\n");
}
-// Tests 'dumpsys --thread'
-TEST_F(DumpsysTest, ListAllServicesWithThread) {
- ExpectListServices({"Locksmith", "Valet"});
- ExpectCheckService("Locksmith");
- ExpectCheckService("Valet");
-
- CallMain({"--thread"});
-
- AssertRunningServices({"Locksmith", "Valet"});
-
- const std::string format("(.|\n)*((Threads in use: [0-9]+/[0-9]+)?\n-(.|\n)*){2}");
- AssertOutputFormat(format);
-}
-
-// Tests 'dumpsys --thread service_name'
-TEST_F(DumpsysTest, ListServiceWithThread) {
- ExpectCheckService("Locksmith");
-
- CallMain({"--thread", "Locksmith"});
- // returns an empty string without root enabled
- const std::string format("(^$|Threads in use: [0-9]/[0-9]+\n)");
- AssertOutputFormat(format);
-}
-
TEST_F(DumpsysTest, GetBytesWritten) {
const char* serviceName = "service2";
const char* dumpContents = "dump1";
@@ -631,13 +586,3 @@ TEST_F(DumpsysTest, WriteDumpWithoutThreadStart) {
/* as_proto = */ false, elapsedDuration, bytesWritten);
EXPECT_THAT(status, Eq(INVALID_OPERATION));
}
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
-
- // start a binder thread pool for testing --thread option
- android::ProcessState::self()->setThreadPoolMaxThreadCount(8);
- ProcessState::self()->startThreadPool();
-
- return RUN_ALL_TESTS();
-}