X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Ftest.h;h=418eae1665c7f9e026f409948d2e5d422ff0e857;hb=2b9639f0f09c5b8bcd245fac49b2fb9da23b0302;hp=e24a1dbbdff32b7d5dd0f7aaccd1ae187aaa5b81;hpb=cfa23cc1bd01f5c44d7746b8b1839f84d5e1b6eb;p=libc-test diff --git a/src/common/test.h b/src/common/test.h index e24a1db..418eae1 100644 --- a/src/common/test.h +++ b/src/common/test.h @@ -1,38 +1,17 @@ #include -#include -#include #include /* TODO: not thread-safe nor fork-safe */ -static volatile int t_status; +extern volatile int t_status; #define T_LOC2(l) __FILE__ ":" #l #define T_LOC1(l) T_LOC2(l) -#define t_error(...) t_printf("ERROR " T_LOC1(__LINE__) ": " __VA_ARGS__) - -static int t_printf(const char *s, ...) -{ - va_list ap; - char buf[512]; - int n; - - t_status = 1; - va_start(ap, s); - n = vsnprintf(buf, sizeof buf, s, ap); - va_end(ap); - if (n < 0) - n = 0; - else if (n >= sizeof buf) { - n = sizeof buf; - buf[n - 1] = '\n'; - buf[n - 2] = '.'; - buf[n - 3] = '.'; - buf[n - 4] = '.'; - } - return write(1, buf, n); -} +#define t_error(...) t_printf(T_LOC1(__LINE__) ": " __VA_ARGS__) + +int t_printf(const char *s, ...); int t_vmfill(void **, size_t *, int); +int t_memfill(void); void t_fdfill(void); @@ -45,3 +24,5 @@ int t_choose(uint64_t n, size_t k, uint64_t *p); char *t_pathrel(char *buf, size_t n, char *argv0, char *p); +int t_setrlim(int r, long lim); +