[libprocinfo] Harden test to work even under ARM emulator
When running under an ARM emulator like qemu, the name of the binary
executing the test might not be "libprocinfo_test", but rather
something like "qemu-aarch64-...".
This hardens the test to not assume the name of the binary and instead
read it from /proc/self/exe.
Change-Id: Ia4564da87c4a8ebb5e512f995cf283327579eed4
Bug: b/307594847
diff --git a/process_test.cpp b/process_test.cpp
index a9d2f19..f0ddfe4 100644
--- a/process_test.cpp
+++ b/process_test.cpp
@@ -59,8 +59,10 @@
ASSERT_NE(-1, fd);
ASSERT_TRUE(android::procinfo::GetProcessInfoFromProcPidFd(fd, gettid(), &self));
+ std::string process_path = android::base::GetExecutablePath();
+ std::string process_name = android::base::Basename(process_path);
// Process name is capped at 15 bytes.
- ASSERT_EQ("libprocinfo_tes", self.name);
+ ASSERT_EQ(process_name.substr(0, 15), self.name);
ASSERT_EQ(gettid(), self.tid);
ASSERT_EQ(getpid(), self.pid);
ASSERT_EQ(getppid(), self.ppid);