Module: wine Branch: master Commit: 167ef04727c177b29372a9abee194dada27bd194 URL: http://source.winehq.org/git/wine.git/?a=commit;h=167ef04727c177b29372a9abee...
Author: Ge van Geldorp ggeldorp@vmware.com Date: Fri Aug 28 12:31:25 2009 +0200
msi/tests: Create only a single restore point.
---
dlls/msi/tests/package.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index a7c0ed6..5fb5b53 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -26,6 +26,7 @@ #include <msidefs.h> #include <msi.h> #include <msiquery.h> +#include <srrestoreptapi.h>
#include "wine/test.h"
@@ -36,10 +37,14 @@ static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
+static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD); +static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*); + static void init_functionpointers(void) { HMODULE hmsi = GetModuleHandleA("msi.dll"); HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll"); + HMODULE hsrclient;
#define GET_PROC(mod, func) \ p ## func = (void*)GetProcAddress(mod, #func); @@ -48,6 +53,9 @@ static void init_functionpointers(void)
GET_PROC(hadvapi32, ConvertSidToStringSidA);
+ hsrclient = LoadLibraryA("srclient.dll"); + GET_PROC(hsrclient, SRRemoveRestorePoint); + GET_PROC(hsrclient, SRSetRestorePointA); #undef GET_PROC }
@@ -774,6 +782,27 @@ done: return ret; }
+static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status) +{ + RESTOREPOINTINFOA spec; + + spec.dwEventType = event_type; + spec.dwRestorePtType = APPLICATION_INSTALL; + spec.llSequenceNumber = status->llSequenceNumber; + lstrcpyA(spec.szDescription, "msitest restore point"); + + return pSRSetRestorePointA(&spec, status); +} + +static void remove_restore_point(DWORD seq_number) +{ + DWORD res; + + res = pSRRemoveRestorePoint(seq_number); + if (res != ERROR_SUCCESS) + trace("Failed to remove the restore point : %08x\n", res); +} + static void test_createpackage(void) { MSIHANDLE hPackage = 0; @@ -11870,10 +11899,22 @@ static void test_MsiApplyPatch(void)
START_TEST(package) { + STATEMGRSTATUS status; + BOOL ret = FALSE; + init_functionpointers();
GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
+ /* Create a restore point ourselves so we circumvent the multitude of restore points + * that would have been created by all the installation and removal tests. + */ + if (pSRSetRestorePointA) + { + memset(&status, 0, sizeof(status)); + ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status); + } + test_createpackage(); test_doaction(); test_gettargetpath_bad(); @@ -11905,4 +11946,11 @@ START_TEST(package) test_MsiSetProperty(); test_MsiApplyMultiplePatches(); test_MsiApplyPatch(); + + if (pSRSetRestorePointA && ret) + { + ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status); + if (ret) + remove_restore_point(status.llSequenceNumber); + } }