Fix uses of readlink in tests.

readlink does not append a terminator, and a few tests assumed it did.

Test: Unit tests pass.
Change-Id: I3ccea4e7895cd919b45e1ca0c90aa6f0031de320
diff --git a/tests/bug_26110743_test.cpp b/tests/bug_26110743_test.cpp
index 89c6dcc..883280f 100644
--- a/tests/bug_26110743_test.cpp
+++ b/tests/bug_26110743_test.cpp
@@ -22,6 +22,8 @@
 #include <sys/stat.h>
 #include <sys/prctl.h>
 
+#include <string>
+
 #include <android-base/scopeguard.h>
 
 extern "C" pid_t gettid();
@@ -35,8 +37,9 @@
   const char* ERRORMSG = "Please apply the following two kernel patches:\n"
     "* https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=73af963f9f3036dffed55c3a2898598186db1045\n"
     "* https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=96d0df79f2644fc823f26c06491e182d87a90c2a\n";
-  ASSERT_NE(-1, readlink(buf, buf2, sizeof(buf2))) << ERRORMSG;
-  ASSERT_STREQ("/dev/null", buf2);
+  ssize_t length = readlink(buf, buf2, sizeof(buf2));
+  ASSERT_LT(0, length) << ERRORMSG;
+  ASSERT_EQ("/dev/null", std::string(buf2, length));
   close(fd);
 }
 
@@ -79,8 +82,9 @@
   snprintf(buf, sizeof(buf), "/proc/%d/task/%d/fd/%d", mypid, mytid, fd);
   const char* ERRORMSG = "Please apply the following kernel patch:\n"
     "* https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=54708d2858e79a2bdda10bf8a20c80eb96c20613\n";
-  ASSERT_NE(-1, readlink(buf, buf2, sizeof(buf2))) << ERRORMSG;
-  ASSERT_STREQ("/dev/null", buf2);
+  ssize_t length = readlink(buf, buf2, sizeof(buf2));
+  ASSERT_LT(0, length) << ERRORMSG;
+  ASSERT_EQ("/dev/null", std::string(buf2, length));
   close(fd);
 }