diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-26 17:07:02 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-26 17:07:02 +0200 |
| commit | 91f912176045fd2f95fd45a0e12354e390dff219 (patch) | |
| tree | f5846c6f243e6951362db403ab54ae87568f1c39 /tools/100_checkdata/checkdata.c | |
| parent | bc2cba8529a163d129dec91b5ec448a29a14591a (diff) | |
| download | nissy-core-91f912176045fd2f95fd45a0e12354e390dff219.tar.gz nissy-core-91f912176045fd2f95fd45a0e12354e390dff219.zip | |
Added checkdata tool
Diffstat (limited to 'tools/100_checkdata/checkdata.c')
| -rw-r--r-- | tools/100_checkdata/checkdata.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c new file mode 100644 index 0000000..05961c1 --- /dev/null +++ b/tools/100_checkdata/checkdata.c | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | #include "../tool.h" | ||
| 2 | #include "../expected_distributions.h" | ||
| 3 | |||
| 4 | char *solver, *options, *filename; | ||
| 5 | |||
| 6 | static void | ||
| 7 | run(void) { | ||
| 8 | int64_t size; | ||
| 9 | char *buf; | ||
| 10 | FILE *f; | ||
| 11 | |||
| 12 | size = nissy_datasize(solver, options); | ||
| 13 | |||
| 14 | if (size <= 0) { | ||
| 15 | fprintf(stderr, "Error in datasize\n"); | ||
| 16 | return; | ||
| 17 | } | ||
| 18 | |||
| 19 | if ((f = fopen(filename, "rb")) == NULL) { | ||
| 20 | fprintf(stderr, "Error reading file %s\n", filename); | ||
| 21 | return; | ||
| 22 | } | ||
| 23 | |||
| 24 | buf = malloc(size); | ||
| 25 | fread(buf, size, 1, f); | ||
| 26 | fclose(f); | ||
| 27 | nissy_checkdata(solver, options, buf); | ||
| 28 | free(buf); | ||
| 29 | |||
| 30 | /* TODO: cross-check with expected distributions? */ | ||
| 31 | } | ||
| 32 | |||
| 33 | int main(int argc, char **argv) { | ||
| 34 | char description[256]; | ||
| 35 | |||
| 36 | if (argc < 4) { | ||
| 37 | fprintf(stderr, "Error: not enough arguments. " | ||
| 38 | "A solver, its options and a file name must be given.\n"); | ||
| 39 | return 1; | ||
| 40 | } | ||
| 41 | |||
| 42 | solver = argv[1]; | ||
| 43 | options = argv[2]; | ||
| 44 | filename = argv[3]; | ||
| 45 | sprintf(description, "checking data for solver %s" | ||
| 46 | "with options %s from file %s", solver, options, filename); | ||
| 47 | nissy_setlogger(log_stderr); | ||
| 48 | |||
| 49 | timerun(run, description); | ||
| 50 | |||
| 51 | return 0; | ||
| 52 | } | ||
