19 #define generate_test_TYPE_array(TYPE) \ 20 void test_##TYPE##_array() { \ 26 fd = open("testfile", O_WRONLY|O_CREAT|O_TRUNC, 0666); \ 27 assert(fd>1 && "Couldn't open file to write test output"); \ 28 for(i=0; i<10; i++) { \ 31 write_##TYPE##_array(fd, a, 10); \ 33 fd = open("testfile", O_RDONLY); \ 34 assert(fd>1 && "Couldn't open file to read test input"); \ 37 assert( parse_##TYPE##_array(p, a, 10)==0 ); \ 38 for(i=0; i<10; i++) { \ 39 assert(a[i]==((TYPE)i)); \ 49 void test_section_jumping() {
53 fd = open(
"input_sections", O_RDONLY);
54 assert(fd>1 &&
"Couldn't open file to read test input");
57 assert(p==s &&
"Couldn't find zeroth section");
59 assert(p+3==s &&
"Couldn't find first section");
61 assert(p+3+5==s &&
"Couldn't find third section");
65 #define TESTSTR "hello world" 75 fd = open(
"testfile", O_WRONLY|O_CREAT|O_TRUNC, 0666);
76 assert(fd>1 &&
"Couldn't open file to write test output");
79 fd = open(
"testfile", O_RDONLY);
80 assert(fd>1 &&
"Couldn't open file to read test input");
84 assert( !memcmp(test, a,
STRLEN) );
88 fd = open(
"testfile", O_WRONLY|O_CREAT|O_TRUNC, 0666);
89 assert(fd>1 &&
"Couldn't open file to write test output");
93 fd = open(
"testfile", O_RDONLY);
94 assert(fd>1 &&
"Couldn't open file to read test input");
97 assert( !memcmp(test, a,
STRLEN+1) );
103 uint64_t RA[3], RB[3];
115 assert( RA[0]==RB[0] &&
"PRNG non-deterministic" );
116 assert( RA[1]==RB[1] &&
"PRNG non-deterministic" );
117 assert( RA[2]==RB[2] &&
"PRNG non-deterministic" );
120 int main(
int argc,
char **argv)
122 test_section_jumping();
123 test_uint8_t_array();
124 test_uint16_t_array();
125 test_uint32_t_array();
126 test_uint64_t_array();
132 printf(
"Success.\n");
static uint64_t prng_rand(struct prng_rand_t *state)
void data_to_output(int fd, void *vdata)
int main(int argc, char **argv)
#define generate_test_TYPE_array(TYPE)
int parse_string(char *s, char *arr, int n)
int write_string(int fd, char *arr, int n)
int write_section_header(int fd)
#define SECTION_TERMINATED
char * find_section_start(char *s, int n)
void output_to_data(int fd, void *vdata)
int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_9, PropertyId p_var_11)
static void prng_srand(uint64_t seed, struct prng_rand_t *state)
void input_to_data(int fd, void *vdata)
void run_benchmark(void *vargs)
int check_data(void *vdata, void *vref)