util: Fixes test_util_get_process_exec_path on windows host with msys2/mingw

```
stderr:
Error: Test 'test_util_get_process_exec_path' failed:
        Expected="C:/work/xemu/xemu-opengl/mesa/build/windows-mingw64/src/util/process_test.exe", Actual="C:\work\xemu\xemu-opengl\mesa\build\windows-mingw64\src\util\process_test.exe"
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
```

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16723>
This commit is contained in:
Yonggang Luo 2022-03-31 02:19:21 +08:00 committed by Marge Bot
parent 746287d221
commit aa7446b17e

View file

@ -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