Author: akhaldi Date: Sun Sep 28 18:32:39 2014 New Revision: 64373
URL: http://svn.reactos.org/svn/reactos?rev=64373&view=rev Log: [INETMIB1_WINETEST] * Sync with Wine 1.7.27. CORE-8540
Modified: trunk/rostests/winetests/inetmib1/main.c
Modified: trunk/rostests/winetests/inetmib1/main.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/inetmib1/main.c?... ============================================================================== --- trunk/rostests/winetests/inetmib1/main.c [iso-8859-1] (original) +++ trunk/rostests/winetests/inetmib1/main.c [iso-8859-1] Sun Sep 28 18:32:39 2014 @@ -23,38 +23,63 @@
#include "wine/test.h"
-static HMODULE inetmib1; +static BOOL (WINAPI *pSnmpExtensionInit)(DWORD, HANDLE*, AsnObjectIdentifier*); +static BOOL (WINAPI *pSnmpExtensionQuery)(BYTE, SnmpVarBindList*, AsnInteger32*, AsnInteger32*); + +static HMODULE init_test_functions(void) +{ + HMODULE mod = LoadLibraryA("inetmib1"); + + ok(mod != NULL, "failed to load inetmib1.dll\n"); + + if (!mod) return NULL; + + pSnmpExtensionInit = (void *)GetProcAddress(mod, "SnmpExtensionInit"); + pSnmpExtensionQuery = (void *)GetProcAddress(mod, "SnmpExtensionQuery"); + + return mod; +} + +static void uninit_test_functions(HMODULE mod) +{ + FreeLibrary(mod); +}
static void testInit(void) { - BOOL (WINAPI *pInit)(DWORD, HANDLE *, AsnObjectIdentifier *); BOOL ret; HANDLE event; AsnObjectIdentifier oid;
- pInit = (void *)GetProcAddress(inetmib1, "SnmpExtensionInit"); - if (!pInit) + if (!pSnmpExtensionInit) { win_skip("no SnmpExtensionInit\n"); return; } - /* Crash - ret = pInit(0, NULL, NULL); - ret = pInit(0, NULL, &oid); - ret = pInit(0, &event, NULL); - */ - ret = pInit(0, &event, &oid); + +if (0) /* crashes on native */ +{ + ret = pSnmpExtensionInit(0, NULL, NULL); + ret = pSnmpExtensionInit(0, NULL, &oid); + ret = pSnmpExtensionInit(0, &event, NULL); +} + + ret = pSnmpExtensionInit(0, &event, &oid); ok(ret, "SnmpExtensionInit failed: %d\n", GetLastError()); ok(!strcmp("1.3.6.1.2.1.1", SnmpUtilOidToA(&oid)), "Expected 1.3.6.1.2.1.1, got %s\n", SnmpUtilOidToA(&oid));
+ +if (0) +{ + /* Fails when called on win8, documentation suggests that + extension itself is responsible for freeing this oid */ SnmpUtilOidFree(&oid); } +}
static void testQuery(void) { - BOOL (WINAPI *pQuery)(BYTE, SnmpVarBindList *, AsnInteger32 *, - AsnInteger32 *); BOOL ret, moreData, noChange; SnmpVarBindList list; AsnInteger32 error, index; @@ -71,25 +96,25 @@ SnmpVarBind vars[3], vars2[3], vars3[3]; UINT entry;
- pQuery = (void *)GetProcAddress(inetmib1, "SnmpExtensionQuery"); - if (!pQuery) + if (!pSnmpExtensionQuery) { win_skip("couldn't find SnmpExtensionQuery\n"); return; } - /* Crash - ret = pQuery(0, NULL, NULL, NULL); - ret = pQuery(0, NULL, &error, NULL); - ret = pQuery(0, NULL, NULL, &index); - ret = pQuery(0, &list, NULL, NULL); - ret = pQuery(0, &list, &error, NULL); - */ - + +if (0) /* crashes on native */ +{ + ret = pSnmpExtensionQuery(0, NULL, NULL, NULL); + ret = pSnmpExtensionQuery(0, NULL, &error, NULL); + ret = pSnmpExtensionQuery(0, NULL, NULL, &index); + ret = pSnmpExtensionQuery(0, &list, NULL, NULL); + ret = pSnmpExtensionQuery(0, &list, &error, NULL); +} /* An empty list succeeds */ list.len = 0; error = 0xdeadbeef; index = 0xdeadbeef; - ret = pQuery(SNMP_PDU_GET, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GET, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOERROR, "expected SNMP_ERRORSTATUS_NOERROR, got %d\n", error); @@ -106,7 +131,7 @@ SetLastError(0xdeadbeef); error = 0xdeadbeef; index = 0xdeadbeef; - ret = pQuery(SNMP_PDU_GET, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GET, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOERROR || broken(error == ERROR_FILE_NOT_FOUND) /* NT4 */, @@ -126,7 +151,7 @@ SetLastError(0xdeadbeef); error = 0xdeadbeef; index = 0xdeadbeef; - ret = pQuery(SNMP_PDU_GET, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GET, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOSUCHNAME, "expected SNMP_ERRORSTATUS_NOSUCHNAME, got %d\n", error); @@ -148,7 +173,7 @@ SetLastError(0xdeadbeef); error = 0xdeadbeef; index = 0xdeadbeef; - ret = pQuery(SNMP_PDU_GET, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GET, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOSUCHNAME, "expected SNMP_ERRORSTATUS_NOSUCHNAME, got %d\n", error); @@ -170,7 +195,7 @@ SetLastError(0xdeadbeef); error = 0xdeadbeef; index = 0xdeadbeef; - ret = pQuery(SNMP_PDU_GETNEXT, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GETNEXT, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOERROR, "expected SNMP_ERRORSTATUS_NOERROR, got %d\n", error); @@ -252,7 +277,7 @@ list.len = 1; list.list = vars2; noChange = FALSE; - ret = pQuery(SNMP_PDU_GETNEXT, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GETNEXT, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOERROR, "expected SNMP_ERRORSTATUS_NOERROR, got %d\n", error); @@ -274,7 +299,7 @@ list.list = vars2; moreData = TRUE; do { - ret = pQuery(SNMP_PDU_GETNEXT, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GETNEXT, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOERROR, "expected SNMP_ERRORSTATUS_NOERROR, got %d\n", error); @@ -340,7 +365,7 @@ moreData = TRUE; noChange = FALSE; do { - ret = pQuery(SNMP_PDU_GETNEXT, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GETNEXT, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); ok(error == SNMP_ERRORSTATUS_NOERROR, "expected SNMP_ERRORSTATUS_NOERROR, got %d\n", error); @@ -406,7 +431,7 @@ moreData = TRUE; noChange = FALSE; do { - ret = pQuery(SNMP_PDU_GETNEXT, &list, &error, &index); + ret = pSnmpExtensionQuery(SNMP_PDU_GETNEXT, &list, &error, &index); ok(ret, "SnmpExtensionQuery failed: %d, %d\n", error, index); /* FIXME: error and index aren't checked here because the UDP table is * the last OID currently supported by Wine, so the last GetNext fails. @@ -471,8 +496,13 @@
START_TEST(main) { - inetmib1 = LoadLibraryA("inetmib1"); + HMODULE mod; + + if (!(mod = init_test_functions())) + return; + testInit(); testQuery(); - FreeLibrary(inetmib1); -} + + uninit_test_functions(mod); +}