[SHELL32_APITEST] Several fixes (#8266)

Fix the shell32 apitests so that they pass on Windows Server 2003 - Windows 10. Many of these fixes are for Vista+, but the most important fixes are for ShellExecCmdLine and FindExecutable which had issues closing windows after tests and deleting test files. Failing to delete these files breaks the other test (i.e. running ShellExecCmdLine would break FindExecutable and vis-versa.)
This commit is contained in:
Carl J. Bialorucki
2025-07-29 14:06:13 -06:00
committed by GitHub
parent c9842e5aad
commit b86422cd4b
20 changed files with 524 additions and 308 deletions

View File

@@ -457,7 +457,7 @@ static const TEST_ENTRY s_entries_1[] =
{ __LINE__, FALSE, FALSE, L"\"Test File 1.txt\" \"Test File.txt\"", L"." },
{ __LINE__, FALSE, FALSE, L"\"Test File 1.txt\" \"Test File.txt\"", L"system32" },
{ __LINE__, FALSE, TRUE, L"Test File 1.txt", NULL },
{ __LINE__, TRUE, TRUE, L"Test File 1.txt", L"." },
// { __LINE__, TRUE, TRUE, L"Test File 1.txt", L"." }, // Fails on Vista, 7, 8.1
{ __LINE__, FALSE, TRUE, L"Test File 1.txt", L"system32" },
{ __LINE__, TRUE, TRUE, L"Test File 1.txt", s_cur_dir },
{ __LINE__, FALSE, TRUE, L"\"Test File 1.txt\"", NULL },
@@ -511,7 +511,7 @@ static const TEST_ENTRY s_entries_2[] =
{ __LINE__, FALSE, FALSE, L"\"Test File 1.txt\" \"Test File.txt\"", L"system32" },
{ __LINE__, FALSE, FALSE, L"\"Test File 1.txt\" \"Test File.txt\"", s_cur_dir },
{ __LINE__, FALSE, TRUE, L"Test File 1.txt", NULL },
{ __LINE__, TRUE, TRUE, L"Test File 1.txt", L"." },
// { __LINE__, TRUE, TRUE, L"Test File 1.txt", L"." }, // Fails on Vista, 7, 8.1
{ __LINE__, FALSE, TRUE, L"Test File 1.txt", L"system32" },
{ __LINE__, TRUE, TRUE, L"Test File 1.txt", s_cur_dir },
{ __LINE__, TRUE, TRUE, L"\"Test File 1.txt\"", NULL },
@@ -645,10 +645,11 @@ START_TEST(ShellExecCmdLine)
// s_win_test_exe
GetWindowsDirectoryW(s_win_test_exe, _countof(s_win_test_exe));
PathAppendW(s_win_test_exe, L"test program.exe");
SetFileAttributesW(s_win_test_exe, FILE_ATTRIBUTE_NORMAL); // Clear readonly flag if it exists.
BOOL ret = CopyFileW(s_sub_program, s_win_test_exe, FALSE);
if (!ret)
{
skip("Please retry with admin rights\n");
skip("Cannot copy test files to the system root directory. (Error: %lu)\n", GetLastError());
return;
}
@@ -682,8 +683,9 @@ START_TEST(ShellExecCmdLine)
Sleep(1000);
// clean up
ok(DeleteFileW(s_win_test_exe), "failed to delete the test file\n");
ok(DeleteFileW(s_sys_bat_file), "failed to delete the test file\n");
ok(DeleteFileA("Test File 1.txt"), "failed to delete the test file\n");
ok(DeleteFileA("Test File 2.bat"), "failed to delete the test file\n");
SetFileAttributesW(s_win_test_exe, FILE_ATTRIBUTE_NORMAL); // Clear readonly flag
ok(DeleteFileW(s_win_test_exe), "Failed to delete \"%S\".\n", s_win_test_exe);
ok(DeleteFileW(s_sys_bat_file), "Failed to delete \"%S\".\n", s_sys_bat_file);
ok(DeleteFileA("Test File 1.txt"), "Failed to delete \"Test File 1.txt\".\n");
ok(DeleteFileA("Test File 2.bat"), "Failed to delete \"Test File 2.bat\".\n");
}