summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Abhijeet Kaur <abkaur@google.com> 2019-06-26 15:01:55 +0100
committer Abhijeet Kaur <abkaur@google.com> 2019-06-26 15:12:51 +0100
commit455fd26c197f2391a3dd8c4e30760e94eaf587b7 (patch)
tree32bfdedb17e601c8b21741e8e6dea3ea49ae8b7a
parent8475fc34a2144b947db4f1a1170a01809e83479d (diff)
Remove unused function GetPidByName()
Due to the fix b/132919954, this function is no longer needed. Bug: 133223733 Test: builds Test: All tests pass * First create `/data/nativetest64`: adb shell mkdir /data/nativetest64 * Then run: mmm -j frameworks/native/cmds/dumpstate/ \ && adb push ${OUT}/data/nativetest64/dumpstate_* /data/nativetest64 \ && adb shell /data/nativetest64/dumpstate_test/dumpstate_test Change-Id: Id52455d8bb82909706e0b2606aa1811c9faf1d69
-rw-r--r--cmds/dumpstate/DumpstateUtil.cpp28
-rw-r--r--cmds/dumpstate/DumpstateUtil.h6
-rw-r--r--cmds/dumpstate/tests/dumpstate_test.cpp20
3 files changed, 0 insertions, 54 deletions
diff --git a/cmds/dumpstate/DumpstateUtil.cpp b/cmds/dumpstate/DumpstateUtil.cpp
index 97c8ae2045..4b69607156 100644
--- a/cmds/dumpstate/DumpstateUtil.cpp
+++ b/cmds/dumpstate/DumpstateUtil.cpp
@@ -378,34 +378,6 @@ int RunCommandToFd(int fd, const std::string& title, const std::vector<std::stri
return status;
}
-int GetPidByName(const std::string& ps_name) {
- DIR* proc_dir;
- struct dirent* ps;
- unsigned int pid;
- std::string cmdline;
-
- if (!(proc_dir = opendir("/proc"))) {
- MYLOGE("Can't open /proc\n");
- return -1;
- }
-
- while ((ps = readdir(proc_dir))) {
- if (!(pid = atoi(ps->d_name))) {
- continue;
- }
- android::base::ReadFileToString("/proc/" + std::string(ps->d_name) + "/cmdline", &cmdline);
- if (cmdline.find(ps_name) == std::string::npos) {
- continue;
- } else {
- closedir(proc_dir);
- return pid;
- }
- }
- MYLOGE("can't find the pid\n");
- closedir(proc_dir);
- return -1;
-}
-
} // namespace dumpstate
} // namespace os
} // namespace android
diff --git a/cmds/dumpstate/DumpstateUtil.h b/cmds/dumpstate/DumpstateUtil.h
index d75b08c046..b7ac25c81e 100644
--- a/cmds/dumpstate/DumpstateUtil.h
+++ b/cmds/dumpstate/DumpstateUtil.h
@@ -205,12 +205,6 @@ int RunCommandToFd(int fd, const std::string& title, const std::vector<std::stri
*/
int DumpFileToFd(int fd, const std::string& title, const std::string& path);
-/*
- * Finds the process id by process name.
- * |ps_name| the process name we want to search for
- */
-int GetPidByName(const std::string& ps_name);
-
} // namespace dumpstate
} // namespace os
} // namespace android
diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp
index c5d01fdf25..ccb2981c56 100644
--- a/cmds/dumpstate/tests/dumpstate_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_test.cpp
@@ -1407,14 +1407,6 @@ class DumpstateUtilTest : public DumpstateBaseTest {
return status;
}
- // Find out the pid of the process_name
- int FindPidOfProcess(const std::string& process_name) {
- CaptureStderr();
- int status = GetPidByName(process_name);
- err = GetCapturedStderr();
- return status;
- }
-
int fd;
// 'fd` output and `stderr` from the last command ran.
@@ -1764,18 +1756,6 @@ TEST_F(DumpstateUtilTest, DumpFileOnDryRun) {
EXPECT_THAT(out, EndsWith("skipped on dry run\n"));
}
-TEST_F(DumpstateUtilTest, FindingPidWithExistingProcess) {
- // init process always has pid 1.
- EXPECT_EQ(1, FindPidOfProcess("init"));
- EXPECT_THAT(err, IsEmpty());
-}
-
-TEST_F(DumpstateUtilTest, FindingPidWithNotExistingProcess) {
- // find the process with abnormal name.
- EXPECT_EQ(-1, FindPidOfProcess("abcdef12345-543"));
- EXPECT_THAT(err, StrEq("can't find the pid\n"));
-}
-
} // namespace dumpstate
} // namespace os
} // namespace android