summaryrefslogtreecommitdiff
path: root/tests/stdio_test.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-08-23 11:17:55 -0700
committerChristopher Ferris <cferris@google.com>2018-08-23 11:30:56 -0700
commit2c4ec7e109a2d9804bff50b7477bfd4df7b4e1b1 (patch)
tree040709fe01139d6dc8a69a3c9fee15e0e7179a1d /tests/stdio_test.cpp
parent05ee196c0a6367b5f07e2f9de502457c3299ecc6 (diff)
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
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r--tests/stdio_test.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index d93c63f42..d96da024b 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -2510,10 +2510,15 @@ TEST(STDIO_TEST, fseek_overflow_32bit) {
TEST(STDIO_TEST, dev_std_files) {
// POSIX only mentions /dev/stdout, but we should have all three (http://b/31824379).
char path[PATH_MAX];
- ASSERT_GT(readlink("/dev/stdin", path, sizeof(path)), 0);
- ASSERT_STREQ("/proc/self/fd/0", path);
- ASSERT_GT(readlink("/dev/stdout", path, sizeof(path)), 0);
- ASSERT_STREQ("/proc/self/fd/1", path);
- ASSERT_GT(readlink("/dev/stderr", path, sizeof(path)), 0);
- ASSERT_STREQ("/proc/self/fd/2", path);
+ ssize_t length = readlink("/dev/stdin", path, sizeof(path));
+ ASSERT_LT(0, length);
+ ASSERT_EQ("/proc/self/fd/0", std::string(path, length));
+
+ length = readlink("/dev/stdout", path, sizeof(path));
+ ASSERT_LT(0, length);
+ ASSERT_EQ("/proc/self/fd/1", std::string(path, length));
+
+ length = readlink("/dev/stderr", path, sizeof(path));
+ ASSERT_LT(0, length);
+ ASSERT_EQ("/proc/self/fd/2", std::string(path, length));
}