X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Ftest-readlink.c;h=97a6788b93ad86ebf59806e4d3026ef9b5f3ea88;hb=0510d19e64a0c3cfdd7ebe31866be9b45229590a;hp=f0f921eddddfb6eb58fbb20060e522fc7f329228;hpb=5835d9b52879c334f16e747c54be8ec9c62e8536;p=pspp diff --git a/tests/test-readlink.c b/tests/test-readlink.c index f0f921eddd..97a6788b93 100644 --- a/tests/test-readlink.c +++ b/tests/test-readlink.c @@ -97,10 +97,21 @@ main () { size_t len = strlen (BASE "dir"); /* When passing too small of a buffer, expect the truncated - length. However, a size of 0 is not portable enough to - test. */ - ASSERT (readlink (BASE "link", buf, 1) == 1); - ASSERT (buf[0] == BASE[0]); + length, or an ERANGE failure. However, a size of 0 is not + portable enough to test. */ + ssize_t result; + errno = 0; + result = readlink (BASE "link", buf, 1); + if (result == -1) + { + ASSERT (errno == ERANGE); + ASSERT (buf[0] == (char) 0xff); + } + else + { + ASSERT (result == 1); + ASSERT (buf[0] == BASE[0]); + } ASSERT (buf[1] == (char) 0xff); ASSERT (readlink (BASE "link", buf, len) == len); ASSERT (strncmp (buf, BASE "dir", len) == 0);