INN commit: trunk/tests/lib (reallocarray-t.c)
INN Commit
rra at isc.org
Sat Sep 6 21:55:35 UTC 2014
Date: Saturday, September 6, 2014 @ 14:55:35
Author: eagle
Revision: 9681
Fix reallocarray test suite to not assume errno is preserved
errno will not be preserved across calls to ok, since it uses stdio.
Save errno and check the saved value instead.
Modified:
trunk/tests/lib/reallocarray-t.c
------------------+
reallocarray-t.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
Modified: reallocarray-t.c
===================================================================
--- reallocarray-t.c 2014-09-06 08:07:27 UTC (rev 9680)
+++ reallocarray-t.c 2014-09-06 21:55:35 UTC (rev 9681)
@@ -36,6 +36,7 @@
{
char *p, *base;
size_t sqrt_max;
+ int oerrno;
plan(15);
@@ -62,25 +63,31 @@
/* Test the range-checking error cases. */
p = test_reallocarray(NULL, 2, SIZE_MAX / 2);
+ oerrno = errno;
ok(p == NULL, "reallocarray fails for 2, SIZE_MAX / 2");
- is_int(ENOMEM, errno, "...with correct errno");
+ is_int(ENOMEM, oerrno, "...with correct errno");
base = malloc(10);
p = test_reallocarray(base, 3, SIZE_MAX / 3);
+ oerrno = errno;
ok(p == NULL, "reallocarray fails for 3, SIZE_MAX / 3");
- is_int(ENOMEM, errno, "...with correct errno");
+ is_int(ENOMEM, oerrno, "...with correct errno");
sqrt_max = (1UL << (sizeof(size_t) * 4));
p = test_reallocarray(base, sqrt_max, sqrt_max);
+ oerrno = errno;
ok(p == NULL, "reallocarray fails for sqrt(SIZE_MAX), sqrt(SIZE_MAX)");
- is_int(ENOMEM, errno, "...with correct errno");
+ is_int(ENOMEM, oerrno, "...with correct errno");
p = test_reallocarray(base, 1, SIZE_MAX);
+ oerrno = errno;
ok(p == NULL, "reallocarray fails for 1, SIZE_MAX");
- is_int(ENOMEM, errno, "...with correct errno");
+ is_int(ENOMEM, oerrno, "...with correct errno");
p = test_reallocarray(base, SIZE_MAX, 1);
+ oerrno = errno;
ok(p == NULL, "reallocarray fails for SIZE_MAX, 1");
- is_int(ENOMEM, errno, "...with correct errno");
+ is_int(ENOMEM, oerrno, "...with correct errno");
p = test_reallocarray(base, 2, SIZE_MAX);
+ oerrno = errno;
ok(p == NULL, "reallocarray fails for 2, SIZE_MAX");
- is_int(ENOMEM, errno, "...with correct errno");
+ is_int(ENOMEM, oerrno, "...with correct errno");
/* Clean up and exit. */
free(base);
More information about the inn-committers
mailing list