Commit 02acc651 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

setupapi/tests: Drop install test workarounds for Windows <= 2000.

parent abd27e09
TESTDLL = setupapi.dll TESTDLL = setupapi.dll
IMPORTS = setupapi user32 advapi32 IMPORTS = setupapi user32 advapi32 shell32
C_SRCS = \ C_SRCS = \
devinst.c \ devinst.c \
......
...@@ -39,23 +39,16 @@ static const WCHAR inffileW[] = {'t','e','s','t','.','i','n','f',0}; ...@@ -39,23 +39,16 @@ static const WCHAR inffileW[] = {'t','e','s','t','.','i','n','f',0};
static char CURR_DIR[MAX_PATH]; static char CURR_DIR[MAX_PATH];
/* Notes on InstallHinfSectionA/W: /* Notes on InstallHinfSectionA/W:
* - InstallHinfSectionW on Win98 and InstallHinfSectionA on WinXP seem to be stubs - they do not do anything * - InstallHinfSectionA on WinXP seems to be a stub - it does not do anything
* and simply return without displaying any error message or setting last error. We test whether * and simply returns without displaying any error message or setting last
* InstallHinfSectionA sets last error, and if it doesn't we set it to NULL and use the W version if available. * error.
* - These functions do not return a value and do not always set last error to ERROR_SUCCESS when installation still * - These functions do not return a value and do not always set last error to
* occurs (e.g., unquoted inf file with spaces, registry keys are written but last error is 6). Also, on Win98 last error * ERROR_SUCCESS when installation still occurs (e.g., unquoted inf file with
* is set to ERROR_SUCCESS even if install fails (e.g., quoted inf file with spaces, no registry keys set, MessageBox with * spaces, registry keys are written but last error is 6).
* "Installation Error" displayed). Thus, we must use functional tests (e.g., is registry key created) to determine whether * - On installation problems, a MessageBox() is displayed and a Beep() is
* or not installation occurred. * issued. The MessageBox() is disabled with a CBT hook.
* - On installation problems, a MessageBox() is displayed and a Beep() is issued. The MessageBox() is disabled with a
* CBT hook.
*/ */
static void (WINAPI *pInstallHinfSectionA)(HWND, HINSTANCE, LPCSTR, INT);
static void (WINAPI *pInstallHinfSectionW)(HWND, HINSTANCE, LPCWSTR, INT);
static BOOL (WINAPI *pSetupGetInfFileListA)(PCSTR, DWORD, PSTR, DWORD, PDWORD);
static BOOL (WINAPI *pSetupGetInfFileListW)(PCWSTR, DWORD, PWSTR, DWORD, PDWORD);
/* /*
* Helpers * Helpers
*/ */
...@@ -93,15 +86,11 @@ static const char *cmdline_inf = "[Version]\n" ...@@ -93,15 +86,11 @@ static const char *cmdline_inf = "[Version]\n"
static void run_cmdline(LPCSTR section, int mode, LPCSTR path) static void run_cmdline(LPCSTR section, int mode, LPCSTR path)
{ {
CHAR cmdline[MAX_PATH * 2]; CHAR cmdline[MAX_PATH * 2];
WCHAR cmdlinew[MAX_PATH * 2];
sprintf(cmdline, "%s %d %s", section, mode, path); sprintf(cmdline, "%s %d %s", section, mode, path);
if (pInstallHinfSectionA) pInstallHinfSectionA(NULL, NULL, cmdline, 0); MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlinew, MAX_PATH*2);
else InstallHinfSectionW(NULL, NULL, cmdlinew, 0);
{
WCHAR cmdlinew[MAX_PATH * 2];
MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlinew, MAX_PATH*2);
pInstallHinfSectionW(NULL, NULL, cmdlinew, 0);
}
} }
static void ok_registry(BOOL expectsuccess) static void ok_registry(BOOL expectsuccess)
...@@ -193,17 +182,6 @@ static void test_install_svc_from(void) ...@@ -193,17 +182,6 @@ static void test_install_svc_from(void)
BOOL ret; BOOL ret;
SC_HANDLE scm_handle, svc_handle; SC_HANDLE scm_handle, svc_handle;
/* Bail out if we are on win98 */
SetLastError(0xdeadbeef);
scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL);
if (!scm_handle && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
win_skip("OpenSCManagerA is not implemented, we are most likely on win9x\n");
return;
}
CloseServiceHandle(scm_handle);
/* Basic inf file to satisfy SetupOpenInfFileA */ /* Basic inf file to satisfy SetupOpenInfFileA */
strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n"); strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n");
create_inf_file(inffile, inf); create_inf_file(inffile, inf);
...@@ -365,16 +343,10 @@ static void test_driver_install(void) ...@@ -365,16 +343,10 @@ static void test_driver_install(void)
"[Winetest.DriverFiles]\n" "[Winetest.DriverFiles]\n"
"winetest.sys"; "winetest.sys";
/* Bail out if we are on win98 */ /* Bail out if we don't have enough rights */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL); scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL);
if (!scm_handle && (GetLastError() == ERROR_ACCESS_DENIED))
if (!scm_handle && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
{
win_skip("OpenSCManagerA is not implemented, we are most likely on win9x\n");
return;
}
else if (!scm_handle && (GetLastError() == ERROR_ACCESS_DENIED))
{ {
skip("Not enough rights to install the service\n"); skip("Not enough rights to install the service\n");
return; return;
...@@ -421,8 +393,6 @@ static void test_driver_install(void) ...@@ -421,8 +393,6 @@ static void test_driver_install(void)
static void test_profile_items(void) static void test_profile_items(void)
{ {
char path[MAX_PATH], commonprogs[MAX_PATH]; char path[MAX_PATH], commonprogs[MAX_PATH];
HMODULE hShell32;
BOOL (WINAPI *pSHGetFolderPathA)(HWND hwnd, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath);
static const char *inf = static const char *inf =
"[Version]\n" "[Version]\n"
...@@ -440,15 +410,7 @@ static void test_profile_items(void) ...@@ -440,15 +410,7 @@ static void test_profile_items(void)
"Name=TestGroup,4\n" "Name=TestGroup,4\n"
; ;
hShell32 = LoadLibraryA("shell32"); if (S_OK != SHGetFolderPathA(NULL, CSIDL_COMMON_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, commonprogs))
pSHGetFolderPathA = (void*)GetProcAddress(hShell32, "SHGetFolderPathA");
if (!pSHGetFolderPathA)
{
win_skip("SHGetFolderPathA is not available\n");
goto cleanup;
}
if (S_OK != pSHGetFolderPathA(NULL, CSIDL_COMMON_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, commonprogs))
{ {
skip("No common program files directory exists\n"); skip("No common program files directory exists\n");
goto cleanup; goto cleanup;
...@@ -467,19 +429,12 @@ static void test_profile_items(void) ...@@ -467,19 +429,12 @@ static void test_profile_items(void)
run_cmdline("DefaultInstall", 128, path); run_cmdline("DefaultInstall", 128, path);
snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs); snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs);
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesA(path)) snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs);
{ ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "directory not created\n");
win_skip("ProfileItems not implemented on this system\n"); snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs);
} ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "link not created\n");
else snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs);
{ ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "group not created\n");
snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs);
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "directory not created\n");
snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs);
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "link not created\n");
snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs);
ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "group not created\n");
}
snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs); snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs);
DeleteFileA(path); DeleteFileA(path);
...@@ -493,7 +448,6 @@ static void test_profile_items(void) ...@@ -493,7 +448,6 @@ static void test_profile_items(void)
RemoveDirectoryA(path); RemoveDirectoryA(path);
cleanup: cleanup:
if (hShell32) FreeLibrary(hShell32);
DeleteFileA(inffile); DeleteFileA(inffile);
} }
...@@ -509,12 +463,6 @@ static void test_inffilelistA(void) ...@@ -509,12 +463,6 @@ static void test_inffilelistA(void)
DWORD expected, outsize; DWORD expected, outsize;
BOOL ret; BOOL ret;
if(!pSetupGetInfFileListA)
{
win_skip("SetupGetInfFileListA not present\n");
return;
}
/* create a private directory, the temp directory may contain some /* create a private directory, the temp directory may contain some
* inf files left over from old installations * inf files left over from old installations
*/ */
...@@ -541,8 +489,8 @@ static void test_inffilelistA(void) ...@@ -541,8 +489,8 @@ static void test_inffilelistA(void)
/* mixed style /* mixed style
*/ */
expected = 3 + strlen(inffile) + strlen(inffile2); expected = 3 + strlen(inffile) + strlen(inffile2);
ret = pSetupGetInfFileListA(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer, ret = SetupGetInfFileListA(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer,
MAX_PATH, &outsize); MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListA to succeed!\n"); ok(ret, "expected SetupGetInfFileListA to succeed!\n");
ok(expected == outsize, "expected required buffersize to be %d, got %d\n", ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize); expected, outsize);
...@@ -579,30 +527,19 @@ static void test_inffilelist(void) ...@@ -579,30 +527,19 @@ static void test_inffilelist(void)
DWORD expected, outsize; DWORD expected, outsize;
BOOL ret; BOOL ret;
if(!pSetupGetInfFileListW)
{
win_skip("SetupGetInfFileListW not present\n");
return;
}
/* NULL means %windir%\\inf /* NULL means %windir%\\inf
* get the value as reference * get the value as reference
*/ */
expected = 0; expected = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(NULL, INF_STYLE_WIN4, NULL, 0, &expected); ret = SetupGetInfFileListW(NULL, INF_STYLE_WIN4, NULL, 0, &expected);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
win_skip("SetupGetInfFileListW not implemented\n");
return;
}
ok(ret, "expected SetupGetInfFileListW to succeed! Error: %d\n", GetLastError()); ok(ret, "expected SetupGetInfFileListW to succeed! Error: %d\n", GetLastError());
ok(expected > 0, "expected required buffersize to be at least 1\n"); ok(expected > 0, "expected required buffersize to be at least 1\n");
/* check if an empty string doesn't behaves like NULL */ /* check if an empty string doesn't behaves like NULL */
outsize = 0; outsize = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
ok(!ret, "expected SetupGetInfFileListW to fail!\n"); ok(!ret, "expected SetupGetInfFileListW to fail!\n");
/* create a private directory, the temp directory may contain some /* create a private directory, the temp directory may contain some
...@@ -632,7 +569,7 @@ static void test_inffilelist(void) ...@@ -632,7 +569,7 @@ static void test_inffilelist(void)
MultiByteToWideChar(CP_ACP, 0, "\\not_existent", -1, ptr, MAX_PATH - lstrlenW(dir)); MultiByteToWideChar(CP_ACP, 0, "\\not_existent", -1, ptr, MAX_PATH - lstrlenW(dir));
outsize = 0xffffffff; outsize = 0xffffffff;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(ret, "expected SetupGetInfFileListW to succeed!\n");
ok(outsize == 1, "expected required buffersize to be 1, got %d\n", outsize); ok(outsize == 1, "expected required buffersize to be 1, got %d\n", outsize);
ok(ERROR_PATH_NOT_FOUND == GetLastError(), ok(ERROR_PATH_NOT_FOUND == GetLastError(),
...@@ -648,7 +585,7 @@ static void test_inffilelist(void) ...@@ -648,7 +585,7 @@ static void test_inffilelist(void)
MultiByteToWideChar(CP_ACP, 0, invalid_inf, -1, ptr+1, MAX_PATH - lstrlenW(dir)); MultiByteToWideChar(CP_ACP, 0, invalid_inf, -1, ptr+1, MAX_PATH - lstrlenW(dir));
outsize = 0xffffffff; outsize = 0xffffffff;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
ok(!ret, "expected SetupGetInfFileListW to fail!\n"); ok(!ret, "expected SetupGetInfFileListW to fail!\n");
ok(ERROR_DIRECTORY == GetLastError(), ok(ERROR_DIRECTORY == GetLastError(),
"expected error ERROR_DIRECTORY, got %d\n", GetLastError()); "expected error ERROR_DIRECTORY, got %d\n", GetLastError());
...@@ -658,7 +595,7 @@ static void test_inffilelist(void) ...@@ -658,7 +595,7 @@ static void test_inffilelist(void)
dir[1 + lstrlenW(dir)] = 0; dir[1 + lstrlenW(dir)] = 0;
dir[lstrlenW(dir)] = '\\'; dir[lstrlenW(dir)] = '\\';
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
ok(!ret, "expected SetupGetInfFileListW to fail!\n"); ok(!ret, "expected SetupGetInfFileListW to fail!\n");
ok(ERROR_DIRECTORY == GetLastError(), ok(ERROR_DIRECTORY == GetLastError(),
"expected error ERROR_DIRECTORY, got %d\n", GetLastError()); "expected error ERROR_DIRECTORY, got %d\n", GetLastError());
...@@ -667,7 +604,7 @@ static void test_inffilelist(void) ...@@ -667,7 +604,7 @@ static void test_inffilelist(void)
*/ */
*ptr = 0; *ptr = 0;
expected = 3 + strlen(inffile) + strlen(inffile2); expected = 3 + strlen(inffile) + strlen(inffile2);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(ret, "expected SetupGetInfFileListW to succeed!\n");
ok(expected == outsize, "expected required buffersize to be %d, got %d\n", ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize); expected, outsize);
...@@ -678,7 +615,7 @@ static void test_inffilelist(void) ...@@ -678,7 +615,7 @@ static void test_inffilelist(void)
/* upper case value /* upper case value
*/ */
create_inf_file(inffile2, inf2); create_inf_file(inffile2, inf2);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(ret, "expected SetupGetInfFileListW to succeed!\n");
ok(expected == outsize, "expected required buffersize to be %d, got %d\n", ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize); expected, outsize);
...@@ -690,7 +627,7 @@ static void test_inffilelist(void) ...@@ -690,7 +627,7 @@ static void test_inffilelist(void)
*/ */
create_inf_file(inffile2, infNT); create_inf_file(inffile2, infNT);
expected = 3 + strlen(inffile) + strlen(inffile2); expected = 3 + strlen(inffile) + strlen(inffile2);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(ret, "expected SetupGetInfFileListW to succeed!\n");
ok(expected == outsize, "expected required buffersize to be %d, got %d\n", ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize); expected, outsize);
...@@ -701,7 +638,7 @@ static void test_inffilelist(void) ...@@ -701,7 +638,7 @@ static void test_inffilelist(void)
/* old style /* old style
*/ */
expected = 2 + strlen(invalid_inf); expected = 2 + strlen(invalid_inf);
ret = pSetupGetInfFileListW(dir, INF_STYLE_OLDNT, buffer, MAX_PATH, &outsize); ret = SetupGetInfFileListW(dir, INF_STYLE_OLDNT, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(ret, "expected SetupGetInfFileListW to succeed!\n");
ok(expected == outsize, "expected required buffersize to be %d, got %d\n", ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize); expected, outsize);
...@@ -711,8 +648,8 @@ static void test_inffilelist(void) ...@@ -711,8 +648,8 @@ static void test_inffilelist(void)
/* mixed style /* mixed style
*/ */
expected = 4 + strlen(inffile) + strlen(inffile2) + strlen(invalid_inf); expected = 4 + strlen(inffile) + strlen(inffile2) + strlen(invalid_inf);
ret = pSetupGetInfFileListW(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer, ret = SetupGetInfFileListW(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer,
MAX_PATH, &outsize); MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(ret, "expected SetupGetInfFileListW to succeed!\n");
ok(expected == outsize, "expected required buffersize to be %d, got %d\n", ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize); expected, outsize);
...@@ -787,7 +724,6 @@ static void test_dirid(void) ...@@ -787,7 +724,6 @@ static void test_dirid(void)
START_TEST(install) START_TEST(install)
{ {
HMODULE hsetupapi = GetModuleHandleA("setupapi.dll");
char temp_path[MAX_PATH], prev_path[MAX_PATH]; char temp_path[MAX_PATH], prev_path[MAX_PATH];
DWORD len; DWORD len;
...@@ -800,49 +736,21 @@ START_TEST(install) ...@@ -800,49 +736,21 @@ START_TEST(install)
if(len && (CURR_DIR[len - 1] == '\\')) if(len && (CURR_DIR[len - 1] == '\\'))
CURR_DIR[len - 1] = 0; CURR_DIR[len - 1] = 0;
pInstallHinfSectionA = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionA"); /* Set CBT hook to disallow MessageBox creation in current thread */
pInstallHinfSectionW = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionW"); hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
pSetupGetInfFileListA = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListA"); assert(hhook != 0);
pSetupGetInfFileListW = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListW");
if (pInstallHinfSectionA) test_cmdline();
{ test_registry();
/* Check if pInstallHinfSectionA sets last error or is a stub (as on WinXP) */ test_install_svc_from();
static const char *minimal_inf = "[Version]\nSignature=\"$Chicago$\"\n"; test_driver_install();
char cmdline[MAX_PATH*2]; test_dirid();
BOOL ret;
create_inf_file(inffile, minimal_inf);
sprintf(cmdline, "DefaultInstall 128 %s\\%s", CURR_DIR, inffile);
SetLastError(0xdeadbeef);
pInstallHinfSectionA(NULL, NULL, cmdline, 0);
if (GetLastError() == 0xdeadbeef)
{
skip("InstallHinfSectionA is broken (stub)\n");
pInstallHinfSectionA = NULL;
}
ret = DeleteFileA(inffile);
ok(ret, "Expected source inf to exist, last error was %d\n", GetLastError());
}
if (!pInstallHinfSectionW && !pInstallHinfSectionA)
win_skip("InstallHinfSectionA and InstallHinfSectionW are not available\n");
else
{
/* Set CBT hook to disallow MessageBox creation in current thread */
hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
assert(hhook != 0);
test_cmdline(); UnhookWindowsHookEx(hhook);
test_registry();
test_install_svc_from();
test_driver_install();
test_dirid();
UnhookWindowsHookEx(hhook); /* We have to run this test after the CBT hook is disabled because
ProfileItems needs to create a window on Windows XP. */
/* We have to run this test after the CBT hook is disabled because test_profile_items();
ProfileItems needs to create a window on Windows XP. */
test_profile_items();
}
test_inffilelist(); test_inffilelist();
test_inffilelistA(); test_inffilelistA();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment