diff options
author | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2018-08-10 15:56:44 +0300 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2018-08-13 13:59:24 +0300 |
commit | 2cd4ae5ee6b385360644ded41d73e070ea81f116 (patch) | |
tree | fa1204c122c5c9a7f271bd26a8efc8973b3c602b /runner/runner_tests.c | |
parent | fce9638b2e60afce872b3056c19a729b1b3708be (diff) |
runner: Fix path handling
absolute_path() tends to return NULL if more than the last element of
the path is nonexistent. That behavior is confusing the callers, which
use NULL as a convention for something not being set at all.
Let's fix that by sprinkling a little bit of recursion onto
absolute_path() and wrapping POSIX in some sanity.
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'runner/runner_tests.c')
-rw-r--r-- | runner/runner_tests.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/runner/runner_tests.c b/runner/runner_tests.c index 7c662acc..89b4377a 100644 --- a/runner/runner_tests.c +++ b/runner/runner_tests.c @@ -231,28 +231,18 @@ igt_main } igt_subtest("absolute-path-converter") { - struct { - char *path; - bool null; - } data[] = { { "simple-name", false }, - { "foo/bar", true }, - { ".", false }, - }; + char paths[][15] = { "simple-name", "foo/bar", "." }; size_t i; - for (i = 0; i < ARRAY_SIZE(data); i++) { + for (i = 0; i < ARRAY_SIZE(paths); i++) { free(path); - path = absolute_path(data[i].path); - if (data[i].null) { - igt_assert(path == NULL); - continue; - } + path = absolute_path(paths[i]); igt_assert(path[0] == '/'); - igt_debug("Got path %s for %s\n", path, data[i].path); + igt_debug("Got path %s for %s\n", path, paths[i]); igt_assert(strstr(path, cwd) == path); - if (strcmp(data[i].path, ".")) { - igt_assert(strstr(path, data[i].path) != NULL); + if (strcmp(paths[i], ".")) { + igt_assert(strstr(path, paths[i]) != NULL); } } } |