1 #include "redump_dat.h"
7 static const char *optional_arg(const char *arg) {
8 if (!arg || strcmp(arg, "-") == 0)
13 int main(int argc, char **argv) {
14 const char *explicit_dir;
15 const char *executable_dir;
17 const char *expected_path;
24 "Usage: %s <explicit-dir|-> <executable-dir|-> "
25 "<basename> <expected-path> <expected-found-0-or-1>\n",
26 argc > 0 ? argv[0] : "test_redump_dat_resolver");
30 explicit_dir = optional_arg(argv[1]);
31 executable_dir = optional_arg(argv[2]);
33 expected_path = argv[4];
34 expected_found = atoi(argv[5]) ? 1 : 0;
36 memset(resolved, 0, sizeof(resolved));
37 found = redump_resolve_dat_path(
45 printf("resolved=%s\n", resolved);
46 printf("found=%d\n", found);
48 if (found != expected_found) {
49 fprintf(stderr, "Found-state mismatch: expected %d, observed %d\n",
50 expected_found, found);
54 if (strcmp(resolved, expected_path) != 0) {
55 fprintf(stderr, "Path mismatch:\n expected: %s\n observed: %s\n",
56 expected_path, resolved);