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 do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
38 /* open a select query */
39 r = MsiDatabaseOpenView(hdb, query, &hview);
40 if (r != ERROR_SUCCESS)
42 r = MsiViewExecute(hview, 0);
43 if (r != ERROR_SUCCESS)
45 ret = MsiViewFetch(hview, phrec);
46 r = MsiViewClose(hview);
47 if (r != ERROR_SUCCESS)
49 r = MsiCloseHandle(hview);
50 if (r != ERROR_SUCCESS)
55 static UINT run_query( MSIHANDLE hdb, const char *query )
60 r = MsiDatabaseOpenView(hdb, query, &hview);
61 if( r != ERROR_SUCCESS )
64 r = MsiViewExecute(hview, 0);
65 if( r == ERROR_SUCCESS )
66 r = MsiViewClose(hview);
67 MsiCloseHandle(hview);
71 static UINT create_component_table( MSIHANDLE hdb )
73 return run_query( hdb,
74 "CREATE TABLE `Component` ( "
75 "`Component` CHAR(72) NOT NULL, "
76 "`ComponentId` CHAR(38), "
77 "`Directory_` CHAR(72) NOT NULL, "
78 "`Attributes` SHORT NOT NULL, "
79 "`Condition` CHAR(255), "
81 "PRIMARY KEY `Component`)" );
84 static UINT create_feature_table( MSIHANDLE hdb )
86 return run_query( hdb,
87 "CREATE TABLE `Feature` ( "
88 "`Feature` CHAR(38) NOT NULL, "
89 "`Feature_Parent` CHAR(38), "
91 "`Description` CHAR(255), "
92 "`Display` SHORT NOT NULL, "
93 "`Level` SHORT NOT NULL, "
94 "`Directory_` CHAR(72), "
95 "`Attributes` SHORT NOT NULL "
96 "PRIMARY KEY `Feature`)" );
99 static UINT create_feature_components_table( MSIHANDLE hdb )
101 return run_query( hdb,
102 "CREATE TABLE `FeatureComponents` ( "
103 "`Feature_` CHAR(38) NOT NULL, "
104 "`Component_` CHAR(72) NOT NULL "
105 "PRIMARY KEY `Feature_`, `Component_` )" );
108 static UINT create_file_table( MSIHANDLE hdb )
110 return run_query( hdb,
111 "CREATE TABLE `File` ("
112 "`File` CHAR(72) NOT NULL, "
113 "`Component_` CHAR(72) NOT NULL, "
114 "`FileName` CHAR(255) NOT NULL, "
115 "`FileSize` LONG NOT NULL, "
116 "`Version` CHAR(72), "
117 "`Language` CHAR(20), "
118 "`Attributes` SHORT, "
119 "`Sequence` SHORT NOT NULL "
120 "PRIMARY KEY `File`)" );
123 static UINT create_remove_file_table( MSIHANDLE hdb )
125 return run_query( hdb,
126 "CREATE TABLE `RemoveFile` ("
127 "`FileKey` CHAR(72) NOT NULL, "
128 "`Component_` CHAR(72) NOT NULL, "
129 "`FileName` CHAR(255) LOCALIZABLE, "
130 "`DirProperty` CHAR(72) NOT NULL, "
131 "`InstallMode` SHORT NOT NULL "
132 "PRIMARY KEY `FileKey`)" );
135 static UINT create_appsearch_table( MSIHANDLE hdb )
137 return run_query( hdb,
138 "CREATE TABLE `AppSearch` ("
139 "`Property` CHAR(72) NOT NULL, "
140 "`Signature_` CHAR(72) NOT NULL "
141 "PRIMARY KEY `Property`, `Signature_`)" );
144 static UINT create_reglocator_table( MSIHANDLE hdb )
146 return run_query( hdb,
147 "CREATE TABLE `RegLocator` ("
148 "`Signature_` CHAR(72) NOT NULL, "
149 "`Root` SHORT NOT NULL, "
150 "`Key` CHAR(255) NOT NULL, "
153 "PRIMARY KEY `Signature_`)" );
156 static UINT create_signature_table( MSIHANDLE hdb )
158 return run_query( hdb,
159 "CREATE TABLE `Signature` ("
160 "`Signature` CHAR(72) NOT NULL, "
161 "`FileName` CHAR(255) NOT NULL, "
162 "`MinVersion` CHAR(20), "
163 "`MaxVersion` CHAR(20), "
168 "`Languages` CHAR(255) "
169 "PRIMARY KEY `Signature`)" );
172 static UINT create_launchcondition_table( MSIHANDLE hdb )
174 return run_query( hdb,
175 "CREATE TABLE `LaunchCondition` ("
176 "`Condition` CHAR(255) NOT NULL, "
177 "`Description` CHAR(255) NOT NULL "
178 "PRIMARY KEY `Condition`)" );
181 static UINT create_property_table( MSIHANDLE hdb )
183 return run_query( hdb,
184 "CREATE TABLE `Property` ("
185 "`Property` CHAR(72) NOT NULL, "
187 "PRIMARY KEY `Property`)" );
190 static UINT add_component_entry( MSIHANDLE hdb, const char *values )
192 char insert[] = "INSERT INTO `Component` "
193 "(`Component`, `ComponentId`, `Directory_`, `Attributes`, `Condition`, `KeyPath`) "
198 sz = strlen(values) + sizeof insert;
199 query = HeapAlloc(GetProcessHeap(),0,sz);
200 sprintf(query,insert,values);
201 r = run_query( hdb, query );
202 HeapFree(GetProcessHeap(), 0, query);
206 static UINT add_feature_entry( MSIHANDLE hdb, const char *values )
208 char insert[] = "INSERT INTO `Feature` (`Feature`, `Feature_Parent`, "
209 "`Title`, `Description`, `Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )";
213 sz = strlen(values) + sizeof insert;
214 query = HeapAlloc(GetProcessHeap(),0,sz);
215 sprintf(query,insert,values);
216 r = run_query( hdb, query );
217 HeapFree(GetProcessHeap(), 0, query);
221 static UINT add_feature_components_entry( MSIHANDLE hdb, const char *values )
223 char insert[] = "INSERT INTO `FeatureComponents` "
224 "(`Feature_`, `Component_`) "
229 sz = strlen(values) + sizeof insert;
230 query = HeapAlloc(GetProcessHeap(),0,sz);
231 sprintf(query,insert,values);
232 r = run_query( hdb, query );
233 HeapFree(GetProcessHeap(), 0, query);
237 static UINT add_file_entry( MSIHANDLE hdb, const char *values )
239 char insert[] = "INSERT INTO `File` "
240 "(`File`, `Component_`, `FileName`, `FileSize`, `Version`, `Language`, `Attributes`, `Sequence`) "
245 sz = strlen(values) + sizeof insert;
246 query = HeapAlloc(GetProcessHeap(),0,sz);
247 sprintf(query,insert,values);
248 r = run_query( hdb, query );
249 HeapFree(GetProcessHeap(), 0, query);
253 static UINT add_appsearch_entry( MSIHANDLE hdb, const char *values )
255 char insert[] = "INSERT INTO `AppSearch` "
256 "(`Property`, `Signature_`) "
261 sz = strlen(values) + sizeof insert;
262 query = HeapAlloc(GetProcessHeap(),0,sz);
263 sprintf(query,insert,values);
264 r = run_query( hdb, query );
265 HeapFree(GetProcessHeap(), 0, query);
269 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *values )
271 char insert[] = "INSERT INTO `RegLocator` "
272 "(`Signature_`, `Root`, `Key`, `Name`, `Type`) "
277 sz = strlen(values) + sizeof insert;
278 query = HeapAlloc(GetProcessHeap(),0,sz);
279 sprintf(query,insert,values);
280 r = run_query( hdb, query );
281 HeapFree(GetProcessHeap(), 0, query);
285 static UINT add_signature_entry( MSIHANDLE hdb, const char *values )
287 char insert[] = "INSERT INTO `Signature` "
288 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
289 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
294 sz = strlen(values) + sizeof insert;
295 query = HeapAlloc(GetProcessHeap(),0,sz);
296 sprintf(query,insert,values);
297 r = run_query( hdb, query );
298 HeapFree(GetProcessHeap(), 0, query);
302 static UINT add_launchcondition_entry( MSIHANDLE hdb, const char *values )
304 char insert[] = "INSERT INTO `LaunchCondition` "
305 "(`Condition`, `Description`) "
310 sz = strlen(values) + sizeof insert;
311 query = HeapAlloc(GetProcessHeap(),0,sz);
312 sprintf(query,insert,values);
313 r = run_query( hdb, query );
314 HeapFree(GetProcessHeap(), 0, query);
318 static UINT add_property_entry( MSIHANDLE hdb, const char *values )
320 char insert[] = "INSERT INTO `Property` "
321 "(`Property`, `Value`) "
326 sz = strlen(values) + sizeof insert;
327 query = HeapAlloc(GetProcessHeap(),0,sz);
328 sprintf(query,insert,values);
329 r = run_query( hdb, query );
330 HeapFree(GetProcessHeap(), 0, query);
334 static UINT set_summary_info(MSIHANDLE hdb)
339 /* build summmary info */
340 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
341 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
343 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
344 "Installation Database");
345 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
347 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
348 "Installation Database");
349 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
351 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
353 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
355 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
357 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
359 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
360 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
361 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
363 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
364 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
366 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
367 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
369 res = MsiSummaryInfoPersist(suminfo);
370 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
372 res = MsiCloseHandle( suminfo);
373 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
379 static MSIHANDLE create_package_db(void)
386 /* create an empty database */
387 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
388 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
389 if( res != ERROR_SUCCESS )
392 res = MsiDatabaseCommit( hdb );
393 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
395 res = set_summary_info(hdb);
397 res = run_query( hdb,
398 "CREATE TABLE `Directory` ( "
399 "`Directory` CHAR(255) NOT NULL, "
400 "`Directory_Parent` CHAR(255), "
401 "`DefaultDir` CHAR(255) NOT NULL "
402 "PRIMARY KEY `Directory`)" );
403 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
408 static MSIHANDLE package_from_db(MSIHANDLE hdb)
414 sprintf(szPackage,"#%li",hdb);
415 res = MsiOpenPackage(szPackage,&hPackage);
416 if (res != ERROR_SUCCESS)
419 res = MsiCloseHandle(hdb);
420 if (res != ERROR_SUCCESS)
426 static void create_test_file(const CHAR *name)
431 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
432 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
433 WriteFile(file, name, strlen(name), &written, NULL);
434 WriteFile(file, "\n", strlen("\n"), &written, NULL);
438 static void test_createpackage(void)
440 MSIHANDLE hPackage = 0;
443 hPackage = package_from_db(create_package_db());
444 ok( hPackage != 0, " Failed to create package\n");
446 res = MsiCloseHandle( hPackage);
447 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
451 static void test_getsourcepath_bad( void )
453 static const char str[] = { 0 };
458 r = MsiGetSourcePath( -1, NULL, NULL, NULL );
459 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
462 r = MsiGetSourcePath( -1, NULL, buffer, &sz );
463 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
466 r = MsiGetSourcePath( -1, str, NULL, &sz );
467 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
470 r = MsiGetSourcePath( -1, str, NULL, NULL );
471 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
474 r = MsiGetSourcePath( -1, str, buffer, &sz );
475 ok( r == ERROR_INVALID_HANDLE, "return value wrong\n");
478 static UINT add_directory_entry( MSIHANDLE hdb, const char *values )
480 char insert[] = "INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )";
484 sz = strlen(values) + sizeof insert;
485 query = HeapAlloc(GetProcessHeap(),0,sz);
486 sprintf(query,insert,values);
487 r = run_query( hdb, query );
488 HeapFree(GetProcessHeap(), 0, query);
492 static void test_getsourcepath( void )
494 static const char str[] = { 0 };
500 hpkg = package_from_db(create_package_db());
501 ok( hpkg, "failed to create package\n");
505 r = MsiGetSourcePath( hpkg, str, buffer, &sz );
506 ok( r == ERROR_DIRECTORY, "return value wrong\n");
507 ok( buffer[0] == 'x', "buffer modified\n");
511 r = MsiGetSourcePath( hpkg, str, buffer, &sz );
512 ok( r == ERROR_DIRECTORY, "return value wrong\n");
513 ok( buffer[0] == 'x', "buffer modified\n");
515 MsiCloseHandle( hpkg );
518 /* another test but try create a directory this time */
519 hdb = create_package_db();
520 ok( hdb, "failed to create database\n");
522 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
523 ok( r == S_OK, "failed\n");
525 hpkg = package_from_db(hdb);
526 ok( hpkg, "failed to create package\n");
528 sz = sizeof buffer -1;
529 strcpy(buffer,"x bad");
530 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
531 ok( r == ERROR_DIRECTORY, "return value wrong\n");
533 r = MsiDoAction( hpkg, "CostInitialize");
534 ok( r == ERROR_SUCCESS, "cost init failed\n");
535 r = MsiDoAction( hpkg, "CostFinalize");
536 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
538 sz = sizeof buffer -1;
540 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
541 ok( r == ERROR_SUCCESS, "return value wrong\n");
542 ok( sz == strlen(buffer), "returned length wrong\n");
545 strcpy(buffer,"x bad");
546 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, &sz );
547 ok( r == ERROR_MORE_DATA, "return value wrong\n");
548 ok( buffer[0] == 'x', "buffer modified\n");
550 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, NULL );
551 ok( r == ERROR_SUCCESS, "return value wrong\n");
553 r = MsiGetSourcePath( hpkg, "TARGETDIR ", NULL, NULL );
554 ok( r == ERROR_DIRECTORY, "return value wrong\n");
556 r = MsiGetSourcePath( hpkg, "targetdir", NULL, NULL );
557 ok( r == ERROR_DIRECTORY, "return value wrong\n");
559 r = MsiGetSourcePath( hpkg, "TARGETDIR", buffer, NULL );
560 ok( r == ERROR_INVALID_PARAMETER, "return value wrong\n");
562 r = MsiGetSourcePath( hpkg, "TARGETDIR", NULL, &sz );
563 ok( r == ERROR_SUCCESS, "return value wrong\n");
565 MsiCloseHandle( hpkg );
569 static void test_doaction( void )
574 r = MsiDoAction( -1, NULL );
575 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
577 hpkg = package_from_db(create_package_db());
578 ok( hpkg, "failed to create package\n");
580 r = MsiDoAction(hpkg, NULL);
581 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
583 r = MsiDoAction(0, "boo");
584 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
586 r = MsiDoAction(hpkg, "boo");
587 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
589 MsiCloseHandle( hpkg );
593 static void test_gettargetpath_bad(void)
600 hpkg = package_from_db(create_package_db());
601 ok( hpkg, "failed to create package\n");
603 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
604 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
606 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
607 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
609 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
610 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
612 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
613 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
615 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
616 ok( r == ERROR_DIRECTORY, "wrong return val\n");
618 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
619 ok( r == ERROR_DIRECTORY, "wrong return val\n");
621 MsiCloseHandle( hpkg );
625 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
631 rec = MsiCreateRecord( 1 );
632 ok(rec, "MsiCreate record failed\n");
634 r = MsiRecordSetString( rec, 0, file );
635 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
638 r = MsiFormatRecord( hpkg, rec, buff, &size );
639 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
641 MsiCloseHandle( rec );
644 static void test_settargetpath(void)
646 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
652 hdb = create_package_db();
653 ok ( hdb, "failed to create package database\n" );
655 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
656 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
658 r = create_component_table( hdb );
659 ok( r == S_OK, "cannot create Component table: %d\n", r );
661 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
662 ok( r == S_OK, "cannot add dummy component: %d\n", r );
664 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
665 ok( r == S_OK, "cannot add test component: %d\n", r );
667 r = create_feature_table( hdb );
668 ok( r == S_OK, "cannot create Feature table: %d\n", r );
670 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
671 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
673 r = create_feature_components_table( hdb );
674 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
676 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
677 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
679 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
680 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
682 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
683 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
685 r = create_file_table( hdb );
686 ok( r == S_OK, "cannot create File table: %d\n", r );
688 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
689 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
691 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
692 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
694 hpkg = package_from_db( hdb );
695 ok( hpkg, "failed to create package\n");
697 r = MsiDoAction( hpkg, "CostInitialize");
698 ok( r == ERROR_SUCCESS, "cost init failed\n");
700 r = MsiDoAction( hpkg, "FileCost");
701 ok( r == ERROR_SUCCESS, "file cost failed\n");
703 r = MsiDoAction( hpkg, "CostFinalize");
704 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
706 r = MsiSetTargetPath( 0, NULL, NULL );
707 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
709 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
710 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
712 r = MsiSetTargetPath( hpkg, "boo", NULL );
713 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
715 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
716 ok( r == ERROR_DIRECTORY, "wrong return val\n");
718 sz = sizeof tempdir - 1;
719 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
720 sprintf( file, "%srootfile.txt", tempdir );
721 query_file_path( hpkg, "[#RootFile]", buffer );
722 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
723 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
725 GetTempFileName( tempdir, "_wt", 0, buffer );
726 sprintf( tempdir, "%s\\subdir", buffer );
728 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
729 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on file returned %d\n", r );
731 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
732 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
734 DeleteFile( buffer );
736 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
737 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
739 r = GetFileAttributes( buffer );
740 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
742 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
743 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
745 sz = sizeof buffer - 1;
746 lstrcat( tempdir, "\\" );
747 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
748 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
749 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
751 sprintf( file, "%srootfile.txt", tempdir );
752 query_file_path( hpkg, "[#RootFile]", buffer );
753 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
755 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
756 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
758 query_file_path( hpkg, "[#TestFile]", buffer );
759 ok( !lstrcmp(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
760 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
762 sz = sizeof buffer - 1;
763 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
764 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
765 ok( !lstrcmp(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
767 MsiCloseHandle( hpkg );
770 static void test_condition(void)
775 hpkg = package_from_db(create_package_db());
776 ok( hpkg, "failed to create package\n");
778 r = MsiEvaluateCondition(0, NULL);
779 ok( r == MSICONDITION_ERROR, "wrong return val\n");
781 r = MsiEvaluateCondition(hpkg, NULL);
782 ok( r == MSICONDITION_NONE, "wrong return val\n");
784 r = MsiEvaluateCondition(hpkg, "");
785 ok( r == MSICONDITION_NONE, "wrong return val\n");
787 r = MsiEvaluateCondition(hpkg, "1");
788 ok( r == MSICONDITION_TRUE, "wrong return val\n");
790 r = MsiEvaluateCondition(hpkg, "0");
791 ok( r == MSICONDITION_FALSE, "wrong return val\n");
793 r = MsiEvaluateCondition(hpkg, "0 = 0");
794 ok( r == MSICONDITION_TRUE, "wrong return val\n");
796 r = MsiEvaluateCondition(hpkg, "0 <> 0");
797 ok( r == MSICONDITION_FALSE, "wrong return val\n");
799 r = MsiEvaluateCondition(hpkg, "0 = 1");
800 ok( r == MSICONDITION_FALSE, "wrong return val\n");
802 r = MsiEvaluateCondition(hpkg, "0 > 1");
803 ok( r == MSICONDITION_FALSE, "wrong return val\n");
805 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
806 ok( r == MSICONDITION_FALSE, "wrong return val\n");
808 r = MsiEvaluateCondition(hpkg, "1 > 1");
809 ok( r == MSICONDITION_FALSE, "wrong return val\n");
811 r = MsiEvaluateCondition(hpkg, "1 ~> 1");
812 ok( r == MSICONDITION_FALSE, "wrong return val\n");
814 r = MsiEvaluateCondition(hpkg, "0 >= 1");
815 ok( r == MSICONDITION_FALSE, "wrong return val\n");
817 r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
818 ok( r == MSICONDITION_FALSE, "wrong return val\n");
820 r = MsiEvaluateCondition(hpkg, "1 >= 1");
821 ok( r == MSICONDITION_TRUE, "wrong return val\n");
823 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
824 ok( r == MSICONDITION_TRUE, "wrong return val\n");
826 r = MsiEvaluateCondition(hpkg, "0 < 1");
827 ok( r == MSICONDITION_TRUE, "wrong return val\n");
829 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
830 ok( r == MSICONDITION_TRUE, "wrong return val\n");
832 r = MsiEvaluateCondition(hpkg, "1 < 1");
833 ok( r == MSICONDITION_FALSE, "wrong return val\n");
835 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
836 ok( r == MSICONDITION_FALSE, "wrong return val\n");
838 r = MsiEvaluateCondition(hpkg, "0 <= 1");
839 ok( r == MSICONDITION_TRUE, "wrong return val\n");
841 r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
842 ok( r == MSICONDITION_TRUE, "wrong return val\n");
844 r = MsiEvaluateCondition(hpkg, "1 <= 1");
845 ok( r == MSICONDITION_TRUE, "wrong return val\n");
847 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
848 ok( r == MSICONDITION_TRUE, "wrong return val\n");
850 r = MsiEvaluateCondition(hpkg, "0 >=");
851 ok( r == MSICONDITION_ERROR, "wrong return val\n");
853 r = MsiEvaluateCondition(hpkg, " ");
854 ok( r == MSICONDITION_NONE, "wrong return val\n");
856 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
857 ok( r == MSICONDITION_TRUE, "wrong return val\n");
859 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
860 ok( r == MSICONDITION_TRUE, "wrong return val\n");
862 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
863 ok( r == MSICONDITION_FALSE, "wrong return val\n");
865 r = MsiEvaluateCondition(hpkg, "not 0");
866 ok( r == MSICONDITION_TRUE, "wrong return val\n");
868 r = MsiEvaluateCondition(hpkg, "not LicView");
869 ok( r == MSICONDITION_TRUE, "wrong return val\n");
871 r = MsiEvaluateCondition(hpkg, "not \"A\"");
872 ok( r == MSICONDITION_FALSE, "wrong return val\n");
874 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
875 ok( r == MSICONDITION_ERROR, "wrong return val\n");
877 r = MsiEvaluateCondition(hpkg, "\"0\"");
878 ok( r == MSICONDITION_TRUE, "wrong return val\n");
880 r = MsiEvaluateCondition(hpkg, "1 and 2");
881 ok( r == MSICONDITION_TRUE, "wrong return val\n");
883 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
884 ok( r == MSICONDITION_TRUE, "wrong return val\n");
886 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
887 ok( r == MSICONDITION_FALSE, "wrong return val\n");
889 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
890 ok( r == MSICONDITION_TRUE, "wrong return val\n");
892 r = MsiEvaluateCondition(hpkg, "(0)");
893 ok( r == MSICONDITION_FALSE, "wrong return val\n");
895 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
896 ok( r == MSICONDITION_ERROR, "wrong return val\n");
898 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
899 ok( r == MSICONDITION_TRUE, "wrong return val\n");
901 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
902 ok( r == MSICONDITION_TRUE, "wrong return val\n");
904 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
905 ok( r == MSICONDITION_FALSE, "wrong return val\n");
907 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
908 ok( r == MSICONDITION_FALSE, "wrong return val\n");
910 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
911 ok( r == MSICONDITION_TRUE, "wrong return val\n");
913 r = MsiEvaluateCondition(hpkg, "0 < > 0");
914 ok( r == MSICONDITION_ERROR, "wrong return val\n");
916 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
917 ok( r == MSICONDITION_ERROR, "wrong return val\n");
919 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
920 ok( r == MSICONDITION_FALSE, "wrong return val\n");
922 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
923 ok( r == MSICONDITION_ERROR, "wrong return val\n");
925 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
926 ok( r == MSICONDITION_TRUE, "wrong return val\n");
928 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
929 ok( r == MSICONDITION_FALSE, "wrong return val\n");
931 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
932 ok( r == MSICONDITION_FALSE, "wrong return val\n");
934 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
935 ok( r == MSICONDITION_TRUE, "wrong return val\n");
937 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
938 ok( r == MSICONDITION_FALSE, "wrong return val\n");
940 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
941 ok( r == MSICONDITION_FALSE, "wrong return val\n");
943 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
944 ok( r == MSICONDITION_FALSE, "wrong return val\n");
946 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
947 ok( r == MSICONDITION_FALSE, "wrong return val\n");
949 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
950 ok( r == MSICONDITION_FALSE, "wrong return val\n");
952 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
953 ok( r == MSICONDITION_FALSE, "wrong return val\n");
955 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
956 ok( r == MSICONDITION_TRUE, "wrong return val\n");
958 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
959 ok( r == MSICONDITION_FALSE, "wrong return val\n");
961 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
962 ok( r == MSICONDITION_TRUE, "wrong return val\n");
964 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
965 ok( r == MSICONDITION_TRUE, "wrong return val\n");
967 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
968 ok( r == MSICONDITION_FALSE, "wrong return val\n");
970 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
971 ok( r == MSICONDITION_TRUE, "wrong return val\n");
973 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
974 ok( r == MSICONDITION_ERROR, "wrong return val\n");
976 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
977 ok( r == MSICONDITION_TRUE, "wrong return val\n");
979 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
980 ok( r == MSICONDITION_TRUE, "wrong return val\n");
982 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
983 ok( r == MSICONDITION_TRUE, "wrong return val\n");
985 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
986 ok( r == MSICONDITION_FALSE, "wrong return val\n");
988 MsiSetProperty(hpkg, "mm", "5" );
990 r = MsiEvaluateCondition(hpkg, "mm = 5");
991 ok( r == MSICONDITION_TRUE, "wrong return val\n");
993 r = MsiEvaluateCondition(hpkg, "mm < 6");
994 ok( r == MSICONDITION_TRUE, "wrong return val\n");
996 r = MsiEvaluateCondition(hpkg, "mm <= 5");
997 ok( r == MSICONDITION_TRUE, "wrong return val\n");
999 r = MsiEvaluateCondition(hpkg, "mm > 4");
1000 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1002 r = MsiEvaluateCondition(hpkg, "mm < 12");
1003 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1005 r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1006 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1008 r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1009 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1011 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1012 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1014 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1015 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1017 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1018 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1020 r = MsiEvaluateCondition(hpkg, "3 >< 1");
1021 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1023 r = MsiEvaluateCondition(hpkg, "3 >< 4");
1024 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1026 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1027 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1029 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1030 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1032 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1033 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1035 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1036 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1038 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1039 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1041 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1042 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1044 r = MsiEvaluateCondition(hpkg, "_1 = _1");
1045 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1047 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1048 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1050 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1051 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1053 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1054 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1056 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1057 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1059 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1060 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1062 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1063 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1065 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1066 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1068 r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1069 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1071 r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1072 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1074 r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1075 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1077 r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1078 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1080 r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1081 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1083 MsiSetProperty(hpkg, "bandalmael", "0" );
1084 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1085 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1087 MsiSetProperty(hpkg, "bandalmael", "" );
1088 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1089 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1091 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1092 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1093 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1095 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1096 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1097 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1099 MsiSetProperty(hpkg, "bandalmael", "0 " );
1100 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1101 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1103 MsiSetProperty(hpkg, "bandalmael", "-0" );
1104 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1105 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1107 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1108 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1109 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1111 MsiSetProperty(hpkg, "bandalmael", "--0" );
1112 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1113 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1115 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1116 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1117 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1119 MsiSetProperty(hpkg, "bandalmael", "-" );
1120 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1121 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1123 MsiSetProperty(hpkg, "bandalmael", "+0" );
1124 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1125 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1127 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1128 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1129 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1130 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1131 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1133 MsiSetProperty(hpkg, "one", "hi");
1134 MsiSetProperty(hpkg, "two", "hithere");
1135 r = MsiEvaluateCondition(hpkg, "one >< two");
1136 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1138 MsiSetProperty(hpkg, "one", "hithere");
1139 MsiSetProperty(hpkg, "two", "hi");
1140 r = MsiEvaluateCondition(hpkg, "one >< two");
1141 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1143 MsiSetProperty(hpkg, "one", "hello");
1144 MsiSetProperty(hpkg, "two", "hi");
1145 r = MsiEvaluateCondition(hpkg, "one >< two");
1146 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1148 MsiSetProperty(hpkg, "one", "hellohithere");
1149 MsiSetProperty(hpkg, "two", "hi");
1150 r = MsiEvaluateCondition(hpkg, "one >< two");
1151 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1153 MsiSetProperty(hpkg, "one", "");
1154 MsiSetProperty(hpkg, "two", "hi");
1155 r = MsiEvaluateCondition(hpkg, "one >< two");
1156 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1158 MsiSetProperty(hpkg, "one", "hi");
1159 MsiSetProperty(hpkg, "two", "");
1160 r = MsiEvaluateCondition(hpkg, "one >< two");
1161 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1163 MsiSetProperty(hpkg, "one", "");
1164 MsiSetProperty(hpkg, "two", "");
1165 r = MsiEvaluateCondition(hpkg, "one >< two");
1166 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1168 MsiSetProperty(hpkg, "one", "1234");
1169 MsiSetProperty(hpkg, "two", "1");
1170 r = MsiEvaluateCondition(hpkg, "one >< two");
1171 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1173 MsiSetProperty(hpkg, "one", "one 1234");
1174 MsiSetProperty(hpkg, "two", "1");
1175 r = MsiEvaluateCondition(hpkg, "one >< two");
1176 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1178 MsiSetProperty(hpkg, "one", "hithere");
1179 MsiSetProperty(hpkg, "two", "hi");
1180 r = MsiEvaluateCondition(hpkg, "one << two");
1181 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1183 MsiSetProperty(hpkg, "one", "hi");
1184 MsiSetProperty(hpkg, "two", "hithere");
1185 r = MsiEvaluateCondition(hpkg, "one << two");
1186 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1188 MsiSetProperty(hpkg, "one", "hi");
1189 MsiSetProperty(hpkg, "two", "hi");
1190 r = MsiEvaluateCondition(hpkg, "one << two");
1191 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1193 MsiSetProperty(hpkg, "one", "abcdhithere");
1194 MsiSetProperty(hpkg, "two", "hi");
1195 r = MsiEvaluateCondition(hpkg, "one << two");
1196 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1198 MsiSetProperty(hpkg, "one", "");
1199 MsiSetProperty(hpkg, "two", "hi");
1200 r = MsiEvaluateCondition(hpkg, "one << two");
1201 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1203 MsiSetProperty(hpkg, "one", "hithere");
1204 MsiSetProperty(hpkg, "two", "");
1205 r = MsiEvaluateCondition(hpkg, "one << two");
1206 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1208 MsiSetProperty(hpkg, "one", "");
1209 MsiSetProperty(hpkg, "two", "");
1210 r = MsiEvaluateCondition(hpkg, "one << two");
1211 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1213 MsiSetProperty(hpkg, "one", "1234");
1214 MsiSetProperty(hpkg, "two", "1");
1215 r = MsiEvaluateCondition(hpkg, "one << two");
1216 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1218 MsiSetProperty(hpkg, "one", "1234 one");
1219 MsiSetProperty(hpkg, "two", "1");
1220 r = MsiEvaluateCondition(hpkg, "one << two");
1221 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1223 MsiSetProperty(hpkg, "one", "hithere");
1224 MsiSetProperty(hpkg, "two", "there");
1225 r = MsiEvaluateCondition(hpkg, "one >> two");
1226 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1228 MsiSetProperty(hpkg, "one", "hithere");
1229 MsiSetProperty(hpkg, "two", "hi");
1230 r = MsiEvaluateCondition(hpkg, "one >> two");
1231 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1233 MsiSetProperty(hpkg, "one", "there");
1234 MsiSetProperty(hpkg, "two", "hithere");
1235 r = MsiEvaluateCondition(hpkg, "one >> two");
1236 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1238 MsiSetProperty(hpkg, "one", "there");
1239 MsiSetProperty(hpkg, "two", "there");
1240 r = MsiEvaluateCondition(hpkg, "one >> two");
1241 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1243 MsiSetProperty(hpkg, "one", "abcdhithere");
1244 MsiSetProperty(hpkg, "two", "hi");
1245 r = MsiEvaluateCondition(hpkg, "one >> two");
1246 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1248 MsiSetProperty(hpkg, "one", "");
1249 MsiSetProperty(hpkg, "two", "there");
1250 r = MsiEvaluateCondition(hpkg, "one >> two");
1251 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1253 MsiSetProperty(hpkg, "one", "there");
1254 MsiSetProperty(hpkg, "two", "");
1255 r = MsiEvaluateCondition(hpkg, "one >> two");
1256 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258 MsiSetProperty(hpkg, "one", "");
1259 MsiSetProperty(hpkg, "two", "");
1260 r = MsiEvaluateCondition(hpkg, "one >> two");
1261 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1263 MsiSetProperty(hpkg, "one", "1234");
1264 MsiSetProperty(hpkg, "two", "4");
1265 r = MsiEvaluateCondition(hpkg, "one >> two");
1266 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1268 MsiSetProperty(hpkg, "one", "one 1234");
1269 MsiSetProperty(hpkg, "two", "4");
1270 r = MsiEvaluateCondition(hpkg, "one >> two");
1271 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273 MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1275 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1276 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1278 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1279 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1281 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1282 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1284 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1285 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1287 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1288 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1290 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1291 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1293 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1294 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1296 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1297 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1299 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1300 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1302 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1303 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1305 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1306 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1308 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1309 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1311 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1312 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1314 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1315 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1317 r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1318 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1320 r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1321 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1323 r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1324 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1326 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1327 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1329 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1330 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1332 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1333 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1335 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1336 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1338 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1339 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1341 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1342 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1344 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1345 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1347 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1348 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1350 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1351 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1353 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1354 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1356 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1357 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1359 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1360 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1362 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1363 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1365 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1366 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1368 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1369 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1371 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1372 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1374 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1375 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1377 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1378 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1380 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1381 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1383 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1384 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1386 MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1387 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1388 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1390 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1391 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1393 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1394 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1396 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1397 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1399 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1400 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1402 MsiSetProperty(hpkg, "one", "1");
1403 r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1404 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1406 MsiSetProperty(hpkg, "X", "5.0");
1408 r = MsiEvaluateCondition(hpkg, "X != \"\"");
1409 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1411 r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1412 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1414 r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1415 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1417 r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1418 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1420 r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1421 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1423 r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1424 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1426 r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1427 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1429 MsiCloseHandle( hpkg );
1430 DeleteFile(msifile);
1433 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1441 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1442 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1445 static void test_props(void)
1447 MSIHANDLE hpkg, hdb;
1452 hdb = create_package_db();
1454 "CREATE TABLE `Property` ( "
1455 "`Property` CHAR(255) NOT NULL, "
1456 "`Value` CHAR(255) "
1457 "PRIMARY KEY `Property`)" );
1458 ok( r == ERROR_SUCCESS , "Failed\n" );
1461 "INSERT INTO `Property` "
1462 "(`Property`, `Value`) "
1463 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1464 ok( r == ERROR_SUCCESS , "Failed\n" );
1466 hpkg = package_from_db( hdb );
1467 ok( hpkg, "failed to create package\n");
1469 /* test invalid values */
1470 r = MsiGetProperty( 0, NULL, NULL, NULL );
1471 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1473 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1474 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1476 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1477 ok( r == ERROR_SUCCESS, "wrong return val\n");
1479 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
1480 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1482 /* test retrieving an empty/nonexistent property */
1484 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
1485 ok( r == ERROR_SUCCESS, "wrong return val\n");
1486 ok( sz == 0, "wrong size returned\n");
1488 check_prop_empty( hpkg, "boo");
1491 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1492 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1493 ok( !strcmp(buffer,"x"), "buffer was changed\n");
1494 ok( sz == 0, "wrong size returned\n");
1498 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1499 ok( r == ERROR_SUCCESS, "wrong return val\n");
1500 ok( buffer[0] == 0, "buffer was not changed\n");
1501 ok( sz == 0, "wrong size returned\n");
1503 /* set the property to something */
1504 r = MsiSetProperty( 0, NULL, NULL );
1505 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1507 r = MsiSetProperty( hpkg, NULL, NULL );
1508 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1510 r = MsiSetProperty( hpkg, "", NULL );
1511 ok( r == ERROR_SUCCESS, "wrong return val\n");
1513 /* try set and get some illegal property identifiers */
1514 r = MsiSetProperty( hpkg, "", "asdf" );
1515 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
1517 r = MsiSetProperty( hpkg, "=", "asdf" );
1518 ok( r == ERROR_SUCCESS, "wrong return val\n");
1520 r = MsiSetProperty( hpkg, " ", "asdf" );
1521 ok( r == ERROR_SUCCESS, "wrong return val\n");
1523 r = MsiSetProperty( hpkg, "'", "asdf" );
1524 ok( r == ERROR_SUCCESS, "wrong return val\n");
1528 r = MsiGetProperty( hpkg, "'", buffer, &sz );
1529 ok( r == ERROR_SUCCESS, "wrong return val\n");
1530 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
1532 /* set empty values */
1533 r = MsiSetProperty( hpkg, "boo", NULL );
1534 ok( r == ERROR_SUCCESS, "wrong return val\n");
1535 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1537 r = MsiSetProperty( hpkg, "boo", "" );
1538 ok( r == ERROR_SUCCESS, "wrong return val\n");
1539 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
1541 /* set a non-empty value */
1542 r = MsiSetProperty( hpkg, "boo", "xyz" );
1543 ok( r == ERROR_SUCCESS, "wrong return val\n");
1547 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1548 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1549 ok( buffer[0] == 0, "buffer was not changed\n");
1550 ok( sz == 3, "wrong size returned\n");
1554 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1555 ok( r == ERROR_SUCCESS, "wrong return val\n");
1556 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
1557 ok( sz == 3, "wrong size returned\n");
1561 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
1562 ok( r == ERROR_MORE_DATA, "wrong return val\n");
1563 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
1564 ok( sz == 3, "wrong size returned\n");
1566 r = MsiSetProperty(hpkg, "SourceDir", "foo");
1567 ok( r == ERROR_SUCCESS, "wrong return val\n");
1570 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
1571 ok( r == ERROR_SUCCESS, "wrong return val\n");
1572 ok( !strcmp(buffer,""), "buffer wrong\n");
1573 ok( sz == 0, "wrong size returned\n");
1576 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
1577 ok( r == ERROR_SUCCESS, "wrong return val\n");
1578 ok( !strcmp(buffer,""), "buffer wrong\n");
1579 ok( sz == 0, "wrong size returned\n");
1582 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
1583 ok( r == ERROR_SUCCESS, "wrong return val\n");
1584 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
1585 ok( sz == 3, "wrong size returned\n");
1587 r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
1588 ok( r == ERROR_SUCCESS, "wrong return val\n");
1591 r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
1592 ok( r == ERROR_SUCCESS, "return wrong\n");
1593 ok( sz == 13, "size wrong (%d)\n", sz);
1596 r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
1597 ok( r == ERROR_MORE_DATA, "return wrong\n");
1598 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
1600 r = MsiSetProperty(hpkg, "property", "value");
1601 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1604 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1605 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1606 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
1608 r = MsiSetProperty(hpkg, "property", NULL);
1609 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1612 r = MsiGetProperty(hpkg, "property", buffer, &sz);
1613 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1614 ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
1616 MsiCloseHandle( hpkg );
1617 DeleteFile(msifile);
1620 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
1622 MSIHANDLE hview, hrec;
1624 CHAR buffer[MAX_PATH];
1628 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
1629 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1630 r = MsiViewExecute(hview, 0);
1631 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
1634 while (r == ERROR_SUCCESS && !found)
1636 r = MsiViewFetch(hview, &hrec);
1637 if (r != ERROR_SUCCESS) break;
1640 r = MsiRecordGetString(hrec, 1, buffer, &sz);
1641 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
1644 r = MsiRecordGetString(hrec, 2, buffer, &sz);
1645 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
1649 MsiCloseHandle(hrec);
1652 MsiViewClose(hview);
1653 MsiCloseHandle(hview);
1658 static void test_property_table(void)
1662 MSIHANDLE hpkg, hdb, hrec;
1663 char buffer[MAX_PATH];
1667 hdb = create_package_db();
1668 ok( hdb, "failed to create package\n");
1670 hpkg = package_from_db(hdb);
1671 ok( hpkg, "failed to create package\n");
1673 MsiCloseHandle(hdb);
1675 hdb = MsiGetActiveDatabase(hpkg);
1677 query = "CREATE TABLE `_Property` ( "
1678 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1679 r = run_query(hdb, query);
1680 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
1682 MsiCloseHandle(hdb);
1683 MsiCloseHandle(hpkg);
1684 DeleteFile(msifile);
1686 hdb = create_package_db();
1687 ok( hdb, "failed to create package\n");
1689 query = "CREATE TABLE `_Property` ( "
1690 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
1691 r = run_query(hdb, query);
1692 ok(r == ERROR_SUCCESS, "failed to create table\n");
1694 query = "ALTER `_Property` ADD `foo` INTEGER";
1695 r = run_query(hdb, query);
1696 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1698 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
1699 r = run_query(hdb, query);
1700 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
1702 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
1703 r = run_query(hdb, query);
1704 ok(r == ERROR_SUCCESS, "failed to add column\n");
1706 hpkg = package_from_db(hdb);
1709 ok(!hpkg, "package should not be created\n");
1712 MsiCloseHandle(hdb);
1713 MsiCloseHandle(hpkg);
1714 DeleteFile(msifile);
1716 hdb = create_package_db();
1717 ok (hdb, "failed to create package database\n");
1719 r = create_property_table(hdb);
1720 ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
1722 r = add_property_entry(hdb, "'prop', 'val'");
1723 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
1725 hpkg = package_from_db(hdb);
1726 ok(hpkg, "failed to create package\n");
1728 MsiCloseHandle(hdb);
1731 r = MsiGetProperty(hpkg, "prop", buffer, &sz);
1732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1733 ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
1735 hdb = MsiGetActiveDatabase(hpkg);
1737 found = find_prop_in_property(hdb, "prop", "val");
1738 ok(found, "prop should be in the _Property table\n");
1740 r = add_property_entry(hdb, "'dantes', 'mercedes'");
1741 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
1743 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
1744 r = do_query(hdb, query, &hrec);
1745 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
1747 found = find_prop_in_property(hdb, "dantes", "mercedes");
1748 ok(found == FALSE, "dantes should not be in the _Property table\n");
1751 lstrcpy(buffer, "aaa");
1752 r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
1753 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1754 ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
1756 r = MsiSetProperty(hpkg, "dantes", "mercedes");
1757 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1759 found = find_prop_in_property(hdb, "dantes", "mercedes");
1760 ok(found == TRUE, "dantes should be in the _Property table\n");
1762 MsiCloseHandle(hdb);
1763 MsiCloseHandle(hpkg);
1764 DeleteFile(msifile);
1767 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
1772 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
1773 if( res == ERROR_SUCCESS )
1777 r = MsiViewExecute( htab, hrec );
1778 if( r != ERROR_SUCCESS )
1781 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
1784 r = MsiViewClose( htab );
1785 if( r != ERROR_SUCCESS )
1788 r = MsiCloseHandle( htab );
1789 if( r != ERROR_SUCCESS )
1795 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
1797 return try_query_param( hdb, szQuery, 0 );
1800 static void test_msipackage(void)
1802 MSIHANDLE hdb = 0, hpack = 100;
1807 DeleteFile(msifile);
1811 r = MsiOpenPackage(name, &hpack);
1812 ok(r == ERROR_SUCCESS, "failed to open package with no name\n");
1813 r = MsiCloseHandle(hpack);
1814 ok(r == ERROR_SUCCESS, "failed to close package\n");
1817 /* just MsiOpenDatabase should not create a file */
1818 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
1819 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
1823 r = MsiOpenPackage(name, &hpack);
1824 ok(r == ERROR_INVALID_HANDLE, "MsiOpenPackage returned wrong code\n");
1827 /* now try again with our empty database */
1828 sprintf(name, "#%ld", hdb);
1829 r = MsiOpenPackage(name, &hpack);
1830 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1831 if (!r) MsiCloseHandle(hpack);
1834 /* create a table */
1835 query = "CREATE TABLE `Property` ( "
1836 "`Property` CHAR(72), `Value` CHAR(0) "
1837 "PRIMARY KEY `Property`)";
1838 r = try_query(hdb, query);
1839 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
1841 query = "CREATE TABLE `InstallExecuteSequence` ("
1842 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
1843 "PRIMARY KEY `Action`)";
1844 r = try_query(hdb, query);
1845 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
1848 sprintf(name, "#%ld", hdb);
1849 r = MsiOpenPackage(name, &hpack);
1850 ok(r == ERROR_INSTALL_PACKAGE_INVALID, "MsiOpenPackage returned wrong code\n");
1851 if (!r) MsiCloseHandle(hpack);
1854 r = MsiCloseHandle(hdb);
1855 ok(r == ERROR_SUCCESS, "MsiCloseHandle(database) failed\n");
1856 DeleteFile(msifile);
1859 static void test_formatrecord2(void)
1861 MSIHANDLE hpkg, hrec ;
1866 hpkg = package_from_db(create_package_db());
1867 ok( hpkg, "failed to create package\n");
1869 r = MsiSetProperty(hpkg, "Manufacturer", " " );
1870 ok( r == ERROR_SUCCESS, "set property failed\n");
1872 hrec = MsiCreateRecord(2);
1873 ok(hrec, "create record failed\n");
1875 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
1876 ok( r == ERROR_SUCCESS, "format record failed\n");
1880 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
1882 r = MsiRecordSetString(hrec, 0, "[foo][1]");
1883 r = MsiRecordSetString(hrec, 1, "hoo");
1885 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1886 ok( sz == 3, "size wrong\n");
1887 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1888 ok( r == ERROR_SUCCESS, "format failed\n");
1890 r = MsiRecordSetString(hrec, 0, "x[~]x");
1892 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1893 ok( sz == 3, "size wrong\n");
1894 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
1895 ok( r == ERROR_SUCCESS, "format failed\n");
1897 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
1898 r = MsiRecordSetString(hrec, 1, "hoo");
1900 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1901 ok( sz == 3, "size wrong\n");
1902 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
1903 ok( r == ERROR_SUCCESS, "format failed\n");
1905 r = MsiRecordSetString(hrec, 0, "[\\[]");
1907 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1908 ok( sz == 1, "size wrong\n");
1909 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
1910 ok( r == ERROR_SUCCESS, "format failed\n");
1912 SetEnvironmentVariable("FOO", "BAR");
1913 r = MsiRecordSetString(hrec, 0, "[%FOO]");
1915 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1916 ok( sz == 3, "size wrong\n");
1917 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1918 ok( r == ERROR_SUCCESS, "format failed\n");
1920 r = MsiRecordSetString(hrec, 0, "[[1]]");
1921 r = MsiRecordSetString(hrec, 1, "%FOO");
1923 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
1924 ok( sz == 3, "size wrong\n");
1925 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
1926 ok( r == ERROR_SUCCESS, "format failed\n");
1928 MsiCloseHandle( hrec );
1929 MsiCloseHandle( hpkg );
1930 DeleteFile(msifile);
1933 /* FIXME: state is INSTALLSTATE_UNKNOWN if any features are removed and the
1934 * feature in question is not in ADD*
1936 static void test_states(void)
1941 INSTALLSTATE state, action;
1943 hdb = create_package_db();
1944 ok ( hdb, "failed to create package database\n" );
1946 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
1947 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
1949 r = create_property_table( hdb );
1950 ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
1952 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
1953 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
1955 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
1956 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
1958 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
1959 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
1961 r = create_feature_table( hdb );
1962 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
1964 r = create_component_table( hdb );
1965 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
1967 /* msidbFeatureAttributesFavorLocal */
1968 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
1969 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1971 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
1972 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
1973 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1975 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
1976 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
1977 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1979 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
1980 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
1981 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1983 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
1984 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
1985 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1987 /* msidbFeatureAttributesFavorSource */
1988 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
1989 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
1991 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
1992 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
1993 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1995 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
1996 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
1997 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
1999 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2000 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2001 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2003 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2004 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2005 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2007 /* msidbFeatureAttributesFavorSource */
2008 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2009 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2011 /* msidbFeatureAttributesFavorLocal */
2012 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2013 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2016 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2017 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2019 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2020 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2021 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2023 /* no feature parent:msidbComponentAttributesLocalOnly */
2024 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2025 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2027 /* msidbFeatureAttributesFavorLocal:removed */
2028 r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2029 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2031 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2032 r = add_component_entry( hdb, "'lambda', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'lambda_file'" );
2033 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2035 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2036 r = add_component_entry( hdb, "'mu', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'mu_file'" );
2037 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2039 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2040 r = add_component_entry( hdb, "'nu', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'nu_file'" );
2041 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2043 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2044 r = add_component_entry( hdb, "'xi', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'xi_file'" );
2045 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2047 /* msidbFeatureAttributesFavorSource:removed */
2048 r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2049 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2051 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2052 r = add_component_entry( hdb, "'omicron', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'omicron_file'" );
2053 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2055 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2056 r = add_component_entry( hdb, "'pi', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'pi_file'" );
2057 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2059 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2060 r = add_component_entry( hdb, "'rho', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'rho_file'" );
2061 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2063 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2064 r = add_component_entry( hdb, "'sigma', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'sigma_file'" );
2065 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2067 r = create_feature_components_table( hdb );
2068 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2070 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2071 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2073 r = add_feature_components_entry( hdb, "'one', 'beta'" );
2074 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2076 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2077 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2079 r = add_feature_components_entry( hdb, "'one', 'theta'" );
2080 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2082 r = add_feature_components_entry( hdb, "'two', 'delta'" );
2083 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2085 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2086 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2088 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2089 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2091 r = add_feature_components_entry( hdb, "'two', 'iota'" );
2092 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2094 r = add_feature_components_entry( hdb, "'three', 'eta'" );
2095 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2097 r = add_feature_components_entry( hdb, "'four', 'eta'" );
2098 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2100 r = add_feature_components_entry( hdb, "'five', 'eta'" );
2101 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2103 r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2104 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2106 r = add_feature_components_entry( hdb, "'six', 'mu'" );
2107 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2109 r = add_feature_components_entry( hdb, "'six', 'nu'" );
2110 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2112 r = add_feature_components_entry( hdb, "'six', 'xi'" );
2113 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2115 r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2116 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2118 r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2119 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2121 r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2122 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2124 r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2125 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2127 r = create_file_table( hdb );
2128 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2130 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2131 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2133 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2134 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2136 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2137 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2139 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2140 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2142 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2143 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2145 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2146 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2148 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2149 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2151 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2152 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2154 /* compressed file */
2155 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2156 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2158 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2159 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2161 r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2162 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2164 r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2165 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2167 r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2168 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2170 r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2171 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2173 r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2174 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2176 r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2177 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2179 r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2180 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2182 r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2183 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2185 hpkg = package_from_db( hdb );
2186 ok( hpkg, "failed to create package\n");
2188 MsiCloseHandle( hdb );
2192 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2193 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2194 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2195 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2199 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2200 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2201 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2202 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2206 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2207 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2208 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2209 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2213 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2214 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2215 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2216 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2220 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2221 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2222 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2223 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2227 r = MsiGetFeatureState(hpkg, "six", &state, &action);
2228 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2229 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2230 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2234 r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2235 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %d\n", r );
2236 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2237 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2241 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2242 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2243 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2244 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2248 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2249 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2250 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2251 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2255 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2256 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2257 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2258 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2262 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2263 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2264 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2265 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2269 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2270 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2271 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2272 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2276 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2277 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2278 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2279 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2283 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2284 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2285 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2286 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2290 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2291 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2292 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2293 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2297 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2298 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2299 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2300 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2304 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2305 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2306 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2307 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2311 r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2312 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2313 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2314 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2318 r = MsiGetComponentState(hpkg, "mu", &state, &action);
2319 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2320 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2321 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2325 r = MsiGetComponentState(hpkg, "nu", &state, &action);
2326 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2327 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2328 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2332 r = MsiGetComponentState(hpkg, "xi", &state, &action);
2333 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2334 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2335 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2339 r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2340 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2341 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2342 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2346 r = MsiGetComponentState(hpkg, "pi", &state, &action);
2347 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2348 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2349 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2353 r = MsiGetComponentState(hpkg, "rho", &state, &action);
2354 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2355 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2356 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2360 r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2361 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r );
2362 ok( state == 0xdeadbee, "Expected 0xdeadbee, got %d\n", state);
2363 ok( action == 0xdeadbee, "Expected 0xdeadbee, got %d\n", action);
2365 r = MsiDoAction( hpkg, "CostInitialize");
2366 ok( r == ERROR_SUCCESS, "cost init failed\n");
2370 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2371 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2372 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2373 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2377 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2378 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2379 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2380 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2384 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2385 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2386 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2387 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2391 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2392 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2393 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2394 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2398 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2399 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2400 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2401 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2405 r = MsiGetFeatureState(hpkg, "six", &state, &action);
2406 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2407 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2408 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2412 r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2413 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2414 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2415 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2419 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2420 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2421 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2422 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2426 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2427 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2428 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2429 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2433 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2434 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2435 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2436 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2440 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2441 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2442 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2443 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2447 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2448 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2449 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2450 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2454 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2455 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2456 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2457 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2461 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2462 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2463 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2464 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2468 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2469 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2470 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2471 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2475 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2476 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2477 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2478 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2482 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2483 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2484 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2485 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2489 r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2490 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2491 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2492 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2496 r = MsiGetComponentState(hpkg, "mu", &state, &action);
2497 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2498 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2499 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2503 r = MsiGetComponentState(hpkg, "nu", &state, &action);
2504 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2505 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2506 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2510 r = MsiGetComponentState(hpkg, "xi", &state, &action);
2511 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2512 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2513 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2517 r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2518 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2519 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2520 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2524 r = MsiGetComponentState(hpkg, "pi", &state, &action);
2525 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2526 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2527 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2531 r = MsiGetComponentState(hpkg, "rho", &state, &action);
2532 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2533 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2534 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2538 r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2539 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2540 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2541 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2543 r = MsiDoAction( hpkg, "FileCost");
2544 ok( r == ERROR_SUCCESS, "file cost failed\n");
2548 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2549 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2550 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2551 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2555 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2556 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2557 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2558 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2562 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2563 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2564 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2565 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2569 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2570 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2571 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2572 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2576 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2577 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2578 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2579 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2583 r = MsiGetFeatureState(hpkg, "six", &state, &action);
2584 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2585 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2586 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2590 r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2591 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2592 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2593 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2597 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2598 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2599 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2600 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2604 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2605 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2606 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2607 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2611 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2612 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2613 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2614 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2618 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2619 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2620 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2621 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2625 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2626 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2627 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2628 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2632 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2633 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2634 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2635 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2639 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2640 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2641 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2642 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2646 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2647 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2648 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2649 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2653 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2654 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2655 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2656 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2660 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2661 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2662 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2663 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2667 r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2668 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2669 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2670 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2674 r = MsiGetComponentState(hpkg, "mu", &state, &action);
2675 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2676 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2677 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2681 r = MsiGetComponentState(hpkg, "nu", &state, &action);
2682 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2683 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2684 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2688 r = MsiGetComponentState(hpkg, "xi", &state, &action);
2689 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2690 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2691 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2695 r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2696 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2697 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2698 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2702 r = MsiGetComponentState(hpkg, "pi", &state, &action);
2703 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2704 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2705 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2709 r = MsiGetComponentState(hpkg, "rho", &state, &action);
2710 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2711 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2712 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2716 r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2717 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2718 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2719 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2721 r = MsiDoAction( hpkg, "CostFinalize");
2722 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
2726 r = MsiGetFeatureState(hpkg, "one", &state, &action);
2727 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2728 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2729 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2733 r = MsiGetFeatureState(hpkg, "two", &state, &action);
2734 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2735 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2738 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2743 r = MsiGetFeatureState(hpkg, "three", &state, &action);
2744 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2745 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2748 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2753 r = MsiGetFeatureState(hpkg, "four", &state, &action);
2754 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2755 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2756 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2760 r = MsiGetFeatureState(hpkg, "five", &state, &action);
2761 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2762 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2763 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2767 r = MsiGetFeatureState(hpkg, "six", &state, &action);
2768 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2769 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2772 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2777 r = MsiGetFeatureState(hpkg, "seven", &state, &action);
2778 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2779 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2782 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2787 r = MsiGetComponentState(hpkg, "alpha", &state, &action);
2788 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2789 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2790 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2794 r = MsiGetComponentState(hpkg, "beta", &state, &action);
2795 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2796 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2797 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2801 r = MsiGetComponentState(hpkg, "gamma", &state, &action);
2802 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2803 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2804 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2808 r = MsiGetComponentState(hpkg, "theta", &state, &action);
2809 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2810 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2811 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2815 r = MsiGetComponentState(hpkg, "delta", &state, &action);
2816 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2817 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2820 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2825 r = MsiGetComponentState(hpkg, "epsilon", &state, &action);
2826 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2827 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2830 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2835 r = MsiGetComponentState(hpkg, "zeta", &state, &action);
2836 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2837 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2840 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
2845 r = MsiGetComponentState(hpkg, "iota", &state, &action);
2846 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2847 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2850 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2855 r = MsiGetComponentState(hpkg, "eta", &state, &action);
2856 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2857 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2858 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
2862 r = MsiGetComponentState(hpkg, "kappa", &state, &action);
2863 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2864 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2865 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2869 r = MsiGetComponentState(hpkg, "lambda", &state, &action);
2870 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2871 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2874 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2879 r = MsiGetComponentState(hpkg, "mu", &state, &action);
2880 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2881 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2884 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2889 r = MsiGetComponentState(hpkg, "nu", &state, &action);
2890 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2891 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2894 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2899 r = MsiGetComponentState(hpkg, "xi", &state, &action);
2900 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2901 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2904 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2909 r = MsiGetComponentState(hpkg, "omicron", &state, &action);
2910 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2911 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2914 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2919 r = MsiGetComponentState(hpkg, "pi", &state, &action);
2920 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2921 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2924 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2929 r = MsiGetComponentState(hpkg, "rho", &state, &action);
2930 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2931 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2934 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2939 r = MsiGetComponentState(hpkg, "sigma", &state, &action);
2940 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
2941 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2944 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
2947 MsiCloseHandle( hpkg );
2948 DeleteFileA( msifile );
2951 static void test_getproperty(void)
2953 MSIHANDLE hPackage = 0;
2955 static CHAR empty[] = "";
2959 hPackage = package_from_db(create_package_db());
2960 ok( hPackage != 0, " Failed to create package\n");
2962 /* set the property */
2963 r = MsiSetProperty(hPackage, "Name", "Value");
2964 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2966 /* retrieve the size, NULL pointer */
2968 r = MsiGetProperty(hPackage, "Name", NULL, &size);
2969 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2970 ok( size == 5, "Expected 5, got %d\n", size);
2972 /* retrieve the size, empty string */
2974 r = MsiGetProperty(hPackage, "Name", empty, &size);
2975 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2976 ok( size == 5, "Expected 5, got %d\n", size);
2978 /* don't change size */
2979 r = MsiGetProperty(hPackage, "Name", prop, &size);
2980 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2981 ok( size == 5, "Expected 5, got %d\n", size);
2982 ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
2984 /* increase the size by 1 */
2986 r = MsiGetProperty(hPackage, "Name", prop, &size);
2987 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2988 ok( size == 5, "Expected 5, got %d\n", size);
2989 ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
2991 r = MsiCloseHandle( hPackage);
2992 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
2993 DeleteFile(msifile);
2996 static void test_removefiles(void)
3001 char CURR_DIR[MAX_PATH];
3003 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
3005 hdb = create_package_db();
3006 ok ( hdb, "failed to create package database\n" );
3008 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3009 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3011 r = create_feature_table( hdb );
3012 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
3014 r = create_component_table( hdb );
3015 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
3017 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3018 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3020 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3021 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3023 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3024 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3026 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3027 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3029 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3030 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3032 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3033 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3035 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3036 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3038 r = create_feature_components_table( hdb );
3039 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
3041 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
3042 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3044 r = add_feature_components_entry( hdb, "'one', 'helium'" );
3045 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3047 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
3048 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3050 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
3051 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3053 r = add_feature_components_entry( hdb, "'one', 'boron'" );
3054 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3056 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
3057 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3059 r = create_file_table( hdb );
3060 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3062 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3063 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3065 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3066 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3068 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3069 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3071 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3072 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3074 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3075 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3077 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3078 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3080 r = create_remove_file_table( hdb );
3081 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
3083 hpkg = package_from_db( hdb );
3084 ok( hpkg, "failed to create package\n");
3086 MsiCloseHandle( hdb );
3088 create_test_file( "hydrogen.txt" );
3089 create_test_file( "helium.txt" );
3090 create_test_file( "lithium.txt" );
3091 create_test_file( "beryllium.txt" );
3092 create_test_file( "boron.txt" );
3093 create_test_file( "carbon.txt" );
3095 r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
3096 ok( r == ERROR_SUCCESS, "set property failed\n");
3098 r = MsiDoAction( hpkg, "CostInitialize");
3099 ok( r == ERROR_SUCCESS, "cost init failed\n");
3101 r = MsiDoAction( hpkg, "FileCost");
3102 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3104 r = MsiDoAction( hpkg, "CostFinalize");
3105 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3107 r = MsiDoAction( hpkg, "InstallValidate");
3108 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3110 r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
3111 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3113 r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
3114 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3116 r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
3117 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3119 r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
3120 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3122 r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
3123 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3125 r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
3126 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3128 r = MsiDoAction( hpkg, "RemoveFiles");
3129 ok( r == ERROR_SUCCESS, "remove files failed\n");
3131 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3132 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3133 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3134 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3135 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3136 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3138 MsiCloseHandle( hpkg );
3139 DeleteFileA(msifile);
3142 static void test_appsearch(void)
3147 CHAR prop[MAX_PATH];
3148 DWORD size = MAX_PATH;
3150 hdb = create_package_db();
3151 ok ( hdb, "failed to create package database\n" );
3153 r = create_appsearch_table( hdb );
3154 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
3156 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
3157 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3159 r = create_reglocator_table( hdb );
3160 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3162 r = add_reglocator_entry( hdb, "'NewSignature1', 0, 'htmlfile\\shell\\open\\command', '', 1" );
3163 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3165 r = create_signature_table( hdb );
3166 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
3168 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3169 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
3171 hpkg = package_from_db( hdb );
3172 ok( hpkg, "failed to create package\n");
3174 MsiCloseHandle( hdb );
3176 r = MsiDoAction( hpkg, "AppSearch" );
3177 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
3179 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
3180 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3181 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3183 MsiCloseHandle( hpkg );
3184 DeleteFileA(msifile);
3187 static void test_featureparents(void)
3192 INSTALLSTATE state, action;
3194 hdb = create_package_db();
3195 ok ( hdb, "failed to create package database\n" );
3197 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3198 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3200 r = create_feature_table( hdb );
3201 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
3203 r = create_component_table( hdb );
3204 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
3206 r = create_feature_components_table( hdb );
3207 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
3209 r = create_file_table( hdb );
3210 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3212 /* msidbFeatureAttributesFavorLocal */
3213 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
3214 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3216 /* msidbFeatureAttributesFavorSource */
3217 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
3218 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3220 /* msidbFeatureAttributesFavorLocal */
3221 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
3222 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3224 /* disabled because of install level */
3225 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
3226 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3228 /* child feature of disabled feature */
3229 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
3230 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3232 /* component of disabled feature (install level) */
3233 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
3234 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3236 /* component of disabled child feature (install level) */
3237 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
3238 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3240 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
3241 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
3242 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3244 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
3245 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
3246 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3248 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
3249 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
3250 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3252 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
3253 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
3254 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3256 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
3257 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
3258 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3260 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
3261 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
3262 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3264 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
3265 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
3266 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3268 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
3269 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
3270 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3272 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
3273 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
3275 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
3276 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3278 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
3279 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3281 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
3282 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3284 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
3285 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3287 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
3288 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3290 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
3291 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3293 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
3294 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3296 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
3297 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3299 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
3300 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3302 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
3303 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3305 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
3306 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3308 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
3309 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3311 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
3312 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3314 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
3315 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3317 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
3318 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3320 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
3321 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3323 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
3324 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3326 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
3327 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3329 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
3330 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3332 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
3333 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3335 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
3336 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3338 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
3339 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3341 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
3342 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3344 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
3345 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3347 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
3348 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3350 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
3351 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3353 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
3354 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3356 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
3357 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3359 hpkg = package_from_db( hdb );
3360 ok( hpkg, "failed to create package\n");
3362 MsiCloseHandle( hdb );
3364 r = MsiDoAction( hpkg, "CostInitialize");
3365 ok( r == ERROR_SUCCESS, "cost init failed\n");
3367 r = MsiDoAction( hpkg, "FileCost");
3368 ok( r == ERROR_SUCCESS, "file cost failed\n");
3370 r = MsiDoAction( hpkg, "CostFinalize");
3371 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3375 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
3376 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3377 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3378 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3382 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
3383 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3384 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3385 ok( action == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", action);
3389 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
3390 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3391 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3392 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3396 r = MsiGetFeatureState(hpkg, "waters", &state, &action);
3397 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3398 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3399 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3403 r = MsiGetFeatureState(hpkg, "bayer", &state, &action);
3404 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3405 ok( state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3406 ok( action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3410 r = MsiGetComponentState(hpkg, "leo", &state, &action);
3411 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3412 ok( state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3413 ok( action == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", action);
3417 r = MsiGetComponentState(hpkg, "virgo", &state, &action);
3418 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3419 ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
3420 ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
3424 r = MsiGetComponentState(hpkg, "libra", &state, &action);
3425 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3426 ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
3427 ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
3431 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
3432 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3433 ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
3434 ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
3438 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
3439 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3440 ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
3441 ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
3445 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
3446 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3447 ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
3448 ok( action == INSTALLSTATE_LOCAL, "Expected andromeda INSTALLSTATE_LOCAL, got %d\n", action);
3452 r = MsiGetComponentState(hpkg, "canis", &state, &action);
3453 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3454 ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
3455 ok( action == INSTALLSTATE_LOCAL, "Expected canis INSTALLSTATE_LOCAL, got %d\n", action);
3459 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
3460 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3461 ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
3462 ok( action == INSTALLSTATE_SOURCE, "Expected monoceros INSTALLSTATE_SOURCE, got %d\n", action);
3466 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
3467 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3468 ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
3469 ok( action == INSTALLSTATE_LOCAL, "Expected lepus INSTALLSTATE_LOCAL, got %d\n", action);
3473 r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
3474 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3475 ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
3476 ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
3480 r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
3481 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3482 ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
3483 ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
3485 r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
3486 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
3490 r = MsiGetFeatureState(hpkg, "zodiac", &state, &action);
3491 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3492 ok( state == INSTALLSTATE_ABSENT, "Expected zodiac INSTALLSTATE_ABSENT, got %d\n", state);
3493 ok( action == INSTALLSTATE_LOCAL, "Expected zodiac INSTALLSTATE_LOCAL, got %d\n", action);
3497 r = MsiGetFeatureState(hpkg, "perseus", &state, &action);
3498 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3499 ok( state == INSTALLSTATE_ABSENT, "Expected perseus INSTALLSTATE_ABSENT, got %d\n", state);
3500 ok( action == INSTALLSTATE_SOURCE, "Expected perseus INSTALLSTATE_SOURCE, got %d\n", action);
3504 r = MsiGetFeatureState(hpkg, "orion", &state, &action);
3505 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3506 ok( state == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", state);
3507 ok( action == INSTALLSTATE_ABSENT, "Expected orion INSTALLSTATE_ABSENT, got %d\n", action);
3511 r = MsiGetComponentState(hpkg, "leo", &state, &action);
3512 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3513 ok( state == INSTALLSTATE_UNKNOWN, "Expected leo INSTALLSTATE_UNKNOWN, got %d\n", state);
3514 ok( action == INSTALLSTATE_LOCAL, "Expected leo INSTALLSTATE_LOCAL, got %d\n", action);
3518 r = MsiGetComponentState(hpkg, "virgo", &state, &action);
3519 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3520 ok( state == INSTALLSTATE_UNKNOWN, "Expected virgo INSTALLSTATE_UNKNOWN, got %d\n", state);
3521 ok( action == INSTALLSTATE_SOURCE, "Expected virgo INSTALLSTATE_SOURCE, got %d\n", action);
3525 r = MsiGetComponentState(hpkg, "libra", &state, &action);
3526 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3527 ok( state == INSTALLSTATE_UNKNOWN, "Expected libra INSTALLSTATE_UNKNOWN, got %d\n", state);
3528 ok( action == INSTALLSTATE_LOCAL, "Expected libra INSTALLSTATE_LOCAL, got %d\n", action);
3532 r = MsiGetComponentState(hpkg, "cassiopeia", &state, &action);
3533 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3534 ok( state == INSTALLSTATE_UNKNOWN, "Expected cassiopeia INSTALLSTATE_UNKNOWN, got %d\n", state);
3535 ok( action == INSTALLSTATE_LOCAL, "Expected cassiopeia INSTALLSTATE_LOCAL, got %d\n", action);
3539 r = MsiGetComponentState(hpkg, "cepheus", &state, &action);
3540 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3541 ok( state == INSTALLSTATE_UNKNOWN, "Expected cepheus INSTALLSTATE_UNKNOWN, got %d\n", state);
3542 ok( action == INSTALLSTATE_SOURCE, "Expected cepheus INSTALLSTATE_SOURCE, got %d\n", action);
3546 r = MsiGetComponentState(hpkg, "andromeda", &state, &action);
3547 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3548 ok( state == INSTALLSTATE_UNKNOWN, "Expected andromeda INSTALLSTATE_UNKNOWN, got %d\n", state);
3549 ok( action == INSTALLSTATE_SOURCE, "Expected andromeda INSTALLSTATE_SOURCE, got %d\n", action);
3553 r = MsiGetComponentState(hpkg, "canis", &state, &action);
3554 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3555 ok( state == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", state);
3556 ok( action == INSTALLSTATE_UNKNOWN, "Expected canis INSTALLSTATE_UNKNOWN, got %d\n", action);
3560 r = MsiGetComponentState(hpkg, "monoceros", &state, &action);
3561 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3562 ok( state == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", state);
3563 ok( action == INSTALLSTATE_UNKNOWN, "Expected monoceros INSTALLSTATE_UNKNOWN, got %d\n", action);
3567 r = MsiGetComponentState(hpkg, "lepus", &state, &action);
3568 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3569 ok( state == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", state);
3570 ok( action == INSTALLSTATE_UNKNOWN, "Expected lepus INSTALLSTATE_UNKNOWN, got %d\n", action);
3574 r = MsiGetComponentState(hpkg, "delphinus", &state, &action);
3575 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3576 ok( state == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", state);
3577 ok( action == INSTALLSTATE_UNKNOWN, "Expected delphinus INSTALLSTATE_UNKNOWN, got %d\n", action);
3581 r = MsiGetComponentState(hpkg, "hydrus", &state, &action);
3582 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
3583 ok( state == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", state);
3584 ok( action == INSTALLSTATE_UNKNOWN, "Expected hydrus INSTALLSTATE_UNKNOWN, got %d\n", action);
3586 MsiCloseHandle(hpkg);
3587 DeleteFileA(msifile);
3590 static void test_installprops(void)
3592 MSIHANDLE hpkg, hdb;
3593 CHAR path[MAX_PATH];
3599 GetCurrentDirectory(MAX_PATH, path);
3600 lstrcat(path, "\\");
3601 lstrcat(path, msifile);
3603 hdb = create_package_db();
3604 ok( hdb, "failed to create database\n");
3606 hpkg = package_from_db(hdb);
3607 ok( hpkg, "failed to create package\n");
3609 MsiCloseHandle(hdb);
3612 r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
3613 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3614 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3616 RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey);
3620 RegQueryValueEx(hkey, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
3623 r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
3624 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3625 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3629 RegQueryValueEx(hkey, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
3632 r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
3633 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3634 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
3637 r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
3638 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3639 trace("VersionDatabase = %s\n", buf);
3642 r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
3643 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3644 trace("VersionMsi = %s\n", buf);
3647 r = MsiGetProperty(hpkg, "Date", buf, &size);
3648 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3649 trace("Date = %s\n", buf);
3652 r = MsiGetProperty(hpkg, "Time", buf, &size);
3653 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3654 trace("Time = %s\n", buf);
3657 r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
3658 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3659 trace("PackageCode = %s\n", buf);
3662 MsiCloseHandle(hpkg);
3663 DeleteFile(msifile);
3666 static void test_sourcedirprop(void)
3668 MSIHANDLE hpkg, hdb;
3669 CHAR source_dir[MAX_PATH];
3670 CHAR path[MAX_PATH];
3674 hdb = create_package_db();
3675 ok ( hdb, "failed to create package database\n" );
3677 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3678 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3680 hpkg = package_from_db( hdb );
3681 ok( hpkg, "failed to create package\n");
3683 MsiCloseHandle( hdb );
3686 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3687 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3688 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3691 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3692 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3693 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3695 r = MsiDoAction( hpkg, "CostInitialize");
3696 ok( r == ERROR_SUCCESS, "cost init failed\n");
3699 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3700 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3701 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3704 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3705 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3706 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3708 r = MsiDoAction( hpkg, "ResolveSource");
3709 ok( r == ERROR_SUCCESS, "file cost failed\n");
3711 GetCurrentDirectory(MAX_PATH, path);
3712 lstrcatA(path, "\\");
3715 r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
3716 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3717 ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3720 r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
3721 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3722 ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
3725 r = MsiGetProperty( hpkg, "SoUrCeDiR", source_dir, &size );
3726 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
3727 ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
3729 MsiCloseHandle(hpkg);
3730 DeleteFileA(msifile);
3733 static void test_prop_path(void)
3735 MSIHANDLE hpkg, hdb;
3736 char buffer[MAX_PATH], cwd[MAX_PATH];
3740 GetCurrentDirectory(MAX_PATH, cwd);
3743 hdb = create_package_db();
3744 ok( hdb, "failed to create database\n");
3746 r = add_directory_entry( hdb, "'TARGETDIR','','SourceDir'" );
3747 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3749 r = add_directory_entry( hdb, "'foo','TARGETDIR','foosrc:footgt'" );
3750 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3752 hpkg = package_from_db(hdb);
3753 ok( hpkg, "failed to create package\n");
3755 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3756 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3758 r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3759 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3761 r = MsiDoAction( hpkg, "CostInitialize");
3762 ok( r == ERROR_SUCCESS, "cost init failed\n");
3766 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3767 ok( r == ERROR_SUCCESS, "property not set\n");
3768 ok( !buffer[0], "SourceDir should be empty\n");
3772 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3773 ok( r == ERROR_SUCCESS, "property not set\n");
3774 ok( !buffer[0], "SourceDir should be empty\n");
3778 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3779 ok( r == ERROR_SUCCESS, "failed to get source path\n");
3780 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3784 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3785 ok( r == ERROR_SUCCESS, "property not set\n");
3787 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3792 r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
3793 ok( r == ERROR_DIRECTORY, "failed to get source path\n");
3797 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
3798 ok( r == ERROR_SUCCESS, "property not set\n");
3800 ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
3803 r = MsiSetProperty(hpkg, "SourceDir", "goo");
3804 ok( r == ERROR_SUCCESS, "property not set\n");
3808 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3809 ok( r == ERROR_SUCCESS, "property not set\n");
3810 ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3814 r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
3815 ok( r == ERROR_SUCCESS, "failed to get source path\n");
3816 ok( !lstrcmpi(buffer, cwd), "SourceDir (%s) should be goo\n", buffer);
3820 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
3821 ok( r == ERROR_SUCCESS, "property not set\n");
3822 ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
3824 MsiCloseHandle( hpkg );
3825 DeleteFile(msifile);
3828 static void test_launchconditions(void)
3834 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3836 hdb = create_package_db();
3837 ok( hdb, "failed to create package database\n" );
3839 r = create_launchcondition_table( hdb );
3840 ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
3842 r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
3843 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
3845 /* invalid condition */
3846 r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
3847 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
3849 hpkg = package_from_db( hdb );
3850 ok( hpkg, "failed to create package\n");
3852 MsiCloseHandle( hdb );
3854 r = MsiSetProperty( hpkg, "X", "1" );
3855 ok( r == ERROR_SUCCESS, "failed to set property\n" );
3857 /* invalid conditions are ignored */
3858 r = MsiDoAction( hpkg, "LaunchConditions" );
3859 ok( r == ERROR_SUCCESS, "cost init failed\n" );
3861 /* verify LaunchConditions still does some verification */
3862 r = MsiSetProperty( hpkg, "X", "2" );
3863 ok( r == ERROR_SUCCESS, "failed to set property\n" );
3865 r = MsiDoAction( hpkg, "LaunchConditions" );
3866 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
3868 MsiCloseHandle( hpkg );
3869 DeleteFile( msifile );
3874 test_createpackage();
3875 test_getsourcepath_bad();
3876 test_getsourcepath();
3878 test_gettargetpath_bad();
3879 test_settargetpath();
3881 test_property_table();
3884 test_formatrecord2();
3889 test_featureparents();
3890 test_installprops();
3891 test_sourcedirprop();
3893 test_launchconditions();