summaryrefslogtreecommitdiffstats
path: root/lmkd/tests
diff options
context:
space:
mode:
authorSuren Baghdasaryan <surenb@google.com>2018-03-09 16:45:26 -0800
committerSuren Baghdasaryan <surenb@google.com>2018-03-13 12:34:18 -0700
commitb453066e20f211fcb7edd3d1f61170588bb978fe (patch)
tree906439250f466b68ffa5317a1605fafe2a57921c /lmkd/tests
parente708b6fc687962941e89aaea69d81a7d1244e32c (diff)
downloadsystem_core-b453066e20f211fcb7edd3d1f61170588bb978fe.tar.gz
system_core-b453066e20f211fcb7edd3d1f61170588bb978fe.tar.bz2
system_core-b453066e20f211fcb7edd3d1f61170588bb978fe.zip
lmkd: Fix lmkd-test to work with relative paths
This change allows lmkd-test to work correctly when it's started using absolute as well as relative path. Change-Id: Ida58d13d66a224119a363f59cc59289f0167d3c9
Diffstat (limited to 'lmkd/tests')
-rw-r--r--lmkd/tests/lmkd_test.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/lmkd/tests/lmkd_test.cpp b/lmkd/tests/lmkd_test.cpp
index 4afaeb81f..f17512daf 100644
--- a/lmkd/tests/lmkd_test.cpp
+++ b/lmkd/tests/lmkd_test.cpp
@@ -110,14 +110,9 @@ std::string getTextAround(const std::string& text, size_t pos,
}
bool getExecPath(std::string &path) {
- char buf[PATH_MAX + 1];
- int ret = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
- if (ret < 0) {
- return false;
- }
- buf[ret] = '\0';
- path = buf;
- return true;
+ // exec path as utf8z c_str().
+ // std::string contains _all_ nul terminated argv[] strings.
+ return android::base::ReadFileToString("/proc/self/cmdline", &path);
}
/* Child synchronization primitives */
@@ -314,8 +309,8 @@ TEST(lmkd, check_for_oom) {
if (getuid() != static_cast<unsigned>(AID_ROOT)) {
// if not root respawn itself as root and capture output
std::string command = StringPrintf(
- "%s=true su root %s 2>&1", LMKDTEST_RESPAWN_FLAG,
- test_path.c_str());
+ "%s=true su root %s --gtest_filter=lmkd.check_for_oom 2>&1",
+ LMKDTEST_RESPAWN_FLAG, test_path.c_str());
std::string test_output = readCommand(command);
GTEST_LOG_(INFO) << test_output;
} else {