Commit 6f463db5 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi/tests: Properly clean up test services.

parent dea323dc
...@@ -5427,28 +5427,23 @@ static void test_start_stop_services(void) ...@@ -5427,28 +5427,23 @@ static void test_start_stop_services(void)
DeleteFileA(msifile); DeleteFileA(msifile);
} }
static void delete_TestService(void) static void delete_test_service(const char *name)
{ {
BOOL ret; BOOL ret;
SC_HANDLE manager, service; SC_HANDLE manager, service;
manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS); manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
ok(manager != NULL, "can't open service manager\n"); ok(manager != NULL, "can't open service manager\n");
if (!manager) if (!manager) return;
return;
service = OpenServiceA(manager, "TestService", GENERIC_ALL);
ok(service != NULL, "TestService doesn't exist\n");
service = OpenServiceA(manager, name, GENERIC_ALL);
if (service) if (service)
{ {
ret = DeleteService( service ); ret = DeleteService( service );
ok( ret, "failed to delete service %u\n", GetLastError() ); ok( ret, "failed to delete service %u\n", GetLastError() );
CloseServiceHandle(service); CloseServiceHandle(service);
} }
CloseServiceHandle(manager); CloseServiceHandle(manager);
} }
static void test_delete_services(void) static void test_delete_services(void)
...@@ -5473,7 +5468,7 @@ static void test_delete_services(void) ...@@ -5473,7 +5468,7 @@ static void test_delete_services(void)
ok(service != NULL, "can't create service %u\n", GetLastError()); ok(service != NULL, "can't create service %u\n", GetLastError());
CloseServiceHandle(service); CloseServiceHandle(service);
CloseServiceHandle(manager); CloseServiceHandle(manager);
if (!service) goto error; if (!service) return;
create_test_files(); create_test_files();
create_database(msifile, sds_tables, sizeof(sds_tables) / sizeof(msi_table)); create_database(msifile, sds_tables, sizeof(sds_tables) / sizeof(msi_table));
...@@ -5516,7 +5511,9 @@ static void test_delete_services(void) ...@@ -5516,7 +5511,9 @@ static void test_delete_services(void)
ok(delete_pf("msitest", FALSE), "Directory not created\n"); ok(delete_pf("msitest", FALSE), "Directory not created\n");
error: error:
delete_TestService(); delete_test_service("TestService");
delete_test_service("TestService2");
delete_test_service("TestService3");
delete_test_files(); delete_test_files();
DeleteFileA(msifile); DeleteFileA(msifile);
} }
...@@ -5558,7 +5555,6 @@ static void test_install_services(void) ...@@ -5558,7 +5555,6 @@ static void test_install_services(void)
service = OpenServiceA(manager, "TestService4", GENERIC_ALL); service = OpenServiceA(manager, "TestService4", GENERIC_ALL);
ok(service == NULL, "TestService4 installed\n"); ok(service == NULL, "TestService4 installed\n");
CloseServiceHandle(manager);
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\TestService", &hKey); res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\TestService", &hKey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
...@@ -5576,6 +5572,11 @@ static void test_install_services(void) ...@@ -5576,6 +5572,11 @@ static void test_install_services(void)
r = MsiInstallProductA(msifile, "REMOVE=ALL"); r = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
service = OpenServiceA(manager, "TestService", GENERIC_ALL);
ok(service != NULL, "TestService deleted\n");
CloseServiceHandle(service);
CloseServiceHandle(manager);
ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n"); ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n"); ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
...@@ -5591,7 +5592,7 @@ static void test_install_services(void) ...@@ -5591,7 +5592,7 @@ static void test_install_services(void)
ok(delete_pf("msitest", FALSE), "Directory not created\n"); ok(delete_pf("msitest", FALSE), "Directory not created\n");
error: error:
delete_TestService(); delete_test_service("TestService");
delete_test_files(); delete_test_files();
DeleteFileA(msifile); DeleteFileA(msifile);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment