From e2b6c0ca2a9e748f3af63738905494629431778b Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 1 Sep 2025 16:52:50 +0200 Subject: [PATCH 1/2] [winpr,file] fix TestFileFindFirstFile --- .../file/test/TestFileFindFirstFile.c | 66 +++++++++++++------ 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/winpr/libwinpr/file/test/TestFileFindFirstFile.c b/winpr/libwinpr/file/test/TestFileFindFirstFile.c index a0776132b..6d61a4864 100644 --- a/winpr/libwinpr/file/test/TestFileFindFirstFile.c +++ b/winpr/libwinpr/file/test/TestFileFindFirstFile.c @@ -10,7 +10,7 @@ static const CHAR testFile1A[] = "TestFile1A"; -static BOOL create_file(const char* FilePath) +static BOOL create_fileA(const char* FilePath) { HANDLE hdl = CreateFileA(FilePath, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); @@ -20,6 +20,16 @@ static BOOL create_file(const char* FilePath) return TRUE; } +static BOOL create_fileW(const WCHAR* FilePath) +{ + HANDLE hdl = + CreateFileW(FilePath, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hdl == INVALID_HANDLE_VALUE) + return FALSE; + (void)CloseHandle(hdl); + return TRUE; +} + static BOOL create_layout_files(size_t level, const char* BasePath, wArrayList* files) { for (size_t x = 0; x < 10; x++) @@ -31,7 +41,7 @@ static BOOL create_layout_files(size_t level, const char* BasePath, wArrayList* (void)_snprintf(name, ARRAYSIZE(name), "%zd-TestFile%zd", level, x); NativePathCchAppendA(FilePath, PATHCCH_MAX_CCH, name); - if (create_file(FilePath)) + if (create_fileA(FilePath)) ArrayList_Append(files, FilePath); } return TRUE; @@ -95,7 +105,7 @@ static BOOL find_first_file_success(const char* FilePath) goto fail; } - printf("FindFirstFile: %s", FindData.cFileName); + printf("FindFirstFile: %s\n", FindData.cFileName); if (strcmp(FindData.cFileName, testFile1A) != 0) { @@ -199,6 +209,8 @@ static BOOL find_first_file_fail(const char* FilePath) static int TestFileFindFirstFileA(const char* str) { int rc = -1; + + printf("[%s] basepath: '%s'\n", __func__, str); if (!str) return -1; @@ -230,11 +242,8 @@ static int TestFileFindFirstFileA(const char* str) if (!find_first_file_fail(FilePath)) goto fail; - HANDLE hdl = - CreateFileA(FilePath, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (hdl == INVALID_HANDLE_VALUE) + if (!create_fileA(FilePath)) goto fail; - (void)CloseHandle(hdl); if (!find_first_file_success(FilePath)) goto fail; @@ -260,6 +269,26 @@ fail: return rc; } +WINPR_ATTR_FORMAT_ARG(1, 0) +static int printf1W(const char* WINPR_FORMAT_ARG fmt, const WCHAR* arg1) +{ + char* var1 = ConvertWCharToUtf8Alloc(arg1, NULL); + const int rc = printf(fmt, var1); + free(var1); + return rc; +} + +WINPR_ATTR_FORMAT_ARG(1, 0) +static int printf2W(const char* WINPR_FORMAT_ARG fmt, const WCHAR* arg1, const WCHAR* arg2) +{ + char* var1 = ConvertWCharToUtf8Alloc(arg1, NULL); + char* var2 = ConvertWCharToUtf8Alloc(arg2, NULL); + const int rc = printf(fmt, var1, var2); + free(var1); + free(var2); + return rc; +} + static int TestFileFindFirstFileW(const char* str) { WCHAR buffer[32] = { 0 }; @@ -270,6 +299,7 @@ static int TestFileFindFirstFileW(const char* str) WCHAR BasePath[PATHCCH_MAX_CCH] = { 0 }; + printf("[%s] basepath: '%s'\n", __func__, str); (void)ConvertUtf8ToWChar(str, BasePath, ARRAYSIZE(BasePath)); const size_t length = _wcsnlen(BasePath, PATHCCH_MAX_CCH - 1); @@ -280,31 +310,27 @@ static int TestFileFindFirstFileW(const char* str) PathCchConvertStyleW(BasePath, length, PATH_STYLE_WINDOWS); NativePathCchAppendW(FilePath, PATHCCH_MAX_CCH, testFile1W); - CHAR FilePathA[PATHCCH_MAX_CCH] = { 0 }; - (void)ConvertWCharNToUtf8(FilePath, ARRAYSIZE(FilePath), FilePathA, ARRAYSIZE(FilePathA)); - if (!create_file(FilePathA)) - return -1; + HANDLE hFind = INVALID_HANDLE_VALUE; + if (!create_fileW(FilePath)) + goto fail; - printf("Finding file: %s\n", FilePathA); + printf1W("Finding file: %s\n", FilePath); WIN32_FIND_DATAW FindData = { 0 }; - HANDLE hFind = FindFirstFileW(FilePath, &FindData); + hFind = FindFirstFileW(FilePath, &FindData); if (hFind == INVALID_HANDLE_VALUE) { - printf("FindFirstFile failure: %s (INVALID_HANDLE_VALUE -1)\n", FilePathA); + printf1W("FindFirstFile failure: %s (INVALID_HANDLE_VALUE -1)\n", FilePath); goto fail; } - CHAR cFileName[MAX_PATH] = { 0 }; - (void)ConvertWCharNToUtf8(FindData.cFileName, ARRAYSIZE(FindData.cFileName), cFileName, - ARRAYSIZE(cFileName)); - - printf("FindFirstFile: %s", cFileName); + printf1W("FindFirstFile: %s\n", FindData.cFileName); if (_wcscmp(FindData.cFileName, testFile1W) != 0) { - printf("FindFirstFile failure: Expected: %s, Actual: %s\n", testFile1A, cFileName); + printf2W("FindFirstFile failure: Expected: %s, Actual: %s\n", testFile1W, + FindData.cFileName); goto fail; } From 41102bf198af7b39bf9f8666a384d96d8b882f9b Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 1 Sep 2025 16:54:36 +0200 Subject: [PATCH 2/2] [ci,mac] cmake installed by local/pinned --- .github/workflows/macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b83fefd6c..0283ed529 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -15,7 +15,7 @@ jobs: - name: "Prepare environment" run: | - brew install autoconf automake cmake git libtool meson + brew install autoconf automake git libtool meson - name: "Run mac os build..." run: |