1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include "../tool.h"
#include "../expected_distributions.h"
char *solver;
uint64_t *expected;
static void
run(void) {
int64_t size;
bool consistent, expected;
char *buf, filename[1024], dataid[NISSY_SIZE_DATAID];
size = generatetable(solver, &buf, dataid);
switch (size) {
case -1:
return;
case -2:
goto gendata_run_finish;
default:
nissy_datainfo(size, buf);
consistent = nissy_checkdata(size, buf) == 0;
expected = check_distribution(solver, size, buf);
if (consistent && expected) {
printf("\n");
printf("Generated %" PRId64 " bytes.\n", size);
sprintf(filename, "tables/%s", dataid);
writetable(buf, size, filename);
}
if (!consistent)
printf("Error: table is not consistent with info"
" (nissy_checkdata() failed)\n");
if (!expected)
printf("Error: distribution is not as expected\n");
break;
}
gendata_run_finish:
free(buf);
}
int main(int argc, char **argv) {
uint8_t h, k;
if (argc < 2) {
printf("Error: not enough arguments. "
"A solver must be given.\n");
return 1;
}
solver = argv[1];
parse_h48_solver(solver, &h, &k);
expected = expected_h48[h][k];
nissy_setlogger(log_stderr, NULL);
timerun(run);
return 0;
}
|