From aa7446b17edb64b196d501a97cca5463a03d7317 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 31 Mar 2022 02:19:21 +0800 Subject: [PATCH] util: Fixes test_util_get_process_exec_path on windows host with msys2/mingw MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ``` 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 Reviewed-by: Jesse Natalie Part-of: --- src/util/tests/process_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/util/tests/process_test.c b/src/util/tests/process_test.c index fdd6ee6..1a17ce7 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 -- 2.7.4