Author: ekohl
Date: Tue Sep 27 13:06:33 2011
New Revision: 53873
URL:
http://svn.reactos.org/svn/reactos?rev=53873&view=rev
Log:
[APITESTS]
Add service tag tests.
Patch by Thomas Faber.
Added:
trunk/rostests/apitests/advapi32/
trunk/rostests/apitests/advapi32/CMakeLists.txt (with props)
trunk/rostests/apitests/advapi32/CreateService.c (with props)
trunk/rostests/apitests/advapi32/advapi32_apitest.rbuild (with props)
trunk/rostests/apitests/advapi32/testlist.c (with props)
Modified:
trunk/rostests/apitests/CMakeLists.txt
trunk/rostests/apitests/directory.rbuild
Modified: trunk/rostests/apitests/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/CMakeLists.txt?r…
==============================================================================
--- trunk/rostests/apitests/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/CMakeLists.txt [iso-8859-1] Tue Sep 27 13:06:33 2011
@@ -1,6 +1,7 @@
add_library(apitest apitest.c)
+add_subdirectory(advapi32)
add_subdirectory(dciman32)
add_subdirectory(gdi32)
add_subdirectory(ntdll)
Added: trunk/rostests/apitests/advapi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
==============================================================================
--- trunk/rostests/apitests/advapi32/CMakeLists.txt (added)
+++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Tue Sep 27 13:06:33 2011
@@ -1,0 +1,12 @@
+
+add_definitions(-D_DLL -D__USE_CRTIMP)
+
+list(APPEND SOURCE
+ CreateService.c
+ testlist.c)
+
+add_executable(advapi32_apitest ${SOURCE})
+target_link_libraries(advapi32_apitest wine)
+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)
Propchange: trunk/rostests/apitests/advapi32/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/rostests/apitests/advapi32/CMakeLists.txt
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: trunk/rostests/apitests/advapi32/CreateService.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CreateS…
==============================================================================
--- trunk/rostests/apitests/advapi32/CreateService.c (added)
+++ trunk/rostests/apitests/advapi32/CreateService.c [iso-8859-1] Tue Sep 27 13:06:33
2011
@@ -1,0 +1,125 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for CreateService
+ * PROGRAMMER: Thomas Faber
+ */
+
+#include <wine/test.h>
+#include <windows.h>
+#include <strsafe.h>
+
+#define ok_lasterr(err, s) ok(GetLastError() == (err), "%s GetLastError()=0x%08lx,
expected 0x%08lx\n", s, GetLastError(), (DWORD)(err))
+
+static int MakeService(SC_HANDLE hScm, const wchar_t *serviceName, SC_HANDLE *hService,
DWORD *tag)
+{
+ DWORD ret;
+ HKEY hKey = NULL;
+ DWORD type = 0, tagData = 0, tagSize;
+ wchar_t keyName[256];
+
+ SetLastError(DNS_ERROR_RCODE_NXRRSET);
+ *hService = CreateServiceW(
+ hScm,
+ serviceName,
+ NULL,
+ DELETE,
+ SERVICE_KERNEL_DRIVER,
+ SERVICE_BOOT_START,
+ SERVICE_ERROR_IGNORE,
+ L"%systemroot%\\drivers\\win32k.sys",
+ L"advapi32_apitest_CreateService_Test_Group",
+ tag,
+ NULL,
+ NULL,
+ NULL);
+
+ ok(*hService != NULL, "Failed to create service, error=0x%08lx\n",
GetLastError());
+ if (!*hService)
+ {
+ skip("No service; cannot proceed with CreateService test\n");
+ return 1;
+ }
+
+ ok_lasterr(ERROR_SUCCESS, "CreateServiceW");
+
+ ok(*tag != 0, "tag is zero, expected nonzero\n");
+
+ StringCbPrintfW(keyName, sizeof keyName,
L"System\\CurrentControlSet\\Services\\%ls", serviceName);
+ ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, keyName, &hKey);
+ ok(ret == ERROR_SUCCESS, "RegOpenKeyW failed with 0x%08lx\n", ret);
+ if (ret)
+ {
+ skip("No regkey; cannot proceed with CreateService test\n");
+ return 2;
+ }
+
+ tagSize = sizeof tagData;
+ ret = RegQueryValueExW(hKey, L"Tag", NULL, &type, (PBYTE)&tagData,
&tagSize);
+ ok(ret == ERROR_SUCCESS, "RegQueryValueExW returned 0x%08lx\n", ret);
+ ok(type == REG_DWORD, "type=%lu, expected REG_DWORD\n", type);
+ ok(tagSize == sizeof tagData, "tagSize=%lu, expected 4\n", tagSize);
+ ok(tagData == *tag, "tag=%lu, but registry says %lu\n", *tag, tagData);
+
+ RegCloseKey(hKey);
+
+ return 0;
+}
+
+static void Test_CreateService(void)
+{
+ SC_HANDLE hScm = NULL;
+ SC_HANDLE hService1 = NULL, hService2 = NULL;
+ LONG ret;
+ DWORD tag1 = 0, tag2 = 0;
+
+ SetLastError(DNS_ERROR_RCODE_NXRRSET);
+ hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
+ ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n",
GetLastError());
+ if (!hScm)
+ {
+ skip("No service control manager; cannot proceed with CreateService
test\n");
+ goto cleanup;
+ }
+
+ ok_lasterr(ERROR_SUCCESS, "OpenSCManagerW");
+
+ if (MakeService(hScm, L"advapi32_apitest_CreateService_Test_Service1",
&hService1, &tag1))
+ goto cleanup;
+
+ if (MakeService(hScm, L"advapi32_apitest_CreateService_Test_Service2",
&hService2, &tag2))
+ goto cleanup;
+
+ ok(tag1 != tag2, "tag1=%lu, tag2=%lu\n", tag1, tag2);
+
+cleanup:
+ if (hService2)
+ {
+ SetLastError(DNS_ERROR_RCODE_NXRRSET);
+ ret = DeleteService(hService2);
+ ok(ret == TRUE, "DeleteService returned %ld, expected 1\n", ret);
+ ok(GetLastError() == DNS_ERROR_RCODE_NXRRSET /* win7 */
+ || GetLastError() == ERROR_SUCCESS /* win2k3 */, "DeleteService (Error:
%ld)\n", GetLastError());
+
+ CloseServiceHandle(hService2);
+ }
+
+ if (hService1)
+ {
+ SetLastError(DNS_ERROR_RCODE_NXRRSET);
+ ret = DeleteService(hService1);
+ ok(ret == TRUE, "DeleteService returned %ld, expected 1\n", ret);
+ ok(GetLastError() == DNS_ERROR_RCODE_NXRRSET /* win7 */
+ || GetLastError() == ERROR_SUCCESS /* win2k3 */, "DeleteService (Error:
%ld)\n", GetLastError());
+
+ CloseServiceHandle(hService1);
+ }
+
+ if (hScm)
+ CloseServiceHandle(hScm);
+}
+
+START_TEST(CreateService)
+{
+ Test_CreateService();
+}
Propchange: trunk/rostests/apitests/advapi32/CreateService.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/rostests/apitests/advapi32/CreateService.c
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: trunk/rostests/apitests/advapi32/advapi32_apitest.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/advapi3…
==============================================================================
--- trunk/rostests/apitests/advapi32/advapi32_apitest.rbuild (added)
+++ trunk/rostests/apitests/advapi32/advapi32_apitest.rbuild [iso-8859-1] Tue Sep 27
13:06:33 2011
@@ -1,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
+<module name="advapi32_apitest" type="win32cui"
installbase="bin" installname="advapi32_apitest.exe">
+ <include base="advapi32_apitest">.</include>
+ <library>wine</library>
+ <library>gdi32</library>
+ <library>user32</library>
+ <library>pseh</library>
+ <library>advapi32</library>
+ <file>testlist.c</file>
+ <file>CreateService.c</file>
+
+</module>
+</group>
Propchange: trunk/rostests/apitests/advapi32/advapi32_apitest.rbuild
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/rostests/apitests/advapi32/advapi32_apitest.rbuild
------------------------------------------------------------------------------
svn:keywords = author date id revision
Added: trunk/rostests/apitests/advapi32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
==============================================================================
--- trunk/rostests/apitests/advapi32/testlist.c (added)
+++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Tue Sep 27 13:06:33 2011
@@ -1,0 +1,16 @@
+#define WIN32_LEAN_AND_MEAN
+#define __ROS_LONG64__
+#include <windows.h>
+
+#define STANDALONE
+#include "wine/test.h"
+
+extern void func_CreateService(void);
+
+const struct test winetest_testlist[] =
+{
+ { "CreateService", func_CreateService },
+
+ { 0, 0 }
+};
+
Propchange: trunk/rostests/apitests/advapi32/testlist.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/rostests/apitests/advapi32/testlist.c
------------------------------------------------------------------------------
svn:keywords = author date id revision
Modified: trunk/rostests/apitests/directory.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/directory.rbuild…
==============================================================================
--- trunk/rostests/apitests/directory.rbuild [iso-8859-1] (original)
+++ trunk/rostests/apitests/directory.rbuild [iso-8859-1] Tue Sep 27 13:06:33 2011
@@ -5,6 +5,10 @@
<include base="apitest">.</include>
<file>apitest.c</file>
</module>
+
+ <directory name="advapi32">
+ <xi:include href="advapi32/advapi32_apitest.rbuild" />
+ </directory>
<directory name="dciman32">
<xi:include href="dciman32/dciman32_apitest.rbuild" />