Mesa (main): util: Fixes test_util_get_process_exec_path on windows host with msys2/mingw

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 26 23:51:35 UTC 2022


Module: Mesa
Branch: main
Commit: aa7446b17edb64b196d501a97cca5463a03d7317
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa7446b17edb64b196d501a97cca5463a03d7317

Author: Yonggang Luo <luoyonggang at gmail.com>
Date:   Thu Mar 31 02:19:21 2022 +0800

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 at gmail.com>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16723>

---

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



More information about the mesa-commit mailing list