diff --git a/src/util/tests/process_test.c b/src/util/tests/process_test.c index fdd6ee6ba01..1a17ce78bdd 100644 --- a/src/util/tests/process_test.c +++ b/src/util/tests/process_test.c @@ -62,6 +62,16 @@ test_util_get_process_name (void) expect_equal_str(expected, name, "util_get_process_name"); } +static void posixify_path(char *path) { + /* Always using posix separator '/' to check path equal */ + char *p = path; + for (; *p != '\0'; p += 1) { + if (*p == '\\') { + *p = '/'; + } + } +} + /* This test gets the real path from Meson (BUILD_FULL_PATH env var), * and compares it to the output of util_get_process_exec_path. */ @@ -73,18 +83,22 @@ test_util_get_process_exec_path (void) error = true; return; } + posixify_path(path); char* build_path = getenv("BUILD_FULL_PATH"); if (!build_path) { fprintf(stderr, "BUILD_FULL_PATH environment variable should be set\n"); error = true; return; } + build_path = strdup(build_path); + posixify_path(build_path); #ifdef __CYGWIN__ int i = strlen(build_path) - 4; if ((i > 0) && (strcmp(&build_path[i], ".exe") == 0)) build_path[i] = 0; #endif expect_equal_str(build_path, path, "util_get_process_name"); + free(build_path); } int