mirror of
https://github.com/reactos/reactos.git
synced 2024-10-29 19:13:58 +00:00
df6860337a
Rewrite the two existing tests for ICMP and add a third one (for IPv6). Patch by Tim Crawford. ROSTESTS-212 #resolve #comment Commited in r70367. Thanks! svn path=/trunk/; revision=70367
91 lines
2 KiB
C
91 lines
2 KiB
C
/*
|
|
* PROJECT: ReactOS API Tests
|
|
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
|
* PURPOSE: Tests for ICMP functions
|
|
* PROGRAMMERS: Tim Crawford
|
|
*/
|
|
|
|
#include <apitest.h>
|
|
#include <ws2tcpip.h>
|
|
#include <iphlpapi.h>
|
|
#include <icmpapi.h>
|
|
|
|
static
|
|
void
|
|
test_IcmpCreateFile(void)
|
|
{
|
|
HANDLE hIcmp;
|
|
|
|
SetLastError(0xDEADBEEF);
|
|
hIcmp = IcmpCreateFile();
|
|
ok(hIcmp != INVALID_HANDLE_VALUE, "IcmpCreateFile failed unexpectedly: %lu\n", GetLastError());
|
|
|
|
if (hIcmp != INVALID_HANDLE_VALUE)
|
|
IcmpCloseHandle(hIcmp);
|
|
}
|
|
|
|
static
|
|
void
|
|
test_Icmp6CreateFile(void)
|
|
{
|
|
HANDLE hIcmp;
|
|
|
|
SetLastError(0xDEADBEEF);
|
|
hIcmp = Icmp6CreateFile();
|
|
|
|
if (GetLastError() == ERROR_FILE_NOT_FOUND)
|
|
{
|
|
/* On Windows Server 2003, the IPv6 protocol must be installed. */
|
|
skip("IPv6 is not available.\n");
|
|
return;
|
|
}
|
|
|
|
ok(hIcmp != INVALID_HANDLE_VALUE, "Icmp6CreateFile failed unexpectedly: %lu\n", GetLastError());
|
|
|
|
if (hIcmp != INVALID_HANDLE_VALUE)
|
|
IcmpCloseHandle(hIcmp);
|
|
}
|
|
|
|
static
|
|
void
|
|
test_IcmpCloseHandle(void)
|
|
{
|
|
HANDLE hIcmp;
|
|
BOOL bRet;
|
|
|
|
SetLastError(0xDEADBEEF);
|
|
hIcmp = IcmpCreateFile();
|
|
if (hIcmp != INVALID_HANDLE_VALUE)
|
|
{
|
|
bRet = IcmpCloseHandle(hIcmp);
|
|
ok(bRet, "IcmpCloseHandle failed unexpectedly: %lu\n", GetLastError());
|
|
}
|
|
|
|
SetLastError(0xDEADBEEF);
|
|
hIcmp = Icmp6CreateFile();
|
|
if (hIcmp != INVALID_HANDLE_VALUE)
|
|
{
|
|
bRet = IcmpCloseHandle(hIcmp);
|
|
ok(bRet, "IcmpCloseHandle failed unexpectedly: %lu\n", GetLastError());
|
|
}
|
|
|
|
hIcmp = INVALID_HANDLE_VALUE;
|
|
SetLastError(0xDEADBEEF);
|
|
bRet = IcmpCloseHandle(hIcmp);
|
|
ok(!bRet, "IcmpCloseHandle succeeded unexpectedly\n");
|
|
ok_err(ERROR_INVALID_HANDLE);
|
|
|
|
hIcmp = NULL;
|
|
SetLastError(0xDEADBEEF);
|
|
bRet = IcmpCloseHandle(hIcmp);
|
|
ok(!bRet, "IcmpCloseHandle succeeded unexpectedly\n");
|
|
ok_err(ERROR_INVALID_HANDLE);
|
|
}
|
|
|
|
START_TEST(icmp)
|
|
{
|
|
test_IcmpCreateFile();
|
|
test_Icmp6CreateFile();
|
|
test_IcmpCloseHandle();
|
|
}
|