2013-01-20 16:25:22 -07:00
|
|
|
|
|
|
|
#ifndef __CMPTEST_H__
|
|
|
|
#define __CMPTEST_H__
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-04-18 05:57:41 -07:00
|
|
|
#include "sodium.h"
|
|
|
|
|
2013-01-20 16:25:22 -07:00
|
|
|
#define TEST_NAME_RES TEST_NAME ".res"
|
2013-04-27 11:43:26 -07:00
|
|
|
#define TEST_NAME_OUT TEST_SRCDIR "/" TEST_NAME ".exp"
|
2013-01-20 16:25:22 -07:00
|
|
|
|
2013-10-06 15:51:45 -07:00
|
|
|
#ifdef HAVE_ARC4RANDOM
|
|
|
|
# undef rand
|
|
|
|
# define rand(X) arc4random(X)
|
|
|
|
#endif
|
|
|
|
|
2013-01-20 16:25:22 -07:00
|
|
|
FILE *fp_res;
|
|
|
|
int xmain(void);
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
FILE *fp_out;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
if ((fp_res = fopen(TEST_NAME_RES, "w+")) == NULL) {
|
|
|
|
perror("fopen(" TEST_NAME_RES ")");
|
|
|
|
return 99;
|
|
|
|
}
|
2013-04-18 10:14:10 -07:00
|
|
|
if (sodium_init() != 0) {
|
|
|
|
return 99;
|
|
|
|
}
|
2013-01-20 16:25:22 -07:00
|
|
|
xmain();
|
|
|
|
rewind(fp_res);
|
|
|
|
if ((fp_out = fopen(TEST_NAME_OUT, "r")) == NULL) {
|
2013-04-21 06:15:25 -07:00
|
|
|
perror("fopen(" TEST_NAME_OUT ")");
|
2013-01-20 16:25:22 -07:00
|
|
|
return 99;
|
|
|
|
}
|
|
|
|
do {
|
|
|
|
if ((c = fgetc(fp_res)) != fgetc(fp_out)) {
|
|
|
|
return 99;
|
|
|
|
}
|
|
|
|
} while (c != EOF);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-25 23:25:39 -07:00
|
|
|
#undef printf
|
2013-01-20 16:25:22 -07:00
|
|
|
#define printf(...) fprintf(fp_res, __VA_ARGS__)
|
|
|
|
#define main xmain
|
|
|
|
|
|
|
|
#endif
|