Remove building with NOCRYPTO option
[minix.git] / tests / kernel / gen_t_subr_prf
blobb58a6ba425d5280f78c3b7461c133085679b0d9a
1 #!/bin/sh
3 cat << _EOF > $2
4 #include <sys/types.h>
5 #include <sys/time.h>
6 #include <stdio.h>
7 #include <stdarg.h>
8 #include <stdint.h>
9 #include <string.h>
10 #include <sha2.h>
12 #include <atf-c.h>
14 /* Avoid SSP re-definitions */
15 #undef snprintf
16 #undef vsnprintf
17 #undef sprintf
18 #undef vsprintf
20 #define KPRINTF_BUFSIZE 1024
21 #undef putchar
22 #define putchar xputchar
24 static int putchar(char c, int foo, void *b)
26 return fputc(c, stderr);
29 #define TOBUFONLY 1
30 static const char HEXDIGITS[] = "0123456789ABCDEF";
31 static const char hexdigits[] = "0123456789abcdef";
33 typedef int device_t;
35 #if 0
36 static SHA512_CTX kprnd_sha;
37 #endif
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);
46 static void
47 empty(void)
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)
61 char buf[10];
62 int i;
64 memset(buf, 'x', sizeof(buf));
65 i = snprintf(buf, sizeof(buf), "number %d", 10);
66 ATF_CHECK_EQ(i, 9);
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)
78 char buf[10];
79 int i;
81 memset(buf, 'x', sizeof(buf));
82 i = snprintf(buf, sizeof(buf), "fjsdfsdjfsdf %d\n", 10);
83 ATF_CHECK_EQ(i, 16);
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)
95 int i;
97 i = snprintf(NULL, 20, "number %d", 10);
98 ATF_CHECK_EQ(i, 9);
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)
109 int i;
111 i = snprintf(NULL, 10, "fjsdfsdjfsdf %d\n", 10);
112 ATF_CHECK_EQ(i, 16);
115 ATF_TP_ADD_TCS(tp)
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();
124 _EOF
126 awk '
127 /^snprintf\(/ {
128 print prevline
129 out = 1
132 if (out) print
133 else prevline = $0
134 }' $1 >>$2