Commit 33dfc0ab authored by Rusty Russell's avatar Rusty Russell

Remove compile warnings of tests under Ubuntu (return value ignored)

parent 36b64ac0
......@@ -3,6 +3,7 @@
#include "alloc/alloc.c"
#include <stdlib.h>
#include <stdbool.h>
#include <err.h>
#define POOL_ORD 16
#define POOL_SIZE (1 << POOL_ORD)
......@@ -34,7 +35,8 @@ int main(int argc, char *argv[])
plan_tests(5);
/* FIXME: Needs to be page aligned for now. */
posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE);
if (posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE) != 0)
errx(1, "Failed allocating aligned memory");
alloc_init(mem, POOL_SIZE);
......
......@@ -2,6 +2,7 @@
#include "tap/tap.h"
#include "alloc/alloc.c"
#include <stdlib.h>
#include <err.h>
#define POOL_ORD 16
#define POOL_SIZE (1 << POOL_ORD)
......@@ -52,7 +53,8 @@ int main(int argc, char *argv[])
plan_tests(178);
/* FIXME: Needs to be page aligned for now. */
posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE);
if (posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE) != 0)
errx(1, "Failed allocating aligned memory");
/* Small pool, all allocs fail, even 0-length. */
alloc_init(mem, 0);
......
......@@ -16,6 +16,20 @@
/* We dup stderr to here. */
static int stderrfd;
/* write_all inlined here to avoid circular dependency. */
static void write_all(int fd, const void *data, size_t size)
{
while (size) {
ssize_t done;
done = write(fd, data, size);
if (done <= 0)
_exit(1);
data += done;
size -= done;
}
}
/* Simple replacement for err() */
static void failmsg(const char *fmt, ...)
{
......@@ -27,9 +41,9 @@ static void failmsg(const char *fmt, ...)
vsprintf(buf, fmt, ap);
va_end(ap);
write(stderrfd, "# ", 2);
write(stderrfd, buf, strlen(buf));
write(stderrfd, "\n", 1);
write_all(stderrfd, "# ", 2);
write_all(stderrfd, buf, strlen(buf));
write_all(stderrfd, "\n", 1);
_exit(1);
}
......@@ -113,6 +127,7 @@ int main(int argc, char *argv[])
expect(p[0], "# Looks like you failed 2 tests of 9.\n");
#endif
write(stdoutfd, "ok 1 - All passed\n", strlen("ok 1 - All passed\n"));
write_all(stdoutfd, "ok 1 - All passed\n",
strlen("ok 1 - All passed\n"));
_exit(0);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment