Author: tfaber
Date: Sat Apr 27 09:12:20 2013
New Revision: 58867
URL:
http://svn.reactos.org/svn/reactos?rev=58867&view=rev
Log:
[ADVAPI32_APITEST]
- Add basic parameter tests for SaferIdentifyLevel
CORE-6942
Added:
trunk/rostests/apitests/advapi32/SaferIdentifyLevel.c (with props)
Modified:
trunk/rostests/apitests/advapi32/CMakeLists.txt
trunk/rostests/apitests/advapi32/testlist.c
Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
==============================================================================
--- trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Sat Apr 27 09:12:20 2013
@@ -1,12 +1,13 @@
list(APPEND SOURCE
- CreateService.c
- LockDatabase.c
- QueryServiceConfig2.c
- testlist.c)
+ CreateService.c
+ LockDatabase.c
+ QueryServiceConfig2.c
+ SaferIdentifyLevel.c
+ testlist.c)
add_executable(advapi32_apitest ${SOURCE})
-target_link_libraries(advapi32_apitest wine)
+target_link_libraries(advapi32_apitest wine ${PSEH_LIB})
set_module_type(advapi32_apitest win32cui)
add_importlibs(advapi32_apitest advapi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET advapi32_apitest DESTINATION reactos/bin FOR all)
Added: trunk/rostests/apitests/advapi32/SaferIdentifyLevel.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/SaferId…
==============================================================================
--- trunk/rostests/apitests/advapi32/SaferIdentifyLevel.c (added)
+++ trunk/rostests/apitests/advapi32/SaferIdentifyLevel.c [iso-8859-1] Sat Apr 27 09:12:20
2013
@@ -1,0 +1,125 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for SaferIdentifyLevel
+ * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de>
+ */
+
+#define WIN32_NO_STATUS
+#include <wine/test.h>
+#include <windows.h>
+#include <ndk/ntndk.h>
+#include <winsafer.h>
+
+#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
+#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus ==
ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus,
ExpectedStatus)
+
+#define InvalidPointer ((PVOID)0x5555555555555555ULL)
+
+#define SaferIdentifyLevel(c, p, h, r) SaferIdentifyLevel(c, (PSAFER_CODE_PROPERTIES)(p),
h, r)
+
+START_TEST(SaferIdentifyLevel)
+{
+ NTSTATUS ExceptionStatus;
+ BOOL ret;
+ DWORD error;
+ SAFER_LEVEL_HANDLE handle;
+ SAFER_CODE_PROPERTIES_V2 props[16];
+
+ StartSeh()
+ SetLastError(0xbadbad00);
+ ret = SaferIdentifyLevel(0, NULL, NULL, NULL);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(error == ERROR_NOACCESS, "error = %lu\n", error);
+ EndSeh(STATUS_SUCCESS);
+
+ StartSeh()
+ (VOID)SaferIdentifyLevel(0, NULL, &handle, NULL);
+ EndSeh(STATUS_ACCESS_VIOLATION);
+
+ StartSeh()
+ ZeroMemory(props, sizeof(props));
+ SetLastError(0xbadbad00);
+ ret = SaferIdentifyLevel(16, props, &handle, NULL);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error);
+ EndSeh(STATUS_SUCCESS);
+
+ StartSeh()
+ ZeroMemory(props, sizeof(props));
+ SetLastError(0xbadbad00);
+ ret = SaferIdentifyLevel(1, props, NULL, NULL);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(error == ERROR_NOACCESS, "error = %lu\n", error);
+ EndSeh(STATUS_SUCCESS);
+
+ StartSeh()
+ handle = InvalidPointer;
+ ZeroMemory(props, sizeof(props));
+ SetLastError(0xbadbad00);
+ ret = SaferIdentifyLevel(1, props, &handle, NULL);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(handle == InvalidPointer, "handle = %p\n", handle);
+ ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error);
+ if (handle && handle != InvalidPointer)
+ SaferCloseLevel(handle);
+ EndSeh(STATUS_SUCCESS);
+
+ /* Struct sizes */
+ StartSeh()
+ handle = InvalidPointer;
+ ZeroMemory(props, sizeof(props));
+ props[0].cbSize = sizeof(SAFER_CODE_PROPERTIES_V1);
+ SetLastError(0xbadbad00);
+ ret = SaferIdentifyLevel(1, props, &handle, NULL);
+ error = GetLastError();
+ ok(ret == TRUE, "ret = %d\n", ret);
+ ok(handle != NULL && handle != INVALID_HANDLE_VALUE && handle !=
InvalidPointer, "handle = %p\n", handle);
+ ok(error == 0xbadbad00, "error = %lu\n", error);
+ if (handle && handle != InvalidPointer)
+ {
+ ret = SaferCloseLevel(handle);
+ ok(ret == TRUE, "ret = %d\n", ret);
+ }
+ EndSeh(STATUS_SUCCESS);
+
+ StartSeh()
+ handle = InvalidPointer;
+ ZeroMemory(props, sizeof(props));
+ props[0].cbSize = sizeof(SAFER_CODE_PROPERTIES_V2);
+ SetLastError(0xbadbad00);
+ ret = SaferIdentifyLevel(1, props, &handle, NULL);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(handle == InvalidPointer, "handle = %p\n", handle);
+ ok(error == ERROR_BAD_LENGTH, "error = %lu\n", error);
+ if (handle && handle != InvalidPointer)
+ SaferCloseLevel(handle);
+ EndSeh(STATUS_SUCCESS);
+
+ /* Test SaferCloseLevel too */
+ StartSeh()
+ ret = SaferCloseLevel(NULL);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error);
+ EndSeh(STATUS_SUCCESS);
+
+ StartSeh()
+ ret = SaferCloseLevel(INVALID_HANDLE_VALUE);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error);
+ EndSeh(STATUS_SUCCESS);
+
+ StartSeh()
+ ret = SaferCloseLevel(InvalidPointer);
+ error = GetLastError();
+ ok(ret == FALSE, "ret = %d\n", ret);
+ ok(error == ERROR_INVALID_HANDLE, "error = %lu\n", error);
+ EndSeh(STATUS_SUCCESS);
+}
Propchange: trunk/rostests/apitests/advapi32/SaferIdentifyLevel.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/advapi32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
==============================================================================
--- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Sat Apr 27 09:12:20 2013
@@ -6,12 +6,14 @@
extern void func_CreateService(void);
extern void func_LockDatabase(void);
extern void func_QueryServiceConfig2(void);
+extern void func_SaferIdentifyLevel(void);
const struct test winetest_testlist[] =
{
{ "CreateService", func_CreateService },
{ "LockDatabase" , func_LockDatabase },
{ "QueryServiceConfig2", func_QueryServiceConfig2 },
+ { "SaferIdentifyLevel", func_SaferIdentifyLevel },
{ 0, 0 }
};