Paul Vriens : advapi32/tests: Add tests for OpenSCManagerA.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jul 2 09:52:09 CDT 2007
Module: wine
Branch: master
Commit: 6dde764898646f1fe6cfe1a60ef25b40b79e35ca
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6dde764898646f1fe6cfe1a60ef25b40b79e35ca
Author: Paul Vriens <paul.vriens.wine at gmail.com>
Date: Mon Jul 2 10:53:47 2007 +0200
advapi32/tests: Add tests for OpenSCManagerA.
---
dlls/advapi32/tests/service.c | 80 +++++++++++++++++++++++++++++++++++++---
1 files changed, 74 insertions(+), 6 deletions(-)
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c
index 206e4f0..c5e391c 100644
--- a/dlls/advapi32/tests/service.c
+++ b/dlls/advapi32/tests/service.c
@@ -27,6 +27,64 @@
#include "wine/test.h"
+static void test_open_scm(void)
+{
+ SC_HANDLE scm_handle;
+
+ /* No access rights */
+ SetLastError(0xdeadbeef);
+ scm_handle = OpenSCManagerA(NULL, NULL, 0);
+ ok(scm_handle != NULL, "Expected success\n");
+ ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
+ GetLastError() == 0xdeadbeef /* NT4, XP */ ||
+ GetLastError() == ERROR_IO_PENDING /* W2K */,
+ "Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
+ CloseServiceHandle(scm_handle);
+
+ /* Unknown database name */
+ SetLastError(0xdeadbeef);
+ scm_handle = OpenSCManagerA(NULL, "DoesNotExist", SC_MANAGER_CONNECT);
+ ok(!scm_handle, "Expected failure\n");
+ ok(GetLastError() == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %d\n", GetLastError());
+ CloseServiceHandle(scm_handle); /* Just in case */
+
+ /* MSDN says only ServiceActive is allowed, or NULL */
+ SetLastError(0xdeadbeef);
+ scm_handle = OpenSCManagerA(NULL, SERVICES_FAILED_DATABASEA, SC_MANAGER_CONNECT);
+ ok(!scm_handle, "Expected failure\n");
+ ok(GetLastError() == ERROR_DATABASE_DOES_NOT_EXIST, "Expected ERROR_DATABASE_DOES_NOT_EXIST, got %d\n", GetLastError());
+ CloseServiceHandle(scm_handle); /* Just in case */
+
+ /* Remote unknown host */
+ SetLastError(0xdeadbeef);
+ scm_handle = OpenSCManagerA("DOESNOTEXIST", SERVICES_ACTIVE_DATABASEA, SC_MANAGER_CONNECT);
+ ok(!scm_handle, "Expected failure\n");
+ todo_wine
+ ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE, "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
+ CloseServiceHandle(scm_handle); /* Just in case */
+
+ /* Proper call with an empty hostname */
+ SetLastError(0xdeadbeef);
+ scm_handle = OpenSCManagerA("", SERVICES_ACTIVE_DATABASEA, SC_MANAGER_CONNECT);
+ ok(scm_handle != NULL, "Expected success\n");
+ ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
+ GetLastError() == ERROR_ENVVAR_NOT_FOUND /* NT4 */ ||
+ GetLastError() == 0xdeadbeef /* XP */ ||
+ GetLastError() == ERROR_IO_PENDING /* W2K */,
+ "Expected ERROR_SUCCESS, ERROR_IO_PENDING, ERROR_ENVVAR_NOT_FOUND or 0xdeadbeef, got %d\n", GetLastError());
+ CloseServiceHandle(scm_handle);
+
+ /* Again a correct one */
+ SetLastError(0xdeadbeef);
+ scm_handle = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
+ ok(scm_handle != NULL, "Expected success\n");
+ ok(GetLastError() == ERROR_SUCCESS /* W2K3, Vista */ ||
+ GetLastError() == 0xdeadbeef /* NT4, XP */ ||
+ GetLastError() == ERROR_IO_PENDING /* W2K */,
+ "Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
+ CloseServiceHandle(scm_handle);
+}
+
static void test_sequence(void)
{
SC_HANDLE scm_handle, svc_handle;
@@ -44,12 +102,7 @@ static void test_sequence(void)
SetLastError(0xdeadbeef);
scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL);
- if (!scm_handle && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
- {
- skip("OpenSCManagerA is not implemented\n");
- return;
- }
- else if (!scm_handle && (GetLastError() == ERROR_ACCESS_DENIED))
+ if (!scm_handle && (GetLastError() == ERROR_ACCESS_DENIED))
{
skip("Not enough rights to get a handle to the manager\n");
return;
@@ -147,6 +200,21 @@ static void test_sequence(void)
START_TEST(service)
{
+ SC_HANDLE scm_handle;
+
+ /* Bail out if we are on win98 */
+ SetLastError(0xdeadbeef);
+ scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL);
+
+ if (!scm_handle && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
+ {
+ skip("OpenSCManagerA is not implemented, we are most likely on win9x\n");
+ return;
+ }
+ CloseServiceHandle(scm_handle);
+
+ /* First some parameter checking */
+ test_open_scm();
/* Test the creation, querying and deletion of a service */
test_sequence();
}
More information about the wine-cvs
mailing list