tools/llvm: Do not build with symbols
[minix3.git] / tests / kernel / gen_t_subr_prf
blobaf03391e0ed9498b4fbe553128b312920cbf3602
1 #!/bin/sh
3 cat << _EOF > $2
4 #include <sys/types.h>
5 #include <stdio.h>
6 #include <stdarg.h>
7 #include <stdint.h>
8 #include <string.h>
10 #include <atf-c.h>
12 /* Avoid SSP re-definitions */
13 #undef snprintf
14 #undef vsnprintf
15 #undef sprintf
16 #undef vsprintf
18 #define KPRINTF_BUFSIZE 1024
19 #undef putchar
20 #define putchar xputchar
21 static int putchar(char c, int foo, void *b)
23 return fputc(c, stderr);
26 #define TOBUFONLY 1
27 static const char HEXDIGITS[] = "0123456789ABCDEF";
28 static const char hexdigits[] = "0123456789abcdef";
30 typedef int device_t;
32 #define device_xname(a) ""
33 int kprintf(const char *, int, void *, char *, va_list) __printflike(1, 0);
34 void device_printf(device_t, const char *, ...) __printflike(2, 3);
36 static void
37 empty(void)
41 static void (*v_flush)(void) = empty;
43 ATF_TC(snprintf_print);
44 ATF_TC_HEAD(snprintf_print, tc)
46 atf_tc_set_md_var(tc, "descr", "checks snprintf print");
49 ATF_TC_BODY(snprintf_print, tc)
51 char buf[10];
52 int i;
54 memset(buf, 'x', sizeof(buf));
55 i = snprintf(buf, sizeof(buf), "number %d", 10);
56 ATF_CHECK_EQ(i, 9);
57 ATF_CHECK_STREQ(buf, "number 10");
60 ATF_TC(snprintf_print_overflow);
61 ATF_TC_HEAD(snprintf_print_overflow, tc)
63 atf_tc_set_md_var(tc, "descr", "checks snprintf print with overflow");
66 ATF_TC_BODY(snprintf_print_overflow, tc)
68 char buf[10];
69 int i;
71 memset(buf, 'x', sizeof(buf));
72 i = snprintf(buf, sizeof(buf), "fjsdfsdjfsdf %d\n", 10);
73 ATF_CHECK_EQ(i, 16);
74 ATF_CHECK_STREQ(buf, "fjsdfsdjf");
77 ATF_TC(snprintf_count);
78 ATF_TC_HEAD(snprintf_count, tc)
80 atf_tc_set_md_var(tc, "descr", "checks snprintf count");
83 ATF_TC_BODY(snprintf_count, tc)
85 int i;
87 i = snprintf(NULL, 20, "number %d", 10);
88 ATF_CHECK_EQ(i, 9);
91 ATF_TC(snprintf_count_overflow);
92 ATF_TC_HEAD(snprintf_count_overflow, tc)
94 atf_tc_set_md_var(tc, "descr", "checks snprintf count with overflow");
97 ATF_TC_BODY(snprintf_count_overflow, tc)
99 int i;
101 i = snprintf(NULL, 10, "fjsdfsdjfsdf %d\n", 10);
102 ATF_CHECK_EQ(i, 16);
105 ATF_TP_ADD_TCS(tp)
107 ATF_TP_ADD_TC(tp, snprintf_print);
108 ATF_TP_ADD_TC(tp, snprintf_print_overflow);
109 ATF_TP_ADD_TC(tp, snprintf_count);
110 ATF_TP_ADD_TC(tp, snprintf_count_overflow);
112 return atf_no_error();
114 _EOF
116 awk '
117 /^snprintf\(/ {
118 print prevline
119 out = 1
122 if (out) print
123 else prevline = $0
124 }' $1 >>$2