2 * Copyright (C) 2006 James Hawkins
4 * A test program for installing MSI products.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/test.h"
31 static const char *msifile
= "msitest.msi";
32 CHAR CURR_DIR
[MAX_PATH
];
33 CHAR PROG_FILES_DIR
[MAX_PATH
];
35 /* msi database data */
37 static const CHAR component_dat
[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
38 "s72\tS38\ts72\ti2\tS255\tS72\n"
39 "Component\tComponent\n"
40 "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
41 "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
42 "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\t\tone.txt\n"
43 "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
44 "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
45 "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
46 "component\t\tMSITESTDIR\t0\t1\tfile\n"
47 "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
49 static const CHAR directory_dat
[] = "Directory\tDirectory_Parent\tDefaultDir\n"
51 "Directory\tDirectory\n"
52 "CABOUTDIR\tMSITESTDIR\tcabout\n"
53 "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
54 "FIRSTDIR\tMSITESTDIR\tfirst\n"
55 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
56 "NEWDIR\tCABOUTDIR\tnew\n"
57 "ProgramFilesFolder\tTARGETDIR\t.\n"
58 "TARGETDIR\t\tSourceDir";
60 static const CHAR feature_dat
[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
61 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
63 "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
64 "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
65 "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
66 "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
67 "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
68 "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
69 "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
71 static const CHAR feature_comp_dat
[] = "Feature_\tComponent_\n"
73 "FeatureComponents\tFeature_\tComponent_\n"
79 "feature\tcomponent\n"
80 "service_feature\tservice_comp\n";
82 static const CHAR file_dat
[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
83 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
85 "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
86 "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
87 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
88 "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
89 "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
90 "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
91 "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
93 static const CHAR install_exec_seq_dat
[] = "Action\tCondition\tSequence\n"
95 "InstallExecuteSequence\tAction\n"
96 "AllocateRegistrySpace\tNOT Installed\t1550\n"
97 "CostFinalize\t\t1000\n"
98 "CostInitialize\t\t800\n"
100 "InstallFiles\t\t4000\n"
101 "InstallServices\t\t5000\n"
102 "InstallFinalize\t\t6600\n"
103 "InstallInitialize\t\t1500\n"
104 "InstallValidate\t\t1400\n"
105 "LaunchConditions\t\t100\n"
106 "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
108 static const CHAR media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
109 "i2\ti4\tL64\tS255\tS32\tS72\n"
111 "1\t3\t\t\tDISK1\t\n"
112 "2\t5\t\tmsitest.cab\tDISK2\t\n";
114 static const CHAR property_dat
[] = "Property\tValue\n"
116 "Property\tProperty\n"
117 "DefaultUIFont\tDlgFont8\n"
120 "InstallMode\tTypical\n"
121 "Manufacturer\tWine\n"
122 "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
123 "ProductCode\t{F1C3AF50-8B56-4A69-A00C-00773FE42F30}\n"
125 "ProductLanguage\t1033\n"
126 "ProductName\tMSITEST\n"
127 "ProductVersion\t1.1.1\n"
128 "PROMPTROLLBACKCOST\tP\n"
130 "UpgradeCode\t{CE067E8D-2E1A-4367-B734-4EB2BDAD6565}";
132 static const CHAR registry_dat
[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
133 "s72\ti2\tl255\tL255\tL0\ts72\n"
134 "Registry\tRegistry\n"
135 "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
136 "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
137 "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
138 "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
140 static const CHAR service_install_dat
[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
141 "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
142 "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
143 "ServiceInstall\tServiceInstall\n"
144 "TestService\tTestService\tTestService\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
146 static const CHAR service_control_dat
[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
147 "s72\tl255\ti2\tL255\tI2\ts72\n"
148 "ServiceControl\tServiceControl\n"
149 "ServiceControl\tTestService\t8\t\t0\tservice_comp";
151 /* tables for test_continuouscabs */
152 static const CHAR cc_component_dat
[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
153 "s72\tS38\ts72\ti2\tS255\tS72\n"
154 "Component\tComponent\n"
155 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
156 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
157 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
159 static const CHAR cc_feature_dat
[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
160 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
162 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
164 static const CHAR cc_feature_comp_dat
[] = "Feature_\tComponent_\n"
166 "FeatureComponents\tFeature_\tComponent_\n"
168 "feature\taugustus\n"
171 static const CHAR cc_file_dat
[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
172 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
174 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
175 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
176 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
178 static const CHAR cc_media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
179 "i2\ti4\tL64\tS255\tS32\tS72\n"
181 "1\t10\t\ttest1.cab\tDISK1\t\n"
182 "2\t2\t\ttest2.cab\tDISK2\t\n"
183 "3\t12\t\ttest3.cab\tDISK3\t\n";
185 static const CHAR co_file_dat
[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
186 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
188 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
189 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
190 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
192 static const CHAR co_media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
193 "i2\ti4\tL64\tS255\tS32\tS72\n"
195 "1\t10\t\ttest1.cab\tDISK1\t\n"
196 "2\t2\t\ttest2.cab\tDISK2\t\n"
197 "3\t3\t\ttest3.cab\tDISK3\t\n";
199 static const CHAR co2_media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
200 "i2\ti4\tL64\tS255\tS32\tS72\n"
202 "1\t10\t\ttest1.cab\tDISK1\t\n"
203 "2\t12\t\ttest3.cab\tDISK3\t\n"
204 "3\t2\t\ttest2.cab\tDISK2\t\n";
206 static const CHAR mm_file_dat
[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
207 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
209 "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
210 "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
211 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
213 static const CHAR mm_media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
214 "i2\ti4\tL64\tS255\tS32\tS72\n"
216 "1\t3\t\ttest1.cab\tDISK1\t\n";
218 static const CHAR ss_media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
219 "i2\ti4\tL64\tS255\tS32\tS72\n"
221 "1\t2\t\ttest1.cab\tDISK1\t\n"
222 "2\t2\t\ttest2.cab\tDISK2\t\n"
223 "3\t12\t\ttest3.cab\tDISK3\t\n";
225 /* tables for test_uiLevelFlags */
226 static const CHAR ui_component_dat
[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
227 "s72\tS38\ts72\ti2\tS255\tS72\n"
228 "Component\tComponent\n"
229 "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
230 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
231 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
233 static const CHAR ui_install_ui_seq_dat
[] = "Action\tCondition\tSequence\n"
235 "InstallUISequence\tAction\n"
236 "SetUIProperty\t\t5\n"
237 "ExecuteAction\t\t1100\n";
239 static const CHAR ui_custom_action_dat
[] = "Action\tType\tSource\tTarget\tISComments\n"
240 "s72\ti2\tS64\tS0\tS255\n"
241 "CustomAction\tAction\n"
242 "SetUIProperty\t51\tHASUIRUN\t1\t\n";
244 static const CHAR rof_component_dat
[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
245 "s72\tS38\ts72\ti2\tS255\tS72\n"
246 "Component\tComponent\n"
247 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
249 static const CHAR rof_feature_dat
[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
250 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
252 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
254 static const CHAR rof_feature_comp_dat
[] = "Feature_\tComponent_\n"
256 "FeatureComponents\tFeature_\tComponent_\n"
259 static const CHAR rof_file_dat
[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
260 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
262 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
264 static const CHAR rof_media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
265 "i2\ti4\tL64\tS255\tS32\tS72\n"
267 "1\t1\t\t\tDISK1\t\n";
269 static const CHAR sdp_install_exec_seq_dat
[] = "Action\tCondition\tSequence\n"
271 "InstallExecuteSequence\tAction\n"
272 "AllocateRegistrySpace\tNOT Installed\t1550\n"
273 "CostFinalize\t\t1000\n"
274 "CostInitialize\t\t800\n"
276 "InstallFiles\t\t4000\n"
277 "InstallFinalize\t\t6600\n"
278 "InstallInitialize\t\t1500\n"
279 "InstallValidate\t\t1400\n"
280 "LaunchConditions\t\t100\n"
281 "SetDirProperty\t\t950";
283 static const CHAR sdp_custom_action_dat
[] = "Action\tType\tSource\tTarget\tISComments\n"
284 "s72\ti2\tS64\tS0\tS255\n"
285 "CustomAction\tAction\n"
286 "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
288 static const CHAR cie_component_dat
[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
289 "s72\tS38\ts72\ti2\tS255\tS72\n"
290 "Component\tComponent\n"
291 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
292 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
293 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
294 "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
296 static const CHAR cie_feature_comp_dat
[] = "Feature_\tComponent_\n"
298 "FeatureComponents\tFeature_\tComponent_\n"
300 "feature\taugustus\n"
304 static const CHAR cie_file_dat
[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
305 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
307 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
308 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
309 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
310 "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
312 static const CHAR cie_media_dat
[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
313 "i2\ti4\tL64\tS255\tS32\tS72\n"
315 "1\t1\t\ttest1.cab\tDISK1\t\n"
316 "2\t2\t\ttest2.cab\tDISK2\t\n"
317 "3\t12\t\ttest3.cab\tDISK3\t\n";
319 static const CHAR ci_install_exec_seq_dat
[] = "Action\tCondition\tSequence\n"
321 "InstallExecuteSequence\tAction\n"
322 "CostFinalize\t\t1000\n"
323 "CostInitialize\t\t800\n"
325 "InstallFiles\t\t4000\n"
326 "InstallServices\t\t5000\n"
327 "InstallFinalize\t\t6600\n"
328 "InstallInitialize\t\t1500\n"
329 "RunInstall\t\t1600\n"
330 "InstallValidate\t\t1400\n"
331 "LaunchConditions\t\t100";
333 static const CHAR ci_custom_action_dat
[] = "Action\tType\tSource\tTarget\tISComments\n"
334 "s72\ti2\tS64\tS0\tS255\n"
335 "CustomAction\tAction\n"
336 "RunInstall\t23\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
338 static const CHAR ci_component_dat
[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
339 "s72\tS38\ts72\ti2\tS255\tS72\n"
340 "Component\tComponent\n"
341 "maximus\t\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
343 static const CHAR ci2_component_dat
[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
344 "s72\tS38\ts72\ti2\tS255\tS72\n"
345 "Component\tComponent\n"
346 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
348 static const CHAR ci2_feature_comp_dat
[] = "Feature_\tComponent_\n"
350 "FeatureComponents\tFeature_\tComponent_\n"
353 static const CHAR ci2_file_dat
[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
354 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
356 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
358 static const CHAR spf_custom_action_dat
[] = "Action\tType\tSource\tTarget\tISComments\n"
359 "s72\ti2\tS64\tS0\tS255\n"
360 "CustomAction\tAction\n"
361 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
363 static const CHAR spf_install_exec_seq_dat
[] = "Action\tCondition\tSequence\n"
365 "InstallExecuteSequence\tAction\n"
366 "CostFinalize\t\t1000\n"
367 "CostInitialize\t\t800\n"
369 "SetFolderProp\t\t950\n"
370 "InstallFiles\t\t4000\n"
371 "InstallServices\t\t5000\n"
372 "InstallFinalize\t\t6600\n"
373 "InstallInitialize\t\t1500\n"
374 "InstallValidate\t\t1400\n"
375 "LaunchConditions\t\t100";
377 static const CHAR spf_install_ui_seq_dat
[] = "Action\tCondition\tSequence\n"
379 "InstallUISequence\tAction\n"
380 "CostInitialize\t\t800\n"
382 "CostFinalize\t\t1000\n"
383 "ExecuteAction\t\t1100\n";
385 typedef struct _msi_table
387 const CHAR
*filename
;
392 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
394 static const msi_table tables
[] =
396 ADD_TABLE(component
),
397 ADD_TABLE(directory
),
399 ADD_TABLE(feature_comp
),
401 ADD_TABLE(install_exec_seq
),
405 ADD_TABLE(service_install
),
406 ADD_TABLE(service_control
)
409 static const msi_table cc_tables
[] =
411 ADD_TABLE(cc_component
),
412 ADD_TABLE(directory
),
413 ADD_TABLE(cc_feature
),
414 ADD_TABLE(cc_feature_comp
),
416 ADD_TABLE(install_exec_seq
),
421 static const msi_table co_tables
[] =
423 ADD_TABLE(cc_component
),
424 ADD_TABLE(directory
),
425 ADD_TABLE(cc_feature
),
426 ADD_TABLE(cc_feature_comp
),
428 ADD_TABLE(install_exec_seq
),
433 static const msi_table co2_tables
[] =
435 ADD_TABLE(cc_component
),
436 ADD_TABLE(directory
),
437 ADD_TABLE(cc_feature
),
438 ADD_TABLE(cc_feature_comp
),
440 ADD_TABLE(install_exec_seq
),
441 ADD_TABLE(co2_media
),
445 static const msi_table mm_tables
[] =
447 ADD_TABLE(cc_component
),
448 ADD_TABLE(directory
),
449 ADD_TABLE(cc_feature
),
450 ADD_TABLE(cc_feature_comp
),
452 ADD_TABLE(install_exec_seq
),
457 static const msi_table ss_tables
[] =
459 ADD_TABLE(cc_component
),
460 ADD_TABLE(directory
),
461 ADD_TABLE(cc_feature
),
462 ADD_TABLE(cc_feature_comp
),
464 ADD_TABLE(install_exec_seq
),
469 static const msi_table ui_tables
[] =
471 ADD_TABLE(ui_component
),
472 ADD_TABLE(directory
),
473 ADD_TABLE(cc_feature
),
474 ADD_TABLE(cc_feature_comp
),
476 ADD_TABLE(install_exec_seq
),
477 ADD_TABLE(ui_install_ui_seq
),
478 ADD_TABLE(ui_custom_action
),
483 static const msi_table rof_tables
[] =
485 ADD_TABLE(rof_component
),
486 ADD_TABLE(directory
),
487 ADD_TABLE(rof_feature
),
488 ADD_TABLE(rof_feature_comp
),
490 ADD_TABLE(install_exec_seq
),
491 ADD_TABLE(rof_media
),
495 static const msi_table sdp_tables
[] =
497 ADD_TABLE(rof_component
),
498 ADD_TABLE(directory
),
499 ADD_TABLE(rof_feature
),
500 ADD_TABLE(rof_feature_comp
),
502 ADD_TABLE(sdp_install_exec_seq
),
503 ADD_TABLE(sdp_custom_action
),
504 ADD_TABLE(rof_media
),
508 static const msi_table cie_tables
[] =
510 ADD_TABLE(cie_component
),
511 ADD_TABLE(directory
),
512 ADD_TABLE(cc_feature
),
513 ADD_TABLE(cie_feature_comp
),
515 ADD_TABLE(install_exec_seq
),
516 ADD_TABLE(cie_media
),
520 static const msi_table ci_tables
[] =
522 ADD_TABLE(ci_component
),
523 ADD_TABLE(directory
),
524 ADD_TABLE(rof_feature
),
525 ADD_TABLE(rof_feature_comp
),
527 ADD_TABLE(ci_install_exec_seq
),
528 ADD_TABLE(rof_media
),
530 ADD_TABLE(ci_custom_action
),
533 static const msi_table ci2_tables
[] =
535 ADD_TABLE(ci2_component
),
536 ADD_TABLE(directory
),
537 ADD_TABLE(rof_feature
),
538 ADD_TABLE(ci2_feature_comp
),
540 ADD_TABLE(install_exec_seq
),
541 ADD_TABLE(rof_media
),
545 static const msi_table spf_tables
[] =
547 ADD_TABLE(ci_component
),
548 ADD_TABLE(directory
),
549 ADD_TABLE(rof_feature
),
550 ADD_TABLE(rof_feature_comp
),
552 ADD_TABLE(spf_install_exec_seq
),
553 ADD_TABLE(rof_media
),
555 ADD_TABLE(spf_custom_action
),
556 ADD_TABLE(spf_install_ui_seq
),
559 /* cabinet definitions */
561 /* make the max size large so there is only one cab file */
562 #define MEDIA_SIZE 0x7FFFFFFF
563 #define FOLDER_THRESHOLD 900000
565 /* the FCI callbacks */
567 static void *mem_alloc(ULONG cb
)
569 return HeapAlloc(GetProcessHeap(), 0, cb
);
572 static void mem_free(void *memory
)
574 HeapFree(GetProcessHeap(), 0, memory
);
577 static BOOL
get_next_cabinet(PCCAB pccab
, ULONG cbPrevCab
, void *pv
)
579 sprintf(pccab
->szCab
, pv
, pccab
->iCab
);
583 static long progress(UINT typeStatus
, ULONG cb1
, ULONG cb2
, void *pv
)
588 static int file_placed(PCCAB pccab
, char *pszFile
, long cbFile
,
589 BOOL fContinuation
, void *pv
)
594 static INT_PTR
fci_open(char *pszFile
, int oflag
, int pmode
, int *err
, void *pv
)
598 DWORD dwShareMode
= 0;
599 DWORD dwCreateDisposition
= OPEN_EXISTING
;
601 dwAccess
= GENERIC_READ
| GENERIC_WRITE
;
602 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
603 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
605 if (GetFileAttributesA(pszFile
) != INVALID_FILE_ATTRIBUTES
)
606 dwCreateDisposition
= OPEN_EXISTING
;
608 dwCreateDisposition
= CREATE_NEW
;
610 handle
= CreateFileA(pszFile
, dwAccess
, dwShareMode
, NULL
,
611 dwCreateDisposition
, 0, NULL
);
613 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to CreateFile %s\n", pszFile
);
615 return (INT_PTR
)handle
;
618 static UINT
fci_read(INT_PTR hf
, void *memory
, UINT cb
, int *err
, void *pv
)
620 HANDLE handle
= (HANDLE
)hf
;
624 res
= ReadFile(handle
, memory
, cb
, &dwRead
, NULL
);
625 ok(res
, "Failed to ReadFile\n");
630 static UINT
fci_write(INT_PTR hf
, void *memory
, UINT cb
, int *err
, void *pv
)
632 HANDLE handle
= (HANDLE
)hf
;
636 res
= WriteFile(handle
, memory
, cb
, &dwWritten
, NULL
);
637 ok(res
, "Failed to WriteFile\n");
642 static int fci_close(INT_PTR hf
, int *err
, void *pv
)
644 HANDLE handle
= (HANDLE
)hf
;
645 ok(CloseHandle(handle
), "Failed to CloseHandle\n");
650 static long fci_seek(INT_PTR hf
, long dist
, int seektype
, int *err
, void *pv
)
652 HANDLE handle
= (HANDLE
)hf
;
655 ret
= SetFilePointer(handle
, dist
, NULL
, seektype
);
656 ok(ret
!= INVALID_SET_FILE_POINTER
, "Failed to SetFilePointer\n");
661 static int fci_delete(char *pszFile
, int *err
, void *pv
)
663 BOOL ret
= DeleteFileA(pszFile
);
664 ok(ret
, "Failed to DeleteFile %s\n", pszFile
);
669 static BOOL
check_record(MSIHANDLE rec
, UINT field
, LPCSTR val
)
676 r
= MsiRecordGetString(rec
, field
, buffer
, &sz
);
677 return (r
== ERROR_SUCCESS
) && !strcmp(val
, buffer
);
680 static BOOL
get_temp_file(char *pszTempName
, int cbTempName
, void *pv
)
684 tempname
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
685 GetTempFileNameA(".", "xx", 0, tempname
);
687 if (tempname
&& (strlen(tempname
) < (unsigned)cbTempName
))
689 lstrcpyA(pszTempName
, tempname
);
690 HeapFree(GetProcessHeap(), 0, tempname
);
694 HeapFree(GetProcessHeap(), 0, tempname
);
699 static INT_PTR
get_open_info(char *pszName
, USHORT
*pdate
, USHORT
*ptime
,
700 USHORT
*pattribs
, int *err
, void *pv
)
702 BY_HANDLE_FILE_INFORMATION finfo
;
708 handle
= CreateFile(pszName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
709 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
| FILE_FLAG_SEQUENTIAL_SCAN
, NULL
);
711 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to CreateFile %s\n", pszName
);
713 res
= GetFileInformationByHandle(handle
, &finfo
);
714 ok(res
, "Expected GetFileInformationByHandle to succeed\n");
716 FileTimeToLocalFileTime(&finfo
.ftLastWriteTime
, &filetime
);
717 FileTimeToDosDateTime(&filetime
, pdate
, ptime
);
719 attrs
= GetFileAttributes(pszName
);
720 ok(attrs
!= INVALID_FILE_ATTRIBUTES
, "Failed to GetFileAttributes\n");
722 return (INT_PTR
)handle
;
725 static BOOL
add_file(HFCI hfci
, const char *file
, TCOMP compress
)
728 char filename
[MAX_PATH
];
730 lstrcpyA(path
, CURR_DIR
);
731 lstrcatA(path
, "\\");
732 lstrcatA(path
, file
);
734 lstrcpyA(filename
, file
);
736 return FCIAddFile(hfci
, path
, filename
, FALSE
, get_next_cabinet
,
737 progress
, get_open_info
, compress
);
740 static void set_cab_parameters(PCCAB pCabParams
, const CHAR
*name
, DWORD max_size
)
742 ZeroMemory(pCabParams
, sizeof(CCAB
));
744 pCabParams
->cb
= max_size
;
745 pCabParams
->cbFolderThresh
= FOLDER_THRESHOLD
;
746 pCabParams
->setID
= 0xbeef;
747 pCabParams
->iCab
= 1;
748 lstrcpyA(pCabParams
->szCabPath
, CURR_DIR
);
749 lstrcatA(pCabParams
->szCabPath
, "\\");
750 lstrcpyA(pCabParams
->szCab
, name
);
753 static void create_cab_file(const CHAR
*name
, DWORD max_size
, const CHAR
*files
)
761 set_cab_parameters(&cabParams
, name
, max_size
);
763 hfci
= FCICreate(&erf
, file_placed
, mem_alloc
, mem_free
, fci_open
,
764 fci_read
, fci_write
, fci_close
, fci_seek
, fci_delete
,
765 get_temp_file
, &cabParams
, NULL
);
767 ok(hfci
!= NULL
, "Failed to create an FCI context\n");
772 res
= add_file(hfci
, ptr
, tcompTYPE_MSZIP
);
773 ok(res
, "Failed to add file: %s\n", ptr
);
774 ptr
+= lstrlen(ptr
) + 1;
777 res
= FCIFlushCabinet(hfci
, FALSE
, get_next_cabinet
, progress
);
778 ok(res
, "Failed to flush the cabinet\n");
780 res
= FCIDestroy(hfci
);
781 ok(res
, "Failed to destroy the cabinet\n");
784 static BOOL
get_program_files_dir(LPSTR buf
)
787 DWORD type
= REG_EXPAND_SZ
, size
;
789 if (RegOpenKey(HKEY_LOCAL_MACHINE
,
790 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey
))
794 if (RegQueryValueEx(hkey
, "ProgramFilesDir", 0, &type
, (LPBYTE
)buf
, &size
))
801 static void create_file(const CHAR
*name
, DWORD size
)
806 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
807 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
808 WriteFile(file
, name
, strlen(name
), &written
, NULL
);
809 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
811 left
= size
- lstrlen(name
) - 1;
813 SetFilePointer(file
, left
, NULL
, FILE_CURRENT
);
819 static void create_test_files(void)
821 CreateDirectoryA("msitest", NULL
);
822 create_file("msitest\\one.txt", 100);
823 CreateDirectoryA("msitest\\first", NULL
);
824 create_file("msitest\\first\\two.txt", 100);
825 CreateDirectoryA("msitest\\second", NULL
);
826 create_file("msitest\\second\\three.txt", 100);
828 create_file("four.txt", 100);
829 create_file("five.txt", 100);
830 create_cab_file("msitest.cab", MEDIA_SIZE
, "four.txt\0five.txt\0");
832 create_file("msitest\\filename", 100);
833 create_file("msitest\\service.exe", 100);
835 DeleteFileA("four.txt");
836 DeleteFileA("five.txt");
839 static BOOL
delete_pf(const CHAR
*rel_path
, BOOL is_file
)
843 lstrcpyA(path
, PROG_FILES_DIR
);
844 lstrcatA(path
, "\\");
845 lstrcatA(path
, rel_path
);
848 return DeleteFileA(path
);
850 return RemoveDirectoryA(path
);
853 static void delete_test_files(void)
855 DeleteFileA("msitest.msi");
856 DeleteFileA("msitest.cab");
857 DeleteFileA("msitest\\second\\three.txt");
858 DeleteFileA("msitest\\first\\two.txt");
859 DeleteFileA("msitest\\one.txt");
860 DeleteFileA("msitest\\service.exe");
861 DeleteFileA("msitest\\filename");
862 RemoveDirectoryA("msitest\\second");
863 RemoveDirectoryA("msitest\\first");
864 RemoveDirectoryA("msitest");
867 static void write_file(const CHAR
*filename
, const char *data
, int data_size
)
871 HANDLE hf
= CreateFile(filename
, GENERIC_WRITE
, 0, NULL
,
872 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
874 WriteFile(hf
, data
, data_size
, &size
, NULL
);
878 static void write_msi_summary_info(MSIHANDLE db
)
883 r
= MsiGetSummaryInformationA(db
, NULL
, 4, &summary
);
884 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
886 r
= MsiSummaryInfoSetPropertyA(summary
, PID_TEMPLATE
, VT_LPSTR
, 0, NULL
, ";1033");
887 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
889 r
= MsiSummaryInfoSetPropertyA(summary
, PID_REVNUMBER
, VT_LPSTR
, 0, NULL
,
890 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
891 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
893 r
= MsiSummaryInfoSetPropertyA(summary
, PID_PAGECOUNT
, VT_I4
, 100, NULL
, NULL
);
894 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
896 r
= MsiSummaryInfoSetPropertyA(summary
, PID_WORDCOUNT
, VT_I4
, 0, NULL
, NULL
);
897 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
899 /* write the summary changes back to the stream */
900 r
= MsiSummaryInfoPersist(summary
);
901 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
903 MsiCloseHandle(summary
);
906 static void create_database(const CHAR
*name
, const msi_table
*tables
, int num_tables
)
912 r
= MsiOpenDatabaseA(name
, MSIDBOPEN_CREATE
, &db
);
913 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
915 /* import the tables into the database */
916 for (j
= 0; j
< num_tables
; j
++)
918 const msi_table
*table
= &tables
[j
];
920 write_file(table
->filename
, table
->data
, (table
->size
- 1) * sizeof(char));
922 r
= MsiDatabaseImportA(db
, CURR_DIR
, table
->filename
);
923 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
925 DeleteFileA(table
->filename
);
928 write_msi_summary_info(db
);
930 r
= MsiDatabaseCommit(db
);
931 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
936 static void check_service_is_installed(void)
938 SC_HANDLE scm
, service
;
941 scm
= OpenSCManager(NULL
, NULL
, SC_MANAGER_ALL_ACCESS
);
942 ok(scm
!= NULL
, "Failed to open the SC Manager\n");
944 service
= OpenService(scm
, "TestService", SC_MANAGER_ALL_ACCESS
);
945 ok(service
!= NULL
, "Failed to open TestService\n");
947 res
= DeleteService(service
);
948 ok(res
, "Failed to delete TestService\n");
951 static void test_MsiInstallProduct(void)
957 DWORD num
, size
, type
;
960 create_database(msifile
, tables
, sizeof(tables
) / sizeof(msi_table
));
962 r
= MsiInstallProductA(msifile
, NULL
);
963 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
965 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE
), "File not installed\n");
966 ok(delete_pf("msitest\\cabout\\new", FALSE
), "File not installed\n");
967 ok(delete_pf("msitest\\cabout\\four.txt", TRUE
), "File not installed\n");
968 ok(delete_pf("msitest\\cabout", FALSE
), "File not installed\n");
969 ok(delete_pf("msitest\\changed\\three.txt", TRUE
), "File not installed\n");
970 ok(delete_pf("msitest\\changed", FALSE
), "File not installed\n");
971 ok(delete_pf("msitest\\first\\two.txt", TRUE
), "File not installed\n");
972 ok(delete_pf("msitest\\first", FALSE
), "File not installed\n");
973 ok(delete_pf("msitest\\one.txt", TRUE
), "File not installed\n");
974 ok(delete_pf("msitest\\filename", TRUE
), "File not installed\n");
975 ok(delete_pf("msitest\\service.exe", TRUE
), "File not installed\n");
976 ok(delete_pf("msitest", FALSE
), "File not installed\n");
978 res
= RegOpenKey(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Wine\\msitest", &hkey
);
979 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
983 res
= RegQueryValueExA(hkey
, "Name", NULL
, &type
, (LPBYTE
)path
, &size
);
984 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
985 ok(!lstrcmpA(path
, "imaname"), "Expected imaname, got %s\n", path
);
989 res
= RegQueryValueExA(hkey
, "blah", NULL
, &type
, (LPBYTE
)path
, &size
);
990 ok(res
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res
);
994 res
= RegQueryValueExA(hkey
, "number", NULL
, &type
, (LPBYTE
)&num
, &size
);
995 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
996 ok(num
== 314, "Expected 314, got %d\n", num
);
1000 res
= RegQueryValueExA(hkey
, "OrderTestName", NULL
, &type
, (LPBYTE
)path
, &size
);
1001 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1002 ok(!lstrcmpA(path
, "OrderTestValue"), "Expected imaname, got %s\n", path
);
1004 check_service_is_installed();
1006 RegDeleteKeyA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Wine\\msitest");
1008 delete_test_files();
1011 static void test_MsiSetComponentState(void)
1013 INSTALLSTATE installed
, action
;
1015 char path
[MAX_PATH
];
1018 create_database(msifile
, tables
, sizeof(tables
) / sizeof(msi_table
));
1022 lstrcpy(path
, CURR_DIR
);
1023 lstrcat(path
, "\\");
1024 lstrcat(path
, msifile
);
1026 r
= MsiOpenPackage(path
, &package
);
1027 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1029 r
= MsiDoAction(package
, "CostInitialize");
1030 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1032 r
= MsiDoAction(package
, "FileCost");
1033 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1035 r
= MsiDoAction(package
, "CostFinalize");
1036 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1038 r
= MsiGetComponentState(package
, "dangler", &installed
, &action
);
1039 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1040 ok(installed
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", installed
);
1041 ok(action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1043 r
= MsiSetComponentState(package
, "dangler", INSTALLSTATE_SOURCE
);
1044 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1046 MsiCloseHandle(package
);
1049 DeleteFileA(msifile
);
1052 static void test_packagecoltypes(void)
1054 MSIHANDLE hdb
, view
, rec
;
1055 char path
[MAX_PATH
];
1059 create_database(msifile
, tables
, sizeof(tables
) / sizeof(msi_table
));
1063 lstrcpy(path
, CURR_DIR
);
1064 lstrcat(path
, "\\");
1065 lstrcat(path
, msifile
);
1067 r
= MsiOpenDatabase(path
, MSIDBOPEN_READONLY
, &hdb
);
1068 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1070 query
= "SELECT * FROM `Media`";
1071 r
= MsiDatabaseOpenView( hdb
, query
, &view
);
1072 ok(r
== ERROR_SUCCESS
, "MsiDatabaseOpenView failed\n");
1074 r
= MsiViewGetColumnInfo( view
, MSICOLINFO_NAMES
, &rec
);
1075 count
= MsiRecordGetFieldCount( rec
);
1076 ok(r
== ERROR_SUCCESS
, "MsiViewGetColumnInfo failed\n");
1077 ok(count
== 6, "Expected 6, got %d\n", count
);
1078 ok(check_record(rec
, 1, "DiskId"), "wrong column label\n");
1079 ok(check_record(rec
, 2, "LastSequence"), "wrong column label\n");
1080 ok(check_record(rec
, 3, "DiskPrompt"), "wrong column label\n");
1081 ok(check_record(rec
, 4, "Cabinet"), "wrong column label\n");
1082 ok(check_record(rec
, 5, "VolumeLabel"), "wrong column label\n");
1083 ok(check_record(rec
, 6, "Source"), "wrong column label\n");
1084 MsiCloseHandle(rec
);
1086 r
= MsiViewGetColumnInfo( view
, MSICOLINFO_TYPES
, &rec
);
1087 count
= MsiRecordGetFieldCount( rec
);
1088 ok(r
== ERROR_SUCCESS
, "MsiViewGetColumnInfo failed\n");
1089 ok(count
== 6, "Expected 6, got %d\n", count
);
1090 ok(check_record(rec
, 1, "i2"), "wrong column label\n");
1091 ok(check_record(rec
, 2, "i4"), "wrong column label\n");
1092 ok(check_record(rec
, 3, "L64"), "wrong column label\n");
1093 ok(check_record(rec
, 4, "S255"), "wrong column label\n");
1094 ok(check_record(rec
, 5, "S32"), "wrong column label\n");
1095 ok(check_record(rec
, 6, "S72"), "wrong column label\n");
1097 MsiCloseHandle(rec
);
1098 MsiCloseHandle(view
);
1099 MsiCloseHandle(hdb
);
1100 DeleteFile(msifile
);
1103 static void create_cc_test_files(void)
1108 static CHAR cab_context
[] = "test%d.cab";
1111 create_file("maximus", 500);
1112 create_file("augustus", 50000);
1113 create_file("caesar", 500);
1115 set_cab_parameters(&cabParams
, "test1.cab", 200);
1117 hfci
= FCICreate(&erf
, file_placed
, mem_alloc
, mem_free
, fci_open
,
1118 fci_read
, fci_write
, fci_close
, fci_seek
, fci_delete
,
1119 get_temp_file
, &cabParams
, cab_context
);
1120 ok(hfci
!= NULL
, "Failed to create an FCI context\n");
1122 res
= add_file(hfci
, "maximus", tcompTYPE_MSZIP
);
1123 ok(res
, "Failed to add file maximus\n");
1125 res
= add_file(hfci
, "augustus", tcompTYPE_MSZIP
);
1126 ok(res
, "Failed to add file augustus\n");
1128 res
= FCIFlushCabinet(hfci
, FALSE
, get_next_cabinet
, progress
);
1129 ok(res
, "Failed to flush the cabinet\n");
1131 res
= FCIDestroy(hfci
);
1132 ok(res
, "Failed to destroy the cabinet\n");
1134 create_cab_file("test3.cab", MEDIA_SIZE
, "caesar\0");
1136 DeleteFile("maximus");
1137 DeleteFile("augustus");
1138 DeleteFile("caesar");
1141 static void delete_cab_files(void)
1143 SHFILEOPSTRUCT shfl
;
1144 CHAR path
[MAX_PATH
];
1146 lstrcpyA(path
, CURR_DIR
);
1147 lstrcatA(path
, "\\*.cab");
1148 path
[strlen(path
) + 1] = '\0';
1151 shfl
.wFunc
= FO_DELETE
;
1152 shfl
.pFrom
= (LPCSTR
)path
;
1154 shfl
.fFlags
= FOF_FILESONLY
| FOF_NOCONFIRMATION
| FOF_NORECURSION
| FOF_SILENT
;
1156 SHFileOperation(&shfl
);
1159 static void test_continuouscabs(void)
1163 create_cc_test_files();
1164 create_database(msifile
, cc_tables
, sizeof(cc_tables
) / sizeof(msi_table
));
1166 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1168 r
= MsiInstallProductA(msifile
, NULL
);
1169 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
1172 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1173 ok(delete_pf("msitest\\augustus", TRUE
), "File not installed\n");
1174 ok(delete_pf("msitest\\caesar", TRUE
), "File not installed\n");
1176 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1179 DeleteFile(msifile
);
1182 static void test_caborder(void)
1186 create_file("imperator", 100);
1187 create_file("maximus", 500);
1188 create_file("augustus", 50000);
1189 create_file("caesar", 500);
1191 create_database(msifile
, cc_tables
, sizeof(cc_tables
) / sizeof(msi_table
));
1193 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1195 create_cab_file("test1.cab", MEDIA_SIZE
, "maximus\0");
1196 create_cab_file("test2.cab", MEDIA_SIZE
, "augustus\0");
1197 create_cab_file("test3.cab", MEDIA_SIZE
, "caesar\0");
1199 r
= MsiInstallProductA(msifile
, NULL
);
1200 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
1201 ok(!delete_pf("msitest\\augustus", TRUE
), "File is installed\n");
1202 ok(!delete_pf("msitest\\caesar", TRUE
), "File is installed\n");
1205 ok(!delete_pf("msitest\\maximus", TRUE
), "File is installed\n");
1206 ok(!delete_pf("msitest", FALSE
), "File is installed\n");
1211 create_cab_file("test1.cab", MEDIA_SIZE
, "imperator\0");
1212 create_cab_file("test2.cab", MEDIA_SIZE
, "maximus\0augustus\0");
1213 create_cab_file("test3.cab", MEDIA_SIZE
, "caesar\0");
1215 r
= MsiInstallProductA(msifile
, NULL
);
1216 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
1217 ok(!delete_pf("msitest\\maximus", TRUE
), "File is installed\n");
1218 ok(!delete_pf("msitest\\augustus", TRUE
), "File is installed\n");
1219 ok(!delete_pf("msitest\\caesar", TRUE
), "File is installed\n");
1222 ok(!delete_pf("msitest", FALSE
), "File is installed\n");
1226 DeleteFile(msifile
);
1228 create_cc_test_files();
1229 create_database(msifile
, co_tables
, sizeof(co_tables
) / sizeof(msi_table
));
1231 r
= MsiInstallProductA(msifile
, NULL
);
1232 ok(!delete_pf("msitest\\augustus", TRUE
), "File is installed\n");
1233 ok(!delete_pf("msitest\\caesar", TRUE
), "File is installed\n");
1234 ok(!delete_pf("msitest", FALSE
), "File is installed\n");
1237 ok(!delete_pf("msitest\\maximus", TRUE
), "File is installed\n");
1238 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
1242 DeleteFile(msifile
);
1244 create_cc_test_files();
1245 create_database(msifile
, co2_tables
, sizeof(co2_tables
) / sizeof(msi_table
));
1247 r
= MsiInstallProductA(msifile
, NULL
);
1248 ok(!delete_pf("msitest\\augustus", TRUE
), "File is installed\n");
1249 ok(!delete_pf("msitest\\caesar", TRUE
), "File is installed\n");
1252 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
1253 ok(!delete_pf("msitest\\maximus", TRUE
), "File is installed\n");
1254 ok(!delete_pf("msitest", FALSE
), "File is installed\n");
1258 DeleteFile("imperator");
1259 DeleteFile("maximus");
1260 DeleteFile("augustus");
1261 DeleteFile("caesar");
1262 DeleteFile(msifile
);
1265 static void test_mixedmedia(void)
1269 CreateDirectoryA("msitest", NULL
);
1270 create_file("msitest\\maximus", 500);
1271 create_file("msitest\\augustus", 500);
1272 create_file("caesar", 500);
1274 create_database(msifile
, mm_tables
, sizeof(mm_tables
) / sizeof(msi_table
));
1276 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1278 create_cab_file("test1.cab", MEDIA_SIZE
, "caesar\0");
1280 r
= MsiInstallProductA(msifile
, NULL
);
1281 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1282 ok(delete_pf("msitest\\augustus", TRUE
), "File not installed\n");
1283 ok(delete_pf("msitest\\caesar", TRUE
), "File not installed\n");
1284 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
1285 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1287 /* Delete the files in the temp (current) folder */
1288 DeleteFile("msitest\\maximus");
1289 DeleteFile("msitest\\augustus");
1290 RemoveDirectory("msitest");
1291 DeleteFile("caesar");
1292 DeleteFile("test1.cab");
1293 DeleteFile(msifile
);
1296 static void test_samesequence(void)
1300 create_cc_test_files();
1301 create_database(msifile
, ss_tables
, sizeof(ss_tables
) / sizeof(msi_table
));
1303 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1305 r
= MsiInstallProductA(msifile
, NULL
);
1308 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1309 ok(delete_pf("msitest\\augustus", TRUE
), "File not installed\n");
1310 ok(delete_pf("msitest\\caesar", TRUE
), "File not installed\n");
1312 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
1313 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1316 DeleteFile(msifile
);
1319 static void test_uiLevelFlags(void)
1323 create_cc_test_files();
1324 create_database(msifile
, ui_tables
, sizeof(ui_tables
) / sizeof(msi_table
));
1326 MsiSetInternalUI(INSTALLUILEVEL_NONE
| INSTALLUILEVEL_SOURCERESONLY
, NULL
);
1328 r
= MsiInstallProductA(msifile
, NULL
);
1329 ok(!delete_pf("msitest\\maximus", TRUE
), "UI install occurred, but execute-only was requested.\n");
1332 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1333 ok(delete_pf("msitest\\caesar", TRUE
), "File not installed\n");
1335 ok(delete_pf("msitest\\augustus", TRUE
), "File not installed\n");
1336 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1339 DeleteFile(msifile
);
1342 static BOOL
file_matches(LPSTR path
)
1348 file
= CreateFile(path
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
1349 NULL
, OPEN_EXISTING
, 0, NULL
);
1351 ZeroMemory(buf
, MAX_PATH
);
1352 ReadFile(file
, buf
, 15, &size
, NULL
);
1355 return !lstrcmp(buf
, "msitest\\maximus");
1358 static void test_readonlyfile(void)
1363 CHAR path
[MAX_PATH
];
1365 CreateDirectoryA("msitest", NULL
);
1366 create_file("msitest\\maximus", 500);
1367 create_database(msifile
, rof_tables
, sizeof(rof_tables
) / sizeof(msi_table
));
1369 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1371 lstrcpy(path
, PROG_FILES_DIR
);
1372 lstrcat(path
, "\\msitest");
1373 CreateDirectory(path
, NULL
);
1375 lstrcat(path
, "\\maximus");
1376 file
= CreateFile(path
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
1377 NULL
, CREATE_NEW
, FILE_ATTRIBUTE_READONLY
, NULL
);
1379 WriteFile(file
, "readonlyfile", 20, &size
, NULL
);
1382 r
= MsiInstallProductA(msifile
, NULL
);
1383 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1384 ok(file_matches(path
), "Expected file to be overwritten\n");
1385 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
1386 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1388 /* Delete the files in the temp (current) folder */
1389 DeleteFile("msitest\\maximus");
1390 RemoveDirectory("msitest");
1391 DeleteFile(msifile
);
1394 static void test_setdirproperty(void)
1398 CreateDirectoryA("msitest", NULL
);
1399 create_file("msitest\\maximus", 500);
1400 create_database(msifile
, sdp_tables
, sizeof(sdp_tables
) / sizeof(msi_table
));
1402 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1404 r
= MsiInstallProductA(msifile
, NULL
);
1405 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1406 ok(delete_pf("Common Files\\msitest\\maximus", TRUE
), "File not installed\n");
1407 ok(delete_pf("Common Files\\msitest", FALSE
), "File not installed\n");
1409 DeleteFile(msifile
);
1412 static void test_cabisextracted(void)
1416 CreateDirectoryA("msitest", NULL
);
1417 create_file("msitest\\gaius", 500);
1418 create_file("maximus", 500);
1419 create_file("augustus", 500);
1420 create_file("caesar", 500);
1422 create_cab_file("test1.cab", MEDIA_SIZE
, "maximus\0");
1423 create_cab_file("test2.cab", MEDIA_SIZE
, "augustus\0");
1424 create_cab_file("test3.cab", MEDIA_SIZE
, "caesar\0");
1426 create_database(msifile
, cie_tables
, sizeof(cie_tables
) / sizeof(msi_table
));
1428 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1430 r
= MsiInstallProductA(msifile
, NULL
);
1431 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1432 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
1433 ok(delete_pf("msitest\\augustus", TRUE
), "File not installed\n");
1434 ok(delete_pf("msitest\\caesar", TRUE
), "File not installed\n");
1435 ok(delete_pf("msitest\\gaius", TRUE
), "File not installed\n");
1436 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1439 DeleteFile(msifile
);
1442 static void test_concurrentinstall(void)
1445 CHAR path
[MAX_PATH
];
1447 CreateDirectoryA("msitest", NULL
);
1448 CreateDirectoryA("msitest\\msitest", NULL
);
1449 create_file("msitest\\maximus", 500);
1450 create_file("msitest\\msitest\\augustus", 500);
1452 create_database(msifile
, ci_tables
, sizeof(ci_tables
) / sizeof(msi_table
));
1454 lstrcpyA(path
, CURR_DIR
);
1455 lstrcatA(path
, "\\msitest\\concurrent.msi");
1456 create_database(path
, ci2_tables
, sizeof(ci2_tables
) / sizeof(msi_table
));
1458 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
1460 r
= MsiInstallProductA(msifile
, NULL
);
1461 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1462 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
1463 ok(delete_pf("msitest\\augustus", TRUE
), "File not installed\n");
1464 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1466 DeleteFile(msifile
);
1469 static void test_setpropertyfolder(void)
1473 CreateDirectoryA("msitest", NULL
);
1474 create_file("msitest\\maximus", 500);
1476 create_database(msifile
, spf_tables
, sizeof(spf_tables
) / sizeof(msi_table
));
1478 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
1480 r
= MsiInstallProductA(msifile
, NULL
);
1481 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1482 ok(delete_pf("msitest\\added\\maximus", TRUE
), "File not installed\n");
1483 ok(delete_pf("msitest\\added", FALSE
), "File not installed\n");
1484 ok(delete_pf("msitest", FALSE
), "File not installed\n");
1486 DeleteFile(msifile
);
1492 char temp_path
[MAX_PATH
], prev_path
[MAX_PATH
];
1494 GetCurrentDirectoryA(MAX_PATH
, prev_path
);
1495 GetTempPath(MAX_PATH
, temp_path
);
1496 SetCurrentDirectoryA(temp_path
);
1498 lstrcpyA(CURR_DIR
, temp_path
);
1499 len
= lstrlenA(CURR_DIR
);
1501 if(len
&& (CURR_DIR
[len
- 1] == '\\'))
1502 CURR_DIR
[len
- 1] = 0;
1504 get_program_files_dir(PROG_FILES_DIR
);
1506 test_MsiInstallProduct();
1507 test_MsiSetComponentState();
1508 test_packagecoltypes();
1509 test_continuouscabs();
1512 test_samesequence();
1513 test_uiLevelFlags();
1514 test_readonlyfile();
1515 test_setdirproperty();
1516 test_cabisextracted();
1517 test_concurrentinstall();
1518 test_setpropertyfolder();
1520 SetCurrentDirectoryA(prev_path
);