Commit 9498fabf authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

localspl: Run EnumPorts tests when InitializePrintMonitor2 is used.

parent 8e9bcf42
...@@ -234,6 +234,14 @@ static BOOL delete_port(LPWSTR portname) ...@@ -234,6 +234,14 @@ static BOOL delete_port(LPWSTR portname)
(lstrlenW(portname) + 1) * sizeof(WCHAR), NULL, 0, NULL) == ERROR_SUCCESS; (lstrlenW(portname) + 1) * sizeof(WCHAR), NULL, 0, NULL) == ERROR_SUCCESS;
} }
static BOOL call_EnumPorts(WCHAR *name, DWORD level, BYTE *buf, DWORD size,
DWORD *needed, DWORD *count)
{
if (pEnumPorts)
return pEnumPorts(name, level, buf, size, needed, count);
return pEnumPorts2(hmon, name, level, buf, size, needed, count);
}
static BOOL call_AddPortEx(WCHAR *name, DWORD level, BYTE *buf, WCHAR *mon) static BOOL call_AddPortEx(WCHAR *name, DWORD level, BYTE *buf, WCHAR *mon)
{ {
if (pAddPortEx) if (pAddPortEx)
...@@ -256,13 +264,13 @@ static void find_installed_ports(void) ...@@ -256,13 +264,13 @@ static void find_installed_ports(void)
have_lpt[0] = '\0'; have_lpt[0] = '\0';
have_file[0] = '\0'; have_file[0] = '\0';
if (!pEnumPorts) return; if (!pEnumPorts && !pEnumPorts2) return;
res = pEnumPorts(NULL, 1, NULL, 0, &needed, &returned); res = call_EnumPorts(NULL, 1, NULL, 0, &needed, &returned);
if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) { if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
pi = HeapAlloc(GetProcessHeap(), 0, needed); pi = HeapAlloc(GetProcessHeap(), 0, needed);
} }
res = pEnumPorts(NULL, 1, (LPBYTE) pi, needed, &needed, &returned); res = call_EnumPorts(NULL, 1, (LPBYTE) pi, needed, &needed, &returned);
if (!res) { if (!res) {
skip("no ports found\n"); skip("no ports found\n");
...@@ -619,7 +627,7 @@ static void test_EnumPorts(void) ...@@ -619,7 +627,7 @@ static void test_EnumPorts(void)
DWORD pcbNeeded; DWORD pcbNeeded;
DWORD pcReturned; DWORD pcReturned;
if (!pEnumPorts) return; if (!pEnumPorts && !pEnumPorts2) return;
/* valid levels are 1 and 2 */ /* valid levels are 1 and 2 */
for(level = 0; level < 4; level++) { for(level = 0; level < 4; level++) {
...@@ -627,15 +635,14 @@ static void test_EnumPorts(void) ...@@ -627,15 +635,14 @@ static void test_EnumPorts(void)
cbBuf = 0xdeadbeef; cbBuf = 0xdeadbeef;
pcReturned = 0xdeadbeef; pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pEnumPorts(NULL, level, NULL, 0, &cbBuf, &pcReturned); res = call_EnumPorts(NULL, level, NULL, 0, &cbBuf, &pcReturned);
/* use only a short test, when we test with an invalid level */ /* use only a short test, when we test with an invalid level */
if(!level || (level > 2)) { if(!level || (level > 2)) {
/* NT4 fails with ERROR_INVALID_LEVEL (as expected) todo_wine ok(!res || broken(res && !GetLastError()),
XP succeeds with ERROR_SUCCESS () */ "EnumPorts succeeded with level %ld\n", level);
ok( (cbBuf == 0) && (pcReturned == 0), todo_wine ok(GetLastError() == ERROR_INVALID_LEVEL || broken(res && !GetLastError()),
"(%ld) returned %ld with %lu and %ld, %ld (expected 0, 0)\n", "GetLastError() = %ld\n", GetLastError());
level, res, GetLastError(), cbBuf, pcReturned);
continue; continue;
} }
...@@ -650,7 +657,7 @@ static void test_EnumPorts(void) ...@@ -650,7 +657,7 @@ static void test_EnumPorts(void)
pcbNeeded = 0xdeadbeef; pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef; pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pEnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned); res = call_EnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n", ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n",
level, res, GetLastError(), pcbNeeded, pcReturned); level, res, GetLastError(), pcbNeeded, pcReturned);
/* We can compare the returned Data with the Registry / "win.ini",[Ports] here */ /* We can compare the returned Data with the Registry / "win.ini",[Ports] here */
...@@ -658,14 +665,14 @@ static void test_EnumPorts(void) ...@@ -658,14 +665,14 @@ static void test_EnumPorts(void)
pcbNeeded = 0xdeadbeef; pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef; pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pEnumPorts(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned); res = call_EnumPorts(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n", ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n",
level, res, GetLastError(), pcbNeeded, pcReturned); level, res, GetLastError(), pcbNeeded, pcReturned);
pcbNeeded = 0xdeadbeef; pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef; pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pEnumPorts(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned); res = call_EnumPorts(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER), ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
"(%ld) returned %ld with %lu and %ld, %ld (expected '0' with " "(%ld) returned %ld with %lu and %ld, %ld (expected '0' with "
"ERROR_INSUFFICIENT_BUFFER)\n", "ERROR_INSUFFICIENT_BUFFER)\n",
...@@ -674,23 +681,23 @@ static void test_EnumPorts(void) ...@@ -674,23 +681,23 @@ static void test_EnumPorts(void)
if (0) if (0)
{ {
/* The following tests crash this app with native localmon/localspl */ /* The following tests crash this app with native localmon/localspl */
pEnumPorts(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned); call_EnumPorts(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
pEnumPorts(NULL, level, buffer, cbBuf, NULL, &pcReturned); call_EnumPorts(NULL, level, buffer, cbBuf, NULL, &pcReturned);
pEnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, NULL); call_EnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
} }
/* The Servername is ignored */ /* The Servername is ignored */
pcbNeeded = 0xdeadbeef; pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef; pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pEnumPorts(emptyW, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned); res = call_EnumPorts(emptyW, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n", ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n",
level, res, GetLastError(), pcbNeeded, pcReturned); level, res, GetLastError(), pcbNeeded, pcReturned);
pcbNeeded = 0xdeadbeef; pcbNeeded = 0xdeadbeef;
pcReturned = 0xdeadbeef; pcReturned = 0xdeadbeef;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pEnumPorts(server_does_not_existW, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned); res = call_EnumPorts(server_does_not_existW, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n", ok( res, "(%ld) returned %ld with %lu and %ld, %ld (expected '!= 0')\n",
level, res, GetLastError(), pcbNeeded, pcReturned); level, res, GetLastError(), pcbNeeded, pcReturned);
......
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