https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8a455da532df6fdc948ee…
commit 8a455da532df6fdc948eecaf8150f72a5d3855e7
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Wed Feb 1 16:34:08 2023 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Mon Apr 17 00:41:31 2023 +0300
[IPHLPAPI_APITEST] Fix tests so they pass on Windows 2003 and Windows 10
---
.../rostests/apitests/iphlpapi/GetInterfaceName.c | 86 +++++++---------------
1 file changed, 26 insertions(+), 60 deletions(-)
diff --git a/modules/rostests/apitests/iphlpapi/GetInterfaceName.c
b/modules/rostests/apitests/iphlpapi/GetInterfaceName.c
index d49e600d343..2228ba943e0 100644
--- a/modules/rostests/apitests/iphlpapi/GetInterfaceName.c
+++ b/modules/rostests/apitests/iphlpapi/GetInterfaceName.c
@@ -38,11 +38,9 @@ test_NhGetInterfaceNameFromGuid(GUID AdapterGUID, DWORD par1, DWORD
par2)
StartSeh()
ApiReturn = pNhGetInterfaceNameFromGuid(NULL, &Name, &ulOutBufLen, par1,
par2);
Error = GetLastError();
- EndSeh(STATUS_SUCCESS);
+ EndSeh(((GetVersion() & 0xFF) >= 6) ? STATUS_SUCCESS :
STATUS_ACCESS_VIOLATION);
- ok(ApiReturn == ERROR_INVALID_PARAMETER,
- "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n",
- ApiReturn);
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_INVALID_PARAMETER :
ERROR_SUCCESS);
ok(Error == 0xbeeffeed,
"GetLastError() returned %ld, expected 0xbeeffeed\n",
Error);
@@ -57,12 +55,8 @@ test_NhGetInterfaceNameFromGuid(GUID AdapterGUID, DWORD par1, DWORD
par2)
ApiReturn = pNhGetInterfaceNameFromGuid(&AdapterGUID, NULL, &ulOutBufLen,
par1, par2);
Error = GetLastError();
- ok(ApiReturn == ERROR_SUCCESS,
- "ApiReturn returned %ld, expected ERROR_SUCCESS\n",
- ApiReturn);
- ok(Error == 0xbeeffeed,
- "GetLastError() returned %ld, expected 0xbeeffeed\n",
- Error);
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_INVALID_PARAMETER :
ERROR_SUCCESS);
+ ok_long(Error, ((GetVersion() & 0xFF) >= 6) ? ERROR_SUCCESS : 0xbeeffeed);
ok(ulOutBufLen > 0,
"ulOutBufLen is %ld, expected > 0\n",
ulOutBufLen);
@@ -72,14 +66,14 @@ test_NhGetInterfaceNameFromGuid(GUID AdapterGUID, DWORD par1, DWORD
par2)
SetLastError(0xbeeffeed);
Error = 0xbeeffeed;
ZeroMemory(&Name, sizeof(Name));
- ApiReturn = ERROR_SUCCESS;
+ ApiReturn = 0xdeadbeef;
StartSeh()
ApiReturn = pNhGetInterfaceNameFromGuid(&AdapterGUID, &Name, NULL, par1,
par2);
Error = GetLastError();
- EndSeh(STATUS_SUCCESS);
+ EndSeh(STATUS_ACCESS_VIOLATION);
- ok(ApiReturn == ERROR_INVALID_PARAMETER,
- "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n",
+ ok(ApiReturn == 0xdeadbeef,
+ "ApiReturn returned %ld, expected 0xdeadbeef\n",
ApiReturn);
ok(Error == 0xbeeffeed,
"GetLastError() returned %ld, expected 0xbeeffeed\n",
@@ -99,9 +93,7 @@ test_NhGetInterfaceNameFromGuid(GUID AdapterGUID, DWORD par1, DWORD
par2)
ok(ApiReturn == ERROR_SUCCESS,
"ApiReturn returned %ld, expected ERROR_SUCCESS\n",
ApiReturn);
- ok(Error == 0xbeeffeed,
- "GetLastError() returned %ld, expected 0xbeeffeed\n",
- Error);
+ ok_long(Error, ((GetVersion() & 0xFF) >= 6) ? 0 : 0xbeeffeed);
ok(ulOutBufLen > 0,
"ulOutBufLen is %ld, expected > 0\n",
ulOutBufLen);
@@ -119,12 +111,8 @@ test_NhGetInterfaceNameFromGuid(GUID AdapterGUID, DWORD par1, DWORD
par2)
ApiReturn = pNhGetInterfaceNameFromGuid((PVOID)&UniqueGUID, &Name,
&ulOutBufLen, par1, par2);
Error = GetLastError();
- ok(ApiReturn == ERROR_NOT_FOUND,
- "ApiReturn returned %ld, expected ERROR_NOT_FOUND\n",
- ApiReturn);
- ok(Error == ERROR_PATH_NOT_FOUND,
- "GetLastError() returned %ld, expected ERROR_PATH_NOT_FOUND\n",
- Error);
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_INVALID_PARAMETER :
ERROR_NOT_FOUND);
+ ok_long(Error, 0);
ok(ulOutBufLen == sizeof(Name),
"ulOutBufLen is %ld, expected = sizeof(Name)\n",
ulOutBufLen);
@@ -137,15 +125,9 @@ test_NhGetInterfaceNameFromGuid(GUID AdapterGUID, DWORD par1, DWORD
par2)
ApiReturn = pNhGetInterfaceNameFromGuid(&AdapterGUID, &Name,
&ulOutBufLen, par1, par2);
Error = GetLastError();
- ok(ApiReturn == ERROR_INSUFFICIENT_BUFFER,
- "ApiReturn returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
- ApiReturn);
- ok(Error == 0xbeeffeed,
- "GetLastError() returned %ld, expected 0xbeeffeed\n",
- Error);
- ok(ulOutBufLen == MAX_INTERFACE_NAME_LEN * 2,
- "ulOutBufLen is %ld, expected = MAX_INTERFACE_NAME_LEN * 2\n",
- ulOutBufLen);
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_NOT_ENOUGH_MEMORY :
ERROR_INSUFFICIENT_BUFFER);
+ ok_long(Error, ((GetVersion() & 0xFF) >= 6) ? 0 : 0xbeeffeed);
+ ok_long(ulOutBufLen, MAX_INTERFACE_NAME_LEN * 2 + ((GetVersion() & 0xFF) >= 6
? 2 : 0));
ok_wstr(L"", Name);
}
@@ -172,12 +154,10 @@ test_NhGetInterfaceNameFromDeviceGuid(GUID AdapterGUID, DWORD par1,
DWORD par2)
StartSeh()
ApiReturn = pNhGetInterfaceNameFromDeviceGuid(NULL, &Name, &ulOutBufLen,
par1, par2);
Error = GetLastError();
- EndSeh(STATUS_SUCCESS);
+ EndSeh(((GetVersion() & 0xFF) >= 6) ? STATUS_SUCCESS :
STATUS_ACCESS_VIOLATION);
- ok(ApiReturn == ERROR_INVALID_PARAMETER,
- "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n",
- ApiReturn);
- ok(Error == ERROR_SUCCESS,
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_INVALID_PARAMETER :
0);
+ ok(Error == 0xbeeffeed,
"GetLastError() returned %ld, expected ERROR_SUCCESS\n",
Error);
ok(ulOutBufLen == sizeof(Name),
@@ -193,14 +173,10 @@ test_NhGetInterfaceNameFromDeviceGuid(GUID AdapterGUID, DWORD par1,
DWORD par2)
StartSeh()
ApiReturn = pNhGetInterfaceNameFromDeviceGuid(&AdapterGUID, NULL,
&ulOutBufLen, par1, par2);
Error = GetLastError();
- EndSeh(STATUS_SUCCESS);
+ EndSeh(((GetVersion() & 0xFF) >= 6) ? STATUS_SUCCESS :
STATUS_ACCESS_VIOLATION);
- ok(ApiReturn == ERROR_INVALID_PARAMETER,
- "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n",
- ApiReturn);
- ok(Error == ERROR_SUCCESS,
- "GetLastError() returned %ld, expected ERROR_SUCCESS\n",
- Error);
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_INVALID_PARAMETER :
0);
+ ok_long(Error, ((GetVersion() & 0xFF) >= 6) ? ERROR_SUCCESS : 0xbeeffeed);
ok(ulOutBufLen > 0,
"ulOutBufLen is %ld, expected > 0\n",
ulOutBufLen);
@@ -214,14 +190,10 @@ test_NhGetInterfaceNameFromDeviceGuid(GUID AdapterGUID, DWORD par1,
DWORD par2)
StartSeh()
ApiReturn = pNhGetInterfaceNameFromDeviceGuid(&AdapterGUID, &Name, NULL,
par1, par2);
Error = GetLastError();
- EndSeh(STATUS_SUCCESS);
+ EndSeh(STATUS_ACCESS_VIOLATION);
- ok(ApiReturn == ERROR_INVALID_PARAMETER,
- "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n",
- ApiReturn);
- ok(Error == ERROR_SUCCESS,
- "GetLastError() returned %ld, expected ERROR_SUCCESS\n",
- Error);
+ ok_long(ApiReturn, 0);
+ ok_long(Error, 0xbeeffeed);
ok(ulOutBufLen > 0,
"ulOutBufLen is %ld, expected > 0\n",
ulOutBufLen);
@@ -257,9 +229,7 @@ test_NhGetInterfaceNameFromDeviceGuid(GUID AdapterGUID, DWORD par1,
DWORD par2)
ApiReturn = pNhGetInterfaceNameFromDeviceGuid((PVOID)&UniqueGUID, &Name,
&ulOutBufLen, par1, par2);
Error = GetLastError();
- ok(ApiReturn == ERROR_NOT_FOUND,
- "ApiReturn returned %ld, expected ERROR_NOT_FOUND\n",
- ApiReturn);
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_INVALID_PARAMETER :
ERROR_NOT_FOUND);
ok(Error == ERROR_SUCCESS,
"GetLastError() returned %ld, expected ERROR_SUCCESS\n",
Error);
@@ -275,15 +245,11 @@ test_NhGetInterfaceNameFromDeviceGuid(GUID AdapterGUID, DWORD par1,
DWORD par2)
ApiReturn = pNhGetInterfaceNameFromDeviceGuid(&AdapterGUID, &Name,
&ulOutBufLen, par1, par2);
Error = GetLastError();
- ok(ApiReturn == ERROR_INSUFFICIENT_BUFFER,
- "ApiReturn returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
- ApiReturn);
+ ok_long(ApiReturn, ((GetVersion() & 0xFF) >= 6) ? ERROR_NOT_ENOUGH_MEMORY :
ERROR_INSUFFICIENT_BUFFER);
ok(Error == ERROR_SUCCESS,
"GetLastError() returned %ld, expected ERROR_SUCCESS\n",
Error);
- ok(ulOutBufLen == MAX_INTERFACE_NAME_LEN * 2,
- "ulOutBufLen is %ld, expected = MAX_INTERFACE_NAME_LEN * 2\n",
- ulOutBufLen);
+ ok_long(ulOutBufLen, MAX_INTERFACE_NAME_LEN * 2 + (((GetVersion() & 0xFF) >=
6) ? 2 : 0));
ok_wstr(L"", Name);
}