https://git.reactos.org/?p=reactos.git;a=commitdiff;h=31eeb62486490fc36e203bd3e8223862302f3575

commit 31eeb62486490fc36e203bd3e8223862302f3575
Author:     winesync <[email protected]>
AuthorDate: Sat Mar 12 15:12:20 2022 +0100
Commit:     Mark Jansen <[email protected]>
CommitDate: Sun Mar 20 19:27:46 2022 +0100

    [WINESYNC] msi/tests: Test deferral of CreateFolders and RemoveFolders.
    
    Signed-off-by: Zebediah Figura <[email protected]>
    Signed-off-by: Hans Leidekker <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 0f7d50c02ea301ceebf0c18c1a49797ae9a93788 by Zebediah Figura 
<[email protected]>
---
 modules/rostests/winetests/msi/CMakeLists.txt |  2 +-
 modules/rostests/winetests/msi/action.c       | 14 +++++
 modules/rostests/winetests/msi/custom.c       | 87 +++++++++++++++++++++++----
 modules/rostests/winetests/msi/custom.spec    |  2 +
 4 files changed, 93 insertions(+), 12 deletions(-)

diff --git a/modules/rostests/winetests/msi/CMakeLists.txt 
b/modules/rostests/winetests/msi/CMakeLists.txt
index 8884c47513c..229847ed1a5 100644
--- a/modules/rostests/winetests/msi/CMakeLists.txt
+++ b/modules/rostests/winetests/msi/CMakeLists.txt
@@ -3,7 +3,7 @@ spec2def(custom.dll custom.spec)
 add_library(custom MODULE custom.c ${CMAKE_CURRENT_BINARY_DIR}/custom.def)
 target_link_libraries(custom uuid)
 set_module_type(custom win32dll)
-add_importlibs(custom msi ole32 msvcrt kernel32)
+add_importlibs(custom msi ole32 shell32 msvcrt kernel32)
 
 list(APPEND SOURCE
     action.c
diff --git a/modules/rostests/winetests/msi/action.c 
b/modules/rostests/winetests/msi/action.c
index 849975d997e..ae1b47b99db 100644
--- a/modules/rostests/winetests/msi/action.c
+++ b/modules/rostests/winetests/msi/action.c
@@ -596,7 +596,11 @@ static const char cf_install_exec_seq_dat[] =
     "FileCost\t\t900\n"
     "RemoveFiles\t\t3500\n"
     "CreateFolders\t\t3700\n"
+    "cf_immediate\tNOT REMOVE\t3701\n"
+    "cf_deferred\tNOT REMOVE\t3702\n"
     "RemoveFolders\t\t3800\n"
+    "rf_immediate\tREMOVE\t3801\n"
+    "rf_deferred\tREMOVE\t3802\n"
     "InstallFiles\t\t4000\n"
     "RegisterUser\t\t6000\n"
     "RegisterProduct\t\t6100\n"
@@ -609,6 +613,15 @@ static const char cf_install_exec_seq_dat[] =
     "InstallValidate\t\t1400\n"
     "LaunchConditions\t\t100\n";
 
+static const char cf_custom_action_dat[] =
+    "Action\tType\tSource\tTarget\n"
+    "s72\ti2\tS64\tS0\n"
+    "CustomAction\tAction\n"
+    "cf_immediate\t1\tcustom.dll\tcf_absent\n"
+    "cf_deferred\t1025\tcustom.dll\tcf_present\n"
+    "rf_immediate\t1\tcustom.dll\tcf_present\n"
+    "rf_deferred\t1025\tcustom.dll\tcf_absent\n";
+
 static const char sr_selfreg_dat[] =
     "File_\tCost\n"
     "s72\tI2\n"
@@ -1771,6 +1784,7 @@ static const msi_table cf_tables[] =
     ADD_TABLE(cf_file),
     ADD_TABLE(cf_create_folders),
     ADD_TABLE(cf_install_exec_seq),
+    ADD_TABLE(cf_custom_action),
     ADD_TABLE(media),
     ADD_TABLE(property)
 };
diff --git a/modules/rostests/winetests/msi/custom.c 
b/modules/rostests/winetests/msi/custom.c
index ff1be9b282a..aeee98e7a9d 100644
--- a/modules/rostests/winetests/msi/custom.c
+++ b/modules/rostests/winetests/msi/custom.c
@@ -24,10 +24,13 @@
 #include <windef.h>
 #include <winbase.h>
 #define COBJMACROS
+#include <shlobj.h>
 #include <msxml.h>
 #include <msi.h>
 #include <msiquery.h>
 
+static int todo_level, todo_do_loop;
+
 static void ok_(MSIHANDLE hinst, int todo, const char *file, int line, int 
condition, const char *msg, ...)
 {
     static char buffer[2000];
@@ -47,8 +50,30 @@ static void ok_(MSIHANDLE hinst, int todo, const char *file, 
int line, int condi
     MsiProcessMessage(hinst, INSTALLMESSAGE_USER, record);
     MsiCloseHandle(record);
 }
-#define ok(hinst, condition, ...)           ok_(hinst, 0, __FILE__, __LINE__, 
condition, __VA_ARGS__)
-#define todo_wine_ok(hinst, condition, ...) ok_(hinst, 1, __FILE__, __LINE__, 
condition, __VA_ARGS__)
+
+static void winetest_start_todo( int is_todo )
+{
+    todo_level = (todo_level << 1) | (is_todo != 0);
+    todo_do_loop=1;
+}
+
+static int winetest_loop_todo(void)
+{
+    int do_loop=todo_do_loop;
+    todo_do_loop=0;
+    return do_loop;
+}
+
+static void winetest_end_todo(void)
+{
+    todo_level >>= 1;
+}
+
+#define ok(hinst, condition, ...)   ok_(hinst, todo_level, __FILE__, __LINE__, 
condition, __VA_ARGS__)
+#define todo_wine_if(is_todo) for (winetest_start_todo(is_todo); \
+                                   winetest_loop_todo(); \
+                                   winetest_end_todo())
+#define todo_wine   todo_wine_if(1)
 
 static const char *dbgstr_w(WCHAR *str)
 {
@@ -886,7 +911,8 @@ static void test_costs(MSIHANDLE hinst)
     cost = 0xdead;
     r = MsiGetFeatureCostA(hinst, NULL, MSICOSTTREE_CHILDREN, 
INSTALLSTATE_LOCAL, &cost);
     ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
-    todo_wine_ok(hinst, !cost, "got %d\n", cost);
+    todo_wine
+    ok(hinst, !cost, "got %d\n", cost);
 
     r = MsiGetFeatureCostA(hinst, "One", MSICOSTTREE_CHILDREN, 
INSTALLSTATE_LOCAL, NULL);
     ok(hinst, r == RPC_X_NULL_REF_POINTER, "got %u\n", r);
@@ -894,7 +920,8 @@ static void test_costs(MSIHANDLE hinst)
     cost = 0xdead;
     r = MsiGetFeatureCostA(hinst, "One", MSICOSTTREE_CHILDREN, 
INSTALLSTATE_LOCAL, &cost);
     ok(hinst, !r, "got %u\n", r);
-    todo_wine_ok(hinst, cost == 8, "got %d\n", cost);
+    todo_wine
+    ok(hinst, cost == 8, "got %d\n", cost);
 
     sz = cost = temp = 0xdead;
     r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, NULL, &sz, 
&cost, &temp);
@@ -946,7 +973,8 @@ static void test_costs(MSIHANDLE hinst)
     r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, buffer, 
&sz, &cost, &temp);
     ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
     ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n", buffer);
-    todo_wine_ok(hinst, sz == 4, "got size %u\n", sz);
+    todo_wine
+    ok(hinst, sz == 4, "got size %u\n", sz);
     ok(hinst, cost == 8, "got cost %d\n", cost);
     ok(hinst, !temp, "got temp %d\n", temp);
 
@@ -954,15 +982,19 @@ static void test_costs(MSIHANDLE hinst)
     strcpy(buffer,"x");
     r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, buffer, 
&sz, &cost, &temp);
     ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
-    todo_wine_ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
-    todo_wine_ok(hinst, sz == 4, "got size %u\n", sz);
+    todo_wine {
+    ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
+    ok(hinst, sz == 4, "got size %u\n", sz);
+    }
 
     sz = 2;
     strcpy(buffer,"x");
     r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, buffer, 
&sz, &cost, &temp);
     ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
-    todo_wine_ok(hinst, !strcmp(buffer, "C"), "got \"%s\"\n", buffer);
-    todo_wine_ok(hinst, sz == 4, "got size %u\n", sz);
+    todo_wine {
+    ok(hinst, !strcmp(buffer, "C"), "got \"%s\"\n", buffer);
+    ok(hinst, sz == 4, "got size %u\n", sz);
+    }
 
     sz = 3;
     strcpy(buffer,"x");
@@ -1021,7 +1053,8 @@ UINT WINAPI main_test(MSIHANDLE hinst)
 
     /* Test MsiGetDatabaseState() */
     res = MsiGetDatabaseState(hinst);
-    todo_wine_ok(hinst, res == MSIDBSTATE_ERROR, "expected MSIDBSTATE_ERROR, 
got %u\n", res);
+    todo_wine
+    ok(hinst, res == MSIDBSTATE_ERROR, "expected MSIDBSTATE_ERROR, got %u\n", 
res);
 
     test_props(hinst);
     test_db(hinst);
@@ -1101,7 +1134,8 @@ UINT WINAPI da_deferred(MSIHANDLE hinst)
     len = sizeof(prop);
     r = MsiGetPropertyA(hinst, "TESTPATH", prop, &len);
     ok(hinst, r == ERROR_SUCCESS, "got %u\n", r);
-    todo_wine_ok(hinst, !prop[0], "got %s\n", prop);
+    todo_wine
+    ok(hinst, !prop[0], "got %s\n", prop);
 
     /* Test modes */
     ok(hinst, MsiGetMode(hinst, MSIRUNMODE_SCHEDULED), "should be 
scheduled\n");
@@ -1113,3 +1147,34 @@ UINT WINAPI da_deferred(MSIHANDLE hinst)
 
     return ERROR_SUCCESS;
 }
+
+static BOOL pf_exists(const char *file)
+{
+    char path[MAX_PATH];
+
+    if (FAILED(SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path)))
+        SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
+    strcat(path, "\\");
+    strcat(path, file);
+    return GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES;
+}
+
+UINT WINAPI cf_present(MSIHANDLE hinst)
+{
+todo_wine_if(!MsiGetMode(hinst, MSIRUNMODE_SCHEDULED)) {
+    ok(hinst, pf_exists("msitest\\first"), "folder absent\n");
+    ok(hinst, pf_exists("msitest\\second"), "folder absent\n");
+    ok(hinst, pf_exists("msitest\\third"), "folder absent\n");
+}
+    return ERROR_SUCCESS;
+}
+
+UINT WINAPI cf_absent(MSIHANDLE hinst)
+{
+todo_wine_if(!MsiGetMode(hinst, MSIRUNMODE_SCHEDULED)) {
+    ok(hinst, !pf_exists("msitest\\first"), "folder present\n");
+    ok(hinst, !pf_exists("msitest\\second"), "folder present\n");
+    ok(hinst, !pf_exists("msitest\\third"), "folder present\n");
+}
+    return ERROR_SUCCESS;
+}
diff --git a/modules/rostests/winetests/msi/custom.spec 
b/modules/rostests/winetests/msi/custom.spec
index 51bb60ec1a4..cac0f85f2b6 100644
--- a/modules/rostests/winetests/msi/custom.spec
+++ b/modules/rostests/winetests/msi/custom.spec
@@ -3,3 +3,5 @@
 @ stdcall da_immediate(long)
 @ stdcall da_deferred(long)
 @ stdcall nested(long)
+@ stdcall cf_present(long)
+@ stdcall cf_absent(long)

Reply via email to