opengl32: Avoid generating a wrapper for internal functions when we can call the...
[wine] / dlls / msi / tests / package.c
1 /*
2  * tests for Microsoft Installer functionality
3  *
4  * Copyright 2005 Mike McCormack for CodeWeavers
5  * Copyright 2005 Aric Stewart for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #define COBJMACROS
23
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msi.h>
27 #include <msiquery.h>
28
29 #include "wine/test.h"
30
31 static const char msifile[] = "winetest.msi";
32
33 static UINT run_query( MSIHANDLE hdb, const char *query )
34 {
35     MSIHANDLE hview = 0;
36     UINT r;
37
38     r = MsiDatabaseOpenView(hdb, query, &hview);
39     if( r != ERROR_SUCCESS )
40         return r;
41
42     r = MsiViewExecute(hview, 0);
43     if( r == ERROR_SUCCESS )
44         r = MsiViewClose(hview);
45     MsiCloseHandle(hview);
46     return r;
47 }
48
49 static UINT create_component_table( MSIHANDLE hdb )
50 {
51     return run_query( hdb,
52             "CREATE TABLE `Component` ( "
53             "`Component` CHAR(72) NOT NULL, "
54             "`ComponentId` CHAR(38), "
55             "`Directory_` CHAR(72) NOT NULL, "
56             "`Attributes` SHORT NOT NULL, "
57             "`Condition` CHAR(255), "
58             "`KeyPath` CHAR(72) "
59             "PRIMARY KEY `Component`)" );
60 }
61
62 static UINT create_feature_table( MSIHANDLE hdb )
63 {
64     return run_query( hdb,
65             "CREATE TABLE `Feature` ( "
66             "`Feature` CHAR(38) NOT NULL, "
67             "`Feature_Parent` CHAR(38), "
68             "`Title` CHAR(64), "
69             "`Description` CHAR(255), "
70             "`Display` SHORT NOT NULL, "
71             "`Level` SHORT NOT NULL, "
72             "`Directory_` CHAR(72), "
73             "`Attributes` SHORT NOT NULL "
74             "PRIMARY KEY `Feature`)" );
75 }
76
77 static UINT create_feature_components_table( MSIHANDLE hdb )
78 {
79     return run_query( hdb,
80             "CREATE TABLE `FeatureComponents` ( "
81             "`Feature_` CHAR(38) NOT NULL, "
82             "`Component_` CHAR(72) NOT NULL "
83             "PRIMARY KEY `Feature_`, `Component_` )" );
84 }
85
86 static UINT create_file_table( MSIHANDLE hdb )
87 {
88     return run_query( hdb,
89             "CREATE TABLE `File` ("
90             "`File` CHAR(72) NOT NULL, "
91             "`Component_` CHAR(72) NOT NULL, "
92             "`FileName` CHAR(255) NOT NULL, "
93             "`FileSize` LONG NOT NULL, "
94             "`Version` CHAR(72), "
95             "`Language` CHAR(20), "
96             "`Attributes` SHORT, "
97             "`Sequence` SHORT NOT NULL "
98             "PRIMARY KEY `File`)" );
99 }
100
101 static UINT create_remove_file_table( MSIHANDLE hdb )
102 {
103     return run_query( hdb,
104             "CREATE TABLE `RemoveFile` ("
105             "`FileKey` CHAR(72) NOT NULL, "
106             "`Component_` CHAR(72) NOT NULL, "
107             "`FileName` CHAR(255) LOCALIZABLE, "
108             "`DirProperty` CHAR(72) NOT NULL, "
109             "`InstallMode` SHORT NOT NULL "
110             "PRIMARY KEY `FileKey`)" );
111 }
112
113 static UINT create_appsearch_table( MSIHANDLE hdb )
114 {
115     return run_query( hdb,
116             "CREATE TABLE `AppSearch` ("
117             "`Property` CHAR(72) NOT NULL, "
118             "`Signature_` CHAR(72) NOT NULL "
119             "PRIMARY KEY `Property`, `Signature_`)" );
120 }
121
122 static UINT create_reglocator_table( MSIHANDLE hdb )
123 {
124     return run_query( hdb,
125             "CREATE TABLE `RegLocator` ("
126             "`Signature_` CHAR(72) NOT NULL, "
127             "`Root` SHORT NOT NULL, "
128             "`Key` CHAR(255) NOT NULL, "
129             "`Name` CHAR(255), "
130             "`Type` SHORT "
131             "PRIMARY KEY `Signature_`)" );
132 }
133
134 static UINT create_signature_table( MSIHANDLE hdb )
135 {
136     return run_query( hdb,
137             "CREATE TABLE `Signature` ("
138             "`Signature` CHAR(72) NOT NULL, "
139             "`FileName` CHAR(255) NOT NULL, "
140             "`MinVersion` CHAR(20), "
141             "`MaxVersion` CHAR(20), "
142             "`MinSize` LONG, "
143             "`MaxSize` LONG, "
144             "`MinDate` LONG, "
145             "`MaxDate` LONG, "
146             "`Languages` CHAR(255) "
147             "PRIMARY KEY `Signature`)" );
148 }
149
150 static UINT add_component_entry( MSIHANDLE hdb, const char *values )
151 {
152     char insert[] = "INSERT INTO `Component`  "
153             "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
154             "VALUES( %s )";
155     char *query;
156     UINT sz, r;
157
158     sz = strlen(values) + sizeof insert;
159     query = HeapAlloc(GetProcessHeap(),0,sz);
160     sprintf(query,insert,values);
161     r = run_query( hdb, query );
162     HeapFree(GetProcessHeap(), 0, query);
163     return r;
164 }
165
166 static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
167 {
168     char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
169                     "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
170     char *query;
171     UINT sz, r;
172
173     sz = strlen(values) + sizeof insert;
174     query = HeapAlloc(GetProcessHeap(),0,sz);
175     sprintf(query,insert,values);
176     r = run_query( hdb, query );
177     HeapFree(GetProcessHeap(), 0, query);
178     return r;
179 }
180
181 static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
182 {
183     char insert[] = "INSERT INTO `FeatureComponents` "
184             "(`Feature_`, `Component_`) "
185             "VALUES( %s )";
186     char *query;
187     UINT sz, r;
188
189     sz = strlen(values) + sizeof insert;
190     query = HeapAlloc(GetProcessHeap(),0,sz);
191     sprintf(query,insert,values);
192     r = run_query( hdb, query );
193     HeapFree(GetProcessHeap(), 0, query);
194     return r;
195 }
196
197 static UINT add_file_entry( MSIHANDLE hdb, const char *values )
198 {
199     char insert[] = "INSERT INTO `File` "
200             "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
201             "VALUES( %s )";
202     char *query;
203     UINT sz, r;
204
205     sz = strlen(values) + sizeof insert;
206     query = HeapAlloc(GetProcessHeap(),0,sz);
207     sprintf(query,insert,values);
208     r = run_query( hdb, query );
209     HeapFree(GetProcessHeap(), 0, query);
210     return r;
211 }
212
213 static UINT add_appsearch_entry( MSIHANDLE hdb, const char *values )
214 {
215     char insert[] = "INSERT INTO `AppSearch` "
216             "(`Property`, `Signature_`) "
217             "VALUES( %s )";
218     char *query;
219     UINT sz, r;
220
221     sz = strlen(values) + sizeof insert;
222     query = HeapAlloc(GetProcessHeap(),0,sz);
223     sprintf(query,insert,values);
224     r = run_query( hdb, query );
225     HeapFree(GetProcessHeap(), 0, query);
226     return r;
227 }
228
229 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *values )
230 {
231     char insert[] = "INSERT INTO `RegLocator` "
232             "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
233             "VALUES( %s )";
234     char *query;
235     UINT sz, r;
236
237     sz = strlen(values) + sizeof insert;
238     query = HeapAlloc(GetProcessHeap(),0,sz);
239     sprintf(query,insert,values);
240     r = run_query( hdb, query );
241     HeapFree(GetProcessHeap(), 0, query);
242     return r;
243 }
244
245 static UINT add_signature_entry( MSIHANDLE hdb, const char *values )
246 {
247     char insert[] = "INSERT INTO `Signature` "
248             "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
249             " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
250             "VALUES( %s )";
251     char *query;
252     UINT sz, r;
253
254     sz = strlen(values) + sizeof insert;
255     query = HeapAlloc(GetProcessHeap(),0,sz);
256     sprintf(query,insert,values);
257     r = run_query( hdb, query );
258     HeapFree(GetProcessHeap(), 0, query);
259     return r;
260 }
261
262 static UINT set_summary_info(MSIHANDLE hdb)
263 {
264     UINT res;
265     MSIHANDLE suminfo;
266
267     /* build summmary info */
268     res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
269     ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
270
271     res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
272                         "Installation Database");
273     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
274
275     res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
276                         "Installation Database");
277     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
278
279     res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
280                         "Wine Hackers");
281     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
282
283     res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
284                     ";1033");
285     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
286
287     res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
288                     "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
289     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
290
291     res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
292     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
293
294     res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
295     ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
296
297     res = MsiSummaryInfoPersist(suminfo);
298     ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
299
300     res = MsiCloseHandle( suminfo);
301     ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
302
303     return res;
304 }
305
306
307 static MSIHANDLE create_package_db(void)
308 {
309     MSIHANDLE hdb = 0;
310     UINT res;
311
312     DeleteFile(msifile);
313
314     /* create an empty database */
315     res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
316     ok( res == ERROR_SUCCESS , "Failed to create database\n" );
317     if( res != ERROR_SUCCESS )
318         return hdb;
319
320     res = MsiDatabaseCommit( hdb );
321     ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
322
323     res = set_summary_info(hdb);
324
325     res = run_query( hdb,
326             "CREATE TABLE `Directory` ( "
327             "`Directory` CHAR(255) NOT NULL, "
328             "`Directory_Parent` CHAR(255), "
329             "`DefaultDir` CHAR(255) NOT NULL "
330             "PRIMARY KEY `Directory`)" );
331     ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
332
333     return hdb;
334 }
335
336 static MSIHANDLE package_from_db(MSIHANDLE hdb)
337 {
338     UINT res;
339     CHAR szPackage[10];
340     MSIHANDLE hPackage;
341
342     sprintf(szPackage,"#%li",hdb);
343     res = MsiOpenPackage(szPackage,&hPackage);
344     ok( res == ERROR_SUCCESS , "Failed to open package\n" );
345
346     res = MsiCloseHandle(hdb);
347     ok( res == ERROR_SUCCESS , "Failed to close db handle\n" );
348
349     return hPackage;
350 }
351
352 static void create_test_file(const CHAR *name)
353 {
354     HANDLE file;
355     DWORD written;
356
357     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
358     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
359     WriteFile(file, name, strlen(name), &written, NULL);
360     WriteFile(file, "\n", strlen("\n"), &written, NULL);
361     CloseHandle(file);
362 }
363
364 static void test_createpackage(void)
365 {
366     MSIHANDLE hPackage = 0;
367     UINT res;
368
369     hPackage = package_from_db(create_package_db());
370     ok( hPackage != 0, " Failed to create package\n");
371
372     res = MsiCloseHandle( hPackage);
373     ok( res == ERROR_SUCCESS , "Failed to close package\n" );
374     DeleteFile(msifile);
375 }
376
377 static void test_getsourcepath_bad( void )
378 {
379     static const char str[] = { 0 };
380     char buffer[0x80];
381     DWORD sz;
382     UINT r;
383
384     r = MsiGetSourcePath( -1, NULL, NULL, NULL );
385     ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
386
387     sz = 0;
388     r = MsiGetSourcePath( -1, NULL, buffer, &sz );
389     ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
390
391     sz = 0;
392     r = MsiGetSourcePath( -1, str, NULL, &sz );
393     ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
394
395     sz = 0;
396     r = MsiGetSourcePath( -1, str, NULL, NULL );
397     ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
398
399     sz = 0;
400     r = MsiGetSourcePath( -1, str, buffer, &sz );
401     ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
402 }
403
404 static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
405 {
406     char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
407     char *query;
408     UINT sz, r;
409
410     sz = strlen(values) + sizeof insert;
411     query = HeapAlloc(GetProcessHeap(),0,sz);
412     sprintf(query,insert,values);
413     r = run_query( hdb, query );
414     HeapFree(GetProcessHeap(), 0, query);
415     return r;
416 }
417
418 static void test_getsourcepath( void )
419 {
420     static const char str[] = { 0 };
421     char buffer[0x80];
422     DWORD sz;
423     UINT r;
424     MSIHANDLE hpkg, hdb;
425
426     hpkg = package_from_db(create_package_db());
427     ok( hpkg, "failed to create package\n");
428
429     sz = 0;
430     buffer[0] = 'x';
431     r = MsiGetSourcePath( hpkg, str, buffer, &sz );
432     ok( r == ERROR_DIRECTORY, "return value wrong\n");
433     ok( buffer[0] == 'x', "buffer modified\n");
434
435     sz = 1;
436     buffer[0] = 'x';
437     r = MsiGetSourcePath( hpkg, str, buffer, &sz );
438     ok( r == ERROR_DIRECTORY, "return value wrong\n");
439     ok( buffer[0] == 'x', "buffer modified\n");
440
441     MsiCloseHandle( hpkg );
442
443
444     /* another test but try create a directory this time */
445     hdb = create_package_db();
446     ok( hdb, "failed to create database\n");
447
448     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
449     ok( r == S_OK, "failed\n");
450
451     hpkg = package_from_db(hdb);
452     ok( hpkg, "failed to create package\n");
453
454     sz = sizeof buffer -1;
455     strcpy(buffer,"x bad");
456     r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
457     ok( r == ERROR_DIRECTORY, "return value wrong\n");
458
459     r = MsiDoAction( hpkg, "CostInitialize");
460     ok( r == ERROR_SUCCESS, "cost init failed\n");
461     r = MsiDoAction( hpkg, "CostFinalize");
462     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
463
464     sz = sizeof buffer -1;
465     buffer[0] = 'x';
466     r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
467     ok( r == ERROR_SUCCESS, "return value wrong\n");
468     ok( sz == strlen(buffer), "returned length wrong\n");
469
470     sz = 0;
471     strcpy(buffer,"x bad");
472     r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
473     ok( r == ERROR_MORE_DATA, "return value wrong\n");
474     ok( buffer[0] == 'x', "buffer modified\n");
475
476     r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, NULL );
477     ok( r == ERROR_SUCCESS, "return value wrong\n");
478
479     r = MsiGetSourcePath( hpkg, "TARGETDIR ", NULL, NULL );
480     ok( r == ERROR_DIRECTORY, "return value wrong\n");
481
482     r = MsiGetSourcePath( hpkg, "targetdir", NULL, NULL );
483     ok( r == ERROR_DIRECTORY, "return value wrong\n");
484
485     r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, NULL );
486     ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
487
488     r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, &sz );
489     ok( r == ERROR_SUCCESS, "return value wrong\n");
490
491     MsiCloseHandle( hpkg );
492     DeleteFile(msifile);
493 }
494
495 static void test_doaction( void )
496 {
497     MSIHANDLE hpkg;
498     UINT r;
499
500     r = MsiDoAction( -1, NULL );
501     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
502
503     hpkg = package_from_db(create_package_db());
504     ok( hpkg, "failed to create package\n");
505
506     r = MsiDoAction(hpkg, NULL);
507     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
508
509     r = MsiDoAction(0, "boo");
510     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
511
512     r = MsiDoAction(hpkg, "boo");
513     ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
514
515     MsiCloseHandle( hpkg );
516     DeleteFile(msifile);
517 }
518
519 static void test_gettargetpath_bad(void)
520 {
521     char buffer[0x80];
522     MSIHANDLE hpkg;
523     DWORD sz;
524     UINT r;
525
526     hpkg = package_from_db(create_package_db());
527     ok( hpkg, "failed to create package\n");
528
529     r = MsiGetTargetPath( 0, NULL, NULL, NULL );
530     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
531
532     r = MsiGetTargetPath( 0, NULL, NULL, &sz );
533     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
534
535     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
536     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
537
538     r = MsiGetTargetPath( 0, "boo", NULL, NULL );
539     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
540
541     r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
542     ok( r == ERROR_DIRECTORY, "wrong return val\n");
543
544     r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
545     ok( r == ERROR_DIRECTORY, "wrong return val\n");
546
547     MsiCloseHandle( hpkg );
548     DeleteFile(msifile);
549 }
550
551 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
552 {
553     UINT r;
554     DWORD size;
555     MSIHANDLE rec;
556
557     rec = MsiCreateRecord( 1 );
558     ok(rec, "MsiCreate record failed\n");
559
560     r = MsiRecordSetString( rec, 0, file );
561     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
562
563     size = MAX_PATH;
564     r = MsiFormatRecord( hpkg, rec, buff, &size );
565     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
566
567     MsiCloseHandle( rec );
568 }
569
570 static void test_settargetpath(void)
571 {
572     char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
573     DWORD sz;
574     MSIHANDLE hpkg;
575     UINT r;
576     MSIHANDLE hdb;
577
578     hdb = create_package_db();
579     ok ( hdb, "failed to create package database\n" );
580
581     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
582     ok( r == S_OK, "failed to add directory entry: %d\n" , r );
583
584     r = create_component_table( hdb );
585     ok( r == S_OK, "cannot create Component table: %d\n", r );
586
587     r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
588     ok( r == S_OK, "cannot add dummy component: %d\n", r );
589
590     r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
591     ok( r == S_OK, "cannot add test component: %d\n", r );
592
593     r = create_feature_table( hdb );
594     ok( r == S_OK, "cannot create Feature table: %d\n", r );
595
596     r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
597     ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
598
599     r = create_feature_components_table( hdb );
600     ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
601
602     r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
603     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
604
605     r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
606     ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
607
608     add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
609     add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
610
611     r = create_file_table( hdb );
612     ok( r == S_OK, "cannot create File table: %d\n", r );
613
614     r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
615     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
616
617     r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
618     ok( r == S_OK, "cannot add file to the File table: %d\n", r );
619
620     hpkg = package_from_db( hdb );
621     ok( hpkg, "failed to create package\n");
622
623     r = MsiDoAction( hpkg, "CostInitialize");
624     ok( r == ERROR_SUCCESS, "cost init failed\n");
625
626     r = MsiDoAction( hpkg, "FileCost");
627     ok( r == ERROR_SUCCESS, "file cost failed\n");
628
629     r = MsiDoAction( hpkg, "CostFinalize");
630     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
631
632     r = MsiSetTargetPath( 0, NULL, NULL );
633     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
634
635     r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
636     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
637
638     r = MsiSetTargetPath( hpkg, "boo", NULL );
639     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
640
641     r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
642     ok( r == ERROR_DIRECTORY, "wrong return val\n");
643
644     sz = sizeof tempdir - 1;
645     r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
646     sprintf( file, "%srootfile.txt", tempdir );
647     query_file_path( hpkg, "[#RootFile]", buffer );
648     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
649     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
650
651     GetTempFileName( tempdir, "_wt", 0, buffer );
652     sprintf( tempdir, "%s\\subdir", buffer );
653
654     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
655     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on file returned %d\n", r );
656
657     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
658     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
659
660     DeleteFile( buffer );
661
662     r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
663     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
664
665     r = GetFileAttributes( buffer );
666     ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
667
668     r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
669     ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
670
671     sz = sizeof buffer - 1;
672     lstrcat( tempdir, "\\" );
673     r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
674     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
675     ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
676
677     sprintf( file, "%srootfile.txt", tempdir );
678     query_file_path( hpkg, "[#RootFile]", buffer );
679     ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
680
681     r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
682     ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
683
684     query_file_path( hpkg, "[#TestFile]", buffer );
685     ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
686         "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
687
688     sz = sizeof buffer - 1;
689     r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
690     ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
691     ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
692
693     MsiCloseHandle( hpkg );
694 }
695
696 static void test_condition(void)
697 {
698     MSICONDITION r;
699     MSIHANDLE hpkg;
700
701     hpkg = package_from_db(create_package_db());
702     ok( hpkg, "failed to create package\n");
703
704     r = MsiEvaluateCondition(0, NULL);
705     ok( r == MSICONDITION_ERROR, "wrong return val\n");
706
707     r = MsiEvaluateCondition(hpkg, NULL);
708     ok( r == MSICONDITION_NONE, "wrong return val\n");
709
710     r = MsiEvaluateCondition(hpkg, "");
711     ok( r == MSICONDITION_NONE, "wrong return val\n");
712
713     r = MsiEvaluateCondition(hpkg, "1");
714     ok( r == MSICONDITION_TRUE, "wrong return val\n");
715
716     r = MsiEvaluateCondition(hpkg, "0");
717     ok( r == MSICONDITION_FALSE, "wrong return val\n");
718
719     r = MsiEvaluateCondition(hpkg, "0 = 0");
720     ok( r == MSICONDITION_TRUE, "wrong return val\n");
721
722     r = MsiEvaluateCondition(hpkg, "0 <> 0");
723     ok( r == MSICONDITION_FALSE, "wrong return val\n");
724
725     r = MsiEvaluateCondition(hpkg, "0 = 1");
726     ok( r == MSICONDITION_FALSE, "wrong return val\n");
727
728     r = MsiEvaluateCondition(hpkg, "0 > 1");
729     ok( r == MSICONDITION_FALSE, "wrong return val\n");
730
731     r = MsiEvaluateCondition(hpkg, "0 ~> 1");
732     ok( r == MSICONDITION_FALSE, "wrong return val\n");
733
734     r = MsiEvaluateCondition(hpkg, "1 > 1");
735     ok( r == MSICONDITION_FALSE, "wrong return val\n");
736
737     r = MsiEvaluateCondition(hpkg, "1 ~> 1");
738     ok( r == MSICONDITION_FALSE, "wrong return val\n");
739
740     r = MsiEvaluateCondition(hpkg, "0 >= 1");
741     ok( r == MSICONDITION_FALSE, "wrong return val\n");
742
743     r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
744     ok( r == MSICONDITION_FALSE, "wrong return val\n");
745
746     r = MsiEvaluateCondition(hpkg, "1 >= 1");
747     ok( r == MSICONDITION_TRUE, "wrong return val\n");
748
749     r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
750     ok( r == MSICONDITION_TRUE, "wrong return val\n");
751
752     r = MsiEvaluateCondition(hpkg, "0 < 1");
753     ok( r == MSICONDITION_TRUE, "wrong return val\n");
754
755     r = MsiEvaluateCondition(hpkg, "0 ~< 1");
756     ok( r == MSICONDITION_TRUE, "wrong return val\n");
757
758     r = MsiEvaluateCondition(hpkg, "1 < 1");
759     ok( r == MSICONDITION_FALSE, "wrong return val\n");
760
761     r = MsiEvaluateCondition(hpkg, "1 ~< 1");
762     ok( r == MSICONDITION_FALSE, "wrong return val\n");
763
764     r = MsiEvaluateCondition(hpkg, "0 <= 1");
765     ok( r == MSICONDITION_TRUE, "wrong return val\n");
766
767     r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
768     ok( r == MSICONDITION_TRUE, "wrong return val\n");
769
770     r = MsiEvaluateCondition(hpkg, "1 <= 1");
771     ok( r == MSICONDITION_TRUE, "wrong return val\n");
772
773     r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
774     ok( r == MSICONDITION_TRUE, "wrong return val\n");
775
776     r = MsiEvaluateCondition(hpkg, "0 >=");
777     ok( r == MSICONDITION_ERROR, "wrong return val\n");
778
779     r = MsiEvaluateCondition(hpkg, " ");
780     ok( r == MSICONDITION_NONE, "wrong return val\n");
781
782     r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
783     ok( r == MSICONDITION_TRUE, "wrong return val\n");
784
785     r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
786     ok( r == MSICONDITION_TRUE, "wrong return val\n");
787
788     r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
789     ok( r == MSICONDITION_FALSE, "wrong return val\n");
790
791     r = MsiEvaluateCondition(hpkg, "not 0");
792     ok( r == MSICONDITION_TRUE, "wrong return val\n");
793
794     r = MsiEvaluateCondition(hpkg, "not LicView");
795     ok( r == MSICONDITION_TRUE, "wrong return val\n");
796
797     r = MsiEvaluateCondition(hpkg, "not \"A\"");
798     ok( r == MSICONDITION_FALSE, "wrong return val\n");
799
800     r = MsiEvaluateCondition(hpkg, "~not \"A\"");
801     ok( r == MSICONDITION_ERROR, "wrong return val\n");
802
803     r = MsiEvaluateCondition(hpkg, "\"0\"");
804     ok( r == MSICONDITION_TRUE, "wrong return val\n");
805
806     r = MsiEvaluateCondition(hpkg, "1 and 2");
807     ok( r == MSICONDITION_TRUE, "wrong return val\n");
808
809     r = MsiEvaluateCondition(hpkg, "not 0 and 3");
810     ok( r == MSICONDITION_TRUE, "wrong return val\n");
811
812     r = MsiEvaluateCondition(hpkg, "not 0 and 0");
813     ok( r == MSICONDITION_FALSE, "wrong return val\n");
814
815     r = MsiEvaluateCondition(hpkg, "not 0 or 1");
816     ok( r == MSICONDITION_TRUE, "wrong return val\n");
817
818     r = MsiEvaluateCondition(hpkg, "(0)");
819     ok( r == MSICONDITION_FALSE, "wrong return val\n");
820
821     r = MsiEvaluateCondition(hpkg, "(((((1))))))");
822     ok( r == MSICONDITION_ERROR, "wrong return val\n");
823
824     r = MsiEvaluateCondition(hpkg, "(((((1)))))");
825     ok( r == MSICONDITION_TRUE, "wrong return val\n");
826
827     r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
828     ok( r == MSICONDITION_TRUE, "wrong return val\n");
829
830     r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
831     ok( r == MSICONDITION_FALSE, "wrong return val\n");
832
833     r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
834     ok( r == MSICONDITION_FALSE, "wrong return val\n");
835
836     r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
837     ok( r == MSICONDITION_TRUE, "wrong return val\n");
838
839     r = MsiEvaluateCondition(hpkg, "0 < > 0");
840     ok( r == MSICONDITION_ERROR, "wrong return val\n");
841
842     r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
843     ok( r == MSICONDITION_ERROR, "wrong return val\n");
844
845     r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
846     ok( r == MSICONDITION_FALSE, "wrong return val\n");
847
848     r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
849     ok( r == MSICONDITION_ERROR, "wrong return val\n");
850
851     r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
852     ok( r == MSICONDITION_TRUE, "wrong return val\n");
853
854     r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
855     ok( r == MSICONDITION_FALSE, "wrong return val\n");
856
857     r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
858     ok( r == MSICONDITION_FALSE, "wrong return val\n");
859
860     r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
861     ok( r == MSICONDITION_TRUE, "wrong return val\n");
862
863     r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
864     ok( r == MSICONDITION_FALSE, "wrong return val\n");
865
866     r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
867     ok( r == MSICONDITION_FALSE, "wrong return val\n");
868
869     r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
870     ok( r == MSICONDITION_FALSE, "wrong return val\n");
871
872     r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
873     ok( r == MSICONDITION_FALSE, "wrong return val\n");
874
875     r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
876     ok( r == MSICONDITION_FALSE, "wrong return val\n");
877
878     r = MsiEvaluateCondition(hpkg, "1 XOR 1");
879     ok( r == MSICONDITION_FALSE, "wrong return val\n");
880
881     r = MsiEvaluateCondition(hpkg, "1 IMP 1");
882     ok( r == MSICONDITION_TRUE, "wrong return val\n");
883
884     r = MsiEvaluateCondition(hpkg, "1 IMP 0");
885     ok( r == MSICONDITION_FALSE, "wrong return val\n");
886
887     r = MsiEvaluateCondition(hpkg, "0 IMP 0");
888     ok( r == MSICONDITION_TRUE, "wrong return val\n");
889
890     r = MsiEvaluateCondition(hpkg, "0 EQV 0");
891     ok( r == MSICONDITION_TRUE, "wrong return val\n");
892
893     r = MsiEvaluateCondition(hpkg, "0 EQV 1");
894     ok( r == MSICONDITION_FALSE, "wrong return val\n");
895
896     r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
897     ok( r == MSICONDITION_TRUE, "wrong return val\n");
898
899     r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
900     ok( r == MSICONDITION_ERROR, "wrong return val\n");
901
902     r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
903     ok( r == MSICONDITION_TRUE, "wrong return val\n");
904
905     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
906     ok( r == MSICONDITION_TRUE, "wrong return val\n");
907
908     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
909     ok( r == MSICONDITION_TRUE, "wrong return val\n");
910
911     r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
912     ok( r == MSICONDITION_FALSE, "wrong return val\n");
913
914     MsiSetProperty(hpkg, "mm", "5" );
915
916     r = MsiEvaluateCondition(hpkg, "mm = 5");
917     ok( r == MSICONDITION_TRUE, "wrong return val\n");
918
919     r = MsiEvaluateCondition(hpkg, "mm < 6");
920     ok( r == MSICONDITION_TRUE, "wrong return val\n");
921
922     r = MsiEvaluateCondition(hpkg, "mm <= 5");
923     ok( r == MSICONDITION_TRUE, "wrong return val\n");
924
925     r = MsiEvaluateCondition(hpkg, "mm > 4");
926     ok( r == MSICONDITION_TRUE, "wrong return val\n");
927
928     r = MsiEvaluateCondition(hpkg, "mm < 12");
929     ok( r == MSICONDITION_TRUE, "wrong return val\n");
930
931     r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
932     ok( r == MSICONDITION_TRUE, "wrong return val\n");
933
934     r = MsiEvaluateCondition(hpkg, "0 = \"\"");
935     ok( r == MSICONDITION_FALSE, "wrong return val\n");
936
937     r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
938     ok( r == MSICONDITION_FALSE, "wrong return val\n");
939
940     r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
941     ok( r == MSICONDITION_FALSE, "wrong return val\n");
942
943     r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
944     ok( r == MSICONDITION_TRUE, "wrong return val\n");
945
946     r = MsiEvaluateCondition(hpkg, "3 >< 1");
947     ok( r == MSICONDITION_TRUE, "wrong return val\n");
948
949     r = MsiEvaluateCondition(hpkg, "3 >< 4");
950     ok( r == MSICONDITION_FALSE, "wrong return val\n");
951
952     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
953     ok( r == MSICONDITION_FALSE, "wrong return val\n");
954
955     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
956     ok( r == MSICONDITION_TRUE, "wrong return val\n");
957
958     r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
959     ok( r == MSICONDITION_FALSE, "wrong return val\n");
960
961     r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
962     ok( r == MSICONDITION_TRUE, "wrong return val\n");
963
964     r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
965     ok( r == MSICONDITION_TRUE, "wrong return val\n");
966
967     r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
968     ok( r == MSICONDITION_TRUE, "wrong return val\n");
969
970     r = MsiEvaluateCondition(hpkg, "_1 = _1");
971     ok( r == MSICONDITION_TRUE, "wrong return val\n");
972
973     r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
974     ok( r == MSICONDITION_ERROR, "wrong return val\n");
975
976     r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
977     ok( r == MSICONDITION_FALSE, "wrong return val\n");
978
979     r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
980     ok( r == MSICONDITION_FALSE, "wrong return val\n");
981
982     r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
983     ok( r == MSICONDITION_FALSE, "wrong return val\n");
984
985     r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
986     ok( r == MSICONDITION_FALSE, "wrong return val\n");
987
988     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
989     ok( r == MSICONDITION_FALSE, "wrong return val\n");
990
991     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
992     ok( r == MSICONDITION_TRUE, "wrong return val\n");
993
994     r = MsiEvaluateCondition(hpkg, "bandalmael<0");
995     ok( r == MSICONDITION_FALSE, "wrong return val\n");
996
997     r = MsiEvaluateCondition(hpkg, "bandalmael>0");
998     ok( r == MSICONDITION_FALSE, "wrong return val\n");
999
1000     r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1001     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1002
1003     r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1004     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1005
1006     r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1007     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1008
1009     MsiSetProperty(hpkg, "bandalmael", "0" );
1010     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1011     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1012
1013     MsiSetProperty(hpkg, "bandalmael", "" );
1014     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1015     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1016
1017     MsiSetProperty(hpkg, "bandalmael", "asdf" );
1018     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1019     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1020
1021     MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1022     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1023     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1024
1025     MsiSetProperty(hpkg, "bandalmael", "0 " );
1026     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1027     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1028
1029     MsiSetProperty(hpkg, "bandalmael", "-0" );
1030     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1031     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1032
1033     MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1034     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1035     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1036
1037     MsiSetProperty(hpkg, "bandalmael", "--0" );
1038     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1039     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1040
1041     MsiSetProperty(hpkg, "bandalmael", "0x00" );
1042     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1043     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1044
1045     MsiSetProperty(hpkg, "bandalmael", "-" );
1046     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1047     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1048
1049     MsiSetProperty(hpkg, "bandalmael", "+0" );
1050     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1051     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1052
1053     MsiSetProperty(hpkg, "bandalmael", "0.0" );
1054     r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1055     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1056     r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1057     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1058
1059     MsiSetProperty(hpkg, "one", "hi");
1060     MsiSetProperty(hpkg, "two", "hithere");
1061     r = MsiEvaluateCondition(hpkg, "one >< two");
1062     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1063
1064     MsiSetProperty(hpkg, "one", "hithere");
1065     MsiSetProperty(hpkg, "two", "hi");
1066     r = MsiEvaluateCondition(hpkg, "one >< two");
1067     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1068
1069     MsiSetProperty(hpkg, "one", "hello");
1070     MsiSetProperty(hpkg, "two", "hi");
1071     r = MsiEvaluateCondition(hpkg, "one >< two");
1072     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1073
1074     MsiSetProperty(hpkg, "one", "hellohithere");
1075     MsiSetProperty(hpkg, "two", "hi");
1076     r = MsiEvaluateCondition(hpkg, "one >< two");
1077     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1078
1079     MsiSetProperty(hpkg, "one", "");
1080     MsiSetProperty(hpkg, "two", "hi");
1081     r = MsiEvaluateCondition(hpkg, "one >< two");
1082     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1083
1084     MsiSetProperty(hpkg, "one", "hi");
1085     MsiSetProperty(hpkg, "two", "");
1086     r = MsiEvaluateCondition(hpkg, "one >< two");
1087     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1088
1089     MsiSetProperty(hpkg, "one", "");
1090     MsiSetProperty(hpkg, "two", "");
1091     r = MsiEvaluateCondition(hpkg, "one >< two");
1092     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1093
1094     MsiSetProperty(hpkg, "one", "1234");
1095     MsiSetProperty(hpkg, "two", "1");
1096     r = MsiEvaluateCondition(hpkg, "one >< two");
1097     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1098
1099     MsiSetProperty(hpkg, "one", "one 1234");
1100     MsiSetProperty(hpkg, "two", "1");
1101     r = MsiEvaluateCondition(hpkg, "one >< two");
1102     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1103
1104     MsiSetProperty(hpkg, "one", "hithere");
1105     MsiSetProperty(hpkg, "two", "hi");
1106     r = MsiEvaluateCondition(hpkg, "one << two");
1107     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1108
1109     MsiSetProperty(hpkg, "one", "hi");
1110     MsiSetProperty(hpkg, "two", "hithere");
1111     r = MsiEvaluateCondition(hpkg, "one << two");
1112     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1113
1114     MsiSetProperty(hpkg, "one", "hi");
1115     MsiSetProperty(hpkg, "two", "hi");
1116     r = MsiEvaluateCondition(hpkg, "one << two");
1117     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1118
1119     MsiSetProperty(hpkg, "one", "abcdhithere");
1120     MsiSetProperty(hpkg, "two", "hi");
1121     r = MsiEvaluateCondition(hpkg, "one << two");
1122     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1123
1124     MsiSetProperty(hpkg, "one", "");
1125     MsiSetProperty(hpkg, "two", "hi");
1126     r = MsiEvaluateCondition(hpkg, "one << two");
1127     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1128
1129     MsiSetProperty(hpkg, "one", "hithere");
1130     MsiSetProperty(hpkg, "two", "");
1131     r = MsiEvaluateCondition(hpkg, "one << two");
1132     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1133
1134     MsiSetProperty(hpkg, "one", "");
1135     MsiSetProperty(hpkg, "two", "");
1136     r = MsiEvaluateCondition(hpkg, "one << two");
1137     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1138
1139     MsiSetProperty(hpkg, "one", "1234");
1140     MsiSetProperty(hpkg, "two", "1");
1141     r = MsiEvaluateCondition(hpkg, "one << two");
1142     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1143
1144     MsiSetProperty(hpkg, "one", "1234 one");
1145     MsiSetProperty(hpkg, "two", "1");
1146     r = MsiEvaluateCondition(hpkg, "one << two");
1147     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1148
1149     MsiSetProperty(hpkg, "one", "hithere");
1150     MsiSetProperty(hpkg, "two", "there");
1151     r = MsiEvaluateCondition(hpkg, "one >> two");
1152     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1153
1154     MsiSetProperty(hpkg, "one", "hithere");
1155     MsiSetProperty(hpkg, "two", "hi");
1156     r = MsiEvaluateCondition(hpkg, "one >> two");
1157     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1158
1159     MsiSetProperty(hpkg, "one", "there");
1160     MsiSetProperty(hpkg, "two", "hithere");
1161     r = MsiEvaluateCondition(hpkg, "one >> two");
1162     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1163
1164     MsiSetProperty(hpkg, "one", "there");
1165     MsiSetProperty(hpkg, "two", "there");
1166     r = MsiEvaluateCondition(hpkg, "one >> two");
1167     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1168
1169     MsiSetProperty(hpkg, "one", "abcdhithere");
1170     MsiSetProperty(hpkg, "two", "hi");
1171     r = MsiEvaluateCondition(hpkg, "one >> two");
1172     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1173
1174     MsiSetProperty(hpkg, "one", "");
1175     MsiSetProperty(hpkg, "two", "there");
1176     r = MsiEvaluateCondition(hpkg, "one >> two");
1177     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1178
1179     MsiSetProperty(hpkg, "one", "there");
1180     MsiSetProperty(hpkg, "two", "");
1181     r = MsiEvaluateCondition(hpkg, "one >> two");
1182     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1183
1184     MsiSetProperty(hpkg, "one", "");
1185     MsiSetProperty(hpkg, "two", "");
1186     r = MsiEvaluateCondition(hpkg, "one >> two");
1187     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1188
1189     MsiSetProperty(hpkg, "one", "1234");
1190     MsiSetProperty(hpkg, "two", "4");
1191     r = MsiEvaluateCondition(hpkg, "one >> two");
1192     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1193
1194     MsiSetProperty(hpkg, "one", "one 1234");
1195     MsiSetProperty(hpkg, "two", "4");
1196     r = MsiEvaluateCondition(hpkg, "one >> two");
1197     ok( r == MSICONDITION_TRUE, "wrong return val\n");
1198
1199     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1200     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1201
1202     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1203     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1204
1205     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1206     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1207
1208     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1209     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1210
1211     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1212     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1213
1214     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1215     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1216
1217     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1218     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1219
1220     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1221     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1222
1223     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1224     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1225
1226     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1227     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1228
1229     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1230     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1231
1232     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1233     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1234
1235     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1236     ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1237
1238     r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1239     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1240
1241     r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1242     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1243
1244     r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1245     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1246
1247     r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1248     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1249
1250     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1251     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1252
1253     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1254     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1255
1256     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1257     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1258
1259     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1260     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1261
1262     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1263     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1264
1265     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1266     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1267
1268     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1269     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1270
1271     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1272     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1273
1274     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1275     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1276
1277     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1278     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1279
1280     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1281     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1282
1283     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1284     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1285
1286     todo_wine {
1287     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1288     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1289
1290     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1291     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1292
1293     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1294     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1295
1296     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1297     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1298
1299     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1300     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1301     }
1302
1303     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1304     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1305
1306     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1307     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1308
1309     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1310     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1311
1312     MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1313     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1314     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1315
1316     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1317     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1318
1319     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1320     ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1321
1322     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1323     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1324
1325     r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1326     ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1327
1328     MsiSetProperty(hpkg, "one", "1");
1329     r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1330     ok( r == MSICONDITION_FALSE, "wrong return val\n");
1331
1332     MsiCloseHandle( hpkg );
1333     DeleteFile(msifile);
1334 }
1335
1336 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1337 {
1338     UINT r;
1339     DWORD sz;
1340     char buffer[2];
1341
1342     sz = sizeof buffer;
1343     strcpy(buffer,"x");
1344     r = MsiGetProperty( hpkg, prop, buffer, &sz );
1345     return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1346 }
1347
1348 static void test_props(void)
1349 {
1350     MSIHANDLE hpkg;
1351     UINT r;
1352     DWORD sz;
1353     char buffer[0x100];
1354
1355     hpkg = package_from_db(create_package_db());
1356     ok( hpkg, "failed to create package\n");
1357
1358     /* test invalid values */
1359     r = MsiGetProperty( 0, NULL, NULL, NULL );
1360     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1361
1362     r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1363     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1364
1365     r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1366     ok( r == ERROR_SUCCESS, "wrong return val\n");
1367
1368     r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1369     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1370
1371     /* test retrieving an empty/nonexistent property */
1372     sz = sizeof buffer;
1373     r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1374     ok( r == ERROR_SUCCESS, "wrong return val\n");
1375     ok( sz == 0, "wrong size returned\n");
1376
1377     check_prop_empty( hpkg, "boo");
1378     sz = 0;
1379     strcpy(buffer,"x");
1380     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1381     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1382     ok( !strcmp(buffer,"x"), "buffer was changed\n");
1383     ok( sz == 0, "wrong size returned\n");
1384
1385     sz = 1;
1386     strcpy(buffer,"x");
1387     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1388     ok( r == ERROR_SUCCESS, "wrong return val\n");
1389     ok( buffer[0] == 0, "buffer was not changed\n");
1390     ok( sz == 0, "wrong size returned\n");
1391
1392     /* set the property to something */
1393     r = MsiSetProperty( 0, NULL, NULL );
1394     ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1395
1396     r = MsiSetProperty( hpkg, NULL, NULL );
1397     ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1398
1399     r = MsiSetProperty( hpkg, "", NULL );
1400     ok( r == ERROR_SUCCESS, "wrong return val\n");
1401
1402     /* try set and get some illegal property identifiers */
1403     r = MsiSetProperty( hpkg, "", "asdf" );
1404     ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1405
1406     r = MsiSetProperty( hpkg, "=", "asdf" );
1407     ok( r == ERROR_SUCCESS, "wrong return val\n");
1408
1409     r = MsiSetProperty( hpkg, " ", "asdf" );
1410     ok( r == ERROR_SUCCESS, "wrong return val\n");
1411
1412     r = MsiSetProperty( hpkg, "'", "asdf" );
1413     ok( r == ERROR_SUCCESS, "wrong return val\n");
1414
1415     sz = sizeof buffer;
1416     buffer[0]=0;
1417     r = MsiGetProperty( hpkg, "'", buffer, &sz );
1418     ok( r == ERROR_SUCCESS, "wrong return val\n");
1419     ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1420
1421     /* set empty values */
1422     r = MsiSetProperty( hpkg, "boo", NULL );
1423     ok( r == ERROR_SUCCESS, "wrong return val\n");
1424     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1425
1426     r = MsiSetProperty( hpkg, "boo", "" );
1427     ok( r == ERROR_SUCCESS, "wrong return val\n");
1428     ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1429
1430     /* set a non-empty value */
1431     r = MsiSetProperty( hpkg, "boo", "xyz" );
1432     ok( r == ERROR_SUCCESS, "wrong return val\n");
1433
1434     sz = 1;
1435     strcpy(buffer,"x");
1436     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1437     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1438     ok( buffer[0] == 0, "buffer was not changed\n");
1439     ok( sz == 3, "wrong size returned\n");
1440
1441     sz = 4;
1442     strcpy(buffer,"x");
1443     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1444     ok( r == ERROR_SUCCESS, "wrong return val\n");
1445     ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1446     ok( sz == 3, "wrong size returned\n");
1447
1448     sz = 3;
1449     strcpy(buffer,"x");
1450     r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1451     ok( r == ERROR_MORE_DATA, "wrong return val\n");
1452     ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1453     ok( sz == 3, "wrong size returned\n");
1454
1455     r = MsiSetProperty(hpkg, "SourceDir", "foo");
1456     ok( r == ERROR_SUCCESS, "wrong return val\n");
1457
1458     sz = 4;
1459     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1460     ok( r == ERROR_SUCCESS, "wrong return val\n");
1461     ok( !strcmp(buffer,""), "buffer wrong\n");
1462     ok( sz == 0, "wrong size returned\n");
1463
1464     sz = 4;
1465     r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1466     ok( r == ERROR_SUCCESS, "wrong return val\n");
1467     ok( !strcmp(buffer,""), "buffer wrong\n");
1468     ok( sz == 0, "wrong size returned\n");
1469
1470     sz = 4;
1471     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1472     ok( r == ERROR_SUCCESS, "wrong return val\n");
1473     ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1474     ok( sz == 3, "wrong size returned\n");
1475
1476     MsiCloseHandle( hpkg );
1477     DeleteFile(msifile);
1478 }
1479
1480 static void test_properties_table(void)
1481 {
1482     const char *query;
1483     UINT r;
1484     MSIHANDLE hpkg, hdb;
1485     char buffer[0x10];
1486     DWORD sz;
1487
1488     hdb = create_package_db();
1489     ok( hdb, "failed to create package\n");
1490
1491     hpkg = package_from_db(hdb);
1492     ok( hpkg, "failed to create package\n");
1493
1494     query = "CREATE TABLE `_Properties` ( "
1495         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1496     r = run_query(hdb, query);
1497     ok(r == ERROR_INVALID_HANDLE, "failed to create table\n");
1498
1499     MsiCloseHandle( hpkg );
1500     DeleteFile(msifile);
1501
1502     hdb = create_package_db();
1503     ok( hdb, "failed to create package\n");
1504
1505     query = "CREATE TABLE `_Properties` ( "
1506         "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1507     r = run_query(hdb, query);
1508     ok(r == ERROR_SUCCESS, "failed to create table\n");
1509
1510     query = "ALTER `_Properties` ADD `foo` INTEGER";
1511     r = run_query(hdb, query);
1512     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1513
1514     query = "ALTER TABLE `_Properties` ADD `foo` INTEGER";
1515     r = run_query(hdb, query);
1516     ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1517
1518     query = "ALTER TABLE `_Properties` ADD `extra` INTEGER";
1519     r = run_query(hdb, query);
1520     todo_wine ok(r == ERROR_SUCCESS, "failed to add column\n");
1521
1522     hpkg = package_from_db(hdb);
1523     ok( hpkg, "failed to create package\n");
1524
1525     r = MsiSetProperty( hpkg, "foo", "bar");
1526     ok(r == ERROR_SUCCESS, "failed to create table\n");
1527
1528     sz = sizeof buffer;
1529     r = MsiGetProperty( hpkg, "foo", buffer, &sz);
1530     ok(r == ERROR_SUCCESS, "failed to create table\n");
1531
1532     MsiCloseHandle( hpkg );
1533     DeleteFile(msifile);
1534 }
1535
1536 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
1537 {
1538     MSIHANDLE htab = 0;
1539     UINT res;
1540
1541     res = MsiDatabaseOpenView( hdb, szQuery, &htab );
1542     if( res == ERROR_SUCCESS )
1543     {
1544         UINT r;
1545
1546         r = MsiViewExecute( htab, hrec );
1547         if( r != ERROR_SUCCESS )
1548         {
1549             res = r;
1550             fprintf(stderr,"MsiViewExecute failed %08x\n", res);
1551         }
1552
1553         r = MsiViewClose( htab );
1554         if( r != ERROR_SUCCESS )
1555             res = r;
1556
1557         r = MsiCloseHandle( htab );
1558         if( r != ERROR_SUCCESS )
1559             res = r;
1560     }
1561     return res;
1562 }
1563
1564 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
1565 {
1566     return try_query_param( hdb, szQuery, 0 );
1567 }
1568
1569 static void test_msipackage(void)
1570 {
1571     MSIHANDLE hdb = 0, hpack = 100;
1572     UINT r;
1573     const char *query;
1574     char name[10];
1575
1576     DeleteFile(msifile);
1577
1578     todo_wine {
1579     name[0] = 0;
1580     r = MsiOpenPackage(name, &hpack);
1581     ok(r == ERROR_SUCCESS, "failed to open package with no name\n");
1582     r = MsiCloseHandle(hpack);
1583     ok(r == ERROR_SUCCESS, "failed to close package\n");
1584     }
1585
1586     /* just MsiOpenDatabase should not create a file */
1587     r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
1588     ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
1589
1590     name[0]='#';
1591     name[1]=0;
1592     r = MsiOpenPackage(name, &hpack);
1593     ok(r == ERROR_INVALID_HANDLE, "MsiOpenPackage returned wrong code\n");
1594
1595     todo_wine {
1596     /* now try again with our empty database */
1597     sprintf(name, "#%ld", hdb);
1598     r = MsiOpenPackage(name, &hpack);
1599     ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1600     if (!r)    MsiCloseHandle(hpack);
1601     }
1602
1603     /* create a table */
1604     query = "CREATE TABLE `Property` ( "
1605             "`Property` CHAR(72), `Value` CHAR(0) "
1606             "PRIMARY KEY `Property`)";
1607     r = try_query(hdb, query);
1608     ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
1609
1610     query = "CREATE TABLE `InstallExecuteSequence` ("
1611             "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
1612             "PRIMARY KEY `Action`)";
1613     r = try_query(hdb, query);
1614     ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
1615
1616     todo_wine {
1617     sprintf(name, "#%ld", hdb);
1618     r = MsiOpenPackage(name, &hpack);
1619     ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1620     if (!r)    MsiCloseHandle(hpack);
1621     }
1622
1623     r = MsiCloseHandle(hdb);
1624     ok(r == ERROR_SUCCESS, "MsiCloseHandle(database) failed\n");
1625     DeleteFile(msifile);
1626 }
1627
1628 static void test_formatrecord2(void)
1629 {
1630     MSIHANDLE hpkg, hrec ;
1631     char buffer[0x100];
1632     DWORD sz;
1633     UINT r;
1634
1635     hpkg = package_from_db(create_package_db());
1636     ok( hpkg, "failed to create package\n");
1637
1638     r = MsiSetProperty(hpkg, "Manufacturer", " " );
1639     ok( r == ERROR_SUCCESS, "set property failed\n");
1640
1641     hrec = MsiCreateRecord(2);
1642     ok(hrec, "create record failed\n");
1643
1644     r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
1645     ok( r == ERROR_SUCCESS, "format record failed\n");
1646
1647     buffer[0] = 0;
1648     sz = sizeof buffer;
1649     r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
1650
1651     r = MsiRecordSetString(hrec, 0, "[foo][1]");
1652     r = MsiRecordSetString(hrec, 1, "hoo");
1653     sz = sizeof buffer;
1654     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1655     ok( sz == 3, "size wrong\n");
1656     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1657     ok( r == ERROR_SUCCESS, "format failed\n");
1658
1659     r = MsiRecordSetString(hrec, 0, "x[~]x");
1660     sz = sizeof buffer;
1661     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1662     ok( sz == 3, "size wrong\n");
1663     ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
1664     ok( r == ERROR_SUCCESS, "format failed\n");
1665
1666     r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
1667     r = MsiRecordSetString(hrec, 1, "hoo");
1668     sz = sizeof buffer;
1669     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1670     ok( sz == 3, "size wrong\n");
1671     ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1672     ok( r == ERROR_SUCCESS, "format failed\n");
1673
1674     r = MsiRecordSetString(hrec, 0, "[\\[]");
1675     sz = sizeof buffer;
1676     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1677     ok( sz == 1, "size wrong\n");
1678     ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
1679     ok( r == ERROR_SUCCESS, "format failed\n");
1680
1681     SetEnvironmentVariable("FOO", "BAR");
1682     r = MsiRecordSetString(hrec, 0, "[%FOO]");
1683     sz = sizeof buffer;
1684     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1685     ok( sz == 3, "size wrong\n");
1686     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1687     ok( r == ERROR_SUCCESS, "format failed\n");
1688
1689     r = MsiRecordSetString(hrec, 0, "[[1]]");
1690     r = MsiRecordSetString(hrec, 1, "%FOO");
1691     sz = sizeof buffer;
1692     r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1693     ok( sz == 3, "size wrong\n");
1694     ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1695     ok( r == ERROR_SUCCESS, "format failed\n");
1696
1697     MsiCloseHandle( hrec );
1698     MsiCloseHandle( hpkg );
1699     DeleteFile(msifile);
1700 }
1701
1702 static void test_states(void)
1703 {
1704     MSIHANDLE hpkg;
1705     UINT r;
1706     MSIHANDLE hdb;
1707     INSTALLSTATE state, action;
1708
1709     hdb = create_package_db();
1710     ok ( hdb, "failed to create package database\n" );
1711
1712     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
1713     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
1714
1715     r = create_feature_table( hdb );
1716     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
1717
1718     r = create_component_table( hdb );
1719     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
1720
1721     /* msidbFeatureAttributesFavorLocal */
1722     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
1723     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1724
1725     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
1726     r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
1727     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1728
1729     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
1730     r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
1731     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1732
1733     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
1734     r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
1735     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1736
1737     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
1738     r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
1739     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1740
1741     /* msidbFeatureAttributesFavorSource */
1742     r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
1743     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1744
1745     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
1746     r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
1747     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1748
1749     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1750     r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
1751     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1752
1753     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
1754     r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
1755     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1756
1757     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
1758     r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
1759     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1760
1761     /* msidbFeatureAttributesFavorSource */
1762     r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
1763     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1764
1765     /* msidbFeatureAttributesFavorLocal */
1766     r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
1767     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1768
1769     /* disabled */
1770     r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
1771     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1772
1773     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1774     r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
1775     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1776
1777     /* no feature parent:msidbComponentAttributesLocalOnly */
1778     r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
1779     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1780
1781     r = create_feature_components_table( hdb );
1782     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
1783
1784     r = add_feature_components_entry( hdb, "'one', 'alpha'" );
1785     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1786
1787     r = add_feature_components_entry( hdb, "'one', 'beta'" );
1788     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1789
1790     r = add_feature_components_entry( hdb, "'one', 'gamma'" );
1791     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1792
1793     r = add_feature_components_entry( hdb, "'one', 'theta'" );
1794     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1795
1796     r = add_feature_components_entry( hdb, "'two', 'delta'" );
1797     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1798
1799     r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
1800     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1801
1802     r = add_feature_components_entry( hdb, "'two', 'zeta'" );
1803     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1804
1805     r = add_feature_components_entry( hdb, "'two', 'iota'" );
1806     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1807
1808     r = add_feature_components_entry( hdb, "'three', 'eta'" );
1809     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1810
1811     r = add_feature_components_entry( hdb, "'four', 'eta'" );
1812     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1813
1814     r = add_feature_components_entry( hdb, "'five', 'eta'" );
1815     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
1816
1817     r = create_file_table( hdb );
1818     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
1819
1820     r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
1821     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1822
1823     r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
1824     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1825
1826     r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
1827     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1828
1829     r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
1830     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1831
1832     r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
1833     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1834
1835     r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
1836     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1837
1838     r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
1839     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1840
1841     r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
1842     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1843
1844     /* compressed file */
1845     r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
1846     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1847
1848     r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
1849     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
1850
1851     hpkg = package_from_db( hdb );
1852     ok( hpkg, "failed to create package\n");
1853
1854     MsiCloseHandle( hdb );
1855
1856     state = 0xdeadbee;
1857     action = 0xdeadbee;
1858     r = MsiGetFeatureState(hpkg, "one", &state, &action);
1859     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1860     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1861     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1862
1863     state = 0xdeadbee;
1864     action = 0xdeadbee;
1865     r = MsiGetFeatureState(hpkg, "two", &state, &action);
1866     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1867     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1868     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1869
1870     state = 0xdeadbee;
1871     action = 0xdeadbee;
1872     r = MsiGetFeatureState(hpkg, "three", &state, &action);
1873     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1874     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1875     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1876
1877     state = 0xdeadbee;
1878     action = 0xdeadbee;
1879     r = MsiGetFeatureState(hpkg, "four", &state, &action);
1880     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1881     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1882     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1883
1884     state = 0xdeadbee;
1885     action = 0xdeadbee;
1886     r = MsiGetFeatureState(hpkg, "five", &state, &action);
1887     ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
1888     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1889     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1890
1891     state = 0xdeadbee;
1892     action = 0xdeadbee;
1893     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
1894     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1895     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1896     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1897
1898     state = 0xdeadbee;
1899     action = 0xdeadbee;
1900     r = MsiGetComponentState(hpkg, "beta", &state, &action);
1901     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1902     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1903     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1904
1905     state = 0xdeadbee;
1906     action = 0xdeadbee;
1907     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
1908     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1909     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1910     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1911
1912     state = 0xdeadbee;
1913     action = 0xdeadbee;
1914     r = MsiGetComponentState(hpkg, "theta", &state, &action);
1915     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1916     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1917     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1918
1919     state = 0xdeadbee;
1920     action = 0xdeadbee;
1921     r = MsiGetComponentState(hpkg, "delta", &state, &action);
1922     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1923     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1924     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1925
1926     state = 0xdeadbee;
1927     action = 0xdeadbee;
1928     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
1929     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1930     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1931     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1932
1933     state = 0xdeadbee;
1934     action = 0xdeadbee;
1935     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
1936     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1937     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1938     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1939
1940     state = 0xdeadbee;
1941     action = 0xdeadbee;
1942     r = MsiGetComponentState(hpkg, "iota", &state, &action);
1943     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1944     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1945     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1946
1947     state = 0xdeadbee;
1948     action = 0xdeadbee;
1949     r = MsiGetComponentState(hpkg, "eta", &state, &action);
1950     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1951     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1952     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1953
1954     state = 0xdeadbee;
1955     action = 0xdeadbee;
1956     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
1957     ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
1958     ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
1959     ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
1960
1961     r = MsiDoAction( hpkg, "CostInitialize");
1962     ok( r == ERROR_SUCCESS, "cost init failed\n");
1963
1964     state = 0xdeadbee;
1965     action = 0xdeadbee;
1966     r = MsiGetFeatureState(hpkg, "one", &state, &action);
1967     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1968     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1969     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1970
1971     state = 0xdeadbee;
1972     action = 0xdeadbee;
1973     r = MsiGetFeatureState(hpkg, "two", &state, &action);
1974     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1975     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1976     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1977
1978     state = 0xdeadbee;
1979     action = 0xdeadbee;
1980     r = MsiGetFeatureState(hpkg, "three", &state, &action);
1981     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1982     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1983     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1984
1985     state = 0xdeadbee;
1986     action = 0xdeadbee;
1987     r = MsiGetFeatureState(hpkg, "four", &state, &action);
1988     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1989     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1990     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1991
1992     state = 0xdeadbee;
1993     action = 0xdeadbee;
1994     r = MsiGetFeatureState(hpkg, "five", &state, &action);
1995     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
1996     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1997     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1998
1999     state = 0xdeadbee;
2000     action = 0xdeadbee;
2001     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2002     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2003     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2004     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2005
2006     state = 0xdeadbee;
2007     action = 0xdeadbee;
2008     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2009     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2010     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2011     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2012
2013     state = 0xdeadbee;
2014     action = 0xdeadbee;
2015     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2016     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2017     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2018     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2019
2020     state = 0xdeadbee;
2021     action = 0xdeadbee;
2022     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2023     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2024     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2025     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2026
2027     state = 0xdeadbee;
2028     action = 0xdeadbee;
2029     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2030     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2031     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2032     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2033
2034     state = 0xdeadbee;
2035     action = 0xdeadbee;
2036     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2037     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2038     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2039     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2040
2041     state = 0xdeadbee;
2042     action = 0xdeadbee;
2043     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2044     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2045     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2046     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2047
2048     state = 0xdeadbee;
2049     action = 0xdeadbee;
2050     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2051     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2052     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2053     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2054
2055     state = 0xdeadbee;
2056     action = 0xdeadbee;
2057     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2058     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2059     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2060     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2061
2062     state = 0xdeadbee;
2063     action = 0xdeadbee;
2064     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2065     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2066     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2067     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2068
2069     r = MsiDoAction( hpkg, "FileCost");
2070     ok( r == ERROR_SUCCESS, "file cost failed\n");
2071
2072     state = 0xdeadbee;
2073     action = 0xdeadbee;
2074     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2075     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2076     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2077     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2078
2079     state = 0xdeadbee;
2080     action = 0xdeadbee;
2081     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2082     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2083     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2084     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2085
2086     state = 0xdeadbee;
2087     action = 0xdeadbee;
2088     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2089     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2090     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2091     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2092
2093     state = 0xdeadbee;
2094     action = 0xdeadbee;
2095     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2096     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2097     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2098     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2099
2100     state = 0xdeadbee;
2101     action = 0xdeadbee;
2102     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2103     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2104     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2105     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2106
2107     state = 0xdeadbee;
2108     action = 0xdeadbee;
2109     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2110     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2111     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2112     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2113
2114     state = 0xdeadbee;
2115     action = 0xdeadbee;
2116     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2117     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2118     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2119     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2120
2121     state = 0xdeadbee;
2122     action = 0xdeadbee;
2123     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2124     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2125     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2126     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2127
2128     state = 0xdeadbee;
2129     action = 0xdeadbee;
2130     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2131     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2132     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2133     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2134
2135     state = 0xdeadbee;
2136     action = 0xdeadbee;
2137     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2138     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2139     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2140     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2141
2142     state = 0xdeadbee;
2143     action = 0xdeadbee;
2144     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2145     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2146     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2147     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2148
2149     state = 0xdeadbee;
2150     action = 0xdeadbee;
2151     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2152     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2153     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2154     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2155
2156     state = 0xdeadbee;
2157     action = 0xdeadbee;
2158     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2159     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2160     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2161     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2162
2163     state = 0xdeadbee;
2164     action = 0xdeadbee;
2165     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2166     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2167     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2168     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2169
2170     state = 0xdeadbee;
2171     action = 0xdeadbee;
2172     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2173     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2174     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2175     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2176
2177     r = MsiDoAction( hpkg, "CostFinalize");
2178     ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
2179
2180     state = 0xdeadbee;
2181     action = 0xdeadbee;
2182     r = MsiGetFeatureState(hpkg, "one", &state, &action);
2183     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2184     ok( state == INSTALLSTATE_ABSENT, "Expected one INSTALLSTATE_ABSENT, got %d\n", state);
2185     ok( action == INSTALLSTATE_LOCAL, "Expected one INSTALLSTATE_LOCAL, got %d\n", action);
2186
2187     state = 0xdeadbee;
2188     action = 0xdeadbee;
2189     r = MsiGetFeatureState(hpkg, "two", &state, &action);
2190     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2191     ok( state == INSTALLSTATE_ABSENT, "Expected two INSTALLSTATE_ABSENT, got %d\n", state);
2192     ok( action == INSTALLSTATE_SOURCE, "Expected two INSTALLSTATE_SOURCE, got %d\n", action);
2193
2194     state = 0xdeadbee;
2195     action = 0xdeadbee;
2196     r = MsiGetFeatureState(hpkg, "three", &state, &action);
2197     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2198     ok( state == INSTALLSTATE_ABSENT, "Expected three INSTALLSTATE_ABSENT, got %d\n", state);
2199     ok( action == INSTALLSTATE_LOCAL, "Expected three INSTALLSTATE_LOCAL, got %d\n", action);
2200
2201     state = 0xdeadbee;
2202     action = 0xdeadbee;
2203     r = MsiGetFeatureState(hpkg, "four", &state, &action);
2204     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2205     ok( state == INSTALLSTATE_ABSENT, "Expected four INSTALLSTATE_ABSENT, got %d\n", state);
2206     ok( action == INSTALLSTATE_LOCAL, "Expected four INSTALLSTATE_LOCAL, got %d\n", action);
2207
2208     state = 0xdeadbee;
2209     action = 0xdeadbee;
2210     r = MsiGetFeatureState(hpkg, "five", &state, &action);
2211     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2212     ok( state == INSTALLSTATE_ABSENT, "Expected five INSTALLSTATE_ABSENT, got %d\n", state);
2213     ok( action == INSTALLSTATE_UNKNOWN, "Expected five INSTALLSTATE_UNKNOWN, got %d\n", action);
2214
2215     state = 0xdeadbee;
2216     action = 0xdeadbee;
2217     r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2218     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2219     ok( state == INSTALLSTATE_ABSENT, "Expected alpha INSTALLSTATE_ABSENT, got %d\n", state);
2220     ok( action == INSTALLSTATE_LOCAL, "Expected alpha INSTALLSTATE_LOCAL, got %d\n", action);
2221
2222     state = 0xdeadbee;
2223     action = 0xdeadbee;
2224     r = MsiGetComponentState(hpkg, "beta", &state, &action);
2225     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2226     ok( state == INSTALLSTATE_ABSENT, "Expected beta INSTALLSTATE_ABSENT, got %d\n", state);
2227     ok( action == INSTALLSTATE_SOURCE, "Expected beta INSTALLSTATE_SOURCE, got %d\n", action);
2228
2229     state = 0xdeadbee;
2230     action = 0xdeadbee;
2231     r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2232     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2233     ok( state == INSTALLSTATE_ABSENT, "Expected gamma INSTALLSTATE_ABSENT, got %d\n", state);
2234     ok( action == INSTALLSTATE_LOCAL, "Expected gamma INSTALLSTATE_LOCAL, got %d\n", action);
2235
2236     state = 0xdeadbee;
2237     action = 0xdeadbee;
2238     r = MsiGetComponentState(hpkg, "theta", &state, &action);
2239     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2240     ok( state == INSTALLSTATE_ABSENT, "Expected theta INSTALLSTATE_ABSENT, got %d\n", state);
2241     ok( action == INSTALLSTATE_LOCAL, "Expected theta INSTALLSTATE_LOCAL, got %d\n", action);
2242
2243     state = 0xdeadbee;
2244     action = 0xdeadbee;
2245     r = MsiGetComponentState(hpkg, "delta", &state, &action);
2246     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2247     ok( state == INSTALLSTATE_ABSENT, "Expected delta INSTALLSTATE_ABSENT, got %d\n", state);
2248     ok( action == INSTALLSTATE_LOCAL, "Expected delta INSTALLSTATE_LOCAL, got %d\n", action);
2249
2250     state = 0xdeadbee;
2251     action = 0xdeadbee;
2252     r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2253     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2254     ok( state == INSTALLSTATE_ABSENT, "Expected epsilon INSTALLSTATE_ABSENT, got %d\n", state);
2255     ok( action == INSTALLSTATE_SOURCE, "Expected epsilon INSTALLSTATE_SOURCE, got %d\n", action);
2256
2257     state = 0xdeadbee;
2258     action = 0xdeadbee;
2259     r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2260     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2261     ok( state == INSTALLSTATE_ABSENT, "Expected zeta INSTALLSTATE_ABSENT, got %d\n", state);
2262     ok( action == INSTALLSTATE_SOURCE, "Expected zeta INSTALLSTATE_SOURCE, got %d\n", action);
2263
2264     state = 0xdeadbee;
2265     action = 0xdeadbee;
2266     r = MsiGetComponentState(hpkg, "iota", &state, &action);
2267     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2268     ok( state == INSTALLSTATE_ABSENT, "Expected iota INSTALLSTATE_ABSENT, got %d\n", state);
2269     ok( action == INSTALLSTATE_LOCAL, "Expected iota INSTALLSTATE_LOCAL, got %d\n", action);
2270
2271     state = 0xdeadbee;
2272     action = 0xdeadbee;
2273     r = MsiGetComponentState(hpkg, "eta", &state, &action);
2274     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2275     ok( state == INSTALLSTATE_ABSENT, "Expected eta INSTALLSTATE_ABSENT, got %d\n", state);
2276     ok( action == INSTALLSTATE_LOCAL, "Expected eta INSTALLSTATE_LOCAL, got %d\n", action);
2277
2278     state = 0xdeadbee;
2279     action = 0xdeadbee;
2280     r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2281     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2282     ok( state == INSTALLSTATE_ABSENT, "Expected kappa INSTALLSTATE_ABSENT, got %d\n", state);
2283     ok( action == INSTALLSTATE_UNKNOWN, "Expected kappa INSTALLSTATE_UNKNOWN, got %d\n", action);
2284
2285     MsiCloseHandle( hpkg );
2286     DeleteFileA( msifile );
2287 }
2288
2289 static void test_getproperty(void)
2290 {
2291     MSIHANDLE hPackage = 0;
2292     char prop[100];
2293     static CHAR empty[] = "";
2294     DWORD size;
2295     UINT r;
2296
2297     hPackage = package_from_db(create_package_db());
2298     ok( hPackage != 0, " Failed to create package\n");
2299
2300     /* set the property */
2301     r = MsiSetProperty(hPackage, "Name", "Value");
2302     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2303
2304     /* retrieve the size, NULL pointer */
2305     size = 0;
2306     r = MsiGetProperty(hPackage, "Name", NULL, &size);
2307     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2308     ok( size == 5, "Expected 5, got %d\n", size);
2309
2310     /* retrieve the size, empty string */
2311     size = 0;
2312     r = MsiGetProperty(hPackage, "Name", empty, &size);
2313     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2314     ok( size == 5, "Expected 5, got %d\n", size);
2315
2316     /* don't change size */
2317     r = MsiGetProperty(hPackage, "Name", prop, &size);
2318     ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2319     ok( size == 5, "Expected 5, got %d\n", size);
2320     ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
2321
2322     /* increase the size by 1 */
2323     size++;
2324     r = MsiGetProperty(hPackage, "Name", prop, &size);
2325     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2326     ok( size == 5, "Expected 5, got %d\n", size);
2327     ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
2328
2329     r = MsiCloseHandle( hPackage);
2330     ok( r == ERROR_SUCCESS , "Failed to close package\n" );
2331     DeleteFile(msifile);
2332 }
2333
2334 static void test_removefiles(void)
2335 {
2336     MSIHANDLE hpkg;
2337     UINT r;
2338     MSIHANDLE hdb;
2339     char CURR_DIR[MAX_PATH];
2340
2341     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
2342
2343     hdb = create_package_db();
2344     ok ( hdb, "failed to create package database\n" );
2345
2346     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2347     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2348
2349     r = create_feature_table( hdb );
2350     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2351
2352     r = create_component_table( hdb );
2353     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2354
2355     r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2356     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2357
2358     r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
2359     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2360
2361     r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
2362     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2363
2364     r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
2365     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2366
2367     r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
2368     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2369
2370     r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
2371     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2372
2373     r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
2374     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2375
2376     r = create_feature_components_table( hdb );
2377     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2378
2379     r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
2380     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2381
2382     r = add_feature_components_entry( hdb, "'one', 'helium'" );
2383     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2384
2385     r = add_feature_components_entry( hdb, "'one', 'lithium'" );
2386     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2387
2388     r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
2389     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2390
2391     r = add_feature_components_entry( hdb, "'one', 'boron'" );
2392     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2393
2394     r = add_feature_components_entry( hdb, "'one', 'carbon'" );
2395     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2396
2397     r = create_file_table( hdb );
2398     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2399
2400     r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
2401     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2402
2403     r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
2404     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2405
2406     r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
2407     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2408
2409     r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
2410     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2411
2412     r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
2413     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2414
2415     r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
2416     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2417
2418     r = create_remove_file_table( hdb );
2419     ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
2420
2421     hpkg = package_from_db( hdb );
2422     ok( hpkg, "failed to create package\n");
2423
2424     MsiCloseHandle( hdb );
2425
2426     create_test_file( "hydrogen.txt" );
2427     create_test_file( "helium.txt" );
2428     create_test_file( "lithium.txt" );
2429     create_test_file( "beryllium.txt" );
2430     create_test_file( "boron.txt" );
2431     create_test_file( "carbon.txt" );
2432
2433     r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
2434     ok( r == ERROR_SUCCESS, "set property failed\n");
2435
2436     r = MsiDoAction( hpkg, "CostInitialize");
2437     ok( r == ERROR_SUCCESS, "cost init failed\n");
2438
2439     r = MsiDoAction( hpkg, "FileCost");
2440     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2441
2442     r = MsiDoAction( hpkg, "CostFinalize");
2443     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2444
2445     r = MsiDoAction( hpkg, "InstallValidate");
2446     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2447
2448     r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
2449     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2450
2451     r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
2452     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2453
2454     r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
2455     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2456
2457     r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
2458     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2459
2460     r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
2461     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2462
2463     r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
2464     ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
2465
2466     r = MsiDoAction( hpkg, "RemoveFiles");
2467     ok( r == ERROR_SUCCESS, "remove files failed\n");
2468
2469     ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
2470     ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");    
2471     ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
2472     ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
2473     ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
2474     ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
2475
2476     MsiCloseHandle( hpkg );
2477     DeleteFileA(msifile);
2478 }
2479
2480 static void test_appsearch(void)
2481 {
2482     MSIHANDLE hpkg;
2483     UINT r;
2484     MSIHANDLE hdb;
2485     CHAR prop[MAX_PATH];
2486     DWORD size = MAX_PATH;
2487
2488     hdb = create_package_db();
2489     ok ( hdb, "failed to create package database\n" );
2490
2491     r = create_appsearch_table( hdb );
2492     ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
2493
2494     r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
2495     ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
2496
2497     r = create_reglocator_table( hdb );
2498     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2499
2500     r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
2501     ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
2502
2503     r = create_signature_table( hdb );
2504     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2505
2506     r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
2507     ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
2508
2509     hpkg = package_from_db( hdb );
2510     ok( hpkg, "failed to create package\n");
2511
2512     MsiCloseHandle( hdb );
2513
2514     r = MsiDoAction( hpkg, "AppSearch" );
2515     ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
2516
2517     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
2518     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2519     ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
2520
2521     MsiCloseHandle( hpkg );
2522     DeleteFileA(msifile);
2523 }
2524
2525 static void test_featureparents(void)
2526 {
2527     MSIHANDLE hpkg;
2528     UINT r;
2529     MSIHANDLE hdb;
2530     INSTALLSTATE state, action;
2531
2532     hdb = create_package_db();
2533     ok ( hdb, "failed to create package database\n" );
2534
2535     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2536     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2537
2538     r = create_feature_table( hdb );
2539     ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2540
2541     r = create_component_table( hdb );
2542     ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2543
2544     r = create_feature_components_table( hdb );
2545     ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2546
2547     r = create_file_table( hdb );
2548     ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2549
2550     /* msidbFeatureAttributesFavorLocal */
2551     r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
2552     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2553
2554     /* msidbFeatureAttributesFavorSource */
2555     r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
2556     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2557
2558     /* msidbFeatureAttributesFavorLocal */
2559     r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
2560     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2561
2562     /* disabled because of install level */
2563     r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
2564     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2565
2566     /* child feature of disabled feature */
2567     r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
2568     ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2569
2570     /* component of disabled feature (install level) */
2571     r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
2572     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2573
2574     /* component of disabled child feature (install level) */
2575     r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
2576     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2577
2578     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2579     r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
2580     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2581
2582     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2583     r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
2584     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2585
2586     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2587     r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
2588     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2589
2590     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2591     r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
2592     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2593
2594     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2595     r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
2596     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2597
2598     /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2599     r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
2600     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2601
2602     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2603     r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
2604     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2605
2606     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2607     r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
2608     ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2609
2610     /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2611     r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
2612
2613     r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
2614     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2615
2616     r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
2617     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2618
2619     r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
2620     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2621
2622     r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
2623     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2624
2625     r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
2626     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2627
2628     r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
2629     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2630
2631     r = add_feature_components_entry( hdb, "'orion', 'leo'" );
2632     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2633
2634     r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
2635     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2636
2637     r = add_feature_components_entry( hdb, "'orion', 'libra'" );
2638     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2639
2640     r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
2641     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2642
2643     r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
2644     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2645
2646     r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
2647     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2648
2649     r = add_feature_components_entry( hdb, "'orion', 'canis'" );
2650     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2651
2652     r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
2653     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2654
2655     r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
2656     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2657
2658     r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
2659     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2660
2661     r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
2662     ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2663
2664     r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
2665     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2666
2667     r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
2668     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2669
2670     r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
2671     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2672
2673     r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
2674     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2675
2676     r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
2677     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2678
2679     r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
2680     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2681
2682     r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
2683     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2684
2685     r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
2686     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2687
2688     r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
2689     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2690
2691     r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
2692     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2693
2694     r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
2695     ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2696
2697     hpkg = package_from_db( hdb );
2698     ok( hpkg, "failed to create package\n");
2699
2700     MsiCloseHandle( hdb );
2701
2702     r = MsiDoAction( hpkg, "CostInitialize");
2703     ok( r == ERROR_SUCCESS, "cost init failed\n");
2704
2705     r = MsiDoAction( hpkg, "FileCost");
2706     ok( r == ERROR_SUCCESS, "file cost failed\n");
2707
2708     r = MsiDoAction( hpkg, "CostFinalize");
2709     ok( r == ERROR_SUCCESS, "cost finalize failed\n");
2710
2711     state = 0xdeadbee;
2712     action = 0xdeadbee;
2713     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2714     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2715     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2716     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2717
2718     state = 0xdeadbee;
2719     action = 0xdeadbee;
2720     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2721     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2722     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2723     ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2724
2725     state = 0xdeadbee;
2726     action = 0xdeadbee;
2727     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2728     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2729     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2730     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2731
2732     state = 0xdeadbee;
2733     action = 0xdeadbee;
2734     r = MsiGetFeatureState(hpkg, "waters", &state, &action);
2735     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2736     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2737     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2738
2739     state = 0xdeadbee;
2740     action = 0xdeadbee;
2741     r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
2742     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2743     ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2744     ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2745
2746     state = 0xdeadbee;
2747     action = 0xdeadbee;
2748     r = MsiGetComponentState(hpkg, "leo", &state, &action);
2749     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2750     ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2751     ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2752
2753     state = 0xdeadbee;
2754     action = 0xdeadbee;
2755     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
2756     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2757     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
2758     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
2759
2760     state = 0xdeadbee;
2761     action = 0xdeadbee;
2762     r = MsiGetComponentState(hpkg, "libra", &state, &action);
2763     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2764     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
2765     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
2766
2767     state = 0xdeadbee;
2768     action = 0xdeadbee;
2769     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2770     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2771     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
2772     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
2773
2774     state = 0xdeadbee;
2775     action = 0xdeadbee;
2776     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2777     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2778     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
2779     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
2780
2781     state = 0xdeadbee;
2782     action = 0xdeadbee;
2783     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2784     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2785     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
2786     ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
2787
2788     state = 0xdeadbee;
2789     action = 0xdeadbee;
2790     r = MsiGetComponentState(hpkg, "canis", &state, &action);
2791     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2792     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
2793     ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
2794
2795     state = 0xdeadbee;
2796     action = 0xdeadbee;
2797     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2798     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2799     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
2800     ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
2801
2802     state = 0xdeadbee;
2803     action = 0xdeadbee;
2804     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2805     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2806     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
2807     ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
2808
2809     state = 0xdeadbee;
2810     action = 0xdeadbee;
2811     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
2812     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2813     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
2814     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
2815
2816     state = 0xdeadbee;
2817     action = 0xdeadbee;
2818     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
2819     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2820     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
2821     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
2822
2823     r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
2824     ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
2825
2826     state = 0xdeadbee;
2827     action = 0xdeadbee;
2828     r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
2829     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2830     ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
2831     ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
2832
2833     state = 0xdeadbee;
2834     action = 0xdeadbee;
2835     r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
2836     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2837     ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
2838     ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
2839
2840     state = 0xdeadbee;
2841     action = 0xdeadbee;
2842     r = MsiGetFeatureState(hpkg, "orion", &state, &action);
2843     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2844     ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
2845     ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
2846
2847     state = 0xdeadbee;
2848     action = 0xdeadbee;
2849     r = MsiGetComponentState(hpkg, "leo", &state, &action);
2850     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2851     ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
2852     ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
2853
2854     state = 0xdeadbee;
2855     action = 0xdeadbee;
2856     r = MsiGetComponentState(hpkg, "virgo", &state, &action);
2857     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2858     ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
2859     ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
2860
2861     state = 0xdeadbee;
2862     action = 0xdeadbee;
2863     r = MsiGetComponentState(hpkg, "libra", &state, &action);
2864     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2865     ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
2866     ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
2867
2868     state = 0xdeadbee;
2869     action = 0xdeadbee;
2870     r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
2871     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2872     ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
2873     ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
2874
2875     state = 0xdeadbee;
2876     action = 0xdeadbee;
2877     r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
2878     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2879     ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
2880     ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
2881
2882     state = 0xdeadbee;
2883     action = 0xdeadbee;
2884     r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
2885     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2886     ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
2887     ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
2888
2889     state = 0xdeadbee;
2890     action = 0xdeadbee;
2891     r = MsiGetComponentState(hpkg, "canis", &state, &action);
2892     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2893     ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
2894     ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
2895
2896     state = 0xdeadbee;
2897     action = 0xdeadbee;
2898     r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
2899     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2900     ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
2901     ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
2902
2903     state = 0xdeadbee;
2904     action = 0xdeadbee;
2905     r = MsiGetComponentState(hpkg, "lepus", &state, &action);
2906     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2907     ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
2908     ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
2909
2910     state = 0xdeadbee;
2911     action = 0xdeadbee;
2912     r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
2913     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2914     ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
2915     ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
2916
2917     state = 0xdeadbee;
2918     action = 0xdeadbee;
2919     r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
2920     ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2921     ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
2922     ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
2923     
2924     MsiCloseHandle(hpkg);
2925     DeleteFileA(msifile);
2926 }
2927
2928 static void test_installprops(void)
2929 {
2930     MSIHANDLE hpkg, hdb;
2931     CHAR path[MAX_PATH];
2932     CHAR buf[MAX_PATH];
2933     DWORD size, type;
2934     HKEY hkey;
2935     UINT r;
2936
2937     GetCurrentDirectory(MAX_PATH, path);
2938     lstrcat(path, "\\");
2939     lstrcat(path, msifile);
2940
2941     hdb = create_package_db();
2942     ok( hdb, "failed to create database\n");
2943
2944     hpkg = package_from_db(hdb);
2945     ok( hpkg, "failed to create package\n");
2946
2947     MsiCloseHandle(hdb);
2948
2949     size = MAX_PATH;
2950     r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
2951     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
2952     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
2953
2954     RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey);
2955
2956     size = MAX_PATH;
2957     type = REG_SZ;
2958     RegQueryValueEx(hkey, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
2959
2960     size = MAX_PATH;
2961     r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
2962     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
2963     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
2964
2965     size = MAX_PATH;
2966     type = REG_SZ;
2967     RegQueryValueEx(hkey, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
2968
2969     size = MAX_PATH;
2970     r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
2971     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
2972     ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
2973
2974     CloseHandle(hkey);
2975     MsiCloseHandle(hpkg);
2976     DeleteFile(msifile);
2977 }
2978
2979 static void test_sourcedirprop(void)
2980 {
2981     MSIHANDLE hpkg, hdb;
2982     CHAR source_dir[MAX_PATH];
2983     CHAR path[MAX_PATH];
2984     DWORD size;
2985     UINT r;
2986
2987     hdb = create_package_db();
2988     ok ( hdb, "failed to create package database\n" );
2989
2990     r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2991     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2992
2993     hpkg = package_from_db( hdb );
2994     ok( hpkg, "failed to create package\n");
2995
2996     MsiCloseHandle( hdb );
2997
2998     size = MAX_PATH;
2999     r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3000     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3001     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3002
3003     size = MAX_PATH;
3004     r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3005     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3006     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3007
3008     r = MsiDoAction( hpkg, "CostInitialize");
3009     ok( r == ERROR_SUCCESS, "cost init failed\n");
3010
3011     size = MAX_PATH;
3012     r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3013     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3014     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3015
3016     size = MAX_PATH;
3017     r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3018     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3019     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3020
3021     r = MsiDoAction( hpkg, "ResolveSource");
3022     ok( r == ERROR_SUCCESS, "file cost failed\n");
3023
3024     GetCurrentDirectory(MAX_PATH, path);
3025     lstrcatA(path, "\\");
3026
3027     size = MAX_PATH;
3028     r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3029     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3030     ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3031
3032     size = MAX_PATH;
3033     r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3034     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3035     ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3036
3037     size = MAX_PATH;
3038     r = MsiGetProperty( hpkg, "SoUrCeDiR", source_dir, &size );
3039     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3040     ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3041
3042     MsiCloseHandle(hpkg);
3043     DeleteFileA(msifile);
3044 }
3045
3046 static void test_prop_path(void)
3047 {
3048     MSIHANDLE hpkg, hdb;
3049     char buffer[MAX_PATH], cwd[MAX_PATH];
3050     DWORD sz;
3051     UINT r;
3052
3053     GetCurrentDirectory(MAX_PATH, cwd);
3054     strcat(cwd, "\\");
3055
3056     hdb = create_package_db();
3057     ok( hdb, "failed to create database\n");
3058
3059     r = add_directory_entry( hdb, "'TARGETDIR','','SourceDir'" );
3060     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3061
3062     r = add_directory_entry( hdb, "'foo','TARGETDIR','foosrc:footgt'" );
3063     ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3064
3065     hpkg = package_from_db(hdb);
3066     ok( hpkg, "failed to create package\n");
3067
3068     r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3069     ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3070
3071     r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3072     ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3073
3074     r = MsiDoAction( hpkg, "CostInitialize");
3075     ok( r == ERROR_SUCCESS, "cost init failed\n");
3076
3077     sz = sizeof buffer;
3078     buffer[0] = 0;
3079     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3080     ok( r == ERROR_SUCCESS, "property not set\n");
3081     ok( !buffer[0], "SourceDir should be empty\n");
3082
3083     sz = sizeof buffer;
3084     buffer[0] = 0;
3085     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3086     ok( r == ERROR_SUCCESS, "property not set\n");
3087     ok( !buffer[0], "SourceDir should be empty\n");
3088
3089     sz = sizeof buffer;
3090     buffer[0] = 0;
3091     r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3092     ok( r == ERROR_SUCCESS, "failed to get source path\n");
3093     ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3094
3095     sz = sizeof buffer;
3096     buffer[0] = 0;
3097     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3098     ok( r == ERROR_SUCCESS, "property not set\n");
3099     todo_wine {
3100     ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3101     }
3102
3103     sz = sizeof buffer;
3104     buffer[0] = 0;
3105     r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3106     ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3107
3108     sz = sizeof buffer;
3109     buffer[0] = 0;
3110     r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3111     ok( r == ERROR_SUCCESS, "property not set\n");
3112     todo_wine {
3113     ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3114     }
3115
3116     r = MsiSetProperty(hpkg, "SourceDir", "goo");
3117     ok( r == ERROR_SUCCESS, "property not set\n");
3118
3119     sz = sizeof buffer;
3120     buffer[0] = 0;
3121     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3122     ok( r == ERROR_SUCCESS, "property not set\n");
3123     ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3124
3125     sz = sizeof buffer;
3126     buffer[0] = 0;
3127     r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3128     ok( r == ERROR_SUCCESS, "failed to get source path\n");
3129     ok( !lstrcmpi(buffer, cwd), "SourceDir (%s) should be goo\n", buffer);
3130
3131     sz = sizeof buffer;
3132     buffer[0] = 0;
3133     r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3134     ok( r == ERROR_SUCCESS, "property not set\n");
3135     ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3136
3137     MsiCloseHandle( hpkg );
3138     DeleteFile(msifile);
3139 }
3140
3141 START_TEST(package)
3142 {
3143     test_createpackage();
3144     test_getsourcepath_bad();
3145     test_getsourcepath();
3146     test_doaction();
3147     test_gettargetpath_bad();
3148     test_settargetpath();
3149     test_props();
3150     test_properties_table();
3151     test_condition();
3152     test_msipackage();
3153     test_formatrecord2();
3154     test_states();
3155     test_getproperty();
3156     test_removefiles();
3157     test_appsearch();
3158     test_featureparents();
3159     test_installprops();
3160     test_sourcedirprop();
3161     test_prop_path();
3162 }