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