aboutsummaryrefslogtreecommitdiff
path: root/tools/000_gendata
diff options
context:
space:
mode:
Diffstat (limited to 'tools/000_gendata')
-rw-r--r--tools/000_gendata/gendata.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c
index 2798862..eec9f76 100644
--- a/tools/000_gendata/gendata.c
+++ b/tools/000_gendata/gendata.c
@@ -1,16 +1,16 @@
1#include "../tool.h" 1#include "../tool.h"
2#include "../expected_distributions.h" 2#include "../expected_distributions.h"
3 3
4char *solver, *options; 4char *solver;
5uint64_t *expected; 5uint64_t *expected;
6 6
7static void 7static void
8run(void) { 8run(void) {
9 int64_t size; 9 int64_t size;
10 bool consistent, expected;
10 char *buf, filename[1024]; 11 char *buf, filename[1024];
11 12
12 getfilename(solver, options, filename); 13 size = generatetable(solver, &buf);
13 size = generatetable(solver, options, &buf);
14 switch (size) { 14 switch (size) {
15 case -1: 15 case -1:
16 return; 16 return;
@@ -18,11 +18,19 @@ run(void) {
18 goto gendata_run_finish; 18 goto gendata_run_finish;
19 default: 19 default:
20 nissy_datainfo(buf, write_stdout); 20 nissy_datainfo(buf, write_stdout);
21 if (check_distribution(solver, buf)) { 21 consistent = nissy_checkdata(solver, buf) == 0;
22 expected = check_distribution(solver, buf);
23 if (consistent && expected) {
22 printf("\n"); 24 printf("\n");
23 printf("Generated %" PRId64 " bytes.\n", size); 25 printf("Generated %" PRId64 " bytes.\n", size);
26 sprintf(filename, "tables/%s", solver);
24 writetable(buf, size, filename); 27 writetable(buf, size, filename);
25 } 28 }
29 if (!consistent)
30 printf("Error: table is not consistent with info"
31 " (nissy_checkdata() failed)\n");
32 if (!expected)
33 printf("Error: distribution is not as expected\n");
26 break; 34 break;
27 } 35 }
28 36
@@ -33,15 +41,14 @@ gendata_run_finish:
33int main(int argc, char **argv) { 41int main(int argc, char **argv) {
34 uint8_t h, k; 42 uint8_t h, k;
35 43
36 if (argc < 3) { 44 if (argc < 2) {
37 fprintf(stderr, "Error: not enough arguments. " 45 fprintf(stderr, "Error: not enough arguments. "
38 "A solver and its options must be given.\n"); 46 "A solver must be given.\n");
39 return 1; 47 return 1;
40 } 48 }
41 49
42 solver = argv[1]; 50 solver = argv[1];
43 options = argv[2]; 51 parse_h48_solver(solver, &h, &k);
44 parse_h48_options(options, &h, &k, NULL);
45 expected = expected_h48[h][k]; 52 expected = expected_h48[h][k];
46 53
47 nissy_setlogger(log_stderr); 54 nissy_setlogger(log_stderr);

Generated with cgit - Back to sebastiano.tronto.net