libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / libsodium / test / default / cmptest.h
blobdd38361669ed9241f4caf6e12acc9aebfcaaaa2e
2 #ifndef __CMPTEST_H__
3 #define __CMPTEST_H__
5 #include <stdio.h>
7 #include "sodium.h"
9 #define TEST_NAME_RES TEST_NAME ".res"
10 #define TEST_NAME_OUT TEST_SRCDIR "/" TEST_NAME ".exp"
12 FILE *fp_res;
13 int xmain(void);
15 int main(void)
17 FILE *fp_out;
18 int c;
20 if ((fp_res = fopen(TEST_NAME_RES, "w+")) == NULL) {
21 perror("fopen(" TEST_NAME_RES ")");
22 return 99;
24 if (sodium_init() != 0) {
25 return 99;
27 xmain();
28 rewind(fp_res);
29 if ((fp_out = fopen(TEST_NAME_OUT, "r")) == NULL) {
30 perror("fopen(" TEST_NAME_OUT ")");
31 return 99;
33 do {
34 if ((c = fgetc(fp_res)) != fgetc(fp_out)) {
35 return 99;
37 } while (c != EOF);
39 return 0;
42 #undef printf
43 #define printf(...) fprintf(fp_res, __VA_ARGS__)
44 #define main xmain
46 #endif