Skip to content

Commit 31eeb62

Browse files
winesynclearn-more
authored andcommitted
[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]>
1 parent 6fc5d38 commit 31eeb62

File tree

4 files changed

+93
-12
lines changed

4 files changed

+93
-12
lines changed

modules/rostests/winetests/msi/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ spec2def(custom.dll custom.spec)
33
add_library(custom MODULE custom.c ${CMAKE_CURRENT_BINARY_DIR}/custom.def)
44
target_link_libraries(custom uuid)
55
set_module_type(custom win32dll)
6-
add_importlibs(custom msi ole32 msvcrt kernel32)
6+
add_importlibs(custom msi ole32 shell32 msvcrt kernel32)
77

88
list(APPEND SOURCE
99
action.c

modules/rostests/winetests/msi/action.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,11 @@ static const char cf_install_exec_seq_dat[] =
596596
"FileCost\t\t900\n"
597597
"RemoveFiles\t\t3500\n"
598598
"CreateFolders\t\t3700\n"
599+
"cf_immediate\tNOT REMOVE\t3701\n"
600+
"cf_deferred\tNOT REMOVE\t3702\n"
599601
"RemoveFolders\t\t3800\n"
602+
"rf_immediate\tREMOVE\t3801\n"
603+
"rf_deferred\tREMOVE\t3802\n"
600604
"InstallFiles\t\t4000\n"
601605
"RegisterUser\t\t6000\n"
602606
"RegisterProduct\t\t6100\n"
@@ -609,6 +613,15 @@ static const char cf_install_exec_seq_dat[] =
609613
"InstallValidate\t\t1400\n"
610614
"LaunchConditions\t\t100\n";
611615

616+
static const char cf_custom_action_dat[] =
617+
"Action\tType\tSource\tTarget\n"
618+
"s72\ti2\tS64\tS0\n"
619+
"CustomAction\tAction\n"
620+
"cf_immediate\t1\tcustom.dll\tcf_absent\n"
621+
"cf_deferred\t1025\tcustom.dll\tcf_present\n"
622+
"rf_immediate\t1\tcustom.dll\tcf_present\n"
623+
"rf_deferred\t1025\tcustom.dll\tcf_absent\n";
624+
612625
static const char sr_selfreg_dat[] =
613626
"File_\tCost\n"
614627
"s72\tI2\n"
@@ -1771,6 +1784,7 @@ static const msi_table cf_tables[] =
17711784
ADD_TABLE(cf_file),
17721785
ADD_TABLE(cf_create_folders),
17731786
ADD_TABLE(cf_install_exec_seq),
1787+
ADD_TABLE(cf_custom_action),
17741788
ADD_TABLE(media),
17751789
ADD_TABLE(property)
17761790
};

modules/rostests/winetests/msi/custom.c

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
#include <windef.h>
2525
#include <winbase.h>
2626
#define COBJMACROS
27+
#include <shlobj.h>
2728
#include <msxml.h>
2829
#include <msi.h>
2930
#include <msiquery.h>
3031

32+
static int todo_level, todo_do_loop;
33+
3134
static void ok_(MSIHANDLE hinst, int todo, const char *file, int line, int condition, const char *msg, ...)
3235
{
3336
static char buffer[2000];
@@ -47,8 +50,30 @@ static void ok_(MSIHANDLE hinst, int todo, const char *file, int line, int condi
4750
MsiProcessMessage(hinst, INSTALLMESSAGE_USER, record);
4851
MsiCloseHandle(record);
4952
}
50-
#define ok(hinst, condition, ...) ok_(hinst, 0, __FILE__, __LINE__, condition, __VA_ARGS__)
51-
#define todo_wine_ok(hinst, condition, ...) ok_(hinst, 1, __FILE__, __LINE__, condition, __VA_ARGS__)
53+
54+
static void winetest_start_todo( int is_todo )
55+
{
56+
todo_level = (todo_level << 1) | (is_todo != 0);
57+
todo_do_loop=1;
58+
}
59+
60+
static int winetest_loop_todo(void)
61+
{
62+
int do_loop=todo_do_loop;
63+
todo_do_loop=0;
64+
return do_loop;
65+
}
66+
67+
static void winetest_end_todo(void)
68+
{
69+
todo_level >>= 1;
70+
}
71+
72+
#define ok(hinst, condition, ...) ok_(hinst, todo_level, __FILE__, __LINE__, condition, __VA_ARGS__)
73+
#define todo_wine_if(is_todo) for (winetest_start_todo(is_todo); \
74+
winetest_loop_todo(); \
75+
winetest_end_todo())
76+
#define todo_wine todo_wine_if(1)
5277

5378
static const char *dbgstr_w(WCHAR *str)
5479
{
@@ -886,15 +911,17 @@ static void test_costs(MSIHANDLE hinst)
886911
cost = 0xdead;
887912
r = MsiGetFeatureCostA(hinst, NULL, MSICOSTTREE_CHILDREN, INSTALLSTATE_LOCAL, &cost);
888913
ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
889-
todo_wine_ok(hinst, !cost, "got %d\n", cost);
914+
todo_wine
915+
ok(hinst, !cost, "got %d\n", cost);
890916

891917
r = MsiGetFeatureCostA(hinst, "One", MSICOSTTREE_CHILDREN, INSTALLSTATE_LOCAL, NULL);
892918
ok(hinst, r == RPC_X_NULL_REF_POINTER, "got %u\n", r);
893919

894920
cost = 0xdead;
895921
r = MsiGetFeatureCostA(hinst, "One", MSICOSTTREE_CHILDREN, INSTALLSTATE_LOCAL, &cost);
896922
ok(hinst, !r, "got %u\n", r);
897-
todo_wine_ok(hinst, cost == 8, "got %d\n", cost);
923+
todo_wine
924+
ok(hinst, cost == 8, "got %d\n", cost);
898925

899926
sz = cost = temp = 0xdead;
900927
r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, NULL, &sz, &cost, &temp);
@@ -946,23 +973,28 @@ static void test_costs(MSIHANDLE hinst)
946973
r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, buffer, &sz, &cost, &temp);
947974
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
948975
ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n", buffer);
949-
todo_wine_ok(hinst, sz == 4, "got size %u\n", sz);
976+
todo_wine
977+
ok(hinst, sz == 4, "got size %u\n", sz);
950978
ok(hinst, cost == 8, "got cost %d\n", cost);
951979
ok(hinst, !temp, "got temp %d\n", temp);
952980

953981
sz = 1;
954982
strcpy(buffer,"x");
955983
r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, buffer, &sz, &cost, &temp);
956984
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
957-
todo_wine_ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
958-
todo_wine_ok(hinst, sz == 4, "got size %u\n", sz);
985+
todo_wine {
986+
ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
987+
ok(hinst, sz == 4, "got size %u\n", sz);
988+
}
959989

960990
sz = 2;
961991
strcpy(buffer,"x");
962992
r = MsiEnumComponentCostsA(hinst, "One", 0, INSTALLSTATE_LOCAL, buffer, &sz, &cost, &temp);
963993
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
964-
todo_wine_ok(hinst, !strcmp(buffer, "C"), "got \"%s\"\n", buffer);
965-
todo_wine_ok(hinst, sz == 4, "got size %u\n", sz);
994+
todo_wine {
995+
ok(hinst, !strcmp(buffer, "C"), "got \"%s\"\n", buffer);
996+
ok(hinst, sz == 4, "got size %u\n", sz);
997+
}
966998

967999
sz = 3;
9681000
strcpy(buffer,"x");
@@ -1021,7 +1053,8 @@ UINT WINAPI main_test(MSIHANDLE hinst)
10211053

10221054
/* Test MsiGetDatabaseState() */
10231055
res = MsiGetDatabaseState(hinst);
1024-
todo_wine_ok(hinst, res == MSIDBSTATE_ERROR, "expected MSIDBSTATE_ERROR, got %u\n", res);
1056+
todo_wine
1057+
ok(hinst, res == MSIDBSTATE_ERROR, "expected MSIDBSTATE_ERROR, got %u\n", res);
10251058

10261059
test_props(hinst);
10271060
test_db(hinst);
@@ -1101,7 +1134,8 @@ UINT WINAPI da_deferred(MSIHANDLE hinst)
11011134
len = sizeof(prop);
11021135
r = MsiGetPropertyA(hinst, "TESTPATH", prop, &len);
11031136
ok(hinst, r == ERROR_SUCCESS, "got %u\n", r);
1104-
todo_wine_ok(hinst, !prop[0], "got %s\n", prop);
1137+
todo_wine
1138+
ok(hinst, !prop[0], "got %s\n", prop);
11051139

11061140
/* Test modes */
11071141
ok(hinst, MsiGetMode(hinst, MSIRUNMODE_SCHEDULED), "should be scheduled\n");
@@ -1113,3 +1147,34 @@ UINT WINAPI da_deferred(MSIHANDLE hinst)
11131147

11141148
return ERROR_SUCCESS;
11151149
}
1150+
1151+
static BOOL pf_exists(const char *file)
1152+
{
1153+
char path[MAX_PATH];
1154+
1155+
if (FAILED(SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path)))
1156+
SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
1157+
strcat(path, "\\");
1158+
strcat(path, file);
1159+
return GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES;
1160+
}
1161+
1162+
UINT WINAPI cf_present(MSIHANDLE hinst)
1163+
{
1164+
todo_wine_if(!MsiGetMode(hinst, MSIRUNMODE_SCHEDULED)) {
1165+
ok(hinst, pf_exists("msitest\\first"), "folder absent\n");
1166+
ok(hinst, pf_exists("msitest\\second"), "folder absent\n");
1167+
ok(hinst, pf_exists("msitest\\third"), "folder absent\n");
1168+
}
1169+
return ERROR_SUCCESS;
1170+
}
1171+
1172+
UINT WINAPI cf_absent(MSIHANDLE hinst)
1173+
{
1174+
todo_wine_if(!MsiGetMode(hinst, MSIRUNMODE_SCHEDULED)) {
1175+
ok(hinst, !pf_exists("msitest\\first"), "folder present\n");
1176+
ok(hinst, !pf_exists("msitest\\second"), "folder present\n");
1177+
ok(hinst, !pf_exists("msitest\\third"), "folder present\n");
1178+
}
1179+
return ERROR_SUCCESS;
1180+
}

modules/rostests/winetests/msi/custom.spec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
@ stdcall da_immediate(long)
44
@ stdcall da_deferred(long)
55
@ stdcall nested(long)
6+
@ stdcall cf_present(long)
7+
@ stdcall cf_absent(long)

0 commit comments

Comments
 (0)