functional: add mntent test
[libc-test.git] / src / common / print.c
blobb9088badb2f6d35c2188442f8e56ad4d009598f8
1 #include <stdio.h>
2 #include <stdarg.h>
3 #include <unistd.h>
4 #include "test.h"
6 volatile int t_status = 0;
8 int t_printf(const char *s, ...)
10 va_list ap;
11 char buf[512];
12 int n;
14 t_status = 1;
15 va_start(ap, s);
16 n = vsnprintf(buf, sizeof buf, s, ap);
17 va_end(ap);
18 if (n < 0)
19 n = 0;
20 else if (n >= sizeof buf) {
21 n = sizeof buf;
22 buf[n - 1] = '\n';
23 buf[n - 2] = '.';
24 buf[n - 3] = '.';
25 buf[n - 4] = '.';
27 return write(1, buf, n);