Skip to content

Commit

Permalink
Add custom unicode test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Nov 8, 2024
1 parent eeda79b commit d639885
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/windows-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ jobs:
- name: Test
run: |
# Change codepage to utf-8
env
cat /d/a/_temp/setup-msys2/msys2.CMD
echo $PATH
echo "Lang:"
Expand All @@ -176,6 +177,7 @@ jobs:
export PYTHONUTF8=1
export PATH="$PWD/build/src/lib:$PATH"
export RNP_LOG_CONSOLE=1
ctest --test-dir build -C Debug -V -R rnp_tests.test_windows_unicode || true
ctest --parallel ${{ env.CORES }} --test-dir build -C Debug --output-on-failure -R rnp_tests.test_cli_rnpkeys_unicode
- name: Install
Expand Down
31 changes: 30 additions & 1 deletion src/tests/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ TEST_F(rnp_tests, test_cli_rnpkeys_unicode)
STARTUPINFOW siw;
ZeroMemory(&siw, sizeof siw);
ZeroMemory(&pi, sizeof pi);
fprintf(stdout, "Running CreateProcessW:\n");
fprintf(stdout, "Running CreateProcessW: %s\n", (char *) cmdline_ws.c_str());
fflush(stdout);
res = CreateProcessW(NULL,
(LPWSTR) cmdline_ws.c_str(), // Command line
Expand Down Expand Up @@ -482,6 +482,35 @@ TEST_F(rnp_tests, test_cli_rnpkeys_unicode)
#endif
}

TEST_F(rnp_tests, test_windows_unicode)
{
#ifdef _WIN32
UINT acp = GetACP();
fprintf(stdout, "GetACP: %u\n", (unsigned) acp);
fflush(stdout);
std::wstring cmdline_ws = L"D:\\a\\rnp\\rnp\\build\\src\\tests/../rnpkeys/rnpkeys.exe "
L"--list-keys \"\x03C9\x0410@b.com\"";
STARTUPINFOW siw;
ZeroMemory(&siw, sizeof siw);
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof pi);
BOOL res = CreateProcessW(NULL,
(LPWSTR) cmdline_ws.c_str(), // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Handle inheritance
0, // Creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&siw, // Pointer to STARTUPINFO structure
&pi); // Pointer to PROCESS_INFORMATION structure
assert_true(res);
assert_true(WaitForSingleObject(pi.hProcess, INFINITE) == WAIT_OBJECT_0);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
#endif
}

TEST_F(rnp_tests, test_cli_rnp)
{
int ret;
Expand Down

0 comments on commit d639885

Please sign in to comment.