summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-04-05 21:56:05 +0000
committerjilles <jilles@FreeBSD.org>2011-04-05 21:56:05 +0000
commitc902a38c4a1577f5b9a27832540f1a955ea78038 (patch)
tree9ba493ad554e8b08e9a294a55e6d6e571583a3e2 /tools
parentbb9f2459b8a1d6a5aca6101af345c3ed3ccabc83 (diff)
downloadFreeBSD-src-c902a38c4a1577f5b9a27832540f1a955ea78038.zip
FreeBSD-src-c902a38c4a1577f5b9a27832540f1a955ea78038.tar.gz
Allow strerror(0) and strerror_r(0, ...).
Of course, strerror_r() may still fail with ERANGE. Although the POSIX specification said this could fail with EINVAL and doing this likely indicates invalid use of errno, most other implementations permitted it, various POSIX testsuites require it to work (matching the older sys_errlist array) and apparently some applications depend on it. PR: standards/151316 MFC after: 1 week
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/lib/libc/string/test-strerror.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/tools/regression/lib/libc/string/test-strerror.c b/tools/regression/lib/libc/string/test-strerror.c
index f5274ed..ffc1633 100644
--- a/tools/regression/lib/libc/string/test-strerror.c
+++ b/tools/regression/lib/libc/string/test-strerror.c
@@ -42,17 +42,12 @@ main(void)
char *sret;
int iret;
- plan_tests(25);
+ plan_tests(27);
/*
* strerror() failure tests.
*/
errno = 0;
- sret = strerror(0);
- ok1(strcmp(sret, "Unknown error: 0") == 0);
- ok1(errno == EINVAL);
-
- errno = 0;
sret = strerror(INT_MAX);
snprintf(buf, sizeof(buf), "Unknown error: %d", INT_MAX);
ok1(strcmp(sret, buf) == 0);
@@ -62,6 +57,11 @@ main(void)
* strerror() success tests.
*/
errno = 0;
+ sret = strerror(0);
+ ok1(strcmp(sret, "No error: 0") == 0);
+ ok1(errno == 0);
+
+ errno = 0;
sret = strerror(EPERM);
ok1(strcmp(sret, "Operation not permitted") == 0);
ok1(errno == 0);
@@ -79,8 +79,8 @@ main(void)
* strerror_r() failure tests.
*/
memset(buf, '*', sizeof(buf));
- iret = strerror_r(0, buf, sizeof(buf));
- ok1(strcmp(buf, "Unknown error: 0") == 0);
+ iret = strerror_r(-1, buf, sizeof(buf));
+ ok1(strcmp(buf, "Unknown error: -1") == 0);
ok1(iret == EINVAL);
memset(buf, '*', sizeof(buf));
@@ -117,6 +117,11 @@ main(void)
* strerror_r() success tests.
*/
memset(buf, '*', sizeof(buf));
+ iret = strerror_r(0, buf, sizeof(buf));
+ ok1(strcmp(buf, "No error: 0") == 0);
+ ok1(iret == 0);
+
+ memset(buf, '*', sizeof(buf));
iret = strerror_r(EDEADLK, buf, sizeof(buf));
ok1(strcmp(buf, "Resource deadlock avoided") == 0);
ok1(iret == 0);
OpenPOWER on IntegriCloud