2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
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.
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.
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
29 #include "wine/test.h"
31 static const char msifile
[] = "winetest.msi";
33 static UINT
run_query( MSIHANDLE hdb
, const char *query
)
38 r
= MsiDatabaseOpenView(hdb
, query
, &hview
);
39 if( r
!= ERROR_SUCCESS
)
42 r
= MsiViewExecute(hview
, 0);
43 if( r
== ERROR_SUCCESS
)
44 r
= MsiViewClose(hview
);
45 MsiCloseHandle(hview
);
49 static UINT
create_component_table( MSIHANDLE hdb
)
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), "
59 "PRIMARY KEY `Component`)" );
62 static UINT
create_feature_table( MSIHANDLE hdb
)
64 return run_query( hdb
,
65 "CREATE TABLE `Feature` ( "
66 "`Feature` CHAR(38) NOT NULL, "
67 "`Feature_Parent` CHAR(38), "
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`)" );
77 static UINT
create_feature_components_table( MSIHANDLE hdb
)
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_` )" );
86 static UINT
create_file_table( MSIHANDLE hdb
)
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`)" );
101 static UINT
create_remove_file_table( MSIHANDLE hdb
)
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`)" );
113 static UINT
add_component_entry( MSIHANDLE hdb
, const char *values
)
115 char insert
[] = "INSERT INTO `Component` "
116 "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
121 sz
= strlen(values
) + sizeof insert
;
122 query
= HeapAlloc(GetProcessHeap(),0,sz
);
123 sprintf(query
,insert
,values
);
124 r
= run_query( hdb
, query
);
125 HeapFree(GetProcessHeap(), 0, query
);
129 static UINT
add_feature_entry( MSIHANDLE hdb
, const char *values
)
131 char insert
[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
132 "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
136 sz
= strlen(values
) + sizeof insert
;
137 query
= HeapAlloc(GetProcessHeap(),0,sz
);
138 sprintf(query
,insert
,values
);
139 r
= run_query( hdb
, query
);
140 HeapFree(GetProcessHeap(), 0, query
);
144 static UINT
add_feature_components_entry( MSIHANDLE hdb
, const char *values
)
146 char insert
[] = "INSERT INTO `FeatureComponents` "
147 "(`Feature_`, `Component_`) "
152 sz
= strlen(values
) + sizeof insert
;
153 query
= HeapAlloc(GetProcessHeap(),0,sz
);
154 sprintf(query
,insert
,values
);
155 r
= run_query( hdb
, query
);
156 HeapFree(GetProcessHeap(), 0, query
);
160 static UINT
add_file_entry( MSIHANDLE hdb
, const char *values
)
162 char insert
[] = "INSERT INTO `File` "
163 "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
168 sz
= strlen(values
) + sizeof insert
;
169 query
= HeapAlloc(GetProcessHeap(),0,sz
);
170 sprintf(query
,insert
,values
);
171 r
= run_query( hdb
, query
);
172 HeapFree(GetProcessHeap(), 0, query
);
176 static UINT
set_summary_info(MSIHANDLE hdb
)
181 /* build summmary info */
182 res
= MsiGetSummaryInformation(hdb
, NULL
, 7, &suminfo
);
183 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
185 res
= MsiSummaryInfoSetProperty(suminfo
,2, VT_LPSTR
, 0,NULL
,
186 "Installation Database");
187 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
189 res
= MsiSummaryInfoSetProperty(suminfo
,3, VT_LPSTR
, 0,NULL
,
190 "Installation Database");
191 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
193 res
= MsiSummaryInfoSetProperty(suminfo
,4, VT_LPSTR
, 0,NULL
,
195 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
197 res
= MsiSummaryInfoSetProperty(suminfo
,7, VT_LPSTR
, 0,NULL
,
199 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
201 res
= MsiSummaryInfoSetProperty(suminfo
,9, VT_LPSTR
, 0,NULL
,
202 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
203 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
205 res
= MsiSummaryInfoSetProperty(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
206 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
208 res
= MsiSummaryInfoSetProperty(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
209 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
211 res
= MsiSummaryInfoPersist(suminfo
);
212 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
214 res
= MsiCloseHandle( suminfo
);
215 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
221 MSIHANDLE
create_package_db(void)
228 /* create an empty database */
229 res
= MsiOpenDatabase(msifile
, MSIDBOPEN_CREATE
, &hdb
);
230 ok( res
== ERROR_SUCCESS
, "Failed to create database\n" );
231 if( res
!= ERROR_SUCCESS
)
234 res
= MsiDatabaseCommit( hdb
);
235 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
237 res
= set_summary_info(hdb
);
239 res
= run_query( hdb
,
240 "CREATE TABLE `Directory` ( "
241 "`Directory` CHAR(255) NOT NULL, "
242 "`Directory_Parent` CHAR(255), "
243 "`DefaultDir` CHAR(255) NOT NULL "
244 "PRIMARY KEY `Directory`)" );
245 ok( res
== ERROR_SUCCESS
, "Failed to create directory table\n" );
250 MSIHANDLE
package_from_db(MSIHANDLE hdb
)
256 sprintf(szPackage
,"#%li",hdb
);
257 res
= MsiOpenPackage(szPackage
,&hPackage
);
258 ok( res
== ERROR_SUCCESS
, "Failed to open package\n" );
260 res
= MsiCloseHandle(hdb
);
261 ok( res
== ERROR_SUCCESS
, "Failed to close db handle\n" );
266 static void create_test_file(const CHAR
*name
)
271 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
272 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
273 WriteFile(file
, name
, strlen(name
), &written
, NULL
);
274 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
278 static void test_createpackage(void)
280 MSIHANDLE hPackage
= 0;
283 hPackage
= package_from_db(create_package_db());
284 ok( hPackage
!= 0, " Failed to create package\n");
286 res
= MsiCloseHandle( hPackage
);
287 ok( res
== ERROR_SUCCESS
, "Failed to close package\n" );
291 static void test_getsourcepath_bad( void )
293 static const char str
[] = { 0 };
298 r
= MsiGetSourcePath( -1, NULL
, NULL
, NULL
);
299 ok( r
== ERROR_INVALID_PARAMETER
, "return value wrong\n");
302 r
= MsiGetSourcePath( -1, NULL
, buffer
, &sz
);
303 ok( r
== ERROR_INVALID_PARAMETER
, "return value wrong\n");
306 r
= MsiGetSourcePath( -1, str
, NULL
, &sz
);
307 ok( r
== ERROR_INVALID_HANDLE
, "return value wrong\n");
310 r
= MsiGetSourcePath( -1, str
, NULL
, NULL
);
311 ok( r
== ERROR_INVALID_HANDLE
, "return value wrong\n");
314 r
= MsiGetSourcePath( -1, str
, buffer
, &sz
);
315 ok( r
== ERROR_INVALID_HANDLE
, "return value wrong\n");
318 static UINT
add_directory_entry( MSIHANDLE hdb
, const char *values
)
320 char insert
[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
324 sz
= strlen(values
) + sizeof insert
;
325 query
= HeapAlloc(GetProcessHeap(),0,sz
);
326 sprintf(query
,insert
,values
);
327 r
= run_query( hdb
, query
);
328 HeapFree(GetProcessHeap(), 0, query
);
332 static void test_getsourcepath( void )
334 static const char str
[] = { 0 };
340 hpkg
= package_from_db(create_package_db());
341 ok( hpkg
, "failed to create package\n");
345 r
= MsiGetSourcePath( hpkg
, str
, buffer
, &sz
);
346 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
347 ok( buffer
[0] == 'x', "buffer modified\n");
351 r
= MsiGetSourcePath( hpkg
, str
, buffer
, &sz
);
352 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
353 ok( buffer
[0] == 'x', "buffer modified\n");
355 MsiCloseHandle( hpkg
);
358 /* another test but try create a directory this time */
359 hdb
= create_package_db();
360 ok( hdb
, "failed to create database\n");
362 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
363 ok( r
== S_OK
, "failed\n");
365 hpkg
= package_from_db(hdb
);
366 ok( hpkg
, "failed to create package\n");
368 sz
= sizeof buffer
-1;
369 strcpy(buffer
,"x bad");
370 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, &sz
);
371 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
373 r
= MsiDoAction( hpkg
, "CostInitialize");
374 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
375 r
= MsiDoAction( hpkg
, "CostFinalize");
376 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
379 sz
= sizeof buffer
-1;
381 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, &sz
);
382 ok( r
== ERROR_SUCCESS
, "return value wrong\n");
383 ok( sz
== strlen(buffer
), "returned length wrong\n");
386 strcpy(buffer
,"x bad");
387 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, &sz
);
388 ok( r
== ERROR_MORE_DATA
, "return value wrong\n");
390 ok( buffer
[0] == 'x', "buffer modified\n");
393 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", NULL
, NULL
);
394 ok( r
== ERROR_SUCCESS
, "return value wrong\n");
397 r
= MsiGetSourcePath( hpkg
, "TARGETDIR ", NULL
, NULL
);
398 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
400 r
= MsiGetSourcePath( hpkg
, "targetdir", NULL
, NULL
);
401 ok( r
== ERROR_DIRECTORY
, "return value wrong\n");
403 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", buffer
, NULL
);
404 ok( r
== ERROR_INVALID_PARAMETER
, "return value wrong\n");
407 r
= MsiGetSourcePath( hpkg
, "TARGETDIR", NULL
, &sz
);
408 ok( r
== ERROR_SUCCESS
, "return value wrong\n");
411 MsiCloseHandle( hpkg
);
415 static void test_doaction( void )
420 r
= MsiDoAction( -1, NULL
);
421 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
423 hpkg
= package_from_db(create_package_db());
424 ok( hpkg
, "failed to create package\n");
426 r
= MsiDoAction(hpkg
, NULL
);
427 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
429 r
= MsiDoAction(0, "boo");
430 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
432 r
= MsiDoAction(hpkg
, "boo");
433 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "wrong return val\n");
435 MsiCloseHandle( hpkg
);
439 static void test_gettargetpath_bad(void)
446 hpkg
= package_from_db(create_package_db());
447 ok( hpkg
, "failed to create package\n");
449 r
= MsiGetTargetPath( 0, NULL
, NULL
, NULL
);
450 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
452 r
= MsiGetTargetPath( 0, NULL
, NULL
, &sz
);
453 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
455 r
= MsiGetTargetPath( 0, "boo", NULL
, NULL
);
456 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
458 r
= MsiGetTargetPath( 0, "boo", NULL
, NULL
);
459 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
461 r
= MsiGetTargetPath( hpkg
, "boo", NULL
, NULL
);
462 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
464 r
= MsiGetTargetPath( hpkg
, "boo", buffer
, NULL
);
465 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
467 MsiCloseHandle( hpkg
);
471 static void query_file_path(MSIHANDLE hpkg
, LPCSTR file
, LPSTR buff
)
477 rec
= MsiCreateRecord( 1 );
478 ok(rec
, "MsiCreate record failed\n");
480 r
= MsiRecordSetString( rec
, 0, file
);
481 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
484 r
= MsiFormatRecord( hpkg
, rec
, buff
, &size
);
485 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
487 MsiCloseHandle( rec
);
490 static void test_settargetpath(void)
492 char tempdir
[MAX_PATH
+8], buffer
[MAX_PATH
];
498 hdb
= create_package_db();
499 ok ( hdb
, "failed to create package database\n" );
501 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
502 ok( r
== S_OK
, "failed to add directory entry: %d\n" , r
);
504 r
= run_query( hdb
, /* these tables required by Windows Installer for MsiSetTargetPath */
505 "CREATE TABLE `Component` ( "
506 "`Component` CHAR(72) NOT NULL, "
507 "`ComponentId` CHAR(38), "
508 "`Directory_` CHAR(72) NOT NULL, "
509 "`Attributes` SHORT NOT NULL, "
510 "`Condition` CHAR(255), "
511 "`KeyPath` CHAR(72) "
512 "PRIMARY KEY `Component`)" );
513 ok( r
== S_OK
, "cannot create Component table: %d\n", r
);
516 "INSERT INTO `Component` "
517 "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
518 "VALUES( 'WinWorkAround', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'FL_dummycomponent')" );
519 ok( r
== S_OK
, "cannot add dummy component: %d\n", r
);
522 "INSERT INTO `Component` "
523 "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
524 "VALUES( 'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile')" );
525 ok( r
== S_OK
, "cannot add test component: %d\n", r
);
528 "CREATE TABLE `Feature` ( "
529 "`Feature` CHAR(38) NOT NULL, "
530 "`Feature_Parent` CHAR(38), "
532 "`Description` CHAR(255), "
533 "`Display` SHORT NOT NULL, "
534 "`Level` SHORT NOT NULL, "
535 "`Directory_` CHAR(72), "
536 "`Attributes` SHORT NOT NULL "
537 "PRIMARY KEY `Feature`)" );
538 ok( r
== S_OK
, "cannot create Feature table: %d\n", r
);
541 "INSERT INTO `Feature` "
542 "(`Feature`, `Feature_Parent`, `Display`, `Level`, `Attributes`) "
543 "VALUES( 'TestFeature', '', 0, 1, 0 )" );
544 ok( r
== ERROR_SUCCESS
, "cannot add TestFeature to Feature table: %d\n", r
);
547 "CREATE TABLE `FeatureComponents` ( "
548 "`Feature_` CHAR(38) NOT NULL, "
549 "`Component_` CHAR(72) NOT NULL "
550 "PRIMARY KEY `Feature_` )" );
551 ok( r
== S_OK
, "cannot create FeatureComponents table: %d\n", r
);
554 "INSERT INTO `FeatureComponents` "
555 "(`Feature_`, `Component_`) "
556 "VALUES( 'TestFeature', 'TestComp' )" );
557 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
559 add_directory_entry( hdb
, "'TestParent', 'TARGETDIR', 'TestParent'" );
560 add_directory_entry( hdb
, "'TestDir', 'TestParent', 'TestDir'" );
563 "CREATE TABLE `File` ("
564 "`File` CHAR(72) NOT NULL, "
565 "`Component_` CHAR(72) NOT NULL, "
566 "`FileName` CHAR(255) NOT NULL, "
567 "`FileSize` LONG NOT NULL, "
568 "`Version` CHAR(72), "
569 "`Language` CHAR(20), "
570 "`Attributes` SHORT, "
571 "`Sequence` SHORT NOT NULL "
572 "PRIMARY KEY `File`)" );
573 ok( r
== S_OK
, "cannot create File table: %d\n", r
);
576 "INSERT INTO `File` "
577 "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
578 "VALUES( 'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1 )" );
579 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
581 hpkg
= package_from_db( hdb
);
582 ok( hpkg
, "failed to create package\n");
584 r
= MsiDoAction( hpkg
, "CostInitialize");
585 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
587 r
= MsiDoAction( hpkg
, "FileCost");
588 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
590 r
= MsiDoAction( hpkg
, "CostFinalize");
591 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
593 r
= MsiSetTargetPath( 0, NULL
, NULL
);
594 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
596 r
= MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
597 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
599 r
= MsiSetTargetPath( hpkg
, "boo", NULL
);
600 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
602 r
= MsiSetTargetPath( hpkg
, "boo", "c:\\bogusx" );
603 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
605 sz
= sizeof tempdir
- 1;
606 r
= MsiGetTargetPath( hpkg
, "TARGETDIR", tempdir
, &sz
);
609 if ( GetTempFileName( tempdir
, "_wt", 0, buffer
) )
611 sprintf( tempdir
, "%s\\subdir", buffer
);
612 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", buffer
);
613 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on file returned %d\n", r
);
615 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", tempdir
);
616 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on 'subdir' of file returned %d\n", r
);
618 DeleteFile( buffer
);
620 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", buffer
);
621 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
623 r
= GetFileAttributes( buffer
);
624 ok ( r
== INVALID_FILE_ATTRIBUTES
, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r
);
626 r
= MsiSetTargetPath( hpkg
, "TARGETDIR", tempdir
);
627 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on subsubdir returned %d\n", r
);
629 trace("GetTempFileName failed, cannot do some tests\n");
632 trace( "MsiGetTargetPath failed: %d\n", r
);
635 r
= MsiSetTargetPath( hpkg
, "TestParent", "C:\\one\\two" );
636 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
638 query_file_path( hpkg
, "[#TestFile]", buffer
);
639 ok( !lstrcmp(buffer
, "C:\\one\\two\\TestDir\\testfile.txt"),
640 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer
);
642 MsiCloseHandle( hpkg
);
645 static void test_condition(void)
650 hpkg
= package_from_db(create_package_db());
651 ok( hpkg
, "failed to create package\n");
653 r
= MsiEvaluateCondition(0, NULL
);
654 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
656 r
= MsiEvaluateCondition(hpkg
, NULL
);
657 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
659 r
= MsiEvaluateCondition(hpkg
, "");
660 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
662 r
= MsiEvaluateCondition(hpkg
, "1");
663 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
665 r
= MsiEvaluateCondition(hpkg
, "0");
666 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
668 r
= MsiEvaluateCondition(hpkg
, "0 = 0");
669 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
671 r
= MsiEvaluateCondition(hpkg
, "0 <> 0");
672 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
674 r
= MsiEvaluateCondition(hpkg
, "0 = 1");
675 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
677 r
= MsiEvaluateCondition(hpkg
, "0 > 1");
678 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
680 r
= MsiEvaluateCondition(hpkg
, "0 ~> 1");
681 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
683 r
= MsiEvaluateCondition(hpkg
, "1 > 1");
684 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
686 r
= MsiEvaluateCondition(hpkg
, "1 ~> 1");
687 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
689 r
= MsiEvaluateCondition(hpkg
, "0 >= 1");
690 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
692 r
= MsiEvaluateCondition(hpkg
, "0 ~>= 1");
693 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
695 r
= MsiEvaluateCondition(hpkg
, "1 >= 1");
696 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
698 r
= MsiEvaluateCondition(hpkg
, "1 ~>= 1");
699 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
701 r
= MsiEvaluateCondition(hpkg
, "0 < 1");
702 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
704 r
= MsiEvaluateCondition(hpkg
, "0 ~< 1");
705 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
707 r
= MsiEvaluateCondition(hpkg
, "1 < 1");
708 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
710 r
= MsiEvaluateCondition(hpkg
, "1 ~< 1");
711 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
713 r
= MsiEvaluateCondition(hpkg
, "0 <= 1");
714 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
716 r
= MsiEvaluateCondition(hpkg
, "0 ~<= 1");
717 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
719 r
= MsiEvaluateCondition(hpkg
, "1 <= 1");
720 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
722 r
= MsiEvaluateCondition(hpkg
, "1 ~<= 1");
723 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
725 r
= MsiEvaluateCondition(hpkg
, "0 >=");
726 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
728 r
= MsiEvaluateCondition(hpkg
, " ");
729 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
731 r
= MsiEvaluateCondition(hpkg
, "LicView <> \"1\"");
732 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
734 r
= MsiEvaluateCondition(hpkg
, "LicView <> \"0\"");
735 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
737 r
= MsiEvaluateCondition(hpkg
, "LicView <> LicView");
738 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
740 r
= MsiEvaluateCondition(hpkg
, "not 0");
741 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
743 r
= MsiEvaluateCondition(hpkg
, "not LicView");
744 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
746 r
= MsiEvaluateCondition(hpkg
, "not \"A\"");
747 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
749 r
= MsiEvaluateCondition(hpkg
, "~not \"A\"");
750 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
752 r
= MsiEvaluateCondition(hpkg
, "\"0\"");
753 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
755 r
= MsiEvaluateCondition(hpkg
, "1 and 2");
756 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
758 r
= MsiEvaluateCondition(hpkg
, "not 0 and 3");
759 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
761 r
= MsiEvaluateCondition(hpkg
, "not 0 and 0");
762 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
764 r
= MsiEvaluateCondition(hpkg
, "not 0 or 1");
765 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
767 r
= MsiEvaluateCondition(hpkg
, "(0)");
768 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
770 r
= MsiEvaluateCondition(hpkg
, "(((((1))))))");
771 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
773 r
= MsiEvaluateCondition(hpkg
, "(((((1)))))");
774 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
776 r
= MsiEvaluateCondition(hpkg
, " \"A\" < \"B\" ");
777 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
779 r
= MsiEvaluateCondition(hpkg
, " \"A\" > \"B\" ");
780 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
782 r
= MsiEvaluateCondition(hpkg
, " \"1\" > \"12\" ");
783 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
785 r
= MsiEvaluateCondition(hpkg
, " \"100\" < \"21\" ");
786 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
788 r
= MsiEvaluateCondition(hpkg
, "0 < > 0");
789 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
791 r
= MsiEvaluateCondition(hpkg
, "(1<<1) == 2");
792 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
794 r
= MsiEvaluateCondition(hpkg
, " \"A\" = \"a\" ");
795 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
797 r
= MsiEvaluateCondition(hpkg
, " \"A\" ~ = \"a\" ");
798 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
800 r
= MsiEvaluateCondition(hpkg
, " \"A\" ~= \"a\" ");
801 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
803 r
= MsiEvaluateCondition(hpkg
, " \"A\" ~= 1 ");
804 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
806 r
= MsiEvaluateCondition(hpkg
, " \"A\" = 1 ");
807 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
809 r
= MsiEvaluateCondition(hpkg
, " 1 ~= 1 ");
810 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
812 r
= MsiEvaluateCondition(hpkg
, " 1 ~= \"1\" ");
813 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
815 r
= MsiEvaluateCondition(hpkg
, " 1 = \"1\" ");
816 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
818 r
= MsiEvaluateCondition(hpkg
, " 0 = \"1\" ");
819 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
821 r
= MsiEvaluateCondition(hpkg
, " 0 < \"100\" ");
822 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
824 r
= MsiEvaluateCondition(hpkg
, " 100 > \"0\" ");
825 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
827 r
= MsiEvaluateCondition(hpkg
, "1 XOR 1");
828 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
830 r
= MsiEvaluateCondition(hpkg
, "1 IMP 1");
831 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
833 r
= MsiEvaluateCondition(hpkg
, "1 IMP 0");
834 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
836 r
= MsiEvaluateCondition(hpkg
, "0 IMP 0");
837 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
839 r
= MsiEvaluateCondition(hpkg
, "0 EQV 0");
840 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
842 r
= MsiEvaluateCondition(hpkg
, "0 EQV 1");
843 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
845 r
= MsiEvaluateCondition(hpkg
, "1 IMP 1 OR 0");
846 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
848 r
= MsiEvaluateCondition(hpkg
, "1 IMPL 1");
849 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
851 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" >< \"S\" ");
852 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
854 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" ~>< \"s\" ");
855 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
857 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" ~>< \"\" ");
858 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
860 r
= MsiEvaluateCondition(hpkg
, "\"ASFD\" ~>< \"sss\" ");
861 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
863 MsiSetProperty(hpkg
, "mm", "5" );
865 r
= MsiEvaluateCondition(hpkg
, "mm = 5");
866 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
868 r
= MsiEvaluateCondition(hpkg
, "mm < 6");
869 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
871 r
= MsiEvaluateCondition(hpkg
, "mm <= 5");
872 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
874 r
= MsiEvaluateCondition(hpkg
, "mm > 4");
875 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
877 r
= MsiEvaluateCondition(hpkg
, "mm < 12");
878 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
880 r
= MsiEvaluateCondition(hpkg
, "mm = \"5\"");
881 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
883 r
= MsiEvaluateCondition(hpkg
, "0 = \"\"");
884 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
886 r
= MsiEvaluateCondition(hpkg
, "0 AND \"\"");
887 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
889 r
= MsiEvaluateCondition(hpkg
, "1 AND \"\"");
890 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
892 r
= MsiEvaluateCondition(hpkg
, "1 AND \"1\"");
893 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
895 r
= MsiEvaluateCondition(hpkg
, "3 >< 1");
896 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
898 r
= MsiEvaluateCondition(hpkg
, "3 >< 4");
899 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
901 r
= MsiEvaluateCondition(hpkg
, "NOT 0 AND 0");
902 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
904 r
= MsiEvaluateCondition(hpkg
, "NOT 0 AND 1");
905 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
907 r
= MsiEvaluateCondition(hpkg
, "NOT 1 OR 0");
908 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
910 r
= MsiEvaluateCondition(hpkg
, "0 AND 1 OR 1");
911 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
913 r
= MsiEvaluateCondition(hpkg
, "0 AND 0 OR 1");
914 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
916 r
= MsiEvaluateCondition(hpkg
, "NOT 0 AND 1 OR 0");
917 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
919 r
= MsiEvaluateCondition(hpkg
, "_1 = _1");
920 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
922 r
= MsiEvaluateCondition(hpkg
, "( 1 AND 1 ) = 2");
923 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
925 r
= MsiEvaluateCondition(hpkg
, "NOT ( 1 AND 1 )");
926 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
928 r
= MsiEvaluateCondition(hpkg
, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
929 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
931 r
= MsiEvaluateCondition(hpkg
, "Installed<>\"\"");
932 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
934 r
= MsiEvaluateCondition(hpkg
, "NOT 1 AND 0");
935 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
937 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
938 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
940 r
= MsiEvaluateCondition(hpkg
, "bandalmael<>0");
941 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
943 r
= MsiEvaluateCondition(hpkg
, "bandalmael<0");
944 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
946 r
= MsiEvaluateCondition(hpkg
, "bandalmael>0");
947 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
949 r
= MsiEvaluateCondition(hpkg
, "bandalmael>=0");
950 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
952 r
= MsiEvaluateCondition(hpkg
, "bandalmael<=0");
953 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
955 r
= MsiEvaluateCondition(hpkg
, "bandalmael~<>0");
956 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
958 MsiSetProperty(hpkg
, "bandalmael", "0" );
959 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
960 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
962 MsiSetProperty(hpkg
, "bandalmael", "" );
963 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
964 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
966 MsiSetProperty(hpkg
, "bandalmael", "asdf" );
967 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
968 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
970 MsiSetProperty(hpkg
, "bandalmael", "0asdf" );
971 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
972 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
974 MsiSetProperty(hpkg
, "bandalmael", "0 " );
975 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
976 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
978 MsiSetProperty(hpkg
, "bandalmael", "-0" );
979 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
980 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
982 MsiSetProperty(hpkg
, "bandalmael", "0000000000000" );
983 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
984 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
986 MsiSetProperty(hpkg
, "bandalmael", "--0" );
987 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
988 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
990 MsiSetProperty(hpkg
, "bandalmael", "0x00" );
991 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
992 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
994 MsiSetProperty(hpkg
, "bandalmael", "-" );
995 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
996 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
998 MsiSetProperty(hpkg
, "bandalmael", "+0" );
999 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1000 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1002 MsiSetProperty(hpkg
, "bandalmael", "0.0" );
1003 r
= MsiEvaluateCondition(hpkg
, "bandalmael=0");
1004 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1005 r
= MsiEvaluateCondition(hpkg
, "bandalmael<>0");
1006 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1008 MsiSetProperty(hpkg
, "one", "hi");
1009 MsiSetProperty(hpkg
, "two", "hithere");
1010 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1011 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1013 MsiSetProperty(hpkg
, "one", "hithere");
1014 MsiSetProperty(hpkg
, "two", "hi");
1015 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1016 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1018 MsiSetProperty(hpkg
, "one", "hello");
1019 MsiSetProperty(hpkg
, "two", "hi");
1020 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1021 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1023 MsiSetProperty(hpkg
, "one", "hellohithere");
1024 MsiSetProperty(hpkg
, "two", "hi");
1025 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1026 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1028 MsiSetProperty(hpkg
, "one", "");
1029 MsiSetProperty(hpkg
, "two", "hi");
1030 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1031 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1033 MsiSetProperty(hpkg
, "one", "hi");
1034 MsiSetProperty(hpkg
, "two", "");
1035 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1036 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1038 MsiSetProperty(hpkg
, "one", "");
1039 MsiSetProperty(hpkg
, "two", "");
1040 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1041 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1043 MsiSetProperty(hpkg
, "one", "1234");
1044 MsiSetProperty(hpkg
, "two", "1");
1045 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1048 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1051 MsiSetProperty(hpkg
, "one", "one 1234");
1052 MsiSetProperty(hpkg
, "two", "1");
1053 r
= MsiEvaluateCondition(hpkg
, "one >< two");
1054 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1056 MsiSetProperty(hpkg
, "one", "hithere");
1057 MsiSetProperty(hpkg
, "two", "hi");
1058 r
= MsiEvaluateCondition(hpkg
, "one << two");
1061 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1064 MsiSetProperty(hpkg
, "one", "hi");
1065 MsiSetProperty(hpkg
, "two", "hithere");
1066 r
= MsiEvaluateCondition(hpkg
, "one << two");
1067 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1069 MsiSetProperty(hpkg
, "one", "hi");
1070 MsiSetProperty(hpkg
, "two", "hi");
1071 r
= MsiEvaluateCondition(hpkg
, "one << two");
1074 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1077 MsiSetProperty(hpkg
, "one", "abcdhithere");
1078 MsiSetProperty(hpkg
, "two", "hi");
1079 r
= MsiEvaluateCondition(hpkg
, "one << two");
1080 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1082 MsiSetProperty(hpkg
, "one", "");
1083 MsiSetProperty(hpkg
, "two", "hi");
1084 r
= MsiEvaluateCondition(hpkg
, "one << two");
1085 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1087 MsiSetProperty(hpkg
, "one", "hithere");
1088 MsiSetProperty(hpkg
, "two", "");
1089 r
= MsiEvaluateCondition(hpkg
, "one << two");
1092 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1095 MsiSetProperty(hpkg
, "one", "");
1096 MsiSetProperty(hpkg
, "two", "");
1097 r
= MsiEvaluateCondition(hpkg
, "one << two");
1098 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1100 MsiSetProperty(hpkg
, "one", "1234");
1101 MsiSetProperty(hpkg
, "two", "1");
1102 r
= MsiEvaluateCondition(hpkg
, "one << two");
1103 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1105 MsiSetProperty(hpkg
, "one", "1234 one");
1106 MsiSetProperty(hpkg
, "two", "1");
1107 r
= MsiEvaluateCondition(hpkg
, "one << two");
1110 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1113 MsiSetProperty(hpkg
, "one", "hithere");
1114 MsiSetProperty(hpkg
, "two", "there");
1115 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1118 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1121 MsiSetProperty(hpkg
, "one", "hithere");
1122 MsiSetProperty(hpkg
, "two", "hi");
1123 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1126 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1129 MsiSetProperty(hpkg
, "one", "there");
1130 MsiSetProperty(hpkg
, "two", "hithere");
1131 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1134 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1137 MsiSetProperty(hpkg
, "one", "there");
1138 MsiSetProperty(hpkg
, "two", "there");
1139 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1142 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1145 MsiSetProperty(hpkg
, "one", "abcdhithere");
1146 MsiSetProperty(hpkg
, "two", "hi");
1147 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1150 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1153 MsiSetProperty(hpkg
, "one", "");
1154 MsiSetProperty(hpkg
, "two", "there");
1155 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1158 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1161 MsiSetProperty(hpkg
, "one", "there");
1162 MsiSetProperty(hpkg
, "two", "");
1163 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1166 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1169 MsiSetProperty(hpkg
, "one", "");
1170 MsiSetProperty(hpkg
, "two", "");
1171 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1174 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1177 MsiSetProperty(hpkg
, "one", "1234");
1178 MsiSetProperty(hpkg
, "two", "4");
1179 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1182 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1185 MsiSetProperty(hpkg
, "one", "one 1234");
1186 MsiSetProperty(hpkg
, "two", "4");
1187 r
= MsiEvaluateCondition(hpkg
, "one >> two");
1190 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1193 MsiCloseHandle( hpkg
);
1194 DeleteFile(msifile
);
1197 static BOOL
check_prop_empty( MSIHANDLE hpkg
, const char * prop
)
1205 r
= MsiGetProperty( hpkg
, prop
, buffer
, &sz
);
1206 return r
== ERROR_SUCCESS
&& buffer
[0] == 0 && sz
== 0;
1209 static void test_props(void)
1216 hpkg
= package_from_db(create_package_db());
1217 ok( hpkg
, "failed to create package\n");
1219 /* test invalid values */
1220 r
= MsiGetProperty( 0, NULL
, NULL
, NULL
);
1221 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1223 r
= MsiGetProperty( hpkg
, NULL
, NULL
, NULL
);
1224 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1226 r
= MsiGetProperty( hpkg
, "boo", NULL
, NULL
);
1227 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1229 r
= MsiGetProperty( hpkg
, "boo", buffer
, NULL
);
1230 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1232 /* test retrieving an empty/nonexistent property */
1234 r
= MsiGetProperty( hpkg
, "boo", NULL
, &sz
);
1235 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1236 ok( sz
== 0, "wrong size returned\n");
1238 check_prop_empty( hpkg
, "boo");
1241 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1242 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
1243 ok( !strcmp(buffer
,"x"), "buffer was changed\n");
1244 ok( sz
== 0, "wrong size returned\n");
1248 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1249 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1250 ok( buffer
[0] == 0, "buffer was not changed\n");
1251 ok( sz
== 0, "wrong size returned\n");
1253 /* set the property to something */
1254 r
= MsiSetProperty( 0, NULL
, NULL
);
1255 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1257 r
= MsiSetProperty( hpkg
, NULL
, NULL
);
1258 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1260 r
= MsiSetProperty( hpkg
, "", NULL
);
1261 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1263 /* try set and get some illegal property identifiers */
1264 r
= MsiSetProperty( hpkg
, "", "asdf" );
1265 ok( r
== ERROR_FUNCTION_FAILED
, "wrong return val\n");
1267 r
= MsiSetProperty( hpkg
, "=", "asdf" );
1268 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1270 r
= MsiSetProperty( hpkg
, " ", "asdf" );
1271 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1273 r
= MsiSetProperty( hpkg
, "'", "asdf" );
1274 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1278 r
= MsiGetProperty( hpkg
, "'", buffer
, &sz
);
1279 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1280 ok( !strcmp(buffer
,"asdf"), "buffer was not changed\n");
1282 /* set empty values */
1283 r
= MsiSetProperty( hpkg
, "boo", NULL
);
1284 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1285 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
1287 r
= MsiSetProperty( hpkg
, "boo", "" );
1288 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1289 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
1291 /* set a non-empty value */
1292 r
= MsiSetProperty( hpkg
, "boo", "xyz" );
1293 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1297 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1298 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
1299 ok( buffer
[0] == 0, "buffer was not changed\n");
1300 ok( sz
== 3, "wrong size returned\n");
1304 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1305 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
1306 ok( !strcmp(buffer
,"xyz"), "buffer was not changed\n");
1307 ok( sz
== 3, "wrong size returned\n");
1311 r
= MsiGetProperty( hpkg
, "boo", buffer
, &sz
);
1312 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
1313 ok( !strcmp(buffer
,"xy"), "buffer was not changed\n");
1314 ok( sz
== 3, "wrong size returned\n");
1316 MsiCloseHandle( hpkg
);
1317 DeleteFile(msifile
);
1320 static UINT
try_query_param( MSIHANDLE hdb
, LPCSTR szQuery
, MSIHANDLE hrec
)
1325 res
= MsiDatabaseOpenView( hdb
, szQuery
, &htab
);
1326 if( res
== ERROR_SUCCESS
)
1330 r
= MsiViewExecute( htab
, hrec
);
1331 if( r
!= ERROR_SUCCESS
)
1334 fprintf(stderr
,"MsiViewExecute failed %08x\n", res
);
1337 r
= MsiViewClose( htab
);
1338 if( r
!= ERROR_SUCCESS
)
1341 r
= MsiCloseHandle( htab
);
1342 if( r
!= ERROR_SUCCESS
)
1348 static UINT
try_query( MSIHANDLE hdb
, LPCSTR szQuery
)
1350 return try_query_param( hdb
, szQuery
, 0 );
1353 static void test_msipackage(void)
1355 MSIHANDLE hdb
= 0, hpack
= 100;
1360 DeleteFile(msifile
);
1364 r
= MsiOpenPackage(name
, &hpack
);
1365 ok(r
== ERROR_SUCCESS
, "failed to open package with no name\n");
1366 r
= MsiCloseHandle(hpack
);
1367 ok(r
== ERROR_SUCCESS
, "failed to close package\n");
1370 /* just MsiOpenDatabase should not create a file */
1371 r
= MsiOpenDatabase(msifile
, MSIDBOPEN_CREATE
, &hdb
);
1372 ok(r
== ERROR_SUCCESS
, "MsiOpenDatabase failed\n");
1376 r
= MsiOpenPackage(name
, &hpack
);
1377 ok(r
== ERROR_INVALID_HANDLE
, "MsiOpenPackage returned wrong code\n");
1380 /* now try again with our empty database */
1381 sprintf(name
, "#%ld", hdb
);
1382 r
= MsiOpenPackage(name
, &hpack
);
1383 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
, "MsiOpenPackage returned wrong code\n");
1384 if (!r
) MsiCloseHandle(hpack
);
1387 /* create a table */
1388 query
= "CREATE TABLE `Property` ( "
1389 "`Property` CHAR(72), `Value` CHAR(0) "
1390 "PRIMARY KEY `Property`)";
1391 r
= try_query(hdb
, query
);
1392 ok(r
== ERROR_SUCCESS
, "failed to create Properties table\n");
1395 query
= "CREATE TABLE `InstallExecuteSequence` ("
1396 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
1397 "PRIMARY KEY `Action`)";
1398 r
= try_query(hdb
, query
);
1399 ok(r
== ERROR_SUCCESS
, "failed to create InstallExecuteSequence table\n");
1401 sprintf(name
, "#%ld", hdb
);
1402 r
= MsiOpenPackage(name
, &hpack
);
1403 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
, "MsiOpenPackage returned wrong code\n");
1404 if (!r
) MsiCloseHandle(hpack
);
1407 r
= MsiCloseHandle(hdb
);
1408 ok(r
== ERROR_SUCCESS
, "MsiCloseHandle(database) failed\n");
1409 DeleteFile(msifile
);
1412 static void test_formatrecord2(void)
1414 MSIHANDLE hpkg
, hrec
;
1419 hpkg
= package_from_db(create_package_db());
1420 ok( hpkg
, "failed to create package\n");
1422 r
= MsiSetProperty(hpkg
, "Manufacturer", " " );
1423 ok( r
== ERROR_SUCCESS
, "set property failed\n");
1425 hrec
= MsiCreateRecord(2);
1426 ok(hrec
, "create record failed\n");
1428 r
= MsiRecordSetString( hrec
, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
1429 ok( r
== ERROR_SUCCESS
, "format record failed\n");
1433 r
= MsiFormatRecord( hpkg
, hrec
, buffer
, &sz
);
1435 r
= MsiRecordSetString(hrec
, 0, "[foo][1]");
1436 r
= MsiRecordSetString(hrec
, 1, "hoo");
1438 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1439 ok( sz
== 3, "size wrong\n");
1440 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
1441 ok( r
== ERROR_SUCCESS
, "format failed\n");
1443 r
= MsiRecordSetString(hrec
, 0, "x[~]x");
1445 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1446 ok( sz
== 3, "size wrong\n");
1447 ok( 0 == strcmp(buffer
,"x"), "wrong output %s\n",buffer
);
1448 ok( r
== ERROR_SUCCESS
, "format failed\n");
1450 r
= MsiRecordSetString(hrec
, 0, "[foo.$%}][1]");
1451 r
= MsiRecordSetString(hrec
, 1, "hoo");
1453 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1454 ok( sz
== 3, "size wrong\n");
1455 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
1456 ok( r
== ERROR_SUCCESS
, "format failed\n");
1458 r
= MsiRecordSetString(hrec
, 0, "[\\[]");
1460 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1461 ok( sz
== 1, "size wrong\n");
1462 ok( 0 == strcmp(buffer
,"["), "wrong output %s\n",buffer
);
1463 ok( r
== ERROR_SUCCESS
, "format failed\n");
1465 SetEnvironmentVariable("FOO", "BAR");
1466 r
= MsiRecordSetString(hrec
, 0, "[%FOO]");
1468 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1469 ok( sz
== 3, "size wrong\n");
1470 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
1471 ok( r
== ERROR_SUCCESS
, "format failed\n");
1473 r
= MsiRecordSetString(hrec
, 0, "[[1]]");
1474 r
= MsiRecordSetString(hrec
, 1, "%FOO");
1476 r
= MsiFormatRecord(hpkg
, hrec
, buffer
, &sz
);
1477 ok( sz
== 3, "size wrong\n");
1478 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
1479 ok( r
== ERROR_SUCCESS
, "format failed\n");
1481 MsiCloseHandle( hrec
);
1482 MsiCloseHandle( hpkg
);
1483 DeleteFile(msifile
);
1486 static void test_states(void)
1491 INSTALLSTATE state
, action
;
1493 hdb
= create_package_db();
1494 ok ( hdb
, "failed to create package database\n" );
1496 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
1497 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
1499 r
= create_feature_table( hdb
);
1500 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
1502 r
= create_component_table( hdb
);
1503 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
1505 /* msidbFeatureAttributesFavorLocal */
1506 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
1507 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
1509 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
1510 r
= add_component_entry( hdb
, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
1511 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1513 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
1514 r
= add_component_entry( hdb
, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
1515 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1517 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
1518 r
= add_component_entry( hdb
, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
1519 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1521 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
1522 r
= add_component_entry( hdb
, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
1523 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1525 /* msidbFeatureAttributesFavorSource */
1526 r
= add_feature_entry( hdb
, "'two', '', '', '', 2, 1, '', 1" );
1527 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
1529 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
1530 r
= add_component_entry( hdb
, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
1531 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1533 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1534 r
= add_component_entry( hdb
, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
1535 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1537 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
1538 r
= add_component_entry( hdb
, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
1539 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1541 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
1542 r
= add_component_entry( hdb
, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
1543 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1545 /* msidbFeatureAttributesFavorSource */
1546 r
= add_feature_entry( hdb
, "'three', '', '', '', 2, 1, '', 1" );
1547 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
1549 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1550 r
= add_component_entry( hdb
, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
1551 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
1553 r
= create_feature_components_table( hdb
);
1554 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
1556 r
= add_feature_components_entry( hdb
, "'one', 'alpha'" );
1557 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1559 r
= add_feature_components_entry( hdb
, "'one', 'beta'" );
1560 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1562 r
= add_feature_components_entry( hdb
, "'one', 'gamma'" );
1563 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1565 r
= add_feature_components_entry( hdb
, "'one', 'theta'" );
1566 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1568 r
= add_feature_components_entry( hdb
, "'two', 'delta'" );
1569 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1571 r
= add_feature_components_entry( hdb
, "'two', 'epsilon'" );
1572 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1574 r
= add_feature_components_entry( hdb
, "'two', 'zeta'" );
1575 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1577 r
= add_feature_components_entry( hdb
, "'two', 'iota'" );
1578 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1580 r
= add_feature_components_entry( hdb
, "'three', 'eta'" );
1581 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
1583 r
= create_file_table( hdb
);
1584 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
1586 r
= add_file_entry( hdb
, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
1587 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1589 r
= add_file_entry( hdb
, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
1590 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1592 r
= add_file_entry( hdb
, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
1593 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1595 r
= add_file_entry( hdb
, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
1596 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1598 r
= add_file_entry( hdb
, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
1599 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1601 r
= add_file_entry( hdb
, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
1602 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1604 r
= add_file_entry( hdb
, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
1605 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1607 r
= add_file_entry( hdb
, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
1608 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1610 /* compressed file */
1611 r
= add_file_entry( hdb
, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
1612 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
1614 hpkg
= package_from_db( hdb
);
1615 ok( hpkg
, "failed to create package\n");
1619 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
1620 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
1621 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1622 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1626 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
1627 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
1628 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1629 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1633 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
1634 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r
);
1635 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1636 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1640 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
1641 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1642 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1643 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1647 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
1648 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1649 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1650 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1654 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
1655 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1656 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1657 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1661 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
1662 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1663 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1664 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1668 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
1669 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1670 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1671 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1675 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
1676 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1677 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1678 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1682 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
1683 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1684 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1685 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1689 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
1690 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1691 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1692 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1696 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
1697 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
1698 ok( state
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", state
);
1699 ok( action
== 0xdeadbee, "Expected 0xdeadbee, got %d\n", action
);
1701 r
= MsiDoAction( hpkg
, "CostInitialize");
1702 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
1706 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
1707 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1710 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1712 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1716 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
1717 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1720 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1722 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1726 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
1727 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1730 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1732 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1736 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
1737 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1740 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1741 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1746 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
1747 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1750 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1751 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1756 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
1757 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1760 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1761 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1766 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
1767 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1770 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1771 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1776 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
1777 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1780 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1781 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1786 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
1787 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1790 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1791 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1796 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
1797 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1800 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1801 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1806 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
1807 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1810 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1811 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1816 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
1817 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1820 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1821 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1824 r
= MsiDoAction( hpkg
, "FileCost");
1825 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
1829 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
1830 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1833 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1835 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1839 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
1840 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1843 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1845 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1849 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
1850 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1853 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1855 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1859 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
1860 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1863 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1864 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1869 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
1870 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1873 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1874 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1879 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
1880 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1883 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1884 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1889 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
1890 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1893 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1894 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1899 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
1900 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1903 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1904 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1909 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
1910 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1913 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1914 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1919 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
1920 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1923 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1924 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1929 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
1930 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1933 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1934 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1939 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
1940 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1943 ok( state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1944 ok( action
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
1947 r
= MsiDoAction( hpkg
, "CostFinalize");
1948 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
1952 r
= MsiGetFeatureState(hpkg
, "one", &state
, &action
);
1953 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1954 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1955 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
1959 r
= MsiGetFeatureState(hpkg
, "two", &state
, &action
);
1960 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1961 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1962 ok( action
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", action
);
1966 r
= MsiGetFeatureState(hpkg
, "three", &state
, &action
);
1967 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1968 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1969 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
1973 r
= MsiGetComponentState(hpkg
, "alpha", &state
, &action
);
1974 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1975 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1976 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
1980 r
= MsiGetComponentState(hpkg
, "beta", &state
, &action
);
1981 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1982 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1983 ok( action
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", action
);
1987 r
= MsiGetComponentState(hpkg
, "gamma", &state
, &action
);
1988 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1989 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1990 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
1994 r
= MsiGetComponentState(hpkg
, "theta", &state
, &action
);
1995 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1996 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1997 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
2001 r
= MsiGetComponentState(hpkg
, "delta", &state
, &action
);
2002 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2003 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2004 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
2008 r
= MsiGetComponentState(hpkg
, "epsilon", &state
, &action
);
2009 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2010 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2011 ok( action
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", action
);
2015 r
= MsiGetComponentState(hpkg
, "zeta", &state
, &action
);
2016 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2017 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2018 ok( action
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", action
);
2022 r
= MsiGetComponentState(hpkg
, "iota", &state
, &action
);
2023 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2024 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2025 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
2029 r
= MsiGetComponentState(hpkg
, "eta", &state
, &action
);
2030 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2031 ok( state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2032 ok( action
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", action
);
2034 MsiCloseHandle( hpkg
);
2037 static void test_getproperty(void)
2039 MSIHANDLE hPackage
= 0;
2041 static CHAR empty
[] = "";
2045 hPackage
= package_from_db(create_package_db());
2046 ok( hPackage
!= 0, " Failed to create package\n");
2048 /* set the property */
2049 r
= MsiSetProperty(hPackage
, "Name", "Value");
2050 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2052 /* retrieve the size, NULL pointer */
2054 r
= MsiGetProperty(hPackage
, "Name", NULL
, &size
);
2055 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2056 ok( size
== 5, "Expected 5, got %ld\n", size
);
2058 /* retrieve the size, empty string */
2060 r
= MsiGetProperty(hPackage
, "Name", empty
, &size
);
2061 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
2062 ok( size
== 5, "Expected 5, got %ld\n", size
);
2064 /* don't change size */
2065 r
= MsiGetProperty(hPackage
, "Name", prop
, &size
);
2066 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
2067 ok( size
== 5, "Expected 5, got %ld\n", size
);
2068 ok( !lstrcmp(prop
, "Valu"), "Expected Valu, got %s\n", prop
);
2070 /* increase the size by 1 */
2072 r
= MsiGetProperty(hPackage
, "Name", prop
, &size
);
2073 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2074 ok( size
== 5, "Expected 5, got %ld\n", size
);
2075 ok( !lstrcmp(prop
, "Value"), "Expected Value, got %s\n", prop
);
2077 r
= MsiCloseHandle( hPackage
);
2078 ok( r
== ERROR_SUCCESS
, "Failed to close package\n" );
2079 DeleteFile(msifile
);
2082 static void test_removefiles(void)
2087 char CURR_DIR
[MAX_PATH
];
2089 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
2091 hdb
= create_package_db();
2092 ok ( hdb
, "failed to create package database\n" );
2094 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
2095 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
2097 r
= create_feature_table( hdb
);
2098 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
2100 r
= create_component_table( hdb
);
2101 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
2103 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
2104 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2106 r
= add_component_entry( hdb
, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
2107 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2109 r
= add_component_entry( hdb
, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
2110 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2112 r
= add_component_entry( hdb
, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
2113 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2115 r
= add_component_entry( hdb
, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
2116 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2118 r
= add_component_entry( hdb
, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
2119 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2121 r
= add_component_entry( hdb
, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
2122 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2124 r
= create_feature_components_table( hdb
);
2125 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
2127 r
= add_feature_components_entry( hdb
, "'one', 'hydrogen'" );
2128 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2130 r
= add_feature_components_entry( hdb
, "'one', 'helium'" );
2131 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2133 r
= add_feature_components_entry( hdb
, "'one', 'lithium'" );
2134 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2136 r
= add_feature_components_entry( hdb
, "'one', 'beryllium'" );
2137 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2139 r
= add_feature_components_entry( hdb
, "'one', 'boron'" );
2140 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2142 r
= add_feature_components_entry( hdb
, "'one', 'carbon'" );
2143 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2145 r
= create_file_table( hdb
);
2146 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
2148 r
= add_file_entry( hdb
, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
2149 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2151 r
= add_file_entry( hdb
, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
2152 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2154 r
= add_file_entry( hdb
, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
2155 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2157 r
= add_file_entry( hdb
, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
2158 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2160 r
= add_file_entry( hdb
, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
2161 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2163 r
= add_file_entry( hdb
, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
2164 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2166 r
= create_remove_file_table( hdb
);
2167 ok( r
== ERROR_SUCCESS
, "cannot create Remove File table: %d\n", r
);
2169 hpkg
= package_from_db( hdb
);
2170 ok( hpkg
, "failed to create package\n");
2172 create_test_file( "hydrogen.txt" );
2173 create_test_file( "helium.txt" );
2174 create_test_file( "lithium.txt" );
2175 create_test_file( "beryllium.txt" );
2176 create_test_file( "boron.txt" );
2177 create_test_file( "carbon.txt" );
2179 r
= MsiSetProperty( hpkg
, "TARGETDIR", CURR_DIR
);
2180 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2182 r
= MsiDoAction( hpkg
, "CostInitialize");
2183 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
2185 r
= MsiDoAction( hpkg
, "FileCost");
2186 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
2188 r
= MsiDoAction( hpkg
, "CostFinalize");
2189 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
2191 r
= MsiDoAction( hpkg
, "InstallValidate");
2192 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
2194 r
= MsiSetComponentState( hpkg
, "hydrogen", INSTALLSTATE_ABSENT
);
2195 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2197 r
= MsiSetComponentState( hpkg
, "helium", INSTALLSTATE_LOCAL
);
2198 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2200 r
= MsiSetComponentState( hpkg
, "lithium", INSTALLSTATE_SOURCE
);
2201 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2203 r
= MsiSetComponentState( hpkg
, "beryllium", INSTALLSTATE_ABSENT
);
2204 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2206 r
= MsiSetComponentState( hpkg
, "boron", INSTALLSTATE_LOCAL
);
2207 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2209 r
= MsiSetComponentState( hpkg
, "carbon", INSTALLSTATE_SOURCE
);
2210 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
2212 r
= MsiDoAction( hpkg
, "RemoveFiles");
2213 ok( r
== ERROR_SUCCESS
, "remove files failed\n");
2215 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
2216 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
2217 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
2218 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
2219 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
2220 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
2222 MsiCloseHandle( hpkg
);
2223 DeleteFileA(msifile
);
2228 test_createpackage();
2229 test_getsourcepath_bad();
2230 test_getsourcepath();
2232 test_gettargetpath_bad();
2233 test_settargetpath();
2237 test_formatrecord2();