t/stest: add log.o smaller helper
authorJens Axboe <axboe@kernel.dk>
Wed, 5 Oct 2011 08:14:03 +0000 (10:14 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 5 Oct 2011 08:14:03 +0000 (10:14 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Makefile
t/log.c [new file with mode: 0644]

index b361603beac626a3b921550adf22ff7eb8638841..84f30883f68f2ce35c987e3a53ad254ae0aa4640 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ endif
 OBJS = $(SOURCE:.c=.o)
 
 T_OBJS = t/stest.o
-T_OBJS += mutex.o smalloc.o
+T_OBJS += mutex.o smalloc.o t/log.o
 T_PROGS = t/stest
 
 ifneq ($(findstring $(MAKEFLAGS),s),s)
diff --git a/t/log.c b/t/log.c
new file mode 100644 (file)
index 0000000..7f1de27
--- /dev/null
+++ b/t/log.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+int log_err(const char *format, ...)
+{
+       char buffer[1024];
+       va_list args;
+       size_t len;
+
+       va_start(args, format);
+       len = vsnprintf(buffer, sizeof(buffer), format, args);
+       va_end(args);
+
+       return fwrite(buffer, len, 1, stderr);
+}