#include "alloc/alloc.c"
#include <stdlib.h>
#include <stdbool.h>
+#include <err.h>
#define POOL_ORD 16
#define POOL_SIZE (1 << POOL_ORD)
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);
#include "tap/tap.h"
#include "alloc/alloc.c"
#include <stdlib.h>
+#include <err.h>
#define POOL_ORD 16
#define POOL_SIZE (1 << POOL_ORD)
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);
/* 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, ...)
{
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);
}
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);
}