14 /* Avoid SSP re-definitions */
20 #define KPRINTF_BUFSIZE 1024
22 #define putchar xputchar
24 static int putchar(char c, int foo, void *b)
26 return fputc(c, stderr);
30 static const char HEXDIGITS[] = "0123456789ABCDEF";
31 static const char hexdigits[] = "0123456789abcdef";
36 static SHA512_CTX kprnd_sha;
39 #define timespec timeval
40 #define nanotime(ts) gettimeofday(ts, NULL)
42 #define device_xname(a) ""
43 int kprintf(const char *, int, void *, char *, va_list) __printflike(1, 0);
44 void device_printf(device_t, const char *, ...) __printflike(2, 3);
51 static void (*v_flush)(void) = empty;
53 ATF_TC(snprintf_print);
54 ATF_TC_HEAD(snprintf_print, tc)
56 atf_tc_set_md_var(tc, "descr", "checks snprintf print");
59 ATF_TC_BODY(snprintf_print, tc)
64 memset(buf, 'x', sizeof(buf));
65 i = snprintf(buf, sizeof(buf), "number %d", 10);
67 ATF_CHECK_STREQ(buf, "number 10");
70 ATF_TC(snprintf_print_overflow);
71 ATF_TC_HEAD(snprintf_print_overflow, tc)
73 atf_tc_set_md_var(tc, "descr", "checks snprintf print with overflow");
76 ATF_TC_BODY(snprintf_print_overflow, tc)
81 memset(buf, 'x', sizeof(buf));
82 i = snprintf(buf, sizeof(buf), "fjsdfsdjfsdf %d\n", 10);
84 ATF_CHECK_STREQ(buf, "fjsdfsdjf");
87 ATF_TC(snprintf_count);
88 ATF_TC_HEAD(snprintf_count, tc)
90 atf_tc_set_md_var(tc, "descr", "checks snprintf count");
93 ATF_TC_BODY(snprintf_count, tc)
97 i = snprintf(NULL, 20, "number %d", 10);
101 ATF_TC(snprintf_count_overflow);
102 ATF_TC_HEAD(snprintf_count_overflow, tc)
104 atf_tc_set_md_var(tc, "descr", "checks snprintf count with overflow");
107 ATF_TC_BODY(snprintf_count_overflow, tc)
111 i = snprintf(NULL, 10, "fjsdfsdjfsdf %d\n", 10);
117 ATF_TP_ADD_TC(tp, snprintf_print);
118 ATF_TP_ADD_TC(tp, snprintf_print_overflow);
119 ATF_TP_ADD_TC(tp, snprintf_count);
120 ATF_TP_ADD_TC(tp, snprintf_count_overflow);
122 return atf_no_error();