[SHELL32_APITEST] Enhance FindExecutable testcase (#6634)

I want to know the details of FindExecutable
behavior.
JIRA issue: CORE-19493
Enhance the tests of return values.
This commit is contained in:
Katayama Hirofumi MZ 2024-03-18 07:36:17 +09:00 committed by GitHub
parent 6af1813fda
commit 1ad90967d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,7 +2,7 @@
* PROJECT: ReactOS api tests
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
* PURPOSE: Test for FindExecutable
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
* COPYRIGHT: Copyright 2021-2024 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#include "shelltest.h"
@ -12,7 +12,7 @@
typedef struct TEST_ENTRY
{
INT lineno;
BOOL ret;
UINT ret; // SE_ERR_NOASSOC, SE_ERR_FNF, or 0xBEEFCAFE (success).
LPCSTR file;
LPCSTR dir;
LPCSTR result;
@ -36,133 +36,142 @@ static char s_sys_txt_file[MAX_PATH];
static const TEST_ENTRY s_entries[] =
{
{ __LINE__, TRUE, "notepad", DIR_0, s_sys_notepad },
{ __LINE__, TRUE, "notepad", DIR_1, s_sys_notepad },
{ __LINE__, TRUE, "notepad", DIR_2, s_sys_notepad },
{ __LINE__, TRUE, "notepad", DIR_3, s_win_notepad },
{ __LINE__, TRUE, "notepad", DIR_4, s_sys_notepad },
{ __LINE__, FALSE, " notepad", DIR_0, "" },
{ __LINE__, FALSE, " notepad", DIR_1, "" },
{ __LINE__, FALSE, " notepad", DIR_2, "" },
{ __LINE__, FALSE, " notepad", DIR_3, "" },
{ __LINE__, FALSE, " notepad", DIR_4, "" },
{ __LINE__, FALSE, "notepad ", DIR_0, "" },
{ __LINE__, FALSE, "notepad ", DIR_1, "" },
{ __LINE__, FALSE, "notepad ", DIR_2, "" },
{ __LINE__, FALSE, "notepad ", DIR_3, "" },
{ __LINE__, FALSE, "notepad ", DIR_4, "" },
{ __LINE__, TRUE, "\"notepad\"", DIR_0, s_sys_notepad },
{ __LINE__, TRUE, "\"notepad\"", DIR_1, s_sys_notepad },
{ __LINE__, TRUE, "\"notepad\"", DIR_2, s_sys_notepad },
{ __LINE__, TRUE, "\"notepad\"", DIR_3, s_win_notepad },
{ __LINE__, TRUE, "\"notepad\"", DIR_4, s_sys_notepad },
{ __LINE__, TRUE, "notepad.exe", DIR_0, s_sys_notepad },
{ __LINE__, TRUE, "notepad.exe", DIR_1, s_sys_notepad },
{ __LINE__, TRUE, "notepad.exe", DIR_2, s_sys_notepad },
{ __LINE__, TRUE, "notepad.exe", DIR_3, s_win_notepad },
{ __LINE__, TRUE, "notepad.exe", DIR_4, s_sys_notepad },
{ __LINE__, FALSE, "notepad.bat", DIR_0, "" },
{ __LINE__, FALSE, "notepad.bat", DIR_1, "" },
{ __LINE__, FALSE, "notepad.bat", DIR_2, "" },
{ __LINE__, FALSE, "notepad.bat", DIR_3, "" },
{ __LINE__, FALSE, "notepad.bat", DIR_4, "" },
{ __LINE__, FALSE, "C:\\notepad.exe", DIR_0, "" },
{ __LINE__, FALSE, "C:\\notepad.exe", DIR_1, "" },
{ __LINE__, FALSE, "C:\\notepad.exe", DIR_2, "" },
{ __LINE__, FALSE, "C:\\notepad.exe", DIR_3, "" },
{ __LINE__, FALSE, "C:\\notepad.exe", DIR_4, "" },
{ __LINE__, FALSE, "..\\notepad.exe", DIR_0, "" },
{ __LINE__, FALSE, "..\\notepad.exe", DIR_1, "" },
{ __LINE__, FALSE, "..\\notepad.exe", DIR_2, "" },
{ __LINE__, FALSE, "..\\notepad.exe", DIR_3, "" },
{ __LINE__, FALSE, "..\\notepad.exe", DIR_4, "" },
{ __LINE__, FALSE, ".\\notepad.exe", DIR_0, "" },
{ __LINE__, FALSE, ".\\notepad.exe", DIR_1, "" },
{ __LINE__, FALSE, ".\\notepad.exe", DIR_2, "" },
{ __LINE__, TRUE, ".\\notepad.exe", DIR_3, s_win_notepad },
{ __LINE__, FALSE, ".\\notepad.exe", DIR_4, "" },
{ __LINE__, FALSE, "system32\\notepad.exe", DIR_0, "" },
{ __LINE__, FALSE, "system32\\notepad.exe", DIR_1, "" },
{ __LINE__, FALSE, "system32\\notepad.exe", DIR_2, "" },
{ __LINE__, TRUE, "system32\\notepad.exe", DIR_3, s_sys_notepad },
{ __LINE__, FALSE, "system32\\notepad.exe", DIR_4, "" },
{ __LINE__, TRUE, s_win_notepad, DIR_0, s_win_notepad },
{ __LINE__, TRUE, s_win_notepad, DIR_1, s_win_notepad },
{ __LINE__, TRUE, s_win_notepad, DIR_2, s_win_notepad },
{ __LINE__, TRUE, s_win_notepad, DIR_3, s_win_notepad },
{ __LINE__, TRUE, s_win_notepad, DIR_4, s_win_notepad },
{ __LINE__, TRUE, "test program", DIR_0, s_sys_test_exe },
{ __LINE__, TRUE, "test program", DIR_1, s_sys_test_exe },
{ __LINE__, TRUE, "test program", DIR_2, s_sys_test_exe },
{ __LINE__, TRUE, "test program", DIR_3, s_win_test_exe },
{ __LINE__, TRUE, "test program", DIR_4, s_sys_test_exe },
{ __LINE__, FALSE, " test program", DIR_0, "" },
{ __LINE__, FALSE, " test program", DIR_1, "" },
{ __LINE__, FALSE, " test program", DIR_2, "" },
{ __LINE__, FALSE, " test program", DIR_3, "" },
{ __LINE__, FALSE, " test program", DIR_4, "" },
{ __LINE__, FALSE, "test program ", DIR_0, "" },
{ __LINE__, FALSE, "test program ", DIR_1, "" },
{ __LINE__, FALSE, "test program ", DIR_2, "" },
{ __LINE__, FALSE, "test program ", DIR_3, "" },
{ __LINE__, FALSE, "test program ", DIR_4, "" },
{ __LINE__, TRUE, "\"test program\"", DIR_0, s_sys_test_exe },
{ __LINE__, TRUE, "\"test program\"", DIR_1, s_sys_test_exe },
{ __LINE__, TRUE, "\"test program\"", DIR_2, s_sys_test_exe },
{ __LINE__, TRUE, "\"test program\"", DIR_3, s_win_test_exe },
{ __LINE__, TRUE, "\"test program\"", DIR_4, s_sys_test_exe },
{ __LINE__, TRUE, "test program.exe", DIR_0, s_sys_test_exe },
{ __LINE__, TRUE, "test program.exe", DIR_1, s_sys_test_exe },
{ __LINE__, TRUE, "test program.exe", DIR_2, s_sys_test_exe },
{ __LINE__, TRUE, "test program.exe", DIR_3, s_win_test_exe },
{ __LINE__, TRUE, "test program.exe", DIR_4, s_sys_test_exe },
{ __LINE__, TRUE, "\"test program.exe\"", DIR_0, s_sys_test_exe },
{ __LINE__, TRUE, "\"test program.exe\"", DIR_1, s_sys_test_exe },
{ __LINE__, TRUE, "\"test program.exe\"", DIR_2, s_sys_test_exe },
{ __LINE__, TRUE, "\"test program.exe\"", DIR_3, s_win_test_exe },
{ __LINE__, TRUE, "\"test program.exe\"", DIR_4, s_sys_test_exe },
{ __LINE__, FALSE, "\"test program.exe \"", DIR_0, "" },
{ __LINE__, FALSE, "\"test program.exe \"", DIR_1, "" },
{ __LINE__, FALSE, "\"test program.exe \"", DIR_2, "" },
{ __LINE__, FALSE, "\"test program.exe \"", DIR_3, "" },
{ __LINE__, FALSE, "\"test program.exe \"", DIR_4, "" },
{ __LINE__, FALSE, "\" test program.exe\"", DIR_0, "" },
{ __LINE__, FALSE, "\" test program.exe\"", DIR_1, "" },
{ __LINE__, FALSE, "\" test program.exe\"", DIR_2, "" },
{ __LINE__, FALSE, "\" test program.exe\"", DIR_3, "" },
{ __LINE__, FALSE, "\" test program.exe\"", DIR_4, "" },
{ __LINE__, TRUE, "test program.bat", DIR_0, s_sys_bat_file },
{ __LINE__, TRUE, "test program.bat", DIR_1, s_sys_bat_file },
{ __LINE__, TRUE, "test program.bat", DIR_2, s_sys_bat_file },
{ __LINE__, TRUE, "test program.bat", DIR_3, s_win_bat_file },
{ __LINE__, TRUE, "test program.bat", DIR_4, s_sys_bat_file },
{ __LINE__, FALSE, " test program.bat ", DIR_0, "" },
{ __LINE__, FALSE, " test program.bat ", DIR_1, "" },
{ __LINE__, FALSE, " test program.bat ", DIR_2, "" },
{ __LINE__, FALSE, " test program.bat ", DIR_3, "" },
{ __LINE__, FALSE, " test program.bat ", DIR_4, "" },
{ __LINE__, TRUE, "\"test program.bat\"", DIR_0, s_sys_bat_file },
{ __LINE__, TRUE, "\"test program.bat\"", DIR_1, s_sys_bat_file },
{ __LINE__, TRUE, "\"test program.bat\"", DIR_2, s_sys_bat_file },
{ __LINE__, TRUE, "\"test program.bat\"", DIR_3, s_win_bat_file },
{ __LINE__, TRUE, "\"test program.bat\"", DIR_4, s_sys_bat_file },
{ __LINE__, TRUE, "test file.txt", DIR_0, s_sys_notepad },
{ __LINE__, TRUE, "test file.txt", DIR_1, s_sys_notepad },
{ __LINE__, TRUE, "test file.txt", DIR_2, s_sys_notepad },
{ __LINE__, TRUE, "test file.txt", DIR_3, s_sys_notepad },
{ __LINE__, TRUE, "test file.txt", DIR_4, s_sys_notepad },
{ __LINE__, FALSE, "invalid file.txt", DIR_0, "" },
{ __LINE__, FALSE, "invalid file.txt", DIR_1, "" },
{ __LINE__, FALSE, "invalid file.txt", DIR_2, "" },
{ __LINE__, FALSE, "invalid file.txt", DIR_3, "" },
{ __LINE__, FALSE, "invalid file.txt", DIR_4, "" },
{ __LINE__, 0xBEEFCAFE, "notepad", DIR_0, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad", DIR_1, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad", DIR_2, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad", DIR_3, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad", DIR_4, s_sys_notepad },
{ __LINE__, SE_ERR_FNF, " notepad", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, " notepad", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, " notepad", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, " notepad", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, " notepad", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, "notepad ", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "notepad ", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "notepad ", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "notepad ", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "notepad ", DIR_4, "" },
{ __LINE__, 0xBEEFCAFE, "\"notepad\"", DIR_0, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "\"notepad\"", DIR_1, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "\"notepad\"", DIR_2, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "\"notepad\"", DIR_3, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, "\"notepad\"", DIR_4, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad.exe", DIR_0, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad.exe", DIR_1, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad.exe", DIR_2, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad.exe", DIR_3, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, "notepad.exe", DIR_4, s_sys_notepad },
{ __LINE__, SE_ERR_FNF, "notepad.bat", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "notepad.bat", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "notepad.bat", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "notepad.bat", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "notepad.bat", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, "C:\\notepad.exe", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "C:\\notepad.exe", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "C:\\notepad.exe", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "C:\\notepad.exe", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "C:\\notepad.exe", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, "..\\notepad.exe", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "..\\notepad.exe", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "..\\notepad.exe", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "..\\notepad.exe", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "..\\notepad.exe", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, ".\\notepad.exe", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, ".\\notepad.exe", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, ".\\notepad.exe", DIR_2, "" },
{ __LINE__, 0xBEEFCAFE, ".\\notepad.exe", DIR_3, s_win_notepad },
{ __LINE__, SE_ERR_FNF, ".\\notepad.exe", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, "system32\\notepad.exe", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "system32\\notepad.exe", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "system32\\notepad.exe", DIR_2, "" },
{ __LINE__, 0xBEEFCAFE, "system32\\notepad.exe", DIR_3, s_sys_notepad },
{ __LINE__, SE_ERR_FNF, "system32\\notepad.exe", DIR_4, "" },
{ __LINE__, 0xBEEFCAFE, s_win_notepad, DIR_0, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, s_win_notepad, DIR_1, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, s_win_notepad, DIR_2, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, s_win_notepad, DIR_3, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, s_win_notepad, DIR_4, s_win_notepad },
{ __LINE__, 0xBEEFCAFE, "test program", DIR_0, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program", DIR_1, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program", DIR_2, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program", DIR_3, s_win_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program", DIR_4, s_sys_test_exe },
{ __LINE__, SE_ERR_FNF, " test program", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, " test program", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, " test program", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, " test program", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, " test program", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, "test program ", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "test program ", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "test program ", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "test program ", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "test program ", DIR_4, "" },
{ __LINE__, 0xBEEFCAFE, "\"test program\"", DIR_0, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program\"", DIR_1, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program\"", DIR_2, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program\"", DIR_3, s_win_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program\"", DIR_4, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program.exe", DIR_0, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program.exe", DIR_1, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program.exe", DIR_2, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program.exe", DIR_3, s_win_test_exe },
{ __LINE__, 0xBEEFCAFE, "test program.exe", DIR_4, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program.exe\"", DIR_0, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program.exe\"", DIR_1, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program.exe\"", DIR_2, s_sys_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program.exe\"", DIR_3, s_win_test_exe },
{ __LINE__, 0xBEEFCAFE, "\"test program.exe\"", DIR_4, s_sys_test_exe },
{ __LINE__, SE_ERR_NOASSOC, "\"test program.exe \"", DIR_0, "" },
{ __LINE__, SE_ERR_NOASSOC, "\"test program.exe \"", DIR_1, "" },
{ __LINE__, SE_ERR_NOASSOC, "\"test program.exe \"", DIR_2, "" },
{ __LINE__, SE_ERR_NOASSOC, "\"test program.exe \"", DIR_3, "" },
{ __LINE__, SE_ERR_NOASSOC, "\"test program.exe \"", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, "\" test program.exe\"", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "\" test program.exe\"", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "\" test program.exe\"", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "\" test program.exe\"", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "\" test program.exe\"", DIR_4, "" },
{ __LINE__, 0xBEEFCAFE, "test program.bat", DIR_0, s_sys_bat_file },
{ __LINE__, 0xBEEFCAFE, "test program.bat", DIR_1, s_sys_bat_file },
{ __LINE__, 0xBEEFCAFE, "test program.bat", DIR_2, s_sys_bat_file },
{ __LINE__, 0xBEEFCAFE, "test program.bat", DIR_3, s_win_bat_file },
{ __LINE__, 0xBEEFCAFE, "test program.bat", DIR_4, s_sys_bat_file },
{ __LINE__, SE_ERR_FNF, " test program.bat ", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, " test program.bat ", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, " test program.bat ", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, " test program.bat ", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, " test program.bat ", DIR_4, "" },
{ __LINE__, 0xBEEFCAFE, "\"test program.bat\"", DIR_0, s_sys_bat_file },
{ __LINE__, 0xBEEFCAFE, "\"test program.bat\"", DIR_1, s_sys_bat_file },
{ __LINE__, 0xBEEFCAFE, "\"test program.bat\"", DIR_2, s_sys_bat_file },
{ __LINE__, 0xBEEFCAFE, "\"test program.bat\"", DIR_3, s_win_bat_file },
{ __LINE__, 0xBEEFCAFE, "\"test program.bat\"", DIR_4, s_sys_bat_file },
{ __LINE__, 0xBEEFCAFE, "test file.txt", DIR_0, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "test file.txt", DIR_1, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "test file.txt", DIR_2, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "test file.txt", DIR_3, s_sys_notepad },
{ __LINE__, 0xBEEFCAFE, "test file.txt", DIR_4, s_sys_notepad },
{ __LINE__, SE_ERR_FNF, "invalid file.txt", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.txt", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.txt", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.txt", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.txt", DIR_4, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.InvalidExtension", DIR_0, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.InvalidExtension", DIR_1, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.InvalidExtension", DIR_2, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.InvalidExtension", DIR_3, "" },
{ __LINE__, SE_ERR_FNF, "invalid file.InvalidExtension", DIR_4, "" },
};
static void DoTestEntry(const TEST_ENTRY *pEntry)
{
char result[MAX_PATH];
result[0] = 0;
BOOL ret = ((INT_PTR)FindExecutableA(pEntry->file, pEntry->dir, result) > 32);
UINT ret = (UINT)(UINT_PTR)FindExecutableA(pEntry->file, pEntry->dir, result);
if (ret > 32)
ret = 0xBEEFCAFE;
ok(ret == pEntry->ret, "Line %u: ret expected %d, got %d\n", pEntry->lineno, pEntry->ret, ret);
GetLongPathNameA(result, result, _countof(result));