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 <srrestoreptapi.h>
32 #include "wine/test.h"
35 static const char msifile
[] = "winetest-package.msi";
36 static const WCHAR msifileW
[] =
37 {'w','i','n','e','t','e','s','t','-','p','a','c','k','a','g','e','.','m','s','i',0};
38 static char CURR_DIR
[MAX_PATH
];
40 static UINT (WINAPI
*pMsiApplyMultiplePatchesA
)(LPCSTR
, LPCSTR
, LPCSTR
);
41 static INSTALLSTATE (WINAPI
*pMsiGetComponentPathExA
)(LPCSTR
, LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPSTR
, LPDWORD
);
42 static HRESULT (WINAPI
*pSHGetFolderPathA
)(HWND
, int, HANDLE
, DWORD
, LPSTR
);
44 static BOOL (WINAPI
*pCheckTokenMembership
)(HANDLE
,PSID
,PBOOL
);
45 static BOOL (WINAPI
*pConvertSidToStringSidA
)(PSID
, LPSTR
*);
46 static BOOL (WINAPI
*pOpenProcessToken
)( HANDLE
, DWORD
, PHANDLE
);
47 static LONG (WINAPI
*pRegDeleteKeyExA
)(HKEY
, LPCSTR
, REGSAM
, DWORD
);
48 static LONG (WINAPI
*pRegDeleteKeyExW
)(HKEY
, LPCWSTR
, REGSAM
, DWORD
);
49 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
, PBOOL
);
50 static void (WINAPI
*pGetSystemInfo
)(LPSYSTEM_INFO
);
51 static void (WINAPI
*pGetNativeSystemInfo
)(LPSYSTEM_INFO
);
52 static UINT (WINAPI
*pGetSystemWow64DirectoryA
)(LPSTR
, UINT
);
54 static BOOL (WINAPI
*pSRRemoveRestorePoint
)(DWORD
);
55 static BOOL (WINAPI
*pSRSetRestorePointA
)(RESTOREPOINTINFOA
*, STATEMGRSTATUS
*);
57 static void init_functionpointers(void)
59 HMODULE hmsi
= GetModuleHandleA("msi.dll");
60 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
61 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
62 HMODULE hshell32
= GetModuleHandleA("shell32.dll");
65 #define GET_PROC(mod, func) \
66 p ## func = (void*)GetProcAddress(mod, #func);
68 GET_PROC(hmsi
, MsiApplyMultiplePatchesA
);
69 GET_PROC(hmsi
, MsiGetComponentPathExA
);
70 GET_PROC(hshell32
, SHGetFolderPathA
);
72 GET_PROC(hadvapi32
, CheckTokenMembership
);
73 GET_PROC(hadvapi32
, ConvertSidToStringSidA
);
74 GET_PROC(hadvapi32
, OpenProcessToken
);
75 GET_PROC(hadvapi32
, RegDeleteKeyExA
)
76 GET_PROC(hadvapi32
, RegDeleteKeyExW
)
77 GET_PROC(hkernel32
, IsWow64Process
)
78 GET_PROC(hkernel32
, GetNativeSystemInfo
)
79 GET_PROC(hkernel32
, GetSystemInfo
)
80 GET_PROC(hkernel32
, GetSystemWow64DirectoryA
)
82 hsrclient
= LoadLibraryA("srclient.dll");
83 GET_PROC(hsrclient
, SRRemoveRestorePoint
);
84 GET_PROC(hsrclient
, SRSetRestorePointA
);
88 static BOOL
is_process_limited(void)
90 SID_IDENTIFIER_AUTHORITY NtAuthority
= {SECURITY_NT_AUTHORITY
};
95 if (!pCheckTokenMembership
|| !pOpenProcessToken
) return FALSE
;
97 if (!AllocateAndInitializeSid(&NtAuthority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
98 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0, &Group
) ||
99 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
101 trace("Could not check if the current user is an administrator\n");
109 if (!AllocateAndInitializeSid(&NtAuthority
, 2,
110 SECURITY_BUILTIN_DOMAIN_RID
,
111 DOMAIN_ALIAS_RID_POWER_USERS
,
112 0, 0, 0, 0, 0, 0, &Group
) ||
113 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
115 trace("Could not check if the current user is a power user\n");
120 /* Only administrators and power users can be powerful */
125 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
128 TOKEN_ELEVATION_TYPE type
= TokenElevationTypeDefault
;
131 ret
= GetTokenInformation(token
, TokenElevationType
, &type
, sizeof(type
), &size
);
133 return (ret
&& type
== TokenElevationTypeLimited
);
138 static LONG
delete_key( HKEY key
, LPCSTR subkey
, REGSAM access
)
140 if (pRegDeleteKeyExA
)
141 return pRegDeleteKeyExA( key
, subkey
, access
, 0 );
142 return RegDeleteKeyA( key
, subkey
);
145 static char *get_user_sid(void)
150 char *usersid
= NULL
;
152 if (!pConvertSidToStringSidA
)
154 win_skip("ConvertSidToStringSidA is not available\n");
157 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
158 GetTokenInformation(token
, TokenUser
, NULL
, size
, &size
);
160 user
= HeapAlloc(GetProcessHeap(), 0, size
);
161 GetTokenInformation(token
, TokenUser
, user
, size
, &size
);
162 pConvertSidToStringSidA(user
->User
.Sid
, &usersid
);
163 HeapFree(GetProcessHeap(), 0, user
);
169 /* RegDeleteTreeW from dlls/advapi32/registry.c */
170 static LSTATUS
package_RegDeleteTreeW(HKEY hKey
, LPCWSTR lpszSubKey
, REGSAM access
)
173 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
174 DWORD dwMaxLen
, dwSize
;
175 WCHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
180 ret
= RegOpenKeyExW(hKey
, lpszSubKey
, 0, access
, &hSubKey
);
184 ret
= RegQueryInfoKeyW(hSubKey
, NULL
, NULL
, NULL
, NULL
,
185 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
186 if (ret
) goto cleanup
;
190 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
191 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(WCHAR
))
193 /* Name too big: alloc a buffer for it */
194 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(WCHAR
))))
196 ret
= ERROR_NOT_ENOUGH_MEMORY
;
201 /* Recursively delete all the subkeys */
205 if (RegEnumKeyExW(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
206 NULL
, NULL
, NULL
)) break;
208 ret
= package_RegDeleteTreeW(hSubKey
, lpszName
, access
);
209 if (ret
) goto cleanup
;
214 if (pRegDeleteKeyExW
)
215 ret
= pRegDeleteKeyExW(hKey
, lpszSubKey
, access
, 0);
217 ret
= RegDeleteKeyW(hKey
, lpszSubKey
);
223 if (RegEnumValueW(hKey
, 0, lpszName
, &dwSize
,
224 NULL
, NULL
, NULL
, NULL
)) break;
226 ret
= RegDeleteValueW(hKey
, lpszName
);
227 if (ret
) goto cleanup
;
231 if (lpszName
!= szNameBuf
)
232 HeapFree(GetProcessHeap(), 0, lpszName
);
234 RegCloseKey(hSubKey
);
238 static BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
243 if (FAILED(CLSIDFromString((LPCOLESTR
)in
, &guid
)))
257 out
[17+i
*2] = in
[n
++];
258 out
[16+i
*2] = in
[n
++];
263 out
[17+i
*2] = in
[n
++];
264 out
[16+i
*2] = in
[n
++];
270 static void create_test_guid(LPSTR prodcode
, LPSTR squashed
)
272 WCHAR guidW
[MAX_PATH
];
273 WCHAR squashedW
[MAX_PATH
];
278 hr
= CoCreateGuid(&guid
);
279 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
281 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
282 ok(size
== 39, "Expected 39, got %d\n", hr
);
284 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, prodcode
, MAX_PATH
, NULL
, NULL
);
285 squash_guid(guidW
, squashedW
);
286 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
289 static void set_component_path(LPCSTR filename
, MSIINSTALLCONTEXT context
,
290 LPCSTR guid
, LPSTR usersid
, BOOL dir
)
292 WCHAR guidW
[MAX_PATH
];
293 WCHAR squashedW
[MAX_PATH
];
294 CHAR squashed
[MAX_PATH
];
295 CHAR comppath
[MAX_PATH
];
296 CHAR prodpath
[MAX_PATH
];
300 REGSAM access
= KEY_ALL_ACCESS
;
303 access
|= KEY_WOW64_64KEY
;
305 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
306 squash_guid(guidW
, squashedW
);
307 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
309 if (context
== MSIINSTALLCONTEXT_MACHINE
)
311 prod
= "3D0DAE300FACA1300AD792060BCDAA92";
313 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
314 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
316 "SOFTWARE\\Classes\\Installer\\"
317 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
319 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
321 prod
= "7D2F387510109040002000060BECB6AB";
323 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
324 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
326 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
327 "Installer\\%s\\Installer\\Products\\"
328 "7D2F387510109040002000060BECB6AB", usersid
);
330 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
332 prod
= "7D2F387510109040002000060BECB6AB";
334 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
335 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
337 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
338 "Installer\\Managed\\%s\\Installer\\Products\\"
339 "7D2F387510109040002000060BECB6AB", usersid
);
342 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, comppath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
344 lstrcpyA(path
, CURR_DIR
);
345 lstrcatA(path
, "\\");
346 if (!dir
) lstrcatA(path
, filename
);
348 RegSetValueExA(hkey
, prod
, 0, REG_SZ
, (LPBYTE
)path
, lstrlenA(path
));
351 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, prodpath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
355 static void delete_component_path(LPCSTR guid
, MSIINSTALLCONTEXT context
, LPSTR usersid
)
357 WCHAR guidW
[MAX_PATH
];
358 WCHAR squashedW
[MAX_PATH
];
359 WCHAR substrW
[MAX_PATH
];
360 CHAR squashed
[MAX_PATH
];
361 CHAR comppath
[MAX_PATH
];
362 CHAR prodpath
[MAX_PATH
];
363 REGSAM access
= KEY_ALL_ACCESS
;
366 access
|= KEY_WOW64_64KEY
;
368 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
369 squash_guid(guidW
, squashedW
);
370 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
372 if (context
== MSIINSTALLCONTEXT_MACHINE
)
375 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
376 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
378 "SOFTWARE\\Classes\\Installer\\"
379 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
381 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
384 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
385 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
387 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
388 "Installer\\%s\\Installer\\Products\\"
389 "7D2F387510109040002000060BECB6AB", usersid
);
391 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
394 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
395 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
397 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
398 "Installer\\Managed\\%s\\Installer\\Products\\"
399 "7D2F387510109040002000060BECB6AB", usersid
);
402 MultiByteToWideChar(CP_ACP
, 0, comppath
, -1, substrW
, MAX_PATH
);
403 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
405 MultiByteToWideChar(CP_ACP
, 0, prodpath
, -1, substrW
, MAX_PATH
);
406 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
409 static UINT
do_query(MSIHANDLE hdb
, const char *query
, MSIHANDLE
*phrec
)
414 /* open a select query */
415 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
416 if (r
!= ERROR_SUCCESS
)
418 r
= MsiViewExecute(hview
, 0);
419 if (r
!= ERROR_SUCCESS
)
421 ret
= MsiViewFetch(hview
, phrec
);
422 r
= MsiViewClose(hview
);
423 if (r
!= ERROR_SUCCESS
)
425 r
= MsiCloseHandle(hview
);
426 if (r
!= ERROR_SUCCESS
)
431 static UINT
run_query( MSIHANDLE hdb
, const char *query
)
436 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
437 if( r
!= ERROR_SUCCESS
)
440 r
= MsiViewExecute(hview
, 0);
441 if( r
== ERROR_SUCCESS
)
442 r
= MsiViewClose(hview
);
443 MsiCloseHandle(hview
);
447 static UINT
create_component_table( MSIHANDLE hdb
)
449 return run_query( hdb
,
450 "CREATE TABLE `Component` ( "
451 "`Component` CHAR(72) NOT NULL, "
452 "`ComponentId` CHAR(38), "
453 "`Directory_` CHAR(72) NOT NULL, "
454 "`Attributes` SHORT NOT NULL, "
455 "`Condition` CHAR(255), "
456 "`KeyPath` CHAR(72) "
457 "PRIMARY KEY `Component`)" );
460 static UINT
create_feature_table( MSIHANDLE hdb
)
462 return run_query( hdb
,
463 "CREATE TABLE `Feature` ( "
464 "`Feature` CHAR(38) NOT NULL, "
465 "`Feature_Parent` CHAR(38), "
467 "`Description` CHAR(255), "
468 "`Display` SHORT NOT NULL, "
469 "`Level` SHORT NOT NULL, "
470 "`Directory_` CHAR(72), "
471 "`Attributes` SHORT NOT NULL "
472 "PRIMARY KEY `Feature`)" );
475 static UINT
create_feature_components_table( MSIHANDLE hdb
)
477 return run_query( hdb
,
478 "CREATE TABLE `FeatureComponents` ( "
479 "`Feature_` CHAR(38) NOT NULL, "
480 "`Component_` CHAR(72) NOT NULL "
481 "PRIMARY KEY `Feature_`, `Component_` )" );
484 static UINT
create_file_table( MSIHANDLE hdb
)
486 return run_query( hdb
,
487 "CREATE TABLE `File` ("
488 "`File` CHAR(72) NOT NULL, "
489 "`Component_` CHAR(72) NOT NULL, "
490 "`FileName` CHAR(255) NOT NULL, "
491 "`FileSize` LONG NOT NULL, "
492 "`Version` CHAR(72), "
493 "`Language` CHAR(20), "
494 "`Attributes` SHORT, "
495 "`Sequence` SHORT NOT NULL "
496 "PRIMARY KEY `File`)" );
499 static UINT
create_remove_file_table( MSIHANDLE hdb
)
501 return run_query( hdb
,
502 "CREATE TABLE `RemoveFile` ("
503 "`FileKey` CHAR(72) NOT NULL, "
504 "`Component_` CHAR(72) NOT NULL, "
505 "`FileName` CHAR(255) LOCALIZABLE, "
506 "`DirProperty` CHAR(72) NOT NULL, "
507 "`InstallMode` SHORT NOT NULL "
508 "PRIMARY KEY `FileKey`)" );
511 static UINT
create_appsearch_table( MSIHANDLE hdb
)
513 return run_query( hdb
,
514 "CREATE TABLE `AppSearch` ("
515 "`Property` CHAR(72) NOT NULL, "
516 "`Signature_` CHAR(72) NOT NULL "
517 "PRIMARY KEY `Property`, `Signature_`)" );
520 static UINT
create_reglocator_table( MSIHANDLE hdb
)
522 return run_query( hdb
,
523 "CREATE TABLE `RegLocator` ("
524 "`Signature_` CHAR(72) NOT NULL, "
525 "`Root` SHORT NOT NULL, "
526 "`Key` CHAR(255) NOT NULL, "
529 "PRIMARY KEY `Signature_`)" );
532 static UINT
create_signature_table( MSIHANDLE hdb
)
534 return run_query( hdb
,
535 "CREATE TABLE `Signature` ("
536 "`Signature` CHAR(72) NOT NULL, "
537 "`FileName` CHAR(255) NOT NULL, "
538 "`MinVersion` CHAR(20), "
539 "`MaxVersion` CHAR(20), "
544 "`Languages` CHAR(255) "
545 "PRIMARY KEY `Signature`)" );
548 static UINT
create_launchcondition_table( MSIHANDLE hdb
)
550 return run_query( hdb
,
551 "CREATE TABLE `LaunchCondition` ("
552 "`Condition` CHAR(255) NOT NULL, "
553 "`Description` CHAR(255) NOT NULL "
554 "PRIMARY KEY `Condition`)" );
557 static UINT
create_property_table( MSIHANDLE hdb
)
559 return run_query( hdb
,
560 "CREATE TABLE `Property` ("
561 "`Property` CHAR(72) NOT NULL, "
563 "PRIMARY KEY `Property`)" );
566 static UINT
create_install_execute_sequence_table( MSIHANDLE hdb
)
568 return run_query( hdb
,
569 "CREATE TABLE `InstallExecuteSequence` ("
570 "`Action` CHAR(72) NOT NULL, "
571 "`Condition` CHAR(255), "
573 "PRIMARY KEY `Action`)" );
576 static UINT
create_media_table( MSIHANDLE hdb
)
578 return run_query( hdb
,
579 "CREATE TABLE `Media` ("
580 "`DiskId` SHORT NOT NULL, "
581 "`LastSequence` SHORT NOT NULL, "
582 "`DiskPrompt` CHAR(64), "
583 "`Cabinet` CHAR(255), "
584 "`VolumeLabel` CHAR(32), "
586 "PRIMARY KEY `DiskId`)" );
589 static UINT
create_ccpsearch_table( MSIHANDLE hdb
)
591 return run_query( hdb
,
592 "CREATE TABLE `CCPSearch` ("
593 "`Signature_` CHAR(72) NOT NULL "
594 "PRIMARY KEY `Signature_`)" );
597 static UINT
create_drlocator_table( MSIHANDLE hdb
)
599 return run_query( hdb
,
600 "CREATE TABLE `DrLocator` ("
601 "`Signature_` CHAR(72) NOT NULL, "
602 "`Parent` CHAR(72), "
605 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
608 static UINT
create_complocator_table( MSIHANDLE hdb
)
610 return run_query( hdb
,
611 "CREATE TABLE `CompLocator` ("
612 "`Signature_` CHAR(72) NOT NULL, "
613 "`ComponentId` CHAR(38) NOT NULL, "
615 "PRIMARY KEY `Signature_`)" );
618 static UINT
create_inilocator_table( MSIHANDLE hdb
)
620 return run_query( hdb
,
621 "CREATE TABLE `IniLocator` ("
622 "`Signature_` CHAR(72) NOT NULL, "
623 "`FileName` CHAR(255) NOT NULL, "
624 "`Section` CHAR(96)NOT NULL, "
625 "`Key` CHAR(128)NOT NULL, "
628 "PRIMARY KEY `Signature_`)" );
631 static UINT
create_custom_action_table( MSIHANDLE hdb
)
633 return run_query( hdb
,
634 "CREATE TABLE `CustomAction` ("
635 "`Action` CHAR(72) NOT NULL, "
636 "`Type` SHORT NOT NULL, "
637 "`Source` CHAR(75), "
638 "`Target` CHAR(255) "
639 "PRIMARY KEY `Action`)" );
642 #define make_add_entry(type, qtext) \
643 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
645 char insert[] = qtext; \
648 sz = strlen(values) + sizeof insert; \
649 query = HeapAlloc(GetProcessHeap(),0,sz); \
650 sprintf(query,insert,values); \
651 r = run_query( hdb, query ); \
652 HeapFree(GetProcessHeap(), 0, query); \
656 make_add_entry(component
,
657 "INSERT INTO `Component` "
658 "(`Component`, `ComponentId`, `Directory_`, "
659 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
661 make_add_entry(directory
,
662 "INSERT INTO `Directory` "
663 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
665 make_add_entry(feature
,
666 "INSERT INTO `Feature` "
667 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
668 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
670 make_add_entry(feature_components
,
671 "INSERT INTO `FeatureComponents` "
672 "(`Feature_`, `Component_`) VALUES( %s )")
675 "INSERT INTO `File` "
676 "(`File`, `Component_`, `FileName`, `FileSize`, "
677 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
679 make_add_entry(appsearch
,
680 "INSERT INTO `AppSearch` "
681 "(`Property`, `Signature_`) VALUES( %s )")
683 make_add_entry(signature
,
684 "INSERT INTO `Signature` "
685 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
686 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
689 make_add_entry(launchcondition
,
690 "INSERT INTO `LaunchCondition` "
691 "(`Condition`, `Description`) VALUES( %s )")
693 make_add_entry(property
,
694 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
696 make_add_entry(install_execute_sequence
,
697 "INSERT INTO `InstallExecuteSequence` "
698 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
700 make_add_entry(media
,
701 "INSERT INTO `Media` "
702 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
703 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
705 make_add_entry(ccpsearch
,
706 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
708 make_add_entry(drlocator
,
709 "INSERT INTO `DrLocator` "
710 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
712 make_add_entry(complocator
,
713 "INSERT INTO `CompLocator` "
714 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
716 make_add_entry(inilocator
,
717 "INSERT INTO `IniLocator` "
718 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
721 make_add_entry(custom_action
,
722 "INSERT INTO `CustomAction` "
723 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
725 static UINT
add_reglocator_entry( MSIHANDLE hdb
, const char *sig
, UINT root
, const char *path
,
726 const char *name
, UINT type
)
728 const char insert
[] =
729 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
730 "VALUES( '%s', %u, '%s', '%s', %u )";
734 sz
= strlen( sig
) + 10 + strlen( path
) + strlen( name
) + 10 + sizeof( insert
);
735 query
= HeapAlloc( GetProcessHeap(), 0, sz
);
736 sprintf( query
, insert
, sig
, root
, path
, name
, type
);
737 r
= run_query( hdb
, query
);
738 HeapFree( GetProcessHeap(), 0, query
);
742 static UINT
set_summary_info(MSIHANDLE hdb
)
747 /* build summary info */
748 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
749 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
751 res
= MsiSummaryInfoSetPropertyA(suminfo
,2, VT_LPSTR
, 0,NULL
,
752 "Installation Database");
753 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
755 res
= MsiSummaryInfoSetPropertyA(suminfo
,3, VT_LPSTR
, 0,NULL
,
756 "Installation Database");
757 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
759 res
= MsiSummaryInfoSetPropertyA(suminfo
,4, VT_LPSTR
, 0,NULL
,
761 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
763 res
= MsiSummaryInfoSetPropertyA(suminfo
,7, VT_LPSTR
, 0,NULL
,
765 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
767 res
= MsiSummaryInfoSetPropertyA(suminfo
,9, VT_LPSTR
, 0,NULL
,
768 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
769 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
771 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
772 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
774 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
775 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
777 res
= MsiSummaryInfoPersist(suminfo
);
778 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
780 res
= MsiCloseHandle( suminfo
);
781 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
787 static MSIHANDLE
create_package_db(void)
792 DeleteFileA(msifile
);
794 /* create an empty database */
795 res
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
796 ok( res
== ERROR_SUCCESS
, "Failed to create database %u\n", res
);
797 if( res
!= ERROR_SUCCESS
)
800 res
= MsiDatabaseCommit( hdb
);
801 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
803 res
= set_summary_info(hdb
);
804 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
806 res
= run_query( hdb
,
807 "CREATE TABLE `Directory` ( "
808 "`Directory` CHAR(255) NOT NULL, "
809 "`Directory_Parent` CHAR(255), "
810 "`DefaultDir` CHAR(255) NOT NULL "
811 "PRIMARY KEY `Directory`)" );
812 ok( res
== ERROR_SUCCESS
, "Failed to create directory table\n" );
817 static UINT
package_from_db(MSIHANDLE hdb
, MSIHANDLE
*handle
)
823 sprintf(szPackage
, "#%u", hdb
);
824 res
= MsiOpenPackageA(szPackage
, &hPackage
);
825 if (res
!= ERROR_SUCCESS
)
831 res
= MsiCloseHandle(hdb
);
832 if (res
!= ERROR_SUCCESS
)
834 MsiCloseHandle(hPackage
);
839 return ERROR_SUCCESS
;
842 static void create_test_file(const CHAR
*name
)
847 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
848 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
849 WriteFile(file
, name
, strlen(name
), &written
, NULL
);
850 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
854 typedef struct _tagVS_VERSIONINFO
861 VS_FIXEDFILEINFO Value
;
866 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
867 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
869 static BOOL
create_file_with_version(const CHAR
*name
, LONG ms
, LONG ls
)
871 VS_VERSIONINFO
*pVerInfo
;
872 VS_FIXEDFILEINFO
*pFixedInfo
;
879 GetSystemDirectoryA(path
, MAX_PATH
);
880 /* Some dlls can't be updated on Vista/W2K8 */
881 lstrcatA(path
, "\\version.dll");
883 CopyFileA(path
, name
, FALSE
);
885 size
= GetFileVersionInfoSizeA(path
, &handle
);
886 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
888 GetFileVersionInfoA(path
, 0, size
, buffer
);
890 pVerInfo
= (VS_VERSIONINFO
*)buffer
;
891 ofs
= (BYTE
*)&pVerInfo
->szKey
[lstrlenW(pVerInfo
->szKey
) + 1];
892 pFixedInfo
= (VS_FIXEDFILEINFO
*)roundpos(pVerInfo
, ofs
, 4);
894 pFixedInfo
->dwFileVersionMS
= ms
;
895 pFixedInfo
->dwFileVersionLS
= ls
;
896 pFixedInfo
->dwProductVersionMS
= ms
;
897 pFixedInfo
->dwProductVersionLS
= ls
;
899 resource
= BeginUpdateResourceA(name
, FALSE
);
903 if (!UpdateResourceA(resource
, (LPCSTR
)RT_VERSION
, (LPCSTR
)MAKEINTRESOURCE(VS_VERSION_INFO
),
904 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), buffer
, size
))
907 if (!EndUpdateResourceA(resource
, FALSE
))
913 HeapFree(GetProcessHeap(), 0, buffer
);
917 static BOOL
notify_system_change(DWORD event_type
, STATEMGRSTATUS
*status
)
919 RESTOREPOINTINFOA spec
;
921 spec
.dwEventType
= event_type
;
922 spec
.dwRestorePtType
= APPLICATION_INSTALL
;
923 spec
.llSequenceNumber
= status
->llSequenceNumber
;
924 lstrcpyA(spec
.szDescription
, "msitest restore point");
926 return pSRSetRestorePointA(&spec
, status
);
929 static void remove_restore_point(DWORD seq_number
)
933 res
= pSRRemoveRestorePoint(seq_number
);
934 if (res
!= ERROR_SUCCESS
)
935 trace("Failed to remove the restore point : %08x\n", res
);
938 static void test_createpackage(void)
940 MSIHANDLE hPackage
= 0;
943 res
= package_from_db(create_package_db(), &hPackage
);
944 if (res
== ERROR_INSTALL_PACKAGE_REJECTED
)
946 skip("Not enough rights to perform tests\n");
947 DeleteFileA(msifile
);
950 ok( res
== ERROR_SUCCESS
, " Failed to create package %u\n", res
);
952 res
= MsiCloseHandle( hPackage
);
953 ok( res
== ERROR_SUCCESS
, "Failed to close package\n" );
954 DeleteFileA(msifile
);
957 static void test_doaction( void )
962 r
= MsiDoActionA( -1, NULL
);
963 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
965 r
= package_from_db(create_package_db(), &hpkg
);
966 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
968 skip("Not enough rights to perform tests\n");
969 DeleteFileA(msifile
);
972 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
974 r
= MsiDoActionA(hpkg
, NULL
);
975 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
977 r
= MsiDoActionA(0, "boo");
978 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
980 r
= MsiDoActionA(hpkg
, "boo");
981 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "wrong return val\n");
983 MsiCloseHandle( hpkg
);
984 DeleteFileA(msifile
);
987 static void test_gettargetpath_bad(void)
989 static const WCHAR boo
[] = {'b','o','o',0};
990 static const WCHAR empty
[] = {0};
997 r
= package_from_db(create_package_db(), &hpkg
);
998 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1000 skip("Not enough rights to perform tests\n");
1001 DeleteFileA(msifile
);
1004 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1006 r
= MsiGetTargetPathA( 0, NULL
, NULL
, NULL
);
1007 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1009 r
= MsiGetTargetPathA( 0, NULL
, NULL
, &sz
);
1010 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1012 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1013 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1015 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1016 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1018 r
= MsiGetTargetPathA( hpkg
, "boo", NULL
, NULL
);
1019 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1021 r
= MsiGetTargetPathA( hpkg
, "boo", buffer
, NULL
);
1022 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1025 r
= MsiGetTargetPathA( hpkg
, "", buffer
, &sz
);
1026 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1028 r
= MsiGetTargetPathW( 0, NULL
, NULL
, NULL
);
1029 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1031 r
= MsiGetTargetPathW( 0, NULL
, NULL
, &sz
);
1032 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1034 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1035 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1037 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1038 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1040 r
= MsiGetTargetPathW( hpkg
, boo
, NULL
, NULL
);
1041 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1043 r
= MsiGetTargetPathW( hpkg
, boo
, bufferW
, NULL
);
1044 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1047 r
= MsiGetTargetPathW( hpkg
, empty
, bufferW
, &sz
);
1048 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1050 MsiCloseHandle( hpkg
);
1051 DeleteFileA(msifile
);
1054 static void query_file_path(MSIHANDLE hpkg
, LPCSTR file
, LPSTR buff
)
1060 rec
= MsiCreateRecord( 1 );
1061 ok(rec
, "MsiCreate record failed\n");
1063 r
= MsiRecordSetStringA( rec
, 0, file
);
1064 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1067 r
= MsiFormatRecordA( hpkg
, rec
, buff
, &size
);
1068 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1070 MsiCloseHandle( rec
);
1073 static void test_settargetpath(void)
1075 char tempdir
[MAX_PATH
+8], buffer
[MAX_PATH
], file
[MAX_PATH
];
1081 hdb
= create_package_db();
1082 ok ( hdb
, "failed to create package database\n" );
1084 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
1085 ok( r
== S_OK
, "failed to add directory entry: %d\n" , r
);
1087 r
= create_component_table( hdb
);
1088 ok( r
== S_OK
, "cannot create Component table: %d\n", r
);
1090 r
= add_component_entry( hdb
, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1091 ok( r
== S_OK
, "cannot add dummy component: %d\n", r
);
1093 r
= add_component_entry( hdb
, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1094 ok( r
== S_OK
, "cannot add test component: %d\n", r
);
1096 r
= create_feature_table( hdb
);
1097 ok( r
== S_OK
, "cannot create Feature table: %d\n", r
);
1099 r
= add_feature_entry( hdb
, "'TestFeature', '', '', '', 0, 1, '', 0" );
1100 ok( r
== ERROR_SUCCESS
, "cannot add TestFeature to Feature table: %d\n", r
);
1102 r
= create_feature_components_table( hdb
);
1103 ok( r
== S_OK
, "cannot create FeatureComponents table: %d\n", r
);
1105 r
= add_feature_components_entry( hdb
, "'TestFeature', 'RootComp'" );
1106 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
1108 r
= add_feature_components_entry( hdb
, "'TestFeature', 'TestComp'" );
1109 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
1111 add_directory_entry( hdb
, "'TestParent', 'TARGETDIR', 'TestParent'" );
1112 add_directory_entry( hdb
, "'TestDir', 'TestParent', 'TestDir'" );
1114 r
= create_file_table( hdb
);
1115 ok( r
== S_OK
, "cannot create File table: %d\n", r
);
1117 r
= add_file_entry( hdb
, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1118 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
1120 r
= add_file_entry( hdb
, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1121 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
1123 r
= package_from_db( hdb
, &hpkg
);
1124 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1126 skip("Not enough rights to perform tests\n");
1127 DeleteFileA(msifile
);
1130 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1132 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1134 r
= MsiDoActionA( hpkg
, "CostInitialize");
1135 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
1137 r
= MsiDoActionA( hpkg
, "FileCost");
1138 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
1140 r
= MsiDoActionA( hpkg
, "CostFinalize");
1141 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
1143 r
= MsiSetTargetPathA( 0, NULL
, NULL
);
1144 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1146 r
= MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1147 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1149 r
= MsiSetTargetPathA( hpkg
, "boo", NULL
);
1150 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1152 r
= MsiSetTargetPathA( hpkg
, "boo", "c:\\bogusx" );
1153 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1155 sz
= sizeof tempdir
- 1;
1156 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", tempdir
, &sz
);
1157 sprintf( file
, "%srootfile.txt", tempdir
);
1159 query_file_path( hpkg
, "[#RootFile]", buffer
);
1160 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1161 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1163 GetTempFileNameA( tempdir
, "_wt", 0, buffer
);
1164 sprintf( tempdir
, "%s\\subdir", buffer
);
1166 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1167 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1168 "MsiSetTargetPath on file returned %d\n", r
);
1170 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1171 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1172 "MsiSetTargetPath on 'subdir' of file returned %d\n", r
);
1174 DeleteFileA( buffer
);
1176 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1177 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1179 r
= GetFileAttributesA( buffer
);
1180 ok ( r
== INVALID_FILE_ATTRIBUTES
, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r
);
1182 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1183 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on subsubdir returned %d\n", r
);
1186 sz
= sizeof buffer
- 1;
1187 lstrcatA( tempdir
, "\\" );
1188 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", buffer
, &sz
);
1189 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1190 ok( !lstrcmpA(buffer
, tempdir
), "Expected %s, got %s\n", tempdir
, buffer
);
1192 sprintf( file
, "%srootfile.txt", tempdir
);
1193 query_file_path( hpkg
, "[#RootFile]", buffer
);
1194 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1197 sz
= sizeof(buffer
);
1198 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1199 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1200 lstrcatA( tempdir
, "TestParent\\" );
1201 ok( !lstrcmpiA(buffer
, tempdir
), "Expected \"%s\", got \"%s\"\n", tempdir
, buffer
);
1203 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two" );
1204 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1207 sz
= sizeof(buffer
);
1208 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1209 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1210 ok( lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\"),
1211 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer
);
1214 query_file_path( hpkg
, "[#TestFile]", buffer
);
1215 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\testfile.txt"),
1216 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer
);
1219 sz
= sizeof buffer
- 1;
1220 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1221 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1222 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer
);
1224 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two\\three" );
1225 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1228 sz
= sizeof buffer
- 1;
1229 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1230 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1231 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer
);
1233 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\one\\\\two " );
1234 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1237 sz
= sizeof buffer
- 1;
1238 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1239 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1240 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer
);
1242 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\ Program Files \\\\ " );
1243 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1246 sz
= sizeof buffer
- 1;
1247 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1248 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1249 ok( !lstrcmpiA(buffer
, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer
);
1251 MsiCloseHandle( hpkg
);
1254 static void test_condition(void)
1256 static const WCHAR cond1
[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1257 static const WCHAR cond2
[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1258 static const WCHAR cond3
[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1259 static const WCHAR cond4
[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1263 r
= package_from_db(create_package_db(), &hpkg
);
1264 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1266 skip("Not enough rights to perform tests\n");
1267 DeleteFileA(msifile
);
1270 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1272 r
= MsiEvaluateConditionA(0, NULL
);
1273 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1275 r
= MsiEvaluateConditionA(hpkg
, NULL
);
1276 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1278 r
= MsiEvaluateConditionA(hpkg
, "");
1279 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1281 r
= MsiEvaluateConditionA(hpkg
, "1");
1282 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1284 r
= MsiEvaluateConditionA(hpkg
, "0");
1285 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1287 r
= MsiEvaluateConditionA(hpkg
, "-1");
1288 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1290 r
= MsiEvaluateConditionA(hpkg
, "0 = 0");
1291 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1293 r
= MsiEvaluateConditionA(hpkg
, "0 <> 0");
1294 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1296 r
= MsiEvaluateConditionA(hpkg
, "0 = 1");
1297 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1299 r
= MsiEvaluateConditionA(hpkg
, "0 > 1");
1300 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1302 r
= MsiEvaluateConditionA(hpkg
, "0 ~> 1");
1303 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1305 r
= MsiEvaluateConditionA(hpkg
, "1 > 1");
1306 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1308 r
= MsiEvaluateConditionA(hpkg
, "1 ~> 1");
1309 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1311 r
= MsiEvaluateConditionA(hpkg
, "0 >= 1");
1312 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1314 r
= MsiEvaluateConditionA(hpkg
, "0 ~>= 1");
1315 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1317 r
= MsiEvaluateConditionA(hpkg
, "1 >= 1");
1318 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1320 r
= MsiEvaluateConditionA(hpkg
, "1 ~>= 1");
1321 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1323 r
= MsiEvaluateConditionA(hpkg
, "0 < 1");
1324 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1326 r
= MsiEvaluateConditionA(hpkg
, "0 ~< 1");
1327 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1329 r
= MsiEvaluateConditionA(hpkg
, "1 < 1");
1330 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1332 r
= MsiEvaluateConditionA(hpkg
, "1 ~< 1");
1333 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1335 r
= MsiEvaluateConditionA(hpkg
, "0 <= 1");
1336 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1338 r
= MsiEvaluateConditionA(hpkg
, "0 ~<= 1");
1339 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1341 r
= MsiEvaluateConditionA(hpkg
, "1 <= 1");
1342 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1344 r
= MsiEvaluateConditionA(hpkg
, "1 ~<= 1");
1345 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1347 r
= MsiEvaluateConditionA(hpkg
, "0 >=");
1348 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1350 r
= MsiEvaluateConditionA(hpkg
, " ");
1351 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1353 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"1\"");
1354 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1356 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"0\"");
1357 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1359 r
= MsiEvaluateConditionA(hpkg
, "LicView <> LicView");
1360 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1362 r
= MsiEvaluateConditionA(hpkg
, "not 0");
1363 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1365 r
= MsiEvaluateConditionA(hpkg
, "not LicView");
1366 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1368 r
= MsiEvaluateConditionA(hpkg
, "\"Testing\" ~<< \"Testing\"");
1369 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1371 r
= MsiEvaluateConditionA(hpkg
, "LicView ~<< \"Testing\"");
1372 ok (r
== MSICONDITION_FALSE
, "wrong return val\n");
1374 r
= MsiEvaluateConditionA(hpkg
, "Not LicView ~<< \"Testing\"");
1375 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1377 r
= MsiEvaluateConditionA(hpkg
, "not \"A\"");
1378 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1380 r
= MsiEvaluateConditionA(hpkg
, "~not \"A\"");
1381 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1383 r
= MsiEvaluateConditionA(hpkg
, "\"0\"");
1384 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1386 r
= MsiEvaluateConditionA(hpkg
, "1 and 2");
1387 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1389 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 3");
1390 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1392 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 0");
1393 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1395 r
= MsiEvaluateConditionA(hpkg
, "not 0 or 1");
1396 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1398 r
= MsiEvaluateConditionA(hpkg
, "(0)");
1399 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1401 r
= MsiEvaluateConditionA(hpkg
, "(((((1))))))");
1402 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1404 r
= MsiEvaluateConditionA(hpkg
, "(((((1)))))");
1405 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1407 r
= MsiEvaluateConditionA(hpkg
, " \"A\" < \"B\" ");
1408 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1410 r
= MsiEvaluateConditionA(hpkg
, " \"A\" > \"B\" ");
1411 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1413 r
= MsiEvaluateConditionA(hpkg
, " \"1\" > \"12\" ");
1414 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1416 r
= MsiEvaluateConditionA(hpkg
, " \"100\" < \"21\" ");
1417 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1419 r
= MsiEvaluateConditionA(hpkg
, "0 < > 0");
1420 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1422 r
= MsiEvaluateConditionA(hpkg
, "(1<<1) == 2");
1423 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1425 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = \"a\" ");
1426 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1428 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~ = \"a\" ");
1429 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1431 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= \"a\" ");
1432 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1434 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= 1 ");
1435 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1437 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = 1 ");
1438 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1440 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= 1 ");
1441 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1443 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= \"1\" ");
1444 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1446 r
= MsiEvaluateConditionA(hpkg
, " 1 = \"1\" ");
1447 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1449 r
= MsiEvaluateConditionA(hpkg
, " 0 = \"1\" ");
1450 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1452 r
= MsiEvaluateConditionA(hpkg
, " 0 < \"100\" ");
1453 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1455 r
= MsiEvaluateConditionA(hpkg
, " 100 > \"0\" ");
1456 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1458 r
= MsiEvaluateConditionA(hpkg
, "1 XOR 1");
1459 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1461 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1");
1462 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1464 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 0");
1465 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1467 r
= MsiEvaluateConditionA(hpkg
, "0 IMP 0");
1468 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1470 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 0");
1471 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1473 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 1");
1474 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1476 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1 OR 0");
1477 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1479 r
= MsiEvaluateConditionA(hpkg
, "1 IMPL 1");
1480 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1482 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" >< \"S\" ");
1483 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1485 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"s\" ");
1486 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1488 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"\" ");
1489 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1491 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"sss\" ");
1492 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1494 MsiSetPropertyA(hpkg
, "mm", "5" );
1496 r
= MsiEvaluateConditionA(hpkg
, "mm = 5");
1497 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1499 r
= MsiEvaluateConditionA(hpkg
, "mm < 6");
1500 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1502 r
= MsiEvaluateConditionA(hpkg
, "mm <= 5");
1503 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1505 r
= MsiEvaluateConditionA(hpkg
, "mm > 4");
1506 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1508 r
= MsiEvaluateConditionA(hpkg
, "mm < 12");
1509 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1511 r
= MsiEvaluateConditionA(hpkg
, "mm = \"5\"");
1512 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1514 r
= MsiEvaluateConditionA(hpkg
, "0 = \"\"");
1515 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1517 r
= MsiEvaluateConditionA(hpkg
, "0 AND \"\"");
1518 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1520 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"\"");
1521 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1523 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"1\"");
1524 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1526 r
= MsiEvaluateConditionA(hpkg
, "3 >< 1");
1527 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1529 r
= MsiEvaluateConditionA(hpkg
, "3 >< 4");
1530 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1532 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 0");
1533 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1535 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1");
1536 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1538 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 OR 0");
1539 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1541 r
= MsiEvaluateConditionA(hpkg
, "0 AND 1 OR 1");
1542 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1544 r
= MsiEvaluateConditionA(hpkg
, "0 AND 0 OR 1");
1545 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1547 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1 OR 0");
1548 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1550 r
= MsiEvaluateConditionA(hpkg
, "_1 = _1");
1551 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1553 r
= MsiEvaluateConditionA(hpkg
, "( 1 AND 1 ) = 2");
1554 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1556 r
= MsiEvaluateConditionA(hpkg
, "NOT ( 1 AND 1 )");
1557 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1559 r
= MsiEvaluateConditionA(hpkg
, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1560 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1562 r
= MsiEvaluateConditionA(hpkg
, "Installed<>\"\"");
1563 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1565 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 AND 0");
1566 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1568 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1569 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1571 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1572 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1574 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<0");
1575 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1577 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>0");
1578 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1580 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>=0");
1581 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1583 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<=0");
1584 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1586 r
= MsiEvaluateConditionA(hpkg
, "bandalmael~<>0");
1587 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1589 MsiSetPropertyA(hpkg
, "bandalmael", "0" );
1590 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1591 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1593 MsiSetPropertyA(hpkg
, "bandalmael", "" );
1594 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1595 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1597 MsiSetPropertyA(hpkg
, "bandalmael", "asdf" );
1598 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1599 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1601 MsiSetPropertyA(hpkg
, "bandalmael", "0asdf" );
1602 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1603 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1605 MsiSetPropertyA(hpkg
, "bandalmael", "0 " );
1606 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1607 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1609 MsiSetPropertyA(hpkg
, "bandalmael", "-0" );
1610 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1611 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1613 MsiSetPropertyA(hpkg
, "bandalmael", "0000000000000" );
1614 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1615 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1617 MsiSetPropertyA(hpkg
, "bandalmael", "--0" );
1618 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1619 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1621 MsiSetPropertyA(hpkg
, "bandalmael", "0x00" );
1622 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1623 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1625 MsiSetPropertyA(hpkg
, "bandalmael", "-" );
1626 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1627 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1629 MsiSetPropertyA(hpkg
, "bandalmael", "+0" );
1630 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1631 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1633 MsiSetPropertyA(hpkg
, "bandalmael", "0.0" );
1634 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1635 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1636 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1637 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1639 MsiSetPropertyA(hpkg
, "one", "hi");
1640 MsiSetPropertyA(hpkg
, "two", "hithere");
1641 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1642 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1644 MsiSetPropertyA(hpkg
, "one", "hithere");
1645 MsiSetPropertyA(hpkg
, "two", "hi");
1646 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1647 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1649 MsiSetPropertyA(hpkg
, "one", "hello");
1650 MsiSetPropertyA(hpkg
, "two", "hi");
1651 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1652 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1654 MsiSetPropertyA(hpkg
, "one", "hellohithere");
1655 MsiSetPropertyA(hpkg
, "two", "hi");
1656 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1657 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1659 MsiSetPropertyA(hpkg
, "one", "");
1660 MsiSetPropertyA(hpkg
, "two", "hi");
1661 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1662 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1664 MsiSetPropertyA(hpkg
, "one", "hi");
1665 MsiSetPropertyA(hpkg
, "two", "");
1666 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1667 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1669 MsiSetPropertyA(hpkg
, "one", "");
1670 MsiSetPropertyA(hpkg
, "two", "");
1671 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1672 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1674 MsiSetPropertyA(hpkg
, "one", "1234");
1675 MsiSetPropertyA(hpkg
, "two", "1");
1676 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1677 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1679 MsiSetPropertyA(hpkg
, "one", "one 1234");
1680 MsiSetPropertyA(hpkg
, "two", "1");
1681 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1682 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1684 MsiSetPropertyA(hpkg
, "one", "hithere");
1685 MsiSetPropertyA(hpkg
, "two", "hi");
1686 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1687 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1689 MsiSetPropertyA(hpkg
, "one", "hi");
1690 MsiSetPropertyA(hpkg
, "two", "hithere");
1691 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1692 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1694 MsiSetPropertyA(hpkg
, "one", "hi");
1695 MsiSetPropertyA(hpkg
, "two", "hi");
1696 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1697 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1699 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1700 MsiSetPropertyA(hpkg
, "two", "hi");
1701 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1702 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1704 MsiSetPropertyA(hpkg
, "one", "");
1705 MsiSetPropertyA(hpkg
, "two", "hi");
1706 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1707 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1709 MsiSetPropertyA(hpkg
, "one", "hithere");
1710 MsiSetPropertyA(hpkg
, "two", "");
1711 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1712 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1714 MsiSetPropertyA(hpkg
, "one", "");
1715 MsiSetPropertyA(hpkg
, "two", "");
1716 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1717 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1719 MsiSetPropertyA(hpkg
, "one", "1234");
1720 MsiSetPropertyA(hpkg
, "two", "1");
1721 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1722 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1724 MsiSetPropertyA(hpkg
, "one", "1234 one");
1725 MsiSetPropertyA(hpkg
, "two", "1");
1726 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1727 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1729 MsiSetPropertyA(hpkg
, "one", "hithere");
1730 MsiSetPropertyA(hpkg
, "two", "there");
1731 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1732 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1734 MsiSetPropertyA(hpkg
, "one", "hithere");
1735 MsiSetPropertyA(hpkg
, "two", "hi");
1736 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1737 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1739 MsiSetPropertyA(hpkg
, "one", "there");
1740 MsiSetPropertyA(hpkg
, "two", "hithere");
1741 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1742 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1744 MsiSetPropertyA(hpkg
, "one", "there");
1745 MsiSetPropertyA(hpkg
, "two", "there");
1746 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1747 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1749 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1750 MsiSetPropertyA(hpkg
, "two", "hi");
1751 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1752 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1754 MsiSetPropertyA(hpkg
, "one", "");
1755 MsiSetPropertyA(hpkg
, "two", "there");
1756 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1757 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1759 MsiSetPropertyA(hpkg
, "one", "there");
1760 MsiSetPropertyA(hpkg
, "two", "");
1761 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1762 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1764 MsiSetPropertyA(hpkg
, "one", "");
1765 MsiSetPropertyA(hpkg
, "two", "");
1766 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1767 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1769 MsiSetPropertyA(hpkg
, "one", "1234");
1770 MsiSetPropertyA(hpkg
, "two", "4");
1771 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1772 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1774 MsiSetPropertyA(hpkg
, "one", "one 1234");
1775 MsiSetPropertyA(hpkg
, "two", "4");
1776 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1777 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1779 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", NULL
); /* make sure it's empty */
1781 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1782 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1784 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport > \"1.1.4322\"");
1785 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1787 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport >= \"1.1.4322\"");
1788 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1790 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <= \"1.1.4322\"");
1791 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1793 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <> \"1.1.4322\"");
1794 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1796 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1797 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1799 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"abcd\"");
1800 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1802 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a1.1.4322\"");
1803 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1805 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322a\"");
1806 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1808 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1809 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1811 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1812 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1814 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1815 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1817 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1");
1818 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1820 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1\"");
1821 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1823 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"12.1\"");
1824 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1826 r
= MsiEvaluateConditionA(hpkg
, "\"02.1\" < \"2.11\"");
1827 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1829 r
= MsiEvaluateConditionA(hpkg
, "\"02.1.1\" < \"2.1\"");
1830 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1832 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1833 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1835 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
1836 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1838 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0\"");
1839 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1841 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"-1\"");
1842 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1844 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a\"");
1845 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1847 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1848 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1850 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1851 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1853 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"/\"");
1854 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1856 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \" \"");
1857 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1859 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"azAZ_\"");
1860 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1862 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]\"");
1863 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1865 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]a\"");
1866 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1868 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]\"");
1869 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1871 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]a\"");
1872 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1874 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a}\"");
1875 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1877 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a\"");
1878 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1880 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a\"");
1881 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1883 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a{\"");
1884 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1886 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a]\"");
1887 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1889 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"A\"");
1890 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1892 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", "1.1.4322");
1893 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1894 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1896 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.14322\"");
1897 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1899 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.5\"");
1900 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1902 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1903 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1905 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
1906 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1908 MsiSetPropertyA(hpkg
, "one", "1");
1909 r
= MsiEvaluateConditionA(hpkg
, "one < \"1\"");
1910 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1912 MsiSetPropertyA(hpkg
, "X", "5.0");
1914 r
= MsiEvaluateConditionA(hpkg
, "X != \"\"");
1915 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1917 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\"");
1918 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1920 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.1\"");
1921 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1923 r
= MsiEvaluateConditionA(hpkg
, "X =\"6.0\"");
1924 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1926 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1927 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1929 r
= MsiEvaluateConditionA(hpkg
, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1930 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1932 r
= MsiEvaluateConditionA(hpkg
, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1933 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1935 /* feature doesn't exist */
1936 r
= MsiEvaluateConditionA(hpkg
, "&nofeature");
1937 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1939 MsiSetPropertyA(hpkg
, "A", "2");
1940 MsiSetPropertyA(hpkg
, "X", "50");
1942 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
1943 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1945 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1946 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1948 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
1949 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1951 MsiSetPropertyA(hpkg
, "X", "50val");
1953 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
1954 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1956 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1957 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1959 MsiSetPropertyA(hpkg
, "A", "7");
1960 MsiSetPropertyA(hpkg
, "X", "50");
1962 r
= MsiEvaluateConditionA(hpkg
, "7 <= X");
1963 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1965 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1966 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1968 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
1969 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1971 MsiSetPropertyA(hpkg
, "X", "50val");
1973 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
1974 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1976 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1977 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1979 r
= MsiEvaluateConditionW(hpkg
, cond1
);
1980 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
1981 "wrong return val (%d)\n", r
);
1983 r
= MsiEvaluateConditionW(hpkg
, cond2
);
1984 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
1985 "wrong return val (%d)\n", r
);
1987 r
= MsiEvaluateConditionW(hpkg
, cond3
);
1988 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
1989 "wrong return val (%d)\n", r
);
1991 r
= MsiEvaluateConditionW(hpkg
, cond4
);
1992 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
1993 "wrong return val (%d)\n", r
);
1995 MsiCloseHandle( hpkg
);
1996 DeleteFileA(msifile
);
1999 static BOOL
check_prop_empty( MSIHANDLE hpkg
, const char * prop
)
2007 r
= MsiGetPropertyA( hpkg
, prop
, buffer
, &sz
);
2008 return r
== ERROR_SUCCESS
&& buffer
[0] == 0 && sz
== 0;
2011 static void test_props(void)
2013 MSIHANDLE hpkg
, hdb
;
2018 hdb
= create_package_db();
2020 "CREATE TABLE `Property` ( "
2021 "`Property` CHAR(255) NOT NULL, "
2022 "`Value` CHAR(255) "
2023 "PRIMARY KEY `Property`)" );
2024 ok( r
== ERROR_SUCCESS
, "Failed\n" );
2027 "INSERT INTO `Property` "
2028 "(`Property`, `Value`) "
2029 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
2030 ok( r
== ERROR_SUCCESS
, "Failed\n" );
2032 r
= package_from_db( hdb
, &hpkg
);
2033 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2035 skip("Not enough rights to perform tests\n");
2036 DeleteFileA(msifile
);
2039 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2041 /* test invalid values */
2042 r
= MsiGetPropertyA( 0, NULL
, NULL
, NULL
);
2043 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2045 r
= MsiGetPropertyA( hpkg
, NULL
, NULL
, NULL
);
2046 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2048 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, NULL
);
2049 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2051 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, NULL
);
2052 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2054 /* test retrieving an empty/nonexistent property */
2056 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, &sz
);
2057 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2058 ok( sz
== 0, "wrong size returned\n");
2060 check_prop_empty( hpkg
, "boo");
2063 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2064 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2065 ok( !strcmp(buffer
,"x"), "buffer was changed\n");
2066 ok( sz
== 0, "wrong size returned\n");
2070 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2071 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2072 ok( buffer
[0] == 0, "buffer was not changed\n");
2073 ok( sz
== 0, "wrong size returned\n");
2075 /* set the property to something */
2076 r
= MsiSetPropertyA( 0, NULL
, NULL
);
2077 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
2079 r
= MsiSetPropertyA( hpkg
, NULL
, NULL
);
2080 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2082 r
= MsiSetPropertyA( hpkg
, "", NULL
);
2083 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2085 /* try set and get some illegal property identifiers */
2086 r
= MsiSetPropertyA( hpkg
, "", "asdf" );
2087 ok( r
== ERROR_FUNCTION_FAILED
, "wrong return val\n");
2089 r
= MsiSetPropertyA( hpkg
, "=", "asdf" );
2090 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2092 r
= MsiSetPropertyA( hpkg
, " ", "asdf" );
2093 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2095 r
= MsiSetPropertyA( hpkg
, "'", "asdf" );
2096 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2100 r
= MsiGetPropertyA( hpkg
, "'", buffer
, &sz
);
2101 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2102 ok( !strcmp(buffer
,"asdf"), "buffer was not changed\n");
2104 /* set empty values */
2105 r
= MsiSetPropertyA( hpkg
, "boo", NULL
);
2106 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2107 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2109 r
= MsiSetPropertyA( hpkg
, "boo", "" );
2110 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2111 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2113 /* set a non-empty value */
2114 r
= MsiSetPropertyA( hpkg
, "boo", "xyz" );
2115 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2119 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2120 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2121 ok( buffer
[0] == 0, "buffer was not changed\n");
2122 ok( sz
== 3, "wrong size returned\n");
2126 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2127 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2128 ok( !strcmp(buffer
,"xyz"), "buffer was not changed\n");
2129 ok( sz
== 3, "wrong size returned\n");
2133 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2134 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2135 ok( !strcmp(buffer
,"xy"), "buffer was not changed\n");
2136 ok( sz
== 3, "wrong size returned\n");
2138 r
= MsiSetPropertyA(hpkg
, "SourceDir", "foo");
2139 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2142 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", buffer
, &sz
);
2143 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2144 ok( !strcmp(buffer
,""), "buffer wrong\n");
2145 ok( sz
== 0, "wrong size returned\n");
2148 r
= MsiGetPropertyA(hpkg
, "SOMERANDOMNAME", buffer
, &sz
);
2149 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2150 ok( !strcmp(buffer
,""), "buffer wrong\n");
2151 ok( sz
== 0, "wrong size returned\n");
2154 r
= MsiGetPropertyA(hpkg
, "SourceDir", buffer
, &sz
);
2155 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2156 ok( !strcmp(buffer
,"foo"), "buffer wrong\n");
2157 ok( sz
== 3, "wrong size returned\n");
2159 r
= MsiSetPropertyA(hpkg
, "MetadataCompName", "Photoshop.dll");
2160 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2163 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", NULL
, &sz
);
2164 ok( r
== ERROR_SUCCESS
, "return wrong\n");
2165 ok( sz
== 13, "size wrong (%d)\n", sz
);
2168 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", buffer
, &sz
);
2169 ok( r
== ERROR_MORE_DATA
, "return wrong\n");
2170 ok( !strcmp(buffer
,"Photoshop.dl"), "buffer wrong\n");
2172 r
= MsiSetPropertyA(hpkg
, "property", "value");
2173 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2176 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2177 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2178 ok( !strcmp(buffer
, "value"), "Expected value, got %s\n", buffer
);
2180 r
= MsiSetPropertyA(hpkg
, "property", NULL
);
2181 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2184 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2185 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2186 ok( !strlen(buffer
), "Expected empty string, got %s\n", buffer
);
2188 MsiCloseHandle( hpkg
);
2189 DeleteFileA(msifile
);
2192 static BOOL
find_prop_in_property(MSIHANDLE hdb
, LPCSTR prop
, LPCSTR val
, int len
)
2194 MSIHANDLE hview
, hrec
;
2196 CHAR buffer
[MAX_PATH
];
2200 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
2201 ok(r
== ERROR_SUCCESS
, "MsiDatabaseOpenView failed\n");
2202 r
= MsiViewExecute(hview
, 0);
2203 ok(r
== ERROR_SUCCESS
, "MsiViewExecute failed\n");
2205 if (len
< 0) len
= lstrlenA(val
);
2207 while (r
== ERROR_SUCCESS
&& !found
)
2209 r
= MsiViewFetch(hview
, &hrec
);
2210 if (r
!= ERROR_SUCCESS
) break;
2213 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &sz
);
2214 if (r
== ERROR_SUCCESS
&& !lstrcmpA(buffer
, prop
))
2217 r
= MsiRecordGetStringA(hrec
, 2, buffer
, &sz
);
2218 if (r
== ERROR_SUCCESS
&& !memcmp(buffer
, val
, len
) && !buffer
[len
])
2220 ok(sz
== len
, "wrong size %u\n", sz
);
2225 MsiCloseHandle(hrec
);
2227 MsiViewClose(hview
);
2228 MsiCloseHandle(hview
);
2232 static void test_property_table(void)
2236 MSIHANDLE hpkg
, hdb
, hrec
;
2237 char buffer
[MAX_PATH
], package
[10];
2241 hdb
= create_package_db();
2242 ok( hdb
, "failed to create package\n");
2244 r
= package_from_db(hdb
, &hpkg
);
2245 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2247 skip("Not enough rights to perform tests\n");
2248 DeleteFileA(msifile
);
2251 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2253 MsiCloseHandle(hdb
);
2255 hdb
= MsiGetActiveDatabase(hpkg
);
2257 query
= "CREATE TABLE `_Property` ( "
2258 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2259 r
= run_query(hdb
, query
);
2260 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2262 MsiCloseHandle(hdb
);
2263 MsiCloseHandle(hpkg
);
2264 DeleteFileA(msifile
);
2266 hdb
= create_package_db();
2267 ok( hdb
, "failed to create package\n");
2269 query
= "CREATE TABLE `_Property` ( "
2270 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2271 r
= run_query(hdb
, query
);
2272 ok(r
== ERROR_SUCCESS
, "failed to create table\n");
2274 query
= "ALTER `_Property` ADD `foo` INTEGER";
2275 r
= run_query(hdb
, query
);
2276 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2278 query
= "ALTER TABLE `_Property` ADD `foo` INTEGER";
2279 r
= run_query(hdb
, query
);
2280 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2282 query
= "ALTER TABLE `_Property` ADD `extra` INTEGER";
2283 r
= run_query(hdb
, query
);
2284 ok(r
== ERROR_SUCCESS
, "failed to add column\n");
2286 sprintf(package
, "#%i", hdb
);
2287 r
= MsiOpenPackageA(package
, &hpkg
);
2288 ok(r
!= ERROR_SUCCESS
, "MsiOpenPackage succeeded\n");
2289 if (r
== ERROR_SUCCESS
)
2290 MsiCloseHandle(hpkg
);
2292 r
= MsiCloseHandle(hdb
);
2293 ok(r
== ERROR_SUCCESS
, "MsiCloseHandle failed %u\n", r
);
2295 hdb
= create_package_db();
2296 ok (hdb
, "failed to create package database\n");
2298 r
= create_property_table(hdb
);
2299 ok(r
== ERROR_SUCCESS
, "cannot create Property table: %d\n", r
);
2301 r
= add_property_entry(hdb
, "'prop', 'val'");
2302 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
2304 r
= create_custom_action_table(hdb
);
2305 ok(r
== ERROR_SUCCESS
, "cannot create CustomAction table: %d\n", r
);
2307 r
= add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop2', '[~]np'" );
2308 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2310 r
= package_from_db(hdb
, &hpkg
);
2311 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2313 MsiCloseHandle(hdb
);
2316 r
= MsiGetPropertyA(hpkg
, "prop", buffer
, &sz
);
2317 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2318 ok(!lstrcmpA(buffer
, "val"), "Expected val, got %s\n", buffer
);
2320 hdb
= MsiGetActiveDatabase(hpkg
);
2322 found
= find_prop_in_property(hdb
, "prop", "val", -1);
2323 ok(found
, "prop should be in the _Property table\n");
2325 r
= add_property_entry(hdb
, "'dantes', 'mercedes'");
2326 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
2328 query
= "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2329 r
= do_query(hdb
, query
, &hrec
);
2330 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2332 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2333 ok(found
== FALSE
, "dantes should not be in the _Property table\n");
2336 lstrcpyA(buffer
, "aaa");
2337 r
= MsiGetPropertyA(hpkg
, "dantes", buffer
, &sz
);
2338 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2339 ok(lstrlenA(buffer
) == 0, "Expected empty string, got %s\n", buffer
);
2341 r
= MsiSetPropertyA(hpkg
, "dantes", "mercedes");
2342 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2344 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2345 ok(found
== TRUE
, "dantes should be in the _Property table\n");
2347 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2348 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2351 memset( buffer
, 'a', sizeof(buffer
) );
2352 r
= MsiGetPropertyA( hpkg
, "prop2", buffer
, &sz
);
2353 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2354 ok( !memcmp( buffer
, "\0np", sizeof("\0np") ), "wrong value\n");
2355 ok( sz
== sizeof("\0np") - 1, "got %u\n", sz
);
2357 found
= find_prop_in_property(hdb
, "prop2", "\0np", 3);
2358 ok(found
== TRUE
, "prop2 should be in the _Property table\n");
2360 MsiCloseHandle(hdb
);
2361 MsiCloseHandle(hpkg
);
2362 DeleteFileA(msifile
);
2365 static UINT
try_query_param( MSIHANDLE hdb
, LPCSTR szQuery
, MSIHANDLE hrec
)
2370 res
= MsiDatabaseOpenViewA( hdb
, szQuery
, &htab
);
2371 if( res
== ERROR_SUCCESS
)
2375 r
= MsiViewExecute( htab
, hrec
);
2376 if( r
!= ERROR_SUCCESS
)
2379 fprintf(stderr
,"MsiViewExecute failed %08x\n", res
);
2382 r
= MsiViewClose( htab
);
2383 if( r
!= ERROR_SUCCESS
)
2386 r
= MsiCloseHandle( htab
);
2387 if( r
!= ERROR_SUCCESS
)
2393 static UINT
try_query( MSIHANDLE hdb
, LPCSTR szQuery
)
2395 return try_query_param( hdb
, szQuery
, 0 );
2398 static void set_summary_str(MSIHANDLE hdb
, DWORD pid
, LPCSTR value
)
2403 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2404 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2406 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_LPSTR
, 0, NULL
, value
);
2407 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2409 r
= MsiSummaryInfoPersist(summary
);
2410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2412 MsiCloseHandle(summary
);
2415 static void set_summary_dword(MSIHANDLE hdb
, DWORD pid
, DWORD value
)
2420 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2421 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2423 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_I4
, value
, NULL
, NULL
);
2424 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2426 r
= MsiSummaryInfoPersist(summary
);
2427 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2429 MsiCloseHandle(summary
);
2432 static void test_msipackage(void)
2434 MSIHANDLE hdb
= 0, hpack
= 100;
2439 /* NULL szPackagePath */
2440 r
= MsiOpenPackageA(NULL
, &hpack
);
2441 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2443 /* empty szPackagePath */
2444 r
= MsiOpenPackageA("", &hpack
);
2445 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2447 skip("Not enough rights to perform tests\n");
2452 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2455 if (r
== ERROR_SUCCESS
)
2456 MsiCloseHandle(hpack
);
2458 /* nonexistent szPackagePath */
2459 r
= MsiOpenPackageA("nonexistent", &hpack
);
2460 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
2463 r
= MsiOpenPackageA(msifile
, NULL
);
2464 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2468 r
= MsiOpenPackageA(name
, &hpack
);
2469 ok(r
== ERROR_INVALID_HANDLE
, "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
2471 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2472 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2474 /* database exists, but is emtpy */
2475 sprintf(name
, "#%d", hdb
);
2476 r
= MsiOpenPackageA(name
, &hpack
);
2477 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2478 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2480 query
= "CREATE TABLE `Property` ( "
2481 "`Property` CHAR(72), `Value` CHAR(0) "
2482 "PRIMARY KEY `Property`)";
2483 r
= try_query(hdb
, query
);
2484 ok(r
== ERROR_SUCCESS
, "failed to create Properties table\n");
2486 query
= "CREATE TABLE `InstallExecuteSequence` ("
2487 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2488 "PRIMARY KEY `Action`)";
2489 r
= try_query(hdb
, query
);
2490 ok(r
== ERROR_SUCCESS
, "failed to create InstallExecuteSequence table\n");
2492 /* a few key tables exist */
2493 sprintf(name
, "#%d", hdb
);
2494 r
= MsiOpenPackageA(name
, &hpack
);
2495 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2496 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2498 MsiCloseHandle(hdb
);
2499 DeleteFileA(msifile
);
2501 /* start with a clean database to show what constitutes a valid package */
2502 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2503 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2505 sprintf(name
, "#%d", hdb
);
2507 /* The following summary information props must exist:
2512 set_summary_dword(hdb
, PID_PAGECOUNT
, 100);
2513 r
= MsiOpenPackageA(name
, &hpack
);
2514 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2515 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2517 set_summary_str(hdb
, PID_REVNUMBER
, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2518 r
= MsiOpenPackageA(name
, &hpack
);
2519 ok(r
== ERROR_SUCCESS
,
2520 "Expected ERROR_SUCCESS, got %d\n", r
);
2522 MsiCloseHandle(hpack
);
2523 MsiCloseHandle(hdb
);
2524 DeleteFileA(msifile
);
2527 static void test_formatrecord2(void)
2529 MSIHANDLE hpkg
, hrec
;
2534 r
= package_from_db(create_package_db(), &hpkg
);
2535 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2537 skip("Not enough rights to perform tests\n");
2538 DeleteFileA(msifile
);
2541 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2543 r
= MsiSetPropertyA(hpkg
, "Manufacturer", " " );
2544 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2546 hrec
= MsiCreateRecord(2);
2547 ok(hrec
, "create record failed\n");
2549 r
= MsiRecordSetStringA( hrec
, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2550 ok( r
== ERROR_SUCCESS
, "format record failed\n");
2554 r
= MsiFormatRecordA( hpkg
, hrec
, buffer
, &sz
);
2555 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2557 r
= MsiRecordSetStringA(hrec
, 0, "[foo][1]");
2558 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2559 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2560 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2562 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2563 ok( sz
== 3, "size wrong\n");
2564 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2565 ok( r
== ERROR_SUCCESS
, "format failed\n");
2567 r
= MsiRecordSetStringA(hrec
, 0, "x[~]x");
2568 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2570 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2571 ok( sz
== 3, "size wrong\n");
2572 ok( 0 == strcmp(buffer
,"x"), "wrong output %s\n",buffer
);
2573 ok( r
== ERROR_SUCCESS
, "format failed\n");
2575 r
= MsiRecordSetStringA(hrec
, 0, "[foo.$%}][1]");
2576 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2577 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2578 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2580 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2581 ok( sz
== 3, "size wrong\n");
2582 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2583 ok( r
== ERROR_SUCCESS
, "format failed\n");
2585 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]");
2586 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2588 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2589 ok( sz
== 1, "size wrong\n");
2590 ok( 0 == strcmp(buffer
,"["), "wrong output %s\n",buffer
);
2591 ok( r
== ERROR_SUCCESS
, "format failed\n");
2593 SetEnvironmentVariableA("FOO", "BAR");
2594 r
= MsiRecordSetStringA(hrec
, 0, "[%FOO]");
2595 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2597 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2598 ok( sz
== 3, "size wrong\n");
2599 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2600 ok( r
== ERROR_SUCCESS
, "format failed\n");
2602 r
= MsiRecordSetStringA(hrec
, 0, "[[1]]");
2603 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2604 r
= MsiRecordSetStringA(hrec
, 1, "%FOO");
2605 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2607 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2608 ok( sz
== 3, "size wrong\n");
2609 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2610 ok( r
== ERROR_SUCCESS
, "format failed\n");
2612 MsiCloseHandle( hrec
);
2613 MsiCloseHandle( hpkg
);
2614 DeleteFileA(msifile
);
2617 static void test_feature_states( UINT line
, MSIHANDLE package
, const char *feature
, UINT error
,
2618 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
2621 INSTALLSTATE state
= 0xdeadbee;
2622 INSTALLSTATE action
= 0xdeadbee;
2624 r
= MsiGetFeatureStateA( package
, feature
, &state
, &action
);
2625 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
2626 if (r
== ERROR_SUCCESS
)
2628 ok( state
== expected_state
, "%u: expected state %d got %d\n",
2629 line
, expected_state
, state
);
2631 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2632 line
, expected_action
, action
);
2634 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2635 line
, expected_action
, action
);
2639 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line
, state
);
2641 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line
, action
);
2643 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line
, action
);
2648 static void test_component_states( UINT line
, MSIHANDLE package
, const char *component
, UINT error
,
2649 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
2652 INSTALLSTATE state
= 0xdeadbee;
2653 INSTALLSTATE action
= 0xdeadbee;
2655 r
= MsiGetComponentStateA( package
, component
, &state
, &action
);
2656 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
2657 if (r
== ERROR_SUCCESS
)
2659 ok( state
== expected_state
, "%u: expected state %d got %d\n",
2660 line
, expected_state
, state
);
2662 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2663 line
, expected_action
, action
);
2665 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2666 line
, expected_action
, action
);
2670 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2673 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2676 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2681 static void test_states(void)
2683 static const char msifile2
[] = "winetest2-package.msi";
2684 static const char msifile3
[] = "winetest3-package.msi";
2685 static const char msifile4
[] = "winetest4-package.msi";
2686 static const WCHAR msifile2W
[] =
2687 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
2688 static const WCHAR msifile3W
[] =
2689 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
2690 static const WCHAR msifile4W
[] =
2691 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
2696 if (is_process_limited())
2698 skip("process is limited\n");
2702 hdb
= create_package_db();
2703 ok ( hdb
, "failed to create package database\n" );
2705 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
2706 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
2708 r
= create_property_table( hdb
);
2709 ok( r
== ERROR_SUCCESS
, "cannot create Property table: %d\n", r
);
2711 r
= add_property_entry( hdb
, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2712 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2714 r
= add_property_entry( hdb
, "'ProductLanguage', '1033'" );
2715 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2717 r
= add_property_entry( hdb
, "'ProductName', 'MSITEST'" );
2718 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2720 r
= add_property_entry( hdb
, "'ProductVersion', '1.1.1'" );
2721 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2723 r
= add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
2724 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2726 r
= create_install_execute_sequence_table( hdb
);
2727 ok( r
== ERROR_SUCCESS
, "cannot create InstallExecuteSequence table: %d\n", r
);
2729 r
= add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
2730 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2732 r
= add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
2733 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2735 r
= add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
2736 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2738 r
= add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1400'" );
2739 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2741 r
= add_install_execute_sequence_entry( hdb
, "'InstallInitialize', '', '1500'" );
2742 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2744 r
= add_install_execute_sequence_entry( hdb
, "'ProcessComponents', '', '1600'" );
2745 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2747 r
= add_install_execute_sequence_entry( hdb
, "'UnpublishFeatures', '', '1800'" );
2748 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2750 r
= add_install_execute_sequence_entry( hdb
, "'RegisterProduct', '', '6100'" );
2751 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2753 r
= add_install_execute_sequence_entry( hdb
, "'PublishFeatures', '', '6300'" );
2754 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2756 r
= add_install_execute_sequence_entry( hdb
, "'PublishProduct', '', '6400'" );
2757 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2759 r
= add_install_execute_sequence_entry( hdb
, "'InstallFinalize', '', '6600'" );
2760 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2762 r
= create_media_table( hdb
);
2763 ok( r
== ERROR_SUCCESS
, "cannot create media table: %d\n", r
);
2765 r
= add_media_entry( hdb
, "'1', '3', '', '', 'DISK1', ''");
2766 ok( r
== ERROR_SUCCESS
, "cannot add media entry: %d\n", r
);
2768 r
= create_feature_table( hdb
);
2769 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
2771 r
= create_component_table( hdb
);
2772 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
2774 /* msidbFeatureAttributesFavorLocal */
2775 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
2776 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2778 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2779 r
= add_component_entry( hdb
, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2780 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2782 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2783 r
= add_component_entry( hdb
, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2784 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2786 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2787 r
= add_component_entry( hdb
, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2788 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2790 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2791 r
= add_component_entry( hdb
, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2792 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2794 /* msidbFeatureAttributesFavorSource */
2795 r
= add_feature_entry( hdb
, "'two', '', '', '', 2, 1, '', 1" );
2796 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2798 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2799 r
= add_component_entry( hdb
, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2800 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2802 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2803 r
= add_component_entry( hdb
, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2804 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2806 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2807 r
= add_component_entry( hdb
, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2808 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2810 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2811 r
= add_component_entry( hdb
, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2812 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2814 /* msidbFeatureAttributesFavorSource */
2815 r
= add_feature_entry( hdb
, "'three', '', '', '', 2, 1, '', 1" );
2816 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2818 /* msidbFeatureAttributesFavorLocal */
2819 r
= add_feature_entry( hdb
, "'four', '', '', '', 2, 1, '', 0" );
2820 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2823 r
= add_feature_entry( hdb
, "'five', '', '', '', 2, 0, '', 1" );
2824 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2826 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2827 r
= add_component_entry( hdb
, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2828 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2830 /* no feature parent:msidbComponentAttributesLocalOnly */
2831 r
= add_component_entry( hdb
, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2832 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2834 /* msidbFeatureAttributesFavorLocal:removed */
2835 r
= add_feature_entry( hdb
, "'six', '', '', '', 2, 1, '', 0" );
2836 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2838 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2839 r
= add_component_entry( hdb
, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2840 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2842 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2843 r
= add_component_entry( hdb
, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2844 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2846 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2847 r
= add_component_entry( hdb
, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2848 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2850 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2851 r
= add_component_entry( hdb
, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2852 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2854 /* msidbFeatureAttributesFavorSource:removed */
2855 r
= add_feature_entry( hdb
, "'seven', '', '', '', 2, 1, '', 1" );
2856 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2858 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2859 r
= add_component_entry( hdb
, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2860 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2862 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2863 r
= add_component_entry( hdb
, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2864 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2866 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2867 r
= add_component_entry( hdb
, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2868 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2870 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2871 r
= add_component_entry( hdb
, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2872 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2874 /* msidbFeatureAttributesFavorLocal */
2875 r
= add_feature_entry( hdb
, "'eight', '', '', '', 2, 1, '', 0" );
2876 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2878 r
= add_component_entry( hdb
, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2879 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2881 /* msidbFeatureAttributesFavorSource */
2882 r
= add_feature_entry( hdb
, "'nine', '', '', '', 2, 1, '', 1" );
2883 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2885 r
= add_component_entry( hdb
, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2886 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2888 /* msidbFeatureAttributesFavorAdvertise */
2889 r
= add_feature_entry( hdb
, "'ten', '', '', '', 2, 1, '', 4" );
2890 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2892 r
= add_component_entry( hdb
, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2893 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2895 /* msidbFeatureAttributesUIDisallowAbsent */
2896 r
= add_feature_entry( hdb
, "'eleven', '', '', '', 2, 1, '', 16" );
2897 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2899 r
= add_component_entry( hdb
, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2900 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2902 r
= create_feature_components_table( hdb
);
2903 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
2905 r
= add_feature_components_entry( hdb
, "'one', 'alpha'" );
2906 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2908 r
= add_feature_components_entry( hdb
, "'one', 'beta'" );
2909 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2911 r
= add_feature_components_entry( hdb
, "'one', 'gamma'" );
2912 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2914 r
= add_feature_components_entry( hdb
, "'one', 'theta'" );
2915 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2917 r
= add_feature_components_entry( hdb
, "'two', 'delta'" );
2918 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2920 r
= add_feature_components_entry( hdb
, "'two', 'epsilon'" );
2921 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2923 r
= add_feature_components_entry( hdb
, "'two', 'zeta'" );
2924 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2926 r
= add_feature_components_entry( hdb
, "'two', 'iota'" );
2927 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2929 r
= add_feature_components_entry( hdb
, "'three', 'eta'" );
2930 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2932 r
= add_feature_components_entry( hdb
, "'four', 'eta'" );
2933 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2935 r
= add_feature_components_entry( hdb
, "'five', 'eta'" );
2936 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2938 r
= add_feature_components_entry( hdb
, "'six', 'lambda'" );
2939 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2941 r
= add_feature_components_entry( hdb
, "'six', 'mu'" );
2942 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2944 r
= add_feature_components_entry( hdb
, "'six', 'nu'" );
2945 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2947 r
= add_feature_components_entry( hdb
, "'six', 'xi'" );
2948 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2950 r
= add_feature_components_entry( hdb
, "'seven', 'omicron'" );
2951 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2953 r
= add_feature_components_entry( hdb
, "'seven', 'pi'" );
2954 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2956 r
= add_feature_components_entry( hdb
, "'seven', 'rho'" );
2957 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2959 r
= add_feature_components_entry( hdb
, "'seven', 'sigma'" );
2960 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2962 r
= add_feature_components_entry( hdb
, "'eight', 'tau'" );
2963 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2965 r
= add_feature_components_entry( hdb
, "'nine', 'phi'" );
2966 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2968 r
= add_feature_components_entry( hdb
, "'ten', 'chi'" );
2969 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2971 r
= add_feature_components_entry( hdb
, "'eleven', 'psi'" );
2972 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2974 r
= create_file_table( hdb
);
2975 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
2977 r
= add_file_entry( hdb
, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2978 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2980 r
= add_file_entry( hdb
, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2981 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2983 r
= add_file_entry( hdb
, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2984 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2986 r
= add_file_entry( hdb
, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2987 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2989 r
= add_file_entry( hdb
, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2990 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2992 r
= add_file_entry( hdb
, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2993 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2995 r
= add_file_entry( hdb
, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2996 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2998 r
= add_file_entry( hdb
, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2999 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3001 /* compressed file */
3002 r
= add_file_entry( hdb
, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3003 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3005 r
= add_file_entry( hdb
, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3006 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3008 r
= add_file_entry( hdb
, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3009 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3011 r
= add_file_entry( hdb
, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3012 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3014 r
= add_file_entry( hdb
, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3015 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3017 r
= add_file_entry( hdb
, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3018 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3020 r
= add_file_entry( hdb
, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3021 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3023 r
= add_file_entry( hdb
, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3024 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3026 r
= add_file_entry( hdb
, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3027 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3029 r
= add_file_entry( hdb
, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3030 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3032 r
= add_file_entry( hdb
, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3033 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3035 r
= add_file_entry( hdb
, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3036 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3038 r
= add_file_entry( hdb
, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3039 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3041 r
= add_file_entry( hdb
, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3042 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3044 MsiDatabaseCommit(hdb
);
3046 /* these properties must not be in the saved msi file */
3047 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3048 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3050 r
= add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3051 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3053 r
= add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3054 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3056 r
= add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3057 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3059 r
= add_property_entry( hdb
, "'REINSTALLMODE', 'omus'");
3060 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3062 r
= package_from_db( hdb
, &hpkg
);
3063 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3065 skip("Not enough rights to perform tests\n");
3066 DeleteFileA(msifile
);
3069 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3071 MsiCloseHandle(hdb
);
3073 CopyFileA(msifile
, msifile2
, FALSE
);
3074 CopyFileA(msifile
, msifile3
, FALSE
);
3075 CopyFileA(msifile
, msifile4
, FALSE
);
3077 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3078 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3080 r
= MsiDoActionA( hpkg
, "CostInitialize");
3081 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3083 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3084 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3086 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3088 r
= MsiDoActionA( hpkg
, "FileCost");
3089 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3091 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3092 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3094 r
= MsiDoActionA( hpkg
, "CostFinalize");
3095 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3097 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3098 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3099 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3100 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3101 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3102 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3103 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3104 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3105 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3106 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3107 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3109 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3110 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3111 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3112 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3113 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3114 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3115 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3116 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3117 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3118 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3119 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3120 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3121 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3122 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3123 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3124 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3125 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3126 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3127 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3128 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3129 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3130 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3132 MsiCloseHandle( hpkg
);
3134 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3136 /* publish the features and components */
3137 r
= MsiInstallProductA(msifile
, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3138 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3140 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
3141 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3143 /* these properties must not be in the saved msi file */
3144 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3145 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3147 r
= add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3148 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3150 r
= add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3151 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3153 r
= add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3154 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3156 r
= package_from_db( hdb
, &hpkg
);
3157 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3159 MsiCloseHandle(hdb
);
3161 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3162 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3164 r
= MsiDoActionA( hpkg
, "CostInitialize");
3165 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3167 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3168 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3170 r
= MsiDoActionA( hpkg
, "FileCost");
3171 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3173 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3174 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3176 r
= MsiDoActionA( hpkg
, "CostFinalize");
3177 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3179 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3180 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3181 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3182 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3183 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3184 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3185 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3186 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3187 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3188 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3189 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3191 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3192 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3193 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3194 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3195 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3196 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3197 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3198 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3199 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3200 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3201 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3202 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3203 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3204 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3205 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3206 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3207 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3208 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3209 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3210 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3211 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3212 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3214 MsiCloseHandle(hpkg
);
3216 /* uninstall the product */
3217 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
3218 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3220 /* all features installed locally */
3221 r
= MsiInstallProductA(msifile2
, "ADDLOCAL=ALL");
3222 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3224 r
= MsiOpenDatabaseW(msifile2W
, MSIDBOPEN_DIRECT
, &hdb
);
3225 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3227 /* these properties must not be in the saved msi file */
3228 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3229 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3231 r
= package_from_db( hdb
, &hpkg
);
3232 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3234 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3235 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3237 r
= MsiDoActionA( hpkg
, "CostInitialize");
3238 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3240 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3241 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3243 r
= MsiDoActionA( hpkg
, "CostFinalize");
3244 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3246 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3247 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3248 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3249 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3250 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3251 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3252 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3253 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3254 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3255 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3256 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3258 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3259 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3260 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3261 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3262 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3263 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3264 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3265 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3266 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3267 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3268 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3269 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3270 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3271 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3272 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3273 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3274 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3275 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3276 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3277 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3278 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3279 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3281 MsiCloseHandle(hpkg
);
3283 /* uninstall the product */
3284 r
= MsiInstallProductA(msifile2
, "REMOVE=ALL");
3285 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3287 /* all features installed from source */
3288 r
= MsiInstallProductA(msifile3
, "ADDSOURCE=ALL");
3289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3291 r
= MsiOpenDatabaseW(msifile3W
, MSIDBOPEN_DIRECT
, &hdb
);
3292 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3294 /* this property must not be in the saved msi file */
3295 r
= add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3296 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3298 r
= package_from_db( hdb
, &hpkg
);
3299 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3301 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3302 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3304 r
= MsiDoActionA( hpkg
, "CostInitialize");
3305 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3307 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3308 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3310 r
= MsiDoActionA( hpkg
, "FileCost");
3311 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3313 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3314 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3316 r
= MsiDoActionA( hpkg
, "CostFinalize");
3317 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3319 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3320 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3321 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3322 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3323 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3324 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3325 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3326 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3327 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3328 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3329 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3331 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3332 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3333 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3334 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3335 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3336 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3337 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3338 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3339 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3340 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3341 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3342 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3343 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3344 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3345 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3346 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3347 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3348 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3349 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3350 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3351 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3352 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3354 MsiCloseHandle(hpkg
);
3356 /* reinstall the product */
3357 r
= MsiInstallProductA(msifile3
, "REINSTALL=ALL");
3358 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3360 r
= MsiOpenDatabaseW(msifile4W
, MSIDBOPEN_DIRECT
, &hdb
);
3361 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3363 /* this property must not be in the saved msi file */
3364 r
= add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3365 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3367 r
= package_from_db( hdb
, &hpkg
);
3368 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3370 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3371 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3373 r
= MsiDoActionA( hpkg
, "CostInitialize");
3374 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3376 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3377 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3379 r
= MsiDoActionA( hpkg
, "FileCost");
3380 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3382 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3383 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3385 r
= MsiDoActionA( hpkg
, "CostFinalize");
3386 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3388 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3389 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3390 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3391 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3392 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3393 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3394 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3395 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3396 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3397 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3398 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3400 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3401 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3402 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3403 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3404 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3405 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3406 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3407 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3408 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3409 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3410 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3411 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3412 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3413 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3414 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3415 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3416 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3417 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3418 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3419 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3420 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3421 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3423 MsiCloseHandle(hpkg
);
3425 /* uninstall the product */
3426 r
= MsiInstallProductA(msifile4
, "REMOVE=ALL");
3427 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3429 DeleteFileA(msifile
);
3430 DeleteFileA(msifile2
);
3431 DeleteFileA(msifile3
);
3432 DeleteFileA(msifile4
);
3435 static void test_getproperty(void)
3437 MSIHANDLE hPackage
= 0;
3439 static CHAR empty
[] = "";
3443 r
= package_from_db(create_package_db(), &hPackage
);
3444 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3446 skip("Not enough rights to perform tests\n");
3447 DeleteFileA(msifile
);
3450 ok( r
== ERROR_SUCCESS
, "Failed to create package %u\n", r
);
3452 /* set the property */
3453 r
= MsiSetPropertyA(hPackage
, "Name", "Value");
3454 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3456 /* retrieve the size, NULL pointer */
3458 r
= MsiGetPropertyA(hPackage
, "Name", NULL
, &size
);
3459 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3460 ok( size
== 5, "Expected 5, got %d\n", size
);
3462 /* retrieve the size, empty string */
3464 r
= MsiGetPropertyA(hPackage
, "Name", empty
, &size
);
3465 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3466 ok( size
== 5, "Expected 5, got %d\n", size
);
3468 /* don't change size */
3469 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3470 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3471 ok( size
== 5, "Expected 5, got %d\n", size
);
3472 ok( !lstrcmpA(prop
, "Valu"), "Expected Valu, got %s\n", prop
);
3474 /* increase the size by 1 */
3476 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3477 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3478 ok( size
== 5, "Expected 5, got %d\n", size
);
3479 ok( !lstrcmpA(prop
, "Value"), "Expected Value, got %s\n", prop
);
3481 r
= MsiCloseHandle( hPackage
);
3482 ok( r
== ERROR_SUCCESS
, "Failed to close package\n" );
3483 DeleteFileA(msifile
);
3486 static void test_removefiles(void)
3491 INSTALLSTATE installed
, action
;
3493 hdb
= create_package_db();
3494 ok ( hdb
, "failed to create package database\n" );
3496 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3497 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
3499 r
= create_feature_table( hdb
);
3500 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
3502 r
= create_component_table( hdb
);
3503 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
3505 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
3506 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
3508 r
= add_component_entry( hdb
, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3509 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3511 r
= add_component_entry( hdb
, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3512 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3514 r
= add_component_entry( hdb
, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3515 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3517 r
= add_component_entry( hdb
, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3518 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3520 r
= add_component_entry( hdb
, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3521 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3523 r
= add_component_entry( hdb
, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3524 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3526 r
= add_component_entry( hdb
, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3527 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3529 r
= create_feature_components_table( hdb
);
3530 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
3532 r
= add_feature_components_entry( hdb
, "'one', 'hydrogen'" );
3533 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3535 r
= add_feature_components_entry( hdb
, "'one', 'helium'" );
3536 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3538 r
= add_feature_components_entry( hdb
, "'one', 'lithium'" );
3539 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3541 r
= add_feature_components_entry( hdb
, "'one', 'beryllium'" );
3542 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3544 r
= add_feature_components_entry( hdb
, "'one', 'boron'" );
3545 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3547 r
= add_feature_components_entry( hdb
, "'one', 'carbon'" );
3548 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3550 r
= add_feature_components_entry( hdb
, "'one', 'oxygen'" );
3551 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3553 r
= create_file_table( hdb
);
3554 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
3556 r
= add_file_entry( hdb
, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3557 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3559 r
= add_file_entry( hdb
, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3560 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3562 r
= add_file_entry( hdb
, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3563 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3565 r
= add_file_entry( hdb
, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3566 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3568 r
= add_file_entry( hdb
, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3569 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3571 r
= add_file_entry( hdb
, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3572 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3574 r
= add_file_entry( hdb
, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3575 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3577 r
= create_remove_file_table( hdb
);
3578 ok( r
== ERROR_SUCCESS
, "cannot create Remove File table: %d\n", r
);
3580 r
= package_from_db( hdb
, &hpkg
);
3581 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3583 skip("Not enough rights to perform tests\n");
3584 DeleteFileA(msifile
);
3587 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3589 MsiCloseHandle( hdb
);
3591 create_test_file( "hydrogen.txt" );
3592 create_test_file( "helium.txt" );
3593 create_test_file( "lithium.txt" );
3594 create_test_file( "beryllium.txt" );
3595 create_test_file( "boron.txt" );
3596 create_test_file( "carbon.txt" );
3597 create_test_file( "oxygen.txt" );
3599 r
= MsiSetPropertyA( hpkg
, "TARGETDIR", CURR_DIR
);
3600 ok( r
== ERROR_SUCCESS
, "set property failed\n");
3602 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3604 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3605 ok( r
== ERROR_UNKNOWN_COMPONENT
, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
3607 r
= MsiDoActionA( hpkg
, "CostInitialize");
3608 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3610 r
= MsiDoActionA( hpkg
, "FileCost");
3611 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3613 installed
= action
= 0xdeadbeef;
3614 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3615 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3616 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3617 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3619 r
= MsiDoActionA( hpkg
, "CostFinalize");
3620 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
3622 r
= MsiDoActionA( hpkg
, "InstallValidate");
3623 ok( r
== ERROR_SUCCESS
, "install validate failed\n");
3625 r
= MsiSetComponentStateA( hpkg
, "hydrogen", INSTALLSTATE_ABSENT
);
3626 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3628 installed
= action
= 0xdeadbeef;
3629 r
= MsiGetComponentStateA( hpkg
, "hydrogen", &installed
, &action
);
3630 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3631 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3632 todo_wine
ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3634 r
= MsiSetComponentStateA( hpkg
, "helium", INSTALLSTATE_LOCAL
);
3635 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3637 r
= MsiSetComponentStateA( hpkg
, "lithium", INSTALLSTATE_SOURCE
);
3638 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3640 r
= MsiSetComponentStateA( hpkg
, "beryllium", INSTALLSTATE_ABSENT
);
3641 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3643 r
= MsiSetComponentStateA( hpkg
, "boron", INSTALLSTATE_LOCAL
);
3644 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3646 r
= MsiSetComponentStateA( hpkg
, "carbon", INSTALLSTATE_SOURCE
);
3647 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3649 installed
= action
= 0xdeadbeef;
3650 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3651 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3652 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3653 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3655 r
= MsiSetComponentStateA( hpkg
, "oxygen", INSTALLSTATE_ABSENT
);
3656 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3658 installed
= action
= 0xdeadbeef;
3659 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3660 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3661 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3662 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3664 r
= MsiDoActionA( hpkg
, "RemoveFiles");
3665 ok( r
== ERROR_SUCCESS
, "remove files failed\n");
3667 installed
= action
= 0xdeadbeef;
3668 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3669 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3670 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3671 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3673 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3674 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3675 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3676 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3677 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3678 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3679 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3681 MsiCloseHandle( hpkg
);
3682 DeleteFileA(msifile
);
3685 static void test_appsearch(void)
3690 CHAR prop
[MAX_PATH
];
3693 hdb
= create_package_db();
3694 ok ( hdb
, "failed to create package database\n" );
3696 r
= create_appsearch_table( hdb
);
3697 ok( r
== ERROR_SUCCESS
, "cannot create AppSearch table: %d\n", r
);
3699 r
= add_appsearch_entry( hdb
, "'WEBBROWSERPROG', 'NewSignature1'" );
3700 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3702 r
= add_appsearch_entry( hdb
, "'NOTEPAD', 'NewSignature2'" );
3703 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3705 r
= create_reglocator_table( hdb
);
3706 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3708 r
= add_reglocator_entry( hdb
, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3709 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3711 r
= create_drlocator_table( hdb
);
3712 ok( r
== ERROR_SUCCESS
, "cannot create DrLocator table: %d\n", r
);
3714 r
= add_drlocator_entry( hdb
, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3715 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3717 r
= create_signature_table( hdb
);
3718 ok( r
== ERROR_SUCCESS
, "cannot create Signature table: %d\n", r
);
3720 r
= add_signature_entry( hdb
, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3721 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3723 r
= add_signature_entry( hdb
, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3724 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3726 r
= package_from_db( hdb
, &hpkg
);
3727 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3729 skip("Not enough rights to perform tests\n");
3730 DeleteFileA(msifile
);
3733 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3734 MsiCloseHandle( hdb
);
3735 if (r
!= ERROR_SUCCESS
)
3738 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3740 r
= MsiDoActionA( hpkg
, "AppSearch" );
3741 ok( r
== ERROR_SUCCESS
, "AppSearch failed: %d\n", r
);
3743 size
= sizeof(prop
);
3744 r
= MsiGetPropertyA( hpkg
, "WEBBROWSERPROG", prop
, &size
);
3745 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3746 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
3748 size
= sizeof(prop
);
3749 r
= MsiGetPropertyA( hpkg
, "NOTEPAD", prop
, &size
);
3750 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3753 MsiCloseHandle( hpkg
);
3754 DeleteFileA(msifile
);
3757 static void test_appsearch_complocator(void)
3759 MSIHANDLE hpkg
, hdb
;
3760 CHAR path
[MAX_PATH
];
3761 CHAR prop
[MAX_PATH
];
3766 if (!(usersid
= get_user_sid()))
3769 if (is_process_limited())
3771 skip("process is limited\n");
3775 create_test_file("FileName1");
3776 create_test_file("FileName4");
3777 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE
,
3778 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL
, FALSE
);
3780 create_test_file("FileName2");
3781 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED
,
3782 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid
, FALSE
);
3784 create_test_file("FileName3");
3785 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED
,
3786 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid
, FALSE
);
3788 create_test_file("FileName5");
3789 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE
,
3790 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL
, TRUE
);
3792 create_test_file("FileName6");
3793 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE
,
3794 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL
, TRUE
);
3796 create_test_file("FileName7");
3797 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE
,
3798 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL
, FALSE
);
3800 /* dir is FALSE, but we're pretending it's a directory */
3801 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE
,
3802 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL
, FALSE
);
3804 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3805 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE
,
3806 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL
, FALSE
);
3808 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3809 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE
,
3810 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL
, FALSE
);
3812 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3813 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE
,
3814 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL
, FALSE
);
3816 hdb
= create_package_db();
3817 ok(hdb
, "Expected a valid database handle\n");
3819 r
= create_appsearch_table(hdb
);
3820 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3822 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
3823 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3825 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
3826 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3828 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
3829 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3831 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
3832 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3834 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
3835 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3837 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
3838 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3840 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
3841 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3843 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
3844 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3846 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
3847 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3849 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
3850 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3852 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
3853 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3855 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
3856 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3858 r
= create_complocator_table(hdb
);
3859 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3861 /* published component, machine, file, signature, misdbLocatorTypeFile */
3862 r
= add_complocator_entry(hdb
, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
3863 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3865 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
3866 r
= add_complocator_entry(hdb
, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
3867 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3869 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
3870 r
= add_complocator_entry(hdb
, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
3871 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3873 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
3874 r
= add_complocator_entry(hdb
, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
3875 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3877 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
3878 r
= add_complocator_entry(hdb
, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
3879 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3881 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
3882 r
= add_complocator_entry(hdb
, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
3883 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3885 /* published component, machine, file, no signature, misdbLocatorTypeFile */
3886 r
= add_complocator_entry(hdb
, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
3887 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3889 /* unpublished component, no signature, misdbLocatorTypeDir */
3890 r
= add_complocator_entry(hdb
, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
3891 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3893 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
3894 r
= add_complocator_entry(hdb
, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
3895 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3897 /* published component, signature w/ ver, misdbLocatorTypeFile */
3898 r
= add_complocator_entry(hdb
, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
3899 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3901 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
3902 r
= add_complocator_entry(hdb
, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
3903 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3905 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
3906 r
= add_complocator_entry(hdb
, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
3907 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3909 r
= create_signature_table(hdb
);
3910 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3912 r
= add_signature_entry(hdb
, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
3913 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3915 r
= add_signature_entry(hdb
, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
3916 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3918 r
= add_signature_entry(hdb
, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
3919 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3921 r
= add_signature_entry(hdb
, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
3922 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3924 r
= add_signature_entry(hdb
, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
3925 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3927 r
= add_signature_entry(hdb
, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3928 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3930 r
= add_signature_entry(hdb
, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3931 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3933 r
= add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3934 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3936 r
= package_from_db(hdb
, &hpkg
);
3937 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3939 skip("Not enough rights to perform tests\n");
3942 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
3944 r
= MsiSetPropertyA(hpkg
, "SIGPROP8", "october");
3945 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3947 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3949 r
= MsiDoActionA(hpkg
, "AppSearch");
3950 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3953 sprintf(path
, "%s\\FileName1", CURR_DIR
);
3954 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
3955 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3956 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
3959 sprintf(path
, "%s\\FileName2", CURR_DIR
);
3960 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
3961 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3962 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
3965 sprintf(path
, "%s\\FileName3", CURR_DIR
);
3966 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
3967 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3968 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
3971 sprintf(path
, "%s\\FileName4", CURR_DIR
);
3972 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
3973 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3974 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
3977 sprintf(path
, "%s\\FileName5", CURR_DIR
);
3978 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
3979 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3980 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
3983 sprintf(path
, "%s\\", CURR_DIR
);
3984 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
3985 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3986 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
3989 sprintf(path
, "%s\\", CURR_DIR
);
3990 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
3991 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3992 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
3995 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
3996 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3997 ok(!lstrcmpA(prop
, "october"), "Expected \"october\", got \"%s\"\n", prop
);
4000 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4001 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4002 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4005 sprintf(path
, "%s\\FileName8.dll", CURR_DIR
);
4006 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4007 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4008 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4011 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4012 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4013 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4016 sprintf(path
, "%s\\FileName10.dll", CURR_DIR
);
4017 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4018 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4019 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4021 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4022 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4023 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4024 MSIINSTALLCONTEXT_USERUNMANAGED
, usersid
);
4025 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4026 MSIINSTALLCONTEXT_USERMANAGED
, usersid
);
4027 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4028 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4029 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4030 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4031 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4032 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4033 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4034 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4035 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4036 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4037 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4038 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4039 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4040 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4042 MsiCloseHandle(hpkg
);
4045 DeleteFileA("FileName1");
4046 DeleteFileA("FileName2");
4047 DeleteFileA("FileName3");
4048 DeleteFileA("FileName4");
4049 DeleteFileA("FileName5");
4050 DeleteFileA("FileName6");
4051 DeleteFileA("FileName7");
4052 DeleteFileA("FileName8.dll");
4053 DeleteFileA("FileName9.dll");
4054 DeleteFileA("FileName10.dll");
4055 DeleteFileA(msifile
);
4059 static void test_appsearch_reglocator(void)
4061 MSIHANDLE hpkg
, hdb
;
4062 CHAR path
[MAX_PATH
], prop
[MAX_PATH
];
4063 DWORD binary
[2], size
, val
;
4064 BOOL space
, version
, is_64bit
= sizeof(void *) > sizeof(int);
4065 HKEY hklm
, classes
, hkcu
, users
;
4066 LPSTR pathdata
, pathvar
, ptr
;
4073 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4076 DeleteFileA("test.dll");
4078 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, "Software\\Wine", &classes
);
4079 if (res
== ERROR_ACCESS_DENIED
)
4081 skip("Not enough rights to perform tests\n");
4084 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4086 res
= RegSetValueExA(classes
, "Value1", 0, REG_SZ
,
4087 (const BYTE
*)"regszdata", 10);
4088 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4090 res
= RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine", &hkcu
);
4091 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4093 res
= RegSetValueExA(hkcu
, "Value1", 0, REG_SZ
,
4094 (const BYTE
*)"regszdata", 10);
4095 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4098 res
= RegCreateKeyA(HKEY_USERS
, "S-1-5-18\\Software\\Wine", &users
);
4099 ok(res
== ERROR_SUCCESS
||
4100 broken(res
== ERROR_INVALID_PARAMETER
),
4101 "Expected ERROR_SUCCESS, got %d\n", res
);
4103 if (res
== ERROR_SUCCESS
)
4105 res
= RegSetValueExA(users
, "Value1", 0, REG_SZ
,
4106 (const BYTE
*)"regszdata", 10);
4107 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4110 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, "Software\\Wine", &hklm
);
4111 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4113 res
= RegSetValueA(hklm
, NULL
, REG_SZ
, "defvalue", 8);
4114 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4116 res
= RegSetValueExA(hklm
, "Value1", 0, REG_SZ
,
4117 (const BYTE
*)"regszdata", 10);
4118 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4121 res
= RegSetValueExA(hklm
, "Value2", 0, REG_DWORD
,
4122 (const BYTE
*)&val
, sizeof(DWORD
));
4123 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4126 res
= RegSetValueExA(hklm
, "Value3", 0, REG_DWORD
,
4127 (const BYTE
*)&val
, sizeof(DWORD
));
4128 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4130 res
= RegSetValueExA(hklm
, "Value4", 0, REG_EXPAND_SZ
,
4131 (const BYTE
*)"%PATH%", 7);
4132 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4134 res
= RegSetValueExA(hklm
, "Value5", 0, REG_EXPAND_SZ
,
4135 (const BYTE
*)"my%NOVAR%", 10);
4136 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4138 res
= RegSetValueExA(hklm
, "Value6", 0, REG_MULTI_SZ
,
4139 (const BYTE
*)"one\0two\0", 9);
4140 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4142 binary
[0] = 0x1234abcd;
4143 binary
[1] = 0x567890ef;
4144 res
= RegSetValueExA(hklm
, "Value7", 0, REG_BINARY
,
4145 (const BYTE
*)binary
, sizeof(binary
));
4146 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4148 res
= RegSetValueExA(hklm
, "Value8", 0, REG_SZ
,
4149 (const BYTE
*)"#regszdata", 11);
4150 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4152 create_test_file("FileName1");
4153 sprintf(path
, "%s\\FileName1", CURR_DIR
);
4154 res
= RegSetValueExA(hklm
, "Value9", 0, REG_SZ
,
4155 (const BYTE
*)path
, lstrlenA(path
) + 1);
4156 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4158 sprintf(path
, "%s\\FileName2", CURR_DIR
);
4159 res
= RegSetValueExA(hklm
, "Value10", 0, REG_SZ
,
4160 (const BYTE
*)path
, lstrlenA(path
) + 1);
4161 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4163 lstrcpyA(path
, CURR_DIR
);
4164 res
= RegSetValueExA(hklm
, "Value11", 0, REG_SZ
,
4165 (const BYTE
*)path
, lstrlenA(path
) + 1);
4166 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4168 res
= RegSetValueExA(hklm
, "Value12", 0, REG_SZ
,
4169 (const BYTE
*)"", 1);
4170 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4172 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4173 sprintf(path
, "%s\\FileName3.dll", CURR_DIR
);
4174 res
= RegSetValueExA(hklm
, "Value13", 0, REG_SZ
,
4175 (const BYTE
*)path
, lstrlenA(path
) + 1);
4176 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4178 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4179 sprintf(path
, "%s\\FileName4.dll", CURR_DIR
);
4180 res
= RegSetValueExA(hklm
, "Value14", 0, REG_SZ
,
4181 (const BYTE
*)path
, lstrlenA(path
) + 1);
4182 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4184 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4185 sprintf(path
, "%s\\FileName5.dll", CURR_DIR
);
4186 res
= RegSetValueExA(hklm
, "Value15", 0, REG_SZ
,
4187 (const BYTE
*)path
, lstrlenA(path
) + 1);
4188 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4190 sprintf(path
, "\"%s\\FileName1\" -option", CURR_DIR
);
4191 res
= RegSetValueExA(hklm
, "value16", 0, REG_SZ
,
4192 (const BYTE
*)path
, lstrlenA(path
) + 1);
4193 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4195 space
= strchr(CURR_DIR
, ' ') != NULL
;
4196 sprintf(path
, "%s\\FileName1 -option", CURR_DIR
);
4197 res
= RegSetValueExA(hklm
, "value17", 0, REG_SZ
,
4198 (const BYTE
*)path
, lstrlenA(path
) + 1);
4199 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4201 hdb
= create_package_db();
4202 ok(hdb
, "Expected a valid database handle\n");
4204 r
= create_appsearch_table(hdb
);
4205 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4207 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4208 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4210 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4211 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4213 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4214 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4216 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4217 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4219 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4220 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4222 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4223 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4225 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4226 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4228 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4229 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4231 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4232 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4234 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4235 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4237 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4238 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4240 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4241 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4243 r
= add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
4244 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4246 r
= add_appsearch_entry(hdb
, "'SIGPROP14', 'NewSignature14'");
4247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4249 r
= add_appsearch_entry(hdb
, "'SIGPROP15', 'NewSignature15'");
4250 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4252 r
= add_appsearch_entry(hdb
, "'SIGPROP16', 'NewSignature16'");
4253 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4255 r
= add_appsearch_entry(hdb
, "'SIGPROP17', 'NewSignature17'");
4256 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4258 r
= add_appsearch_entry(hdb
, "'SIGPROP18', 'NewSignature18'");
4259 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4261 r
= add_appsearch_entry(hdb
, "'SIGPROP19', 'NewSignature19'");
4262 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4264 r
= add_appsearch_entry(hdb
, "'SIGPROP20', 'NewSignature20'");
4265 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4267 r
= add_appsearch_entry(hdb
, "'SIGPROP21', 'NewSignature21'");
4268 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4270 r
= add_appsearch_entry(hdb
, "'SIGPROP22', 'NewSignature22'");
4271 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4273 r
= add_appsearch_entry(hdb
, "'SIGPROP23', 'NewSignature23'");
4274 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4276 r
= add_appsearch_entry(hdb
, "'SIGPROP24', 'NewSignature24'");
4277 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4279 r
= add_appsearch_entry(hdb
, "'SIGPROP25', 'NewSignature25'");
4280 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4282 r
= add_appsearch_entry(hdb
, "'SIGPROP26', 'NewSignature26'");
4283 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4285 r
= add_appsearch_entry(hdb
, "'SIGPROP27', 'NewSignature27'");
4286 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4288 r
= add_appsearch_entry(hdb
, "'SIGPROP28', 'NewSignature28'");
4289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4291 r
= add_appsearch_entry(hdb
, "'SIGPROP29', 'NewSignature29'");
4292 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4294 r
= add_appsearch_entry(hdb
, "'SIGPROP30', 'NewSignature30'");
4295 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4297 r
= create_reglocator_table(hdb
);
4298 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4300 type
= msidbLocatorTypeRawValue
;
4302 type
|= msidbLocatorType64bit
;
4304 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4305 r
= add_reglocator_entry(hdb
, "NewSignature1", 2, "Software\\Wine", "Value1", type
);
4306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4308 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4309 r
= add_reglocator_entry(hdb
, "NewSignature2", 2, "Software\\Wine", "Value2", type
);
4310 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4312 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4313 r
= add_reglocator_entry(hdb
, "NewSignature3", 2, "Software\\Wine", "Value3", type
);
4314 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4316 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4317 r
= add_reglocator_entry(hdb
, "NewSignature4", 2, "Software\\Wine", "Value4", type
);
4318 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4320 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4321 r
= add_reglocator_entry(hdb
, "NewSignature5", 2, "Software\\Wine", "Value5", type
);
4322 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4324 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4325 r
= add_reglocator_entry(hdb
, "NewSignature6", 2, "Software\\Wine", "Value6", type
);
4326 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4328 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4329 r
= add_reglocator_entry(hdb
, "NewSignature7", 2, "Software\\Wine", "Value7", type
);
4330 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4332 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4333 r
= add_reglocator_entry(hdb
, "NewSignature8", 2, "Software\\Wine", "Value8", type
);
4334 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4336 type
= msidbLocatorTypeFileName
;
4338 type
|= msidbLocatorType64bit
;
4340 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4341 r
= add_reglocator_entry(hdb
, "NewSignature9", 2, "Software\\Wine", "Value9", type
);
4342 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4344 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4345 r
= add_reglocator_entry(hdb
, "NewSignature10", 2, "Software\\Wine", "Value10", type
);
4346 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4348 /* HKLM, msidbLocatorTypeFileName, no signature */
4349 r
= add_reglocator_entry(hdb
, "NewSignature11", 2, "Software\\Wine", "Value9", type
);
4350 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4352 type
= msidbLocatorTypeDirectory
;
4354 type
|= msidbLocatorType64bit
;
4356 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4357 r
= add_reglocator_entry(hdb
, "NewSignature12", 2, "Software\\Wine", "Value9", type
);
4358 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4360 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4361 r
= add_reglocator_entry(hdb
, "NewSignature13", 2, "Software\\Wine", "Value11", type
);
4362 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4364 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4365 r
= add_reglocator_entry(hdb
, "NewSignature14", 2, "Software\\Wine", "Value9", type
);
4366 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4368 type
= msidbLocatorTypeRawValue
;
4370 type
|= msidbLocatorType64bit
;
4372 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4373 r
= add_reglocator_entry(hdb
, "NewSignature15", 0, "Software\\Wine", "Value1", type
);
4374 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4376 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4377 r
= add_reglocator_entry(hdb
, "NewSignature16", 1, "Software\\Wine", "Value1", type
);
4378 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4380 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4381 r
= add_reglocator_entry(hdb
, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type
);
4382 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4384 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4385 r
= add_reglocator_entry(hdb
, "NewSignature18", 2, "Software\\Wine", "", type
);
4386 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4388 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4389 r
= add_reglocator_entry(hdb
, "NewSignature19", 2, "Software\\IDontExist", "", type
);
4390 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4392 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4393 r
= add_reglocator_entry(hdb
, "NewSignature20", 2, "Software\\Wine", "Value12", type
);
4394 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4396 type
= msidbLocatorTypeFileName
;
4398 type
|= msidbLocatorType64bit
;
4400 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4401 r
= add_reglocator_entry(hdb
, "NewSignature21", 2, "Software\\Wine", "Value13", type
);
4402 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4404 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4405 r
= add_reglocator_entry(hdb
, "NewSignature22", 2, "Software\\Wine", "Value14", type
);
4406 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4408 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4409 r
= add_reglocator_entry(hdb
, "NewSignature23", 2, "Software\\Wine", "Value15", type
);
4410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4412 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4413 r
= add_reglocator_entry(hdb
, "NewSignature24", 2, "Software\\Wine", "Value11", type
);
4414 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4416 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4417 r
= add_reglocator_entry(hdb
, "NewSignature25", 2, "Software\\Wine", "Value10", type
);
4418 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4420 type
= msidbLocatorTypeDirectory
;
4422 type
|= msidbLocatorType64bit
;
4424 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4425 r
= add_reglocator_entry(hdb
, "NewSignature26", 2, "Software\\Wine", "Value11", type
);
4426 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4428 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4429 r
= add_reglocator_entry(hdb
, "NewSignature27", 2, "Software\\Wine", "Value10", type
);
4430 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4432 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4433 r
= add_reglocator_entry(hdb
, "NewSignature28", 2, "Software\\Wine", "Value10", type
);
4434 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4436 type
= msidbLocatorTypeFileName
;
4438 type
|= msidbLocatorType64bit
;
4440 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4441 r
= add_reglocator_entry(hdb
, "NewSignature29", 2, "Software\\Wine", "Value16", type
);
4442 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4444 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4445 r
= add_reglocator_entry(hdb
, "NewSignature30", 2, "Software\\Wine", "Value17", type
);
4446 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4448 r
= create_signature_table(hdb
);
4449 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4451 str
= "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4452 r
= add_signature_entry(hdb
, str
);
4453 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4455 str
= "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4456 r
= add_signature_entry(hdb
, str
);
4457 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4459 str
= "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4460 r
= add_signature_entry(hdb
, str
);
4461 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4463 str
= "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4464 r
= add_signature_entry(hdb
, str
);
4465 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4467 str
= "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4468 r
= add_signature_entry(hdb
, str
);
4469 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4471 str
= "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4472 r
= add_signature_entry(hdb
, str
);
4473 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4475 ptr
= strrchr(CURR_DIR
, '\\') + 1;
4476 sprintf(path
, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr
);
4477 r
= add_signature_entry(hdb
, path
);
4478 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4480 str
= "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4481 r
= add_signature_entry(hdb
, str
);
4482 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4484 str
= "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4485 r
= add_signature_entry(hdb
, str
);
4486 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4488 str
= "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4489 r
= add_signature_entry(hdb
, str
);
4490 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4492 r
= package_from_db(hdb
, &hpkg
);
4493 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4495 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4497 r
= MsiDoActionA(hpkg
, "AppSearch");
4498 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4501 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4502 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4503 ok(!lstrcmpA(prop
, "regszdata"),
4504 "Expected \"regszdata\", got \"%s\"\n", prop
);
4507 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4508 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4509 ok(!lstrcmpA(prop
, "#42"), "Expected \"#42\", got \"%s\"\n", prop
);
4512 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4513 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4514 ok(!lstrcmpA(prop
, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop
);
4516 memset(&si
, 0, sizeof(si
));
4517 if (pGetNativeSystemInfo
) pGetNativeSystemInfo(&si
);
4519 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
4521 size
= ExpandEnvironmentStringsA("%PATH%", NULL
, 0);
4522 pathvar
= HeapAlloc(GetProcessHeap(), 0, size
);
4523 ExpandEnvironmentStringsA("%PATH%", pathvar
, size
);
4526 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", NULL
, &size
);
4527 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4529 pathdata
= HeapAlloc(GetProcessHeap(), 0, ++size
);
4530 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", pathdata
, &size
);
4531 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4532 ok(!lstrcmpA(pathdata
, pathvar
),
4533 "Expected \"%s\", got \"%s\"\n", pathvar
, pathdata
);
4535 HeapFree(GetProcessHeap(), 0, pathvar
);
4536 HeapFree(GetProcessHeap(), 0, pathdata
);
4540 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4541 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4543 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop
);
4546 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4547 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4550 ok(!memcmp(prop
, "\0one\0two\0\0", 10),
4551 "Expected \"\\0one\\0two\\0\\0\"\n");
4555 lstrcpyA(path
, "#xCDAB3412EF907856");
4556 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4557 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4558 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4561 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4562 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4563 ok(!lstrcmpA(prop
, "##regszdata"),
4564 "Expected \"##regszdata\", got \"%s\"\n", prop
);
4567 sprintf(path
, "%s\\FileName1", CURR_DIR
);
4568 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4569 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4570 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4573 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4574 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4575 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4578 sprintf(path
, "%s\\", CURR_DIR
);
4579 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4580 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4581 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4584 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4585 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4586 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4589 sprintf(path
, "%s\\", CURR_DIR
);
4590 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
4591 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4592 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4595 r
= MsiGetPropertyA(hpkg
, "SIGPROP14", prop
, &size
);
4596 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4597 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4600 r
= MsiGetPropertyA(hpkg
, "SIGPROP15", prop
, &size
);
4601 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4602 ok(!lstrcmpA(prop
, "regszdata"),
4603 "Expected \"regszdata\", got \"%s\"\n", prop
);
4606 r
= MsiGetPropertyA(hpkg
, "SIGPROP16", prop
, &size
);
4607 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4608 ok(!lstrcmpA(prop
, "regszdata"),
4609 "Expected \"regszdata\", got \"%s\"\n", prop
);
4614 r
= MsiGetPropertyA(hpkg
, "SIGPROP17", prop
, &size
);
4615 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4616 ok(!lstrcmpA(prop
, "regszdata"),
4617 "Expected \"regszdata\", got \"%s\"\n", prop
);
4621 r
= MsiGetPropertyA(hpkg
, "SIGPROP18", prop
, &size
);
4622 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4623 ok(!lstrcmpA(prop
, "defvalue"),
4624 "Expected \"defvalue\", got \"%s\"\n", prop
);
4627 r
= MsiGetPropertyA(hpkg
, "SIGPROP19", prop
, &size
);
4628 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4629 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4632 r
= MsiGetPropertyA(hpkg
, "SIGPROP20", prop
, &size
);
4633 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4634 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4639 sprintf(path
, "%s\\FileName3.dll", CURR_DIR
);
4640 r
= MsiGetPropertyA(hpkg
, "SIGPROP21", prop
, &size
);
4641 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4642 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4645 r
= MsiGetPropertyA(hpkg
, "SIGPROP22", prop
, &size
);
4646 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4647 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4650 sprintf(path
, "%s\\FileName5.dll", CURR_DIR
);
4651 r
= MsiGetPropertyA(hpkg
, "SIGPROP23", prop
, &size
);
4652 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4653 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4657 lstrcpyA(path
, CURR_DIR
);
4658 ptr
= strrchr(path
, '\\') + 1;
4660 r
= MsiGetPropertyA(hpkg
, "SIGPROP24", prop
, &size
);
4661 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4662 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4665 sprintf(path
, "%s\\", CURR_DIR
);
4666 r
= MsiGetPropertyA(hpkg
, "SIGPROP25", prop
, &size
);
4667 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4668 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4671 r
= MsiGetPropertyA(hpkg
, "SIGPROP26", prop
, &size
);
4672 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4673 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4676 r
= MsiGetPropertyA(hpkg
, "SIGPROP27", prop
, &size
);
4677 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4678 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4681 r
= MsiGetPropertyA(hpkg
, "SIGPROP28", prop
, &size
);
4682 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4683 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4686 sprintf(path
, "%s\\FileName1", CURR_DIR
);
4687 r
= MsiGetPropertyA(hpkg
, "SIGPROP29", prop
, &size
);
4688 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4689 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4692 sprintf(path
, "%s\\FileName1", CURR_DIR
);
4693 r
= MsiGetPropertyA(hpkg
, "SIGPROP30", prop
, &size
);
4694 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4696 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4698 todo_wine
ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4700 RegSetValueA(hklm
, NULL
, REG_SZ
, "", 0);
4701 RegDeleteValueA(hklm
, "Value1");
4702 RegDeleteValueA(hklm
, "Value2");
4703 RegDeleteValueA(hklm
, "Value3");
4704 RegDeleteValueA(hklm
, "Value4");
4705 RegDeleteValueA(hklm
, "Value5");
4706 RegDeleteValueA(hklm
, "Value6");
4707 RegDeleteValueA(hklm
, "Value7");
4708 RegDeleteValueA(hklm
, "Value8");
4709 RegDeleteValueA(hklm
, "Value9");
4710 RegDeleteValueA(hklm
, "Value10");
4711 RegDeleteValueA(hklm
, "Value11");
4712 RegDeleteValueA(hklm
, "Value12");
4713 RegDeleteValueA(hklm
, "Value13");
4714 RegDeleteValueA(hklm
, "Value14");
4715 RegDeleteValueA(hklm
, "Value15");
4716 RegDeleteValueA(hklm
, "Value16");
4717 RegDeleteValueA(hklm
, "Value17");
4718 RegDeleteKeyA(hklm
, "");
4721 RegDeleteValueA(classes
, "Value1");
4722 RegDeleteKeyA(classes
, "");
4723 RegCloseKey(classes
);
4725 RegDeleteValueA(hkcu
, "Value1");
4726 RegDeleteKeyA(hkcu
, "");
4729 RegDeleteValueA(users
, "Value1");
4730 RegDeleteKeyA(users
, "");
4733 DeleteFileA("FileName1");
4734 DeleteFileA("FileName3.dll");
4735 DeleteFileA("FileName4.dll");
4736 DeleteFileA("FileName5.dll");
4737 MsiCloseHandle(hpkg
);
4738 DeleteFileA(msifile
);
4741 static void delete_win_ini(LPCSTR file
)
4743 CHAR path
[MAX_PATH
];
4745 GetWindowsDirectoryA(path
, MAX_PATH
);
4746 lstrcatA(path
, "\\");
4747 lstrcatA(path
, file
);
4752 static void test_appsearch_inilocator(void)
4754 MSIHANDLE hpkg
, hdb
;
4755 CHAR path
[MAX_PATH
];
4756 CHAR prop
[MAX_PATH
];
4764 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4767 DeleteFileA("test.dll");
4769 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4771 create_test_file("FileName1");
4772 sprintf(path
, "%s\\FileName1", CURR_DIR
);
4773 WritePrivateProfileStringA("Section", "Key2", path
, "IniFile.ini");
4775 WritePrivateProfileStringA("Section", "Key3", CURR_DIR
, "IniFile.ini");
4777 sprintf(path
, "%s\\IDontExist", CURR_DIR
);
4778 WritePrivateProfileStringA("Section", "Key4", path
, "IniFile.ini");
4780 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4781 sprintf(path
, "%s\\FileName2.dll", CURR_DIR
);
4782 WritePrivateProfileStringA("Section", "Key5", path
, "IniFile.ini");
4784 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4785 sprintf(path
, "%s\\FileName3.dll", CURR_DIR
);
4786 WritePrivateProfileStringA("Section", "Key6", path
, "IniFile.ini");
4788 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4789 sprintf(path
, "%s\\FileName4.dll", CURR_DIR
);
4790 WritePrivateProfileStringA("Section", "Key7", path
, "IniFile.ini");
4792 hdb
= create_package_db();
4793 ok(hdb
, "Expected a valid database handle\n");
4795 r
= create_appsearch_table(hdb
);
4796 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4798 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4799 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4801 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4802 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4804 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4805 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4807 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4808 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4810 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4811 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4813 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4814 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4816 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4817 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4819 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4820 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4822 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4823 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4825 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4826 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4828 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4829 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4831 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4832 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4834 r
= create_inilocator_table(hdb
);
4835 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4837 /* msidbLocatorTypeRawValue, field 1 */
4838 str
= "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
4839 r
= add_inilocator_entry(hdb
, str
);
4840 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4842 /* msidbLocatorTypeRawValue, field 2 */
4843 str
= "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
4844 r
= add_inilocator_entry(hdb
, str
);
4845 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4847 /* msidbLocatorTypeRawValue, entire field */
4848 str
= "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
4849 r
= add_inilocator_entry(hdb
, str
);
4850 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4852 /* msidbLocatorTypeFile */
4853 str
= "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4854 r
= add_inilocator_entry(hdb
, str
);
4855 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4857 /* msidbLocatorTypeDirectory, file */
4858 str
= "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
4859 r
= add_inilocator_entry(hdb
, str
);
4860 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4862 /* msidbLocatorTypeDirectory, directory */
4863 str
= "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
4864 r
= add_inilocator_entry(hdb
, str
);
4865 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4867 /* msidbLocatorTypeFile, file, no signature */
4868 str
= "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4869 r
= add_inilocator_entry(hdb
, str
);
4870 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4872 /* msidbLocatorTypeFile, dir, no signature */
4873 str
= "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
4874 r
= add_inilocator_entry(hdb
, str
);
4875 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4877 /* msidbLocatorTypeFile, file does not exist */
4878 str
= "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
4879 r
= add_inilocator_entry(hdb
, str
);
4880 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4882 /* msidbLocatorTypeFile, signature with version */
4883 str
= "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
4884 r
= add_inilocator_entry(hdb
, str
);
4885 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4887 /* msidbLocatorTypeFile, signature with version, ver > max */
4888 str
= "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
4889 r
= add_inilocator_entry(hdb
, str
);
4890 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4892 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4893 str
= "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
4894 r
= add_inilocator_entry(hdb
, str
);
4895 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4897 r
= create_signature_table(hdb
);
4898 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4900 r
= add_signature_entry(hdb
, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4901 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4903 r
= add_signature_entry(hdb
, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4904 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4906 r
= add_signature_entry(hdb
, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4907 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4909 r
= add_signature_entry(hdb
, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4910 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4912 r
= add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4913 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4915 r
= package_from_db(hdb
, &hpkg
);
4916 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4918 skip("Not enough rights to perform tests\n");
4921 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4923 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4925 r
= MsiDoActionA(hpkg
, "AppSearch");
4926 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4929 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4930 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4931 ok(!lstrcmpA(prop
, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop
);
4934 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4935 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4936 ok(!lstrcmpA(prop
, "field2"), "Expected \"field2\", got \"%s\"\n", prop
);
4939 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4940 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4941 ok(!lstrcmpA(prop
, "keydata,field2"),
4942 "Expected \"keydata,field2\", got \"%s\"\n", prop
);
4945 sprintf(path
, "%s\\FileName1", CURR_DIR
);
4946 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
4947 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4948 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4951 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4952 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4953 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4956 sprintf(path
, "%s\\", CURR_DIR
);
4957 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4958 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4959 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4962 sprintf(path
, "%s\\", CURR_DIR
);
4963 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4964 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4965 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4968 lstrcpyA(path
, CURR_DIR
);
4969 ptr
= strrchr(path
, '\\');
4971 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4972 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4973 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4976 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4977 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4978 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4983 sprintf(path
, "%s\\FileName2.dll", CURR_DIR
);
4984 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4985 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4986 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4989 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4990 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4991 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4994 sprintf(path
, "%s\\FileName4.dll", CURR_DIR
);
4995 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4996 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4997 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5000 MsiCloseHandle(hpkg
);
5003 delete_win_ini("IniFile.ini");
5004 DeleteFileA("FileName1");
5005 DeleteFileA("FileName2.dll");
5006 DeleteFileA("FileName3.dll");
5007 DeleteFileA("FileName4.dll");
5008 DeleteFileA(msifile
);
5012 * MSI AppSearch action on DrLocator table always returns absolute paths.
5013 * If a relative path was set, it returns the first absolute path that
5014 * matches or an empty string if it didn't find anything.
5015 * This helper function replicates this behaviour.
5017 static void search_absolute_directory(LPSTR absolute
, LPCSTR relative
)
5022 size
= lstrlenA(relative
);
5023 drives
= GetLogicalDrives();
5024 lstrcpyA(absolute
, "A:\\");
5025 for (i
= 0; i
< 26; absolute
[0] = '\0', i
++)
5027 if (!(drives
& (1 << i
)))
5030 absolute
[0] = 'A' + i
;
5031 if (GetDriveTypeA(absolute
) != DRIVE_FIXED
)
5034 lstrcpynA(absolute
+ 3, relative
, size
+ 1);
5035 attr
= GetFileAttributesA(absolute
);
5036 if (attr
!= INVALID_FILE_ATTRIBUTES
&&
5037 (attr
& FILE_ATTRIBUTE_DIRECTORY
))
5039 if (absolute
[3 + size
- 1] != '\\')
5040 lstrcatA(absolute
, "\\");
5047 static void test_appsearch_drlocator(void)
5049 MSIHANDLE hpkg
, hdb
;
5050 CHAR path
[MAX_PATH
];
5051 CHAR prop
[MAX_PATH
];
5058 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5061 DeleteFileA("test.dll");
5063 create_test_file("FileName1");
5064 CreateDirectoryA("one", NULL
);
5065 CreateDirectoryA("one\\two", NULL
);
5066 CreateDirectoryA("one\\two\\three", NULL
);
5067 create_test_file("one\\two\\three\\FileName2");
5068 CreateDirectoryA("another", NULL
);
5069 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5070 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5071 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5073 hdb
= create_package_db();
5074 ok(hdb
, "Expected a valid database handle\n");
5076 r
= create_appsearch_table(hdb
);
5077 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5079 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
5080 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5082 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
5083 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5085 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
5086 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5088 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
5089 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5091 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
5092 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5094 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
5095 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5097 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
5098 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5100 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
5101 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5103 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
5104 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5106 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
5107 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5109 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
5110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5112 r
= add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
5113 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5115 r
= create_drlocator_table(hdb
);
5116 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5118 /* no parent, full path, depth 0, signature */
5119 sprintf(path
, "'NewSignature1', '', '%s', 0", CURR_DIR
);
5120 r
= add_drlocator_entry(hdb
, path
);
5121 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5123 /* no parent, full path, depth 0, no signature */
5124 sprintf(path
, "'NewSignature2', '', '%s', 0", CURR_DIR
);
5125 r
= add_drlocator_entry(hdb
, path
);
5126 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5128 /* no parent, relative path, depth 0, no signature */
5129 sprintf(path
, "'NewSignature3', '', '%s', 0", CURR_DIR
+ 3);
5130 r
= add_drlocator_entry(hdb
, path
);
5131 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5133 /* no parent, full path, depth 2, signature */
5134 sprintf(path
, "'NewSignature4', '', '%s', 2", CURR_DIR
);
5135 r
= add_drlocator_entry(hdb
, path
);
5136 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5138 /* no parent, full path, depth 3, signature */
5139 sprintf(path
, "'NewSignature5', '', '%s', 3", CURR_DIR
);
5140 r
= add_drlocator_entry(hdb
, path
);
5141 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5143 /* no parent, full path, depth 1, signature is dir */
5144 sprintf(path
, "'NewSignature6', '', '%s', 1", CURR_DIR
);
5145 r
= add_drlocator_entry(hdb
, path
);
5146 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5148 /* parent is in DrLocator, relative path, depth 0, signature */
5149 sprintf(path
, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5150 r
= add_drlocator_entry(hdb
, path
);
5151 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5153 /* no parent, full path, depth 0, signature w/ version */
5154 sprintf(path
, "'NewSignature8', '', '%s', 0", CURR_DIR
);
5155 r
= add_drlocator_entry(hdb
, path
);
5156 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5158 /* no parent, full path, depth 0, signature w/ version, ver > max */
5159 sprintf(path
, "'NewSignature9', '', '%s', 0", CURR_DIR
);
5160 r
= add_drlocator_entry(hdb
, path
);
5161 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5163 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5164 sprintf(path
, "'NewSignature10', '', '%s', 0", CURR_DIR
);
5165 r
= add_drlocator_entry(hdb
, path
);
5166 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5168 /* no parent, relative empty path, depth 0, no signature */
5169 sprintf(path
, "'NewSignature11', '', '', 0");
5170 r
= add_drlocator_entry(hdb
, path
);
5171 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5173 r
= create_reglocator_table(hdb
);
5174 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5177 r
= add_reglocator_entry(hdb
, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5178 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5180 /* parent is in RegLocator, no path, depth 0, no signature */
5181 sprintf(path
, "'NewSignature13', 'NewSignature12', '', 0");
5182 r
= add_drlocator_entry(hdb
, path
);
5183 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5185 r
= create_signature_table(hdb
);
5186 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5188 str
= "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5189 r
= add_signature_entry(hdb
, str
);
5190 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5192 str
= "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5193 r
= add_signature_entry(hdb
, str
);
5194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5196 str
= "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5197 r
= add_signature_entry(hdb
, str
);
5198 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5200 str
= "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5201 r
= add_signature_entry(hdb
, str
);
5202 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5204 str
= "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5205 r
= add_signature_entry(hdb
, str
);
5206 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5208 str
= "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5209 r
= add_signature_entry(hdb
, str
);
5210 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5212 str
= "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5213 r
= add_signature_entry(hdb
, str
);
5214 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5216 str
= "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5217 r
= add_signature_entry(hdb
, str
);
5218 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5220 r
= package_from_db(hdb
, &hpkg
);
5221 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5223 skip("Not enough rights to perform tests\n");
5226 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5228 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5230 r
= MsiDoActionA(hpkg
, "AppSearch");
5231 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5234 sprintf(path
, "%s\\FileName1", CURR_DIR
);
5235 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5236 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5237 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5240 sprintf(path
, "%s\\", CURR_DIR
);
5241 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5242 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5243 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5246 search_absolute_directory(path
, CURR_DIR
+ 3);
5247 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5248 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5249 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5252 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5253 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5254 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5257 sprintf(path
, "%s\\one\\two\\three\\FileName2", CURR_DIR
);
5258 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5259 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5260 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5263 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5264 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5265 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5268 sprintf(path
, "%s\\one\\two\\three\\FileName2", CURR_DIR
);
5269 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5270 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5271 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5276 sprintf(path
, "%s\\FileName3.dll", CURR_DIR
);
5277 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5278 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5279 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5282 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5283 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5284 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5287 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5288 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5289 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5293 search_absolute_directory(path
, "");
5294 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5295 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5296 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5299 strcpy(path
, "c:\\");
5300 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
5301 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5302 ok(!prop
[0], "Expected \"\", got \"%s\"\n", prop
);
5304 MsiCloseHandle(hpkg
);
5307 DeleteFileA("FileName1");
5308 DeleteFileA("FileName3.dll");
5309 DeleteFileA("FileName4.dll");
5310 DeleteFileA("FileName5.dll");
5311 DeleteFileA("one\\two\\three\\FileName2");
5312 RemoveDirectoryA("one\\two\\three");
5313 RemoveDirectoryA("one\\two");
5314 RemoveDirectoryA("one");
5315 RemoveDirectoryA("another");
5316 DeleteFileA(msifile
);
5319 static void test_featureparents(void)
5325 hdb
= create_package_db();
5326 ok ( hdb
, "failed to create package database\n" );
5328 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
5329 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
5331 r
= create_feature_table( hdb
);
5332 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
5334 r
= create_component_table( hdb
);
5335 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
5337 r
= create_feature_components_table( hdb
);
5338 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
5340 r
= create_file_table( hdb
);
5341 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
5343 /* msidbFeatureAttributesFavorLocal */
5344 r
= add_feature_entry( hdb
, "'zodiac', '', '', '', 2, 1, '', 0" );
5345 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5347 /* msidbFeatureAttributesFavorSource */
5348 r
= add_feature_entry( hdb
, "'perseus', '', '', '', 2, 1, '', 1" );
5349 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5351 /* msidbFeatureAttributesFavorLocal */
5352 r
= add_feature_entry( hdb
, "'orion', '', '', '', 2, 1, '', 0" );
5353 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5355 /* msidbFeatureAttributesUIDisallowAbsent */
5356 r
= add_feature_entry( hdb
, "'lyra', '', '', '', 2, 1, '', 16" );
5357 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5359 /* disabled because of install level */
5360 r
= add_feature_entry( hdb
, "'waters', '', '', '', 15, 101, '', 9" );
5361 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5363 /* child feature of disabled feature */
5364 r
= add_feature_entry( hdb
, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5365 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5367 /* component of disabled feature (install level) */
5368 r
= add_component_entry( hdb
, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5369 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5371 /* component of disabled child feature (install level) */
5372 r
= add_component_entry( hdb
, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5373 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5375 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5376 r
= add_component_entry( hdb
, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5377 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5379 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5380 r
= add_component_entry( hdb
, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5381 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5383 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5384 r
= add_component_entry( hdb
, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5385 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5387 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5388 r
= add_component_entry( hdb
, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5389 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5391 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5392 r
= add_component_entry( hdb
, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5393 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5395 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5396 r
= add_component_entry( hdb
, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5397 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5399 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5400 r
= add_component_entry( hdb
, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5401 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5403 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5404 r
= add_component_entry( hdb
, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5405 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5407 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5408 r
= add_component_entry( hdb
, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5409 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5411 r
= add_feature_components_entry( hdb
, "'zodiac', 'leo'" );
5412 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5414 r
= add_feature_components_entry( hdb
, "'zodiac', 'virgo'" );
5415 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5417 r
= add_feature_components_entry( hdb
, "'zodiac', 'libra'" );
5418 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5420 r
= add_feature_components_entry( hdb
, "'perseus', 'cassiopeia'" );
5421 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5423 r
= add_feature_components_entry( hdb
, "'perseus', 'cepheus'" );
5424 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5426 r
= add_feature_components_entry( hdb
, "'perseus', 'andromeda'" );
5427 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5429 r
= add_feature_components_entry( hdb
, "'orion', 'leo'" );
5430 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5432 r
= add_feature_components_entry( hdb
, "'orion', 'virgo'" );
5433 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5435 r
= add_feature_components_entry( hdb
, "'orion', 'libra'" );
5436 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5438 r
= add_feature_components_entry( hdb
, "'orion', 'cassiopeia'" );
5439 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5441 r
= add_feature_components_entry( hdb
, "'orion', 'cepheus'" );
5442 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5444 r
= add_feature_components_entry( hdb
, "'orion', 'andromeda'" );
5445 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5447 r
= add_feature_components_entry( hdb
, "'orion', 'canis'" );
5448 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5450 r
= add_feature_components_entry( hdb
, "'orion', 'monoceros'" );
5451 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5453 r
= add_feature_components_entry( hdb
, "'orion', 'lepus'" );
5454 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5456 r
= add_feature_components_entry( hdb
, "'waters', 'delphinus'" );
5457 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5459 r
= add_feature_components_entry( hdb
, "'bayer', 'hydrus'" );
5460 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5462 r
= add_file_entry( hdb
, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5463 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5465 r
= add_file_entry( hdb
, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5466 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5468 r
= add_file_entry( hdb
, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5469 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5471 r
= add_file_entry( hdb
, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5472 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5474 r
= add_file_entry( hdb
, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5475 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5477 r
= add_file_entry( hdb
, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5478 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5480 r
= add_file_entry( hdb
, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5481 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5483 r
= add_file_entry( hdb
, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5484 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5486 r
= add_file_entry( hdb
, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5487 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5489 r
= add_file_entry( hdb
, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5490 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5492 r
= add_file_entry( hdb
, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5493 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5495 r
= package_from_db( hdb
, &hpkg
);
5496 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5498 skip("Not enough rights to perform tests\n");
5499 DeleteFileA(msifile
);
5502 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5504 MsiCloseHandle( hdb
);
5506 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5508 r
= MsiDoActionA( hpkg
, "CostInitialize");
5509 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
5511 r
= MsiDoActionA( hpkg
, "FileCost");
5512 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
5514 r
= MsiDoActionA( hpkg
, "CostFinalize");
5515 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
5517 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5518 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5519 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5520 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5521 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5522 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5524 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5525 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5526 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5527 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5528 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5529 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5530 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5531 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5532 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5533 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5534 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5536 r
= MsiSetFeatureStateA(hpkg
, "orion", INSTALLSTATE_ABSENT
);
5537 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5539 r
= MsiSetFeatureStateA(hpkg
, "lyra", INSTALLSTATE_ABSENT
);
5540 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5542 r
= MsiSetFeatureStateA(hpkg
, "nosuchfeature", INSTALLSTATE_ABSENT
);
5543 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
5545 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5546 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5547 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5548 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5549 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5550 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5552 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5553 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5554 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5555 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5556 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5557 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5558 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5559 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5560 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5561 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5562 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5564 MsiCloseHandle(hpkg
);
5565 DeleteFileA(msifile
);
5568 static void test_installprops(void)
5570 MSIHANDLE hpkg
, hdb
;
5571 CHAR path
[MAX_PATH
], buf
[MAX_PATH
];
5577 REGSAM access
= KEY_ALL_ACCESS
;
5579 INSTALLUILEVEL uilevel
;
5582 access
|= KEY_WOW64_64KEY
;
5584 GetCurrentDirectoryA(MAX_PATH
, path
);
5585 lstrcatA(path
, "\\");
5586 lstrcatA(path
, msifile
);
5588 uilevel
= MsiSetInternalUI(INSTALLUILEVEL_BASIC
|INSTALLUILEVEL_SOURCERESONLY
, NULL
);
5590 hdb
= create_package_db();
5591 ok( hdb
, "failed to create database\n");
5593 r
= package_from_db(hdb
, &hpkg
);
5594 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5596 skip("Not enough rights to perform tests\n");
5597 MsiSetInternalUI(uilevel
, NULL
);
5598 DeleteFileA(msifile
);
5601 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5603 MsiCloseHandle(hdb
);
5607 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5608 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5609 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5611 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5615 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5616 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5617 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5621 r
= MsiGetPropertyA(hpkg
, "DATABASE", buf
, &size
);
5622 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5623 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5625 RegOpenKeyA(HKEY_CURRENT_USER
, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1
);
5626 RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access
, &hkey2
);
5631 if (RegQueryValueExA(hkey1
, "DefName", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5635 RegQueryValueExA(hkey2
, "RegisteredOwner", NULL
, &type
, (LPBYTE
)path
, &size
);
5640 r
= MsiGetPropertyA(hpkg
, "USERNAME", buf
, &size
);
5641 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5642 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5647 if (RegQueryValueExA(hkey1
, "DefCompany", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5651 RegQueryValueExA(hkey2
, "RegisteredOrganization", NULL
, &type
, (LPBYTE
)path
, &size
);
5658 r
= MsiGetPropertyA(hpkg
, "COMPANYNAME", buf
, &size
);
5659 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5660 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5665 r
= MsiGetPropertyA(hpkg
, "VersionDatabase", buf
, &size
);
5666 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5667 trace("VersionDatabase = %s\n", buf
);
5671 r
= MsiGetPropertyA(hpkg
, "VersionMsi", buf
, &size
);
5672 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5673 trace("VersionMsi = %s\n", buf
);
5677 r
= MsiGetPropertyA(hpkg
, "Date", buf
, &size
);
5678 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5679 trace("Date = %s\n", buf
);
5683 r
= MsiGetPropertyA(hpkg
, "Time", buf
, &size
);
5684 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5685 trace("Time = %s\n", buf
);
5689 r
= MsiGetPropertyA(hpkg
, "PackageCode", buf
, &size
);
5690 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5691 trace("PackageCode = %s\n", buf
);
5695 r
= MsiGetPropertyA(hpkg
, "ComputerName", buf
, &size
);
5696 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5697 trace("ComputerName = %s\n", buf
);
5699 langid
= GetUserDefaultLangID();
5700 sprintf(path
, "%d", langid
);
5704 r
= MsiGetPropertyA(hpkg
, "UserLanguageID", buf
, &size
);
5705 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5706 ok( !lstrcmpA(buf
, path
), "Expected \"%s\", got \"%s\"\n", path
, buf
);
5708 res
= GetSystemMetrics(SM_CXSCREEN
);
5711 r
= MsiGetPropertyA(hpkg
, "ScreenX", buf
, &size
);
5712 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5713 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5715 res
= GetSystemMetrics(SM_CYSCREEN
);
5718 r
= MsiGetPropertyA(hpkg
, "ScreenY", buf
, &size
);
5719 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5720 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5722 if (pGetSystemInfo
&& pSHGetFolderPathA
)
5724 pGetSystemInfo(&si
);
5725 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
5729 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5730 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5731 ok(buf
[0], "property not set\n");
5735 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5736 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5737 ok(buf
[0], "property not set\n");
5741 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5742 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5743 ok(buf
[0], "property not set\n");
5747 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5748 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5749 GetSystemDirectoryA(path
, MAX_PATH
);
5750 if (size
) buf
[size
- 1] = 0;
5751 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5755 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5756 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5757 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5758 if (size
) buf
[size
- 1] = 0;
5759 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5763 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
5764 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5765 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
5766 if (size
) buf
[size
- 1] = 0;
5767 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5771 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5772 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5773 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
5774 if (size
) buf
[size
- 1] = 0;
5775 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5779 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
5780 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5781 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
5782 if (size
) buf
[size
- 1] = 0;
5783 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5787 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5788 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5789 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
5790 if (size
) buf
[size
- 1] = 0;
5791 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5795 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5796 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5797 ok(buf
[0], "property not set\n");
5799 else if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
5805 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5806 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5807 ok(buf
[0], "property not set\n");
5811 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5812 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5813 ok(!buf
[0], "property set\n");
5817 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5818 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5819 ok(!buf
[0], "property set\n");
5823 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5824 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5825 ok(!buf
[0], "property set\n");
5829 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5830 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5831 GetSystemDirectoryA(path
, MAX_PATH
);
5832 if (size
) buf
[size
- 1] = 0;
5833 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5837 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
5838 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5839 ok(!buf
[0], "property set\n");
5843 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5844 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5845 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
5846 if (size
) buf
[size
- 1] = 0;
5847 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5851 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
5852 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5853 ok(!buf
[0], "property set\n");
5857 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5858 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5859 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
5860 if (size
) buf
[size
- 1] = 0;
5861 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5865 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5866 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5867 ok(!buf
[0], "property set\n");
5873 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5874 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5875 ok(buf
[0], "property not set\n");
5879 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5880 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5881 ok(buf
[0], "property not set\n");
5885 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5886 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5887 ok(buf
[0], "property not set\n");
5891 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5892 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5893 GetSystemDirectoryA(path
, MAX_PATH
);
5894 if (size
) buf
[size
- 1] = 0;
5895 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5899 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5900 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5901 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5902 if (size
) buf
[size
- 1] = 0;
5903 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5907 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder64", buf
, &size
);
5908 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5909 ok(!buf
[0], "property set\n");
5913 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5914 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5915 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
5916 if (size
) buf
[size
- 1] = 0;
5917 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5921 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder64", buf
, &size
);
5922 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5923 ok(!buf
[0], "property set\n");
5927 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5928 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5929 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
5930 if (size
) buf
[size
- 1] = 0;
5931 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5935 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5936 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5937 ok(buf
[0], "property not set\n");
5944 MsiCloseHandle(hpkg
);
5945 DeleteFileA(msifile
);
5946 MsiSetInternalUI(uilevel
, NULL
);
5949 static void test_launchconditions(void)
5955 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5957 hdb
= create_package_db();
5958 ok( hdb
, "failed to create package database\n" );
5960 r
= create_launchcondition_table( hdb
);
5961 ok( r
== ERROR_SUCCESS
, "cannot create LaunchCondition table: %d\n", r
);
5963 r
= add_launchcondition_entry( hdb
, "'X = \"1\"', 'one'" );
5964 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
5966 /* invalid condition */
5967 r
= add_launchcondition_entry( hdb
, "'X != \"1\"', 'one'" );
5968 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
5970 r
= package_from_db( hdb
, &hpkg
);
5971 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5973 skip("Not enough rights to perform tests\n");
5974 DeleteFileA(msifile
);
5977 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5979 MsiCloseHandle( hdb
);
5981 r
= MsiSetPropertyA( hpkg
, "X", "1" );
5982 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
5984 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5986 /* invalid conditions are ignored */
5987 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
5988 ok( r
== ERROR_SUCCESS
, "cost init failed\n" );
5990 /* verify LaunchConditions still does some verification */
5991 r
= MsiSetPropertyA( hpkg
, "X", "2" );
5992 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
5994 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
5995 ok( r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
5997 MsiCloseHandle( hpkg
);
5998 DeleteFileA( msifile
);
6001 static void test_ccpsearch(void)
6003 MSIHANDLE hdb
, hpkg
;
6004 CHAR prop
[MAX_PATH
];
6005 DWORD size
= MAX_PATH
;
6008 hdb
= create_package_db();
6009 ok(hdb
, "failed to create package database\n");
6011 r
= create_ccpsearch_table(hdb
);
6012 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6014 r
= add_ccpsearch_entry(hdb
, "'CCP_random'");
6015 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6017 r
= add_ccpsearch_entry(hdb
, "'RMCCP_random'");
6018 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6020 r
= create_reglocator_table(hdb
);
6021 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6023 r
= add_reglocator_entry(hdb
, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
6024 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6026 r
= create_drlocator_table(hdb
);
6027 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6029 r
= add_drlocator_entry(hdb
, "'RMCCP_random', '', 'C:\\', '0'");
6030 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6032 r
= create_signature_table(hdb
);
6033 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6035 r
= package_from_db(hdb
, &hpkg
);
6036 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6038 skip("Not enough rights to perform tests\n");
6039 DeleteFileA(msifile
);
6042 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6044 MsiCloseHandle(hdb
);
6046 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6048 r
= MsiDoActionA(hpkg
, "CCPSearch");
6049 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6051 r
= MsiGetPropertyA(hpkg
, "CCP_Success", prop
, &size
);
6052 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6053 ok(!lstrcmpA(prop
, "1"), "Expected 1, got %s\n", prop
);
6055 MsiCloseHandle(hpkg
);
6056 DeleteFileA(msifile
);
6059 static void test_complocator(void)
6061 MSIHANDLE hdb
, hpkg
;
6063 CHAR prop
[MAX_PATH
];
6064 CHAR expected
[MAX_PATH
];
6065 DWORD size
= MAX_PATH
;
6067 hdb
= create_package_db();
6068 ok(hdb
, "failed to create package database\n");
6070 r
= create_appsearch_table(hdb
);
6071 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6073 r
= add_appsearch_entry(hdb
, "'ABELISAURUS', 'abelisaurus'");
6074 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6076 r
= add_appsearch_entry(hdb
, "'BACTROSAURUS', 'bactrosaurus'");
6077 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6079 r
= add_appsearch_entry(hdb
, "'CAMELOTIA', 'camelotia'");
6080 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6082 r
= add_appsearch_entry(hdb
, "'DICLONIUS', 'diclonius'");
6083 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6085 r
= add_appsearch_entry(hdb
, "'ECHINODON', 'echinodon'");
6086 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6088 r
= add_appsearch_entry(hdb
, "'FALCARIUS', 'falcarius'");
6089 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6091 r
= add_appsearch_entry(hdb
, "'GALLIMIMUS', 'gallimimus'");
6092 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6094 r
= add_appsearch_entry(hdb
, "'HAGRYPHUS', 'hagryphus'");
6095 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6097 r
= add_appsearch_entry(hdb
, "'IGUANODON', 'iguanodon'");
6098 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6100 r
= add_appsearch_entry(hdb
, "'JOBARIA', 'jobaria'");
6101 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6103 r
= add_appsearch_entry(hdb
, "'KAKURU', 'kakuru'");
6104 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6106 r
= add_appsearch_entry(hdb
, "'LABOCANIA', 'labocania'");
6107 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6109 r
= add_appsearch_entry(hdb
, "'MEGARAPTOR', 'megaraptor'");
6110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6112 r
= add_appsearch_entry(hdb
, "'NEOSODON', 'neosodon'");
6113 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6115 r
= add_appsearch_entry(hdb
, "'OLOROTITAN', 'olorotitan'");
6116 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6118 r
= add_appsearch_entry(hdb
, "'PANTYDRACO', 'pantydraco'");
6119 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6121 r
= create_complocator_table(hdb
);
6122 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6124 r
= add_complocator_entry(hdb
, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6125 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6127 r
= add_complocator_entry(hdb
, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6128 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6130 r
= add_complocator_entry(hdb
, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6131 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6133 r
= add_complocator_entry(hdb
, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6134 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6136 r
= add_complocator_entry(hdb
, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6137 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6139 r
= add_complocator_entry(hdb
, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6140 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6142 r
= add_complocator_entry(hdb
, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6143 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6145 r
= add_complocator_entry(hdb
, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6146 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6148 r
= add_complocator_entry(hdb
, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6149 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6151 r
= add_complocator_entry(hdb
, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6152 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6154 r
= add_complocator_entry(hdb
, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6155 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6157 r
= add_complocator_entry(hdb
, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6158 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6160 r
= add_complocator_entry(hdb
, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6161 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6163 r
= add_complocator_entry(hdb
, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6164 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6166 r
= add_complocator_entry(hdb
, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6167 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6169 r
= add_complocator_entry(hdb
, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6170 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6172 r
= create_signature_table(hdb
);
6173 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6175 r
= add_signature_entry(hdb
, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6176 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6178 r
= add_signature_entry(hdb
, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6179 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6181 r
= add_signature_entry(hdb
, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6182 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6184 r
= add_signature_entry(hdb
, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6185 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6187 r
= add_signature_entry(hdb
, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6188 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6190 r
= add_signature_entry(hdb
, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6191 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6193 r
= add_signature_entry(hdb
, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6196 r
= add_signature_entry(hdb
, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6197 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6199 r
= package_from_db(hdb
, &hpkg
);
6200 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6202 skip("Not enough rights to perform tests\n");
6203 DeleteFileA(msifile
);
6206 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6208 MsiCloseHandle(hdb
);
6210 create_test_file("abelisaurus");
6211 create_test_file("bactrosaurus");
6212 create_test_file("camelotia");
6213 create_test_file("diclonius");
6214 create_test_file("echinodon");
6215 create_test_file("falcarius");
6216 create_test_file("gallimimus");
6217 create_test_file("hagryphus");
6218 CreateDirectoryA("iguanodon", NULL
);
6219 CreateDirectoryA("jobaria", NULL
);
6220 CreateDirectoryA("kakuru", NULL
);
6221 CreateDirectoryA("labocania", NULL
);
6222 CreateDirectoryA("megaraptor", NULL
);
6223 CreateDirectoryA("neosodon", NULL
);
6224 CreateDirectoryA("olorotitan", NULL
);
6225 CreateDirectoryA("pantydraco", NULL
);
6227 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE
,
6228 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL
, FALSE
);
6229 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE
,
6230 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL
, FALSE
);
6231 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE
,
6232 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL
, FALSE
);
6233 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE
,
6234 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL
, FALSE
);
6235 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE
,
6236 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL
, FALSE
);
6237 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE
,
6238 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL
, FALSE
);
6239 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE
,
6240 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL
, FALSE
);
6241 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE
,
6242 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL
, FALSE
);
6244 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6246 r
= MsiDoActionA(hpkg
, "AppSearch");
6247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6250 r
= MsiGetPropertyA(hpkg
, "ABELISAURUS", prop
, &size
);
6251 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6253 lstrcpyA(expected
, CURR_DIR
);
6254 lstrcatA(expected
, "\\abelisaurus");
6255 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6256 "Expected %s or empty string, got %s\n", expected
, prop
);
6259 r
= MsiGetPropertyA(hpkg
, "BACTROSAURUS", prop
, &size
);
6260 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6261 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6264 r
= MsiGetPropertyA(hpkg
, "CAMELOTIA", prop
, &size
);
6265 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6266 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6269 r
= MsiGetPropertyA(hpkg
, "DICLONIUS", prop
, &size
);
6270 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6271 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6274 r
= MsiGetPropertyA(hpkg
, "ECHINODON", prop
, &size
);
6275 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6277 lstrcpyA(expected
, CURR_DIR
);
6278 lstrcatA(expected
, "\\");
6279 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6280 "Expected %s or empty string, got %s\n", expected
, prop
);
6283 r
= MsiGetPropertyA(hpkg
, "FALCARIUS", prop
, &size
);
6284 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6285 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6288 r
= MsiGetPropertyA(hpkg
, "GALLIMIMUS", prop
, &size
);
6289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6290 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6293 r
= MsiGetPropertyA(hpkg
, "HAGRYPHUS", prop
, &size
);
6294 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6295 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6298 r
= MsiGetPropertyA(hpkg
, "IGUANODON", prop
, &size
);
6299 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6300 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6303 r
= MsiGetPropertyA(hpkg
, "JOBARIA", prop
, &size
);
6304 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6305 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6308 r
= MsiGetPropertyA(hpkg
, "KAKURU", prop
, &size
);
6309 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6310 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6313 r
= MsiGetPropertyA(hpkg
, "LABOCANIA", prop
, &size
);
6314 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6315 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6318 r
= MsiGetPropertyA(hpkg
, "MEGARAPTOR", prop
, &size
);
6319 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6321 lstrcpyA(expected
, CURR_DIR
);
6322 lstrcatA(expected
, "\\");
6323 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6324 "Expected %s or empty string, got %s\n", expected
, prop
);
6327 r
= MsiGetPropertyA(hpkg
, "NEOSODON", prop
, &size
);
6328 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6330 lstrcpyA(expected
, CURR_DIR
);
6331 lstrcatA(expected
, "\\neosodon\\");
6332 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6333 "Expected %s or empty string, got %s\n", expected
, prop
);
6336 r
= MsiGetPropertyA(hpkg
, "OLOROTITAN", prop
, &size
);
6337 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6338 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6341 r
= MsiGetPropertyA(hpkg
, "PANTYDRACO", prop
, &size
);
6342 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6343 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6345 MsiCloseHandle(hpkg
);
6346 DeleteFileA("abelisaurus");
6347 DeleteFileA("bactrosaurus");
6348 DeleteFileA("camelotia");
6349 DeleteFileA("diclonius");
6350 DeleteFileA("echinodon");
6351 DeleteFileA("falcarius");
6352 DeleteFileA("gallimimus");
6353 DeleteFileA("hagryphus");
6354 RemoveDirectoryA("iguanodon");
6355 RemoveDirectoryA("jobaria");
6356 RemoveDirectoryA("kakuru");
6357 RemoveDirectoryA("labocania");
6358 RemoveDirectoryA("megaraptor");
6359 RemoveDirectoryA("neosodon");
6360 RemoveDirectoryA("olorotitan");
6361 RemoveDirectoryA("pantydraco");
6362 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6363 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6364 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6365 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6366 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6367 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6368 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6369 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6370 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6371 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6372 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6373 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6374 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6375 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6376 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6377 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6378 DeleteFileA(msifile
);
6381 static void set_suminfo_prop(MSIHANDLE db
, DWORD prop
, DWORD val
)
6386 r
= MsiGetSummaryInformationA(db
, NULL
, 1, &summary
);
6387 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6389 r
= MsiSummaryInfoSetPropertyA(summary
, prop
, VT_I4
, val
, NULL
, NULL
);
6390 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6392 r
= MsiSummaryInfoPersist(summary
);
6393 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
6395 MsiCloseHandle(summary
);
6398 static void test_MsiGetSourcePath(void)
6400 MSIHANDLE hdb
, hpkg
;
6401 CHAR path
[MAX_PATH
];
6403 CHAR subsrc
[MAX_PATH
];
6404 CHAR sub2
[MAX_PATH
];
6408 lstrcpyA(cwd
, CURR_DIR
);
6409 lstrcatA(cwd
, "\\");
6411 lstrcpyA(subsrc
, cwd
);
6412 lstrcatA(subsrc
, "subsource");
6413 lstrcatA(subsrc
, "\\");
6415 lstrcpyA(sub2
, subsrc
);
6416 lstrcatA(sub2
, "sub2");
6417 lstrcatA(sub2
, "\\");
6419 /* uncompressed source */
6421 hdb
= create_package_db();
6422 ok( hdb
, "failed to create database\n");
6424 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
6426 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
6427 ok(r
== S_OK
, "failed\n");
6429 r
= add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6430 ok(r
== S_OK
, "failed\n");
6432 r
= add_directory_entry(hdb
, "'SubDir2', 'SubDir', 'sub2'");
6433 ok(r
== S_OK
, "failed\n");
6435 r
= MsiDatabaseCommit(hdb
);
6436 ok(r
== ERROR_SUCCESS
, "Failed to commit database\n");
6438 r
= package_from_db(hdb
, &hpkg
);
6439 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6441 skip("Not enough rights to perform tests\n");
6442 DeleteFileA(msifile
);
6445 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6447 MsiCloseHandle(hdb
);
6449 /* invalid database handle */
6451 lstrcpyA(path
, "kiwi");
6452 r
= MsiGetSourcePathA(-1, "TARGETDIR", path
, &size
);
6453 ok(r
== ERROR_INVALID_HANDLE
,
6454 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
6455 ok(!lstrcmpA(path
, "kiwi"),
6456 "Expected path to be unchanged, got \"%s\"\n", path
);
6457 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6461 lstrcpyA(path
, "kiwi");
6462 r
= MsiGetSourcePathA(hpkg
, NULL
, path
, &size
);
6463 ok(r
== ERROR_INVALID_PARAMETER
,
6464 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6465 ok(!lstrcmpA(path
, "kiwi"),
6466 "Expected path to be unchanged, got \"%s\"\n", path
);
6467 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6469 /* empty szFolder */
6471 lstrcpyA(path
, "kiwi");
6472 r
= MsiGetSourcePathA(hpkg
, "", path
, &size
);
6473 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6474 ok(!lstrcmpA(path
, "kiwi"),
6475 "Expected path to be unchanged, got \"%s\"\n", path
);
6476 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6480 lstrcpyA(path
, "kiwi");
6481 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6482 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6483 ok(!lstrcmpA(path
, "kiwi"),
6484 "Expected path to be unchanged, got \"%s\"\n", path
);
6485 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6488 lstrcpyA(path
, "kiwi");
6489 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6490 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6491 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6492 ok(size
== 0, "Expected 0, got %d\n", size
);
6495 lstrcpyA(path
, "kiwi");
6496 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6497 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6498 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6499 ok(size
== 0, "Expected 0, got %d\n", size
);
6503 lstrcpyA(path
, "kiwi");
6504 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6505 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6506 ok(!lstrcmpA(path
, "kiwi"),
6507 "Expected path to be unchanged, got \"%s\"\n", path
);
6508 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6512 lstrcpyA(path
, "kiwi");
6513 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6514 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6515 ok(!lstrcmpA(path
, "kiwi"),
6516 "Expected path to be unchanged, got \"%s\"\n", path
);
6517 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6519 /* source path does not exist, but the property exists */
6521 lstrcpyA(path
, "kiwi");
6522 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6523 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6524 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6525 ok(size
== 0, "Expected 0, got %d\n", size
);
6528 lstrcpyA(path
, "kiwi");
6529 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6530 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6531 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6532 ok(size
== 0, "Expected 0, got %d\n", size
);
6536 lstrcpyA(path
, "kiwi");
6537 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6538 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6539 ok(!lstrcmpA(path
, "kiwi"),
6540 "Expected path to be unchanged, got \"%s\"\n", path
);
6541 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6545 lstrcpyA(path
, "kiwi");
6546 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6547 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6548 ok(!lstrcmpA(path
, "kiwi"),
6549 "Expected path to be unchanged, got \"%s\"\n", path
);
6550 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6552 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6554 r
= MsiDoActionA(hpkg
, "CostInitialize");
6555 ok(r
== ERROR_SUCCESS
, "cost init failed\n");
6557 /* try TARGETDIR after CostInitialize */
6559 lstrcpyA(path
, "kiwi");
6560 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6561 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6562 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6563 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6565 /* try SourceDir after CostInitialize */
6567 lstrcpyA(path
, "kiwi");
6568 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6569 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6570 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6571 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6573 /* try SOURCEDIR after CostInitialize */
6575 lstrcpyA(path
, "kiwi");
6576 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6577 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6578 ok(!lstrcmpA(path
, "kiwi"),
6579 "Expected path to be unchanged, got \"%s\"\n", path
);
6580 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6582 /* source path does not exist, but the property exists */
6584 lstrcpyA(path
, "kiwi");
6585 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6586 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6587 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6588 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6591 lstrcpyA(path
, "kiwi");
6592 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6593 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6594 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6595 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6597 /* try SubDir after CostInitialize */
6599 lstrcpyA(path
, "kiwi");
6600 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6601 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6602 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6603 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6605 /* try SubDir2 after CostInitialize */
6607 lstrcpyA(path
, "kiwi");
6608 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6609 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6610 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6611 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6613 r
= MsiDoActionA(hpkg
, "ResolveSource");
6614 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6616 /* try TARGETDIR after ResolveSource */
6618 lstrcpyA(path
, "kiwi");
6619 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6620 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6621 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6622 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6624 /* try SourceDir after ResolveSource */
6626 lstrcpyA(path
, "kiwi");
6627 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6628 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6629 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6630 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6632 /* try SOURCEDIR after ResolveSource */
6634 lstrcpyA(path
, "kiwi");
6635 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6636 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6637 ok(!lstrcmpA(path
, "kiwi"),
6638 "Expected path to be unchanged, got \"%s\"\n", path
);
6639 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6641 /* source path does not exist, but the property exists */
6643 lstrcpyA(path
, "kiwi");
6644 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6645 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6646 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6647 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6650 lstrcpyA(path
, "kiwi");
6651 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6652 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6653 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6654 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6656 /* try SubDir after ResolveSource */
6658 lstrcpyA(path
, "kiwi");
6659 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6660 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6661 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6662 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6664 /* try SubDir2 after ResolveSource */
6666 lstrcpyA(path
, "kiwi");
6667 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6668 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6669 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6670 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6672 r
= MsiDoActionA(hpkg
, "FileCost");
6673 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6675 /* try TARGETDIR after FileCost */
6677 lstrcpyA(path
, "kiwi");
6678 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6679 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6680 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6681 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6683 /* try SourceDir after FileCost */
6685 lstrcpyA(path
, "kiwi");
6686 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6687 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6688 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6689 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6691 /* try SOURCEDIR after FileCost */
6693 lstrcpyA(path
, "kiwi");
6694 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6695 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6696 ok(!lstrcmpA(path
, "kiwi"),
6697 "Expected path to be unchanged, got \"%s\"\n", path
);
6698 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6700 /* source path does not exist, but the property exists */
6702 lstrcpyA(path
, "kiwi");
6703 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6704 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6705 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6706 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6709 lstrcpyA(path
, "kiwi");
6710 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6711 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6712 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6713 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6715 /* try SubDir after FileCost */
6717 lstrcpyA(path
, "kiwi");
6718 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6719 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6720 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6721 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6723 /* try SubDir2 after FileCost */
6725 lstrcpyA(path
, "kiwi");
6726 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6727 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6728 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6729 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6731 r
= MsiDoActionA(hpkg
, "CostFinalize");
6732 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6734 /* try TARGETDIR after CostFinalize */
6736 lstrcpyA(path
, "kiwi");
6737 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6738 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6739 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6740 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6742 /* try SourceDir after CostFinalize */
6744 lstrcpyA(path
, "kiwi");
6745 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6746 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6747 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6748 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6750 /* try SOURCEDIR after CostFinalize */
6752 lstrcpyA(path
, "kiwi");
6753 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6754 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6755 ok(!lstrcmpA(path
, "kiwi"),
6756 "Expected path to be unchanged, got \"%s\"\n", path
);
6757 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6759 /* source path does not exist, but the property exists */
6761 lstrcpyA(path
, "kiwi");
6762 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6763 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6764 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6765 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6768 lstrcpyA(path
, "kiwi");
6769 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6770 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6771 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6772 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6774 /* try SubDir after CostFinalize */
6776 lstrcpyA(path
, "kiwi");
6777 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6778 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6779 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6780 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6782 /* try SubDir2 after CostFinalize */
6784 lstrcpyA(path
, "kiwi");
6785 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6786 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6787 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6788 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6790 /* nonexistent directory */
6792 lstrcpyA(path
, "kiwi");
6793 r
= MsiGetSourcePathA(hpkg
, "IDontExist", path
, &size
);
6794 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6795 ok(!lstrcmpA(path
, "kiwi"),
6796 "Expected path to be unchanged, got \"%s\"\n", path
);
6797 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6799 /* NULL szPathBuf */
6801 r
= MsiGetSourcePathA(hpkg
, "SourceDir", NULL
, &size
);
6802 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6803 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6805 /* NULL pcchPathBuf */
6806 lstrcpyA(path
, "kiwi");
6807 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, NULL
);
6808 ok(r
== ERROR_INVALID_PARAMETER
,
6809 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6810 ok(!lstrcmpA(path
, "kiwi"),
6811 "Expected path to be unchanged, got \"%s\"\n", path
);
6813 /* pcchPathBuf is 0 */
6815 lstrcpyA(path
, "kiwi");
6816 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6817 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6818 ok(!lstrcmpA(path
, "kiwi"),
6819 "Expected path to be unchanged, got \"%s\"\n", path
);
6820 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6822 /* pcchPathBuf does not have room for NULL terminator */
6823 size
= lstrlenA(cwd
);
6824 lstrcpyA(path
, "kiwi");
6825 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6826 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6827 ok(!strncmp(path
, cwd
, lstrlenA(cwd
) - 1),
6828 "Expected path with no backslash, got \"%s\"\n", path
);
6829 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6831 /* pcchPathBuf has room for NULL terminator */
6832 size
= lstrlenA(cwd
) + 1;
6833 lstrcpyA(path
, "kiwi");
6834 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6835 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6836 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6837 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6839 /* remove property */
6840 r
= MsiSetPropertyA(hpkg
, "SourceDir", NULL
);
6841 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6843 /* try SourceDir again */
6845 lstrcpyA(path
, "kiwi");
6846 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6847 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6848 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6849 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6851 /* set property to a valid directory */
6852 r
= MsiSetPropertyA(hpkg
, "SOURCEDIR", cwd
);
6853 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6855 /* try SOURCEDIR again */
6857 lstrcpyA(path
, "kiwi");
6858 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6859 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6860 ok(!lstrcmpA(path
, "kiwi"),
6861 "Expected path to be unchanged, got \"%s\"\n", path
);
6862 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6864 MsiCloseHandle(hpkg
);
6866 /* compressed source */
6868 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
6869 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6871 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeCompressed
);
6873 r
= package_from_db(hdb
, &hpkg
);
6874 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6878 lstrcpyA(path
, "kiwi");
6879 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6880 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6881 ok(!lstrcmpA(path
, "kiwi"),
6882 "Expected path to be unchanged, got \"%s\"\n", path
);
6883 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6887 lstrcpyA(path
, "kiwi");
6888 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6889 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6890 ok(!lstrcmpA(path
, "kiwi"),
6891 "Expected path to be unchanged, got \"%s\"\n", path
);
6892 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6896 lstrcpyA(path
, "kiwi");
6897 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6898 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6899 ok(!lstrcmpA(path
, "kiwi"),
6900 "Expected path to be unchanged, got \"%s\"\n", path
);
6901 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6903 /* source path nor the property exist */
6905 lstrcpyA(path
, "kiwi");
6906 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6907 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6908 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6909 ok(size
== 0, "Expected 0, got %d\n", size
);
6912 lstrcpyA(path
, "kiwi");
6913 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6914 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6915 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6916 ok(size
== 0, "Expected 0, got %d\n", size
);
6920 lstrcpyA(path
, "kiwi");
6921 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6922 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6923 ok(!lstrcmpA(path
, "kiwi"),
6924 "Expected path to be unchanged, got \"%s\"\n", path
);
6925 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6929 lstrcpyA(path
, "kiwi");
6930 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6931 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6932 ok(!lstrcmpA(path
, "kiwi"),
6933 "Expected path to be unchanged, got \"%s\"\n", path
);
6934 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6936 r
= MsiDoActionA(hpkg
, "CostInitialize");
6937 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6939 /* try TARGETDIR after CostInitialize */
6941 lstrcpyA(path
, "kiwi");
6942 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6943 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6944 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6945 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6947 /* try SourceDir after CostInitialize */
6949 lstrcpyA(path
, "kiwi");
6950 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6951 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6952 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6953 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6955 /* try SOURCEDIR after CostInitialize */
6957 lstrcpyA(path
, "kiwi");
6958 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6961 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6962 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6963 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6966 /* source path does not exist, but the property exists */
6968 lstrcpyA(path
, "kiwi");
6969 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6970 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6971 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6972 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6975 lstrcpyA(path
, "kiwi");
6976 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6977 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6978 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6979 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6981 /* try SubDir after CostInitialize */
6983 lstrcpyA(path
, "kiwi");
6984 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6985 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6986 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6987 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6989 /* try SubDir2 after CostInitialize */
6991 lstrcpyA(path
, "kiwi");
6992 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6993 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6994 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6995 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6997 r
= MsiDoActionA(hpkg
, "ResolveSource");
6998 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7000 /* try TARGETDIR after ResolveSource */
7002 lstrcpyA(path
, "kiwi");
7003 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7004 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7005 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7006 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7008 /* try SourceDir after ResolveSource */
7010 lstrcpyA(path
, "kiwi");
7011 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7012 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7013 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7014 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7016 /* try SOURCEDIR after ResolveSource */
7018 lstrcpyA(path
, "kiwi");
7019 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7023 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7024 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7027 /* source path and the property exist */
7029 lstrcpyA(path
, "kiwi");
7030 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7031 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7032 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7033 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7036 lstrcpyA(path
, "kiwi");
7037 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7038 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7039 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7040 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7042 /* try SubDir after ResolveSource */
7044 lstrcpyA(path
, "kiwi");
7045 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7046 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7047 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7048 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7050 /* try SubDir2 after ResolveSource */
7052 lstrcpyA(path
, "kiwi");
7053 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7054 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7055 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7056 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7058 r
= MsiDoActionA(hpkg
, "FileCost");
7059 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7061 /* try TARGETDIR after CostFinalize */
7063 lstrcpyA(path
, "kiwi");
7064 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7065 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7066 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7067 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7069 /* try SourceDir after CostFinalize */
7071 lstrcpyA(path
, "kiwi");
7072 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7073 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7074 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7075 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7077 /* try SOURCEDIR after CostFinalize */
7079 lstrcpyA(path
, "kiwi");
7080 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7083 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7084 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7085 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7088 /* source path and the property exist */
7090 lstrcpyA(path
, "kiwi");
7091 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7092 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7093 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7094 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7097 lstrcpyA(path
, "kiwi");
7098 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7099 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7100 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7101 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7103 /* try SubDir after CostFinalize */
7105 lstrcpyA(path
, "kiwi");
7106 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7107 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7108 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7109 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7111 /* try SubDir2 after CostFinalize */
7113 lstrcpyA(path
, "kiwi");
7114 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7115 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7116 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7117 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7119 r
= MsiDoActionA(hpkg
, "CostFinalize");
7120 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7122 /* try TARGETDIR after CostFinalize */
7124 lstrcpyA(path
, "kiwi");
7125 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7126 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7127 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7128 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7130 /* try SourceDir after CostFinalize */
7132 lstrcpyA(path
, "kiwi");
7133 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7134 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7135 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7136 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7138 /* try SOURCEDIR after CostFinalize */
7140 lstrcpyA(path
, "kiwi");
7141 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7144 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7145 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7146 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7149 /* source path and the property exist */
7151 lstrcpyA(path
, "kiwi");
7152 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7153 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7154 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7155 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7158 lstrcpyA(path
, "kiwi");
7159 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7160 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7161 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7162 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7164 /* try SubDir after CostFinalize */
7166 lstrcpyA(path
, "kiwi");
7167 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7168 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7169 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7170 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7172 /* try SubDir2 after CostFinalize */
7174 lstrcpyA(path
, "kiwi");
7175 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7176 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7177 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7178 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7180 MsiCloseHandle(hpkg
);
7181 DeleteFileA(msifile
);
7184 static void test_shortlongsource(void)
7186 MSIHANDLE hdb
, hpkg
;
7187 CHAR path
[MAX_PATH
];
7189 CHAR subsrc
[MAX_PATH
];
7193 lstrcpyA(cwd
, CURR_DIR
);
7194 lstrcatA(cwd
, "\\");
7196 lstrcpyA(subsrc
, cwd
);
7197 lstrcatA(subsrc
, "long");
7198 lstrcatA(subsrc
, "\\");
7200 /* long file names */
7202 hdb
= create_package_db();
7203 ok( hdb
, "failed to create database\n");
7205 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
7207 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7208 ok(r
== S_OK
, "failed\n");
7210 r
= add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'short|long'");
7211 ok(r
== S_OK
, "failed\n");
7213 /* CostInitialize:short */
7214 r
= add_directory_entry(hdb
, "'SubDir2', 'TARGETDIR', 'one|two'");
7215 ok(r
== S_OK
, "failed\n");
7217 /* CostInitialize:long */
7218 r
= add_directory_entry(hdb
, "'SubDir3', 'TARGETDIR', 'three|four'");
7219 ok(r
== S_OK
, "failed\n");
7221 /* FileCost:short */
7222 r
= add_directory_entry(hdb
, "'SubDir4', 'TARGETDIR', 'five|six'");
7223 ok(r
== S_OK
, "failed\n");
7226 r
= add_directory_entry(hdb
, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7227 ok(r
== S_OK
, "failed\n");
7229 /* CostFinalize:short */
7230 r
= add_directory_entry(hdb
, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7231 ok(r
== S_OK
, "failed\n");
7233 /* CostFinalize:long */
7234 r
= add_directory_entry(hdb
, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7235 ok(r
== S_OK
, "failed\n");
7237 MsiDatabaseCommit(hdb
);
7239 r
= package_from_db(hdb
, &hpkg
);
7240 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7242 skip("Not enough rights to perform tests\n");
7243 DeleteFileA(msifile
);
7246 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7248 MsiCloseHandle(hdb
);
7250 CreateDirectoryA("one", NULL
);
7251 CreateDirectoryA("four", NULL
);
7253 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7255 r
= MsiDoActionA(hpkg
, "CostInitialize");
7256 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7258 CreateDirectoryA("five", NULL
);
7259 CreateDirectoryA("eight", NULL
);
7261 r
= MsiDoActionA(hpkg
, "FileCost");
7262 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7264 CreateDirectoryA("nine", NULL
);
7265 CreateDirectoryA("twelve", NULL
);
7267 r
= MsiDoActionA(hpkg
, "CostFinalize");
7268 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7270 /* neither short nor long source directories exist */
7272 lstrcpyA(path
, "kiwi");
7273 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7274 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7275 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7276 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7278 CreateDirectoryA("short", NULL
);
7280 /* short source directory exists */
7282 lstrcpyA(path
, "kiwi");
7283 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7284 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7285 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7286 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7288 CreateDirectoryA("long", NULL
);
7290 /* both short and long source directories exist */
7292 lstrcpyA(path
, "kiwi");
7293 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7294 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7295 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7296 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7298 lstrcpyA(subsrc
, cwd
);
7299 lstrcatA(subsrc
, "two");
7300 lstrcatA(subsrc
, "\\");
7302 /* short dir exists before CostInitialize */
7304 lstrcpyA(path
, "kiwi");
7305 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7307 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7308 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7310 lstrcpyA(subsrc
, cwd
);
7311 lstrcatA(subsrc
, "four");
7312 lstrcatA(subsrc
, "\\");
7314 /* long dir exists before CostInitialize */
7316 lstrcpyA(path
, "kiwi");
7317 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7318 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7319 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7320 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7322 lstrcpyA(subsrc
, cwd
);
7323 lstrcatA(subsrc
, "six");
7324 lstrcatA(subsrc
, "\\");
7326 /* short dir exists before FileCost */
7328 lstrcpyA(path
, "kiwi");
7329 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7330 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7331 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7332 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7334 lstrcpyA(subsrc
, cwd
);
7335 lstrcatA(subsrc
, "eight");
7336 lstrcatA(subsrc
, "\\");
7338 /* long dir exists before FileCost */
7340 lstrcpyA(path
, "kiwi");
7341 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7342 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7343 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7344 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7346 lstrcpyA(subsrc
, cwd
);
7347 lstrcatA(subsrc
, "ten");
7348 lstrcatA(subsrc
, "\\");
7350 /* short dir exists before CostFinalize */
7352 lstrcpyA(path
, "kiwi");
7353 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7354 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7355 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7356 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7358 lstrcpyA(subsrc
, cwd
);
7359 lstrcatA(subsrc
, "twelve");
7360 lstrcatA(subsrc
, "\\");
7362 /* long dir exists before CostFinalize */
7364 lstrcpyA(path
, "kiwi");
7365 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7366 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7367 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7368 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7370 MsiCloseHandle(hpkg
);
7371 RemoveDirectoryA("short");
7372 RemoveDirectoryA("long");
7373 RemoveDirectoryA("one");
7374 RemoveDirectoryA("four");
7375 RemoveDirectoryA("five");
7376 RemoveDirectoryA("eight");
7377 RemoveDirectoryA("nine");
7378 RemoveDirectoryA("twelve");
7380 /* short file names */
7382 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
7383 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7385 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeSFN
);
7387 r
= package_from_db(hdb
, &hpkg
);
7388 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7390 MsiCloseHandle(hdb
);
7392 CreateDirectoryA("one", NULL
);
7393 CreateDirectoryA("four", NULL
);
7395 r
= MsiDoActionA(hpkg
, "CostInitialize");
7396 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7398 CreateDirectoryA("five", NULL
);
7399 CreateDirectoryA("eight", NULL
);
7401 r
= MsiDoActionA(hpkg
, "FileCost");
7402 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7404 CreateDirectoryA("nine", NULL
);
7405 CreateDirectoryA("twelve", NULL
);
7407 r
= MsiDoActionA(hpkg
, "CostFinalize");
7408 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7410 lstrcpyA(subsrc
, cwd
);
7411 lstrcatA(subsrc
, "short");
7412 lstrcatA(subsrc
, "\\");
7414 /* neither short nor long source directories exist */
7416 lstrcpyA(path
, "kiwi");
7417 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7418 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7419 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7420 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7422 CreateDirectoryA("short", NULL
);
7424 /* short source directory exists */
7426 lstrcpyA(path
, "kiwi");
7427 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7428 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7429 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7430 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7432 CreateDirectoryA("long", NULL
);
7434 /* both short and long source directories exist */
7436 lstrcpyA(path
, "kiwi");
7437 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7439 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7440 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7442 lstrcpyA(subsrc
, cwd
);
7443 lstrcatA(subsrc
, "one");
7444 lstrcatA(subsrc
, "\\");
7446 /* short dir exists before CostInitialize */
7448 lstrcpyA(path
, "kiwi");
7449 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7450 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7451 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7452 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7454 lstrcpyA(subsrc
, cwd
);
7455 lstrcatA(subsrc
, "three");
7456 lstrcatA(subsrc
, "\\");
7458 /* long dir exists before CostInitialize */
7460 lstrcpyA(path
, "kiwi");
7461 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7462 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7463 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7464 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7466 lstrcpyA(subsrc
, cwd
);
7467 lstrcatA(subsrc
, "five");
7468 lstrcatA(subsrc
, "\\");
7470 /* short dir exists before FileCost */
7472 lstrcpyA(path
, "kiwi");
7473 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7474 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7475 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7476 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7478 lstrcpyA(subsrc
, cwd
);
7479 lstrcatA(subsrc
, "seven");
7480 lstrcatA(subsrc
, "\\");
7482 /* long dir exists before FileCost */
7484 lstrcpyA(path
, "kiwi");
7485 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7486 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7487 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7488 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7490 lstrcpyA(subsrc
, cwd
);
7491 lstrcatA(subsrc
, "nine");
7492 lstrcatA(subsrc
, "\\");
7494 /* short dir exists before CostFinalize */
7496 lstrcpyA(path
, "kiwi");
7497 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7498 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7499 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7500 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7502 lstrcpyA(subsrc
, cwd
);
7503 lstrcatA(subsrc
, "eleven");
7504 lstrcatA(subsrc
, "\\");
7506 /* long dir exists before CostFinalize */
7508 lstrcpyA(path
, "kiwi");
7509 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7510 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7511 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7512 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7514 MsiCloseHandle(hpkg
);
7515 RemoveDirectoryA("short");
7516 RemoveDirectoryA("long");
7517 RemoveDirectoryA("one");
7518 RemoveDirectoryA("four");
7519 RemoveDirectoryA("five");
7520 RemoveDirectoryA("eight");
7521 RemoveDirectoryA("nine");
7522 RemoveDirectoryA("twelve");
7523 DeleteFileA(msifile
);
7526 static void test_sourcedir(void)
7528 MSIHANDLE hdb
, hpkg
;
7530 CHAR path
[MAX_PATH
];
7532 CHAR subsrc
[MAX_PATH
];
7536 lstrcpyA(cwd
, CURR_DIR
);
7537 lstrcatA(cwd
, "\\");
7539 lstrcpyA(subsrc
, cwd
);
7540 lstrcatA(subsrc
, "long");
7541 lstrcatA(subsrc
, "\\");
7543 hdb
= create_package_db();
7544 ok( hdb
, "failed to create database\n");
7546 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7547 ok(r
== S_OK
, "failed\n");
7549 sprintf(package
, "#%u", hdb
);
7550 r
= MsiOpenPackageA(package
, &hpkg
);
7551 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7553 skip("Not enough rights to perform tests\n");
7556 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7558 /* properties only */
7560 /* SourceDir prop */
7562 lstrcpyA(path
, "kiwi");
7563 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7564 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7565 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7566 ok(size
== 0, "Expected 0, got %d\n", size
);
7568 /* SOURCEDIR prop */
7570 lstrcpyA(path
, "kiwi");
7571 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7572 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7573 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7574 ok(size
== 0, "Expected 0, got %d\n", size
);
7576 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7578 r
= MsiDoActionA(hpkg
, "CostInitialize");
7579 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7581 /* SourceDir after CostInitialize */
7583 lstrcpyA(path
, "kiwi");
7584 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7585 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7586 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7587 ok(size
== 0, "Expected 0, got %d\n", size
);
7589 /* SOURCEDIR after CostInitialize */
7591 lstrcpyA(path
, "kiwi");
7592 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7593 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7594 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7595 ok(size
== 0, "Expected 0, got %d\n", size
);
7597 r
= MsiDoActionA(hpkg
, "FileCost");
7598 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7600 /* SourceDir after FileCost */
7602 lstrcpyA(path
, "kiwi");
7603 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7604 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7605 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7606 ok(size
== 0, "Expected 0, got %d\n", size
);
7608 /* SOURCEDIR after FileCost */
7610 lstrcpyA(path
, "kiwi");
7611 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7612 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7613 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7614 ok(size
== 0, "Expected 0, got %d\n", size
);
7616 r
= MsiDoActionA(hpkg
, "CostFinalize");
7617 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7619 /* SourceDir after CostFinalize */
7621 lstrcpyA(path
, "kiwi");
7622 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7623 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7624 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7625 ok(size
== 0, "Expected 0, got %d\n", size
);
7627 /* SOURCEDIR after CostFinalize */
7629 lstrcpyA(path
, "kiwi");
7630 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7631 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7632 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7633 ok(size
== 0, "Expected 0, got %d\n", size
);
7636 lstrcpyA(path
, "kiwi");
7637 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7638 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7639 ok(!lstrcmpA(path
, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path
);
7640 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
7642 /* SOURCEDIR after calling MsiGetSourcePath */
7644 lstrcpyA(path
, "kiwi");
7645 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7646 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7648 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7649 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7652 r
= MsiDoActionA(hpkg
, "ResolveSource");
7653 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7655 /* SourceDir after ResolveSource */
7657 lstrcpyA(path
, "kiwi");
7658 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7659 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7660 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7661 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7663 /* SOURCEDIR after ResolveSource */
7665 lstrcpyA(path
, "kiwi");
7666 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7667 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7668 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7669 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7673 lstrcpyA(path
, "kiwi");
7674 r
= MsiGetPropertyA(hpkg
, "SoUrCeDiR", path
, &size
);
7675 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7676 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7677 ok(size
== 0, "Expected 0, got %d\n", size
);
7679 MsiCloseHandle(hpkg
);
7681 /* reset the package state */
7682 sprintf(package
, "#%i", hdb
);
7683 r
= MsiOpenPackageA(package
, &hpkg
);
7684 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7686 /* test how MsiGetSourcePath affects the properties */
7688 /* SourceDir prop */
7690 lstrcpyA(path
, "kiwi");
7691 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7692 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7695 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7696 ok(size
== 0, "Expected 0, got %d\n", size
);
7700 lstrcpyA(path
, "kiwi");
7701 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7702 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7703 ok(!lstrcmpA(path
, "kiwi"),
7704 "Expected path to be unchanged, got \"%s\"\n", path
);
7705 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7707 /* SourceDir after MsiGetSourcePath */
7709 lstrcpyA(path
, "kiwi");
7710 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7711 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7714 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7715 ok(size
== 0, "Expected 0, got %d\n", size
);
7718 /* SOURCEDIR prop */
7720 lstrcpyA(path
, "kiwi");
7721 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7722 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7725 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7726 ok(size
== 0, "Expected 0, got %d\n", size
);
7730 lstrcpyA(path
, "kiwi");
7731 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7732 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7733 ok(!lstrcmpA(path
, "kiwi"),
7734 "Expected path to be unchanged, got \"%s\"\n", path
);
7735 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7737 /* SOURCEDIR prop after MsiGetSourcePath */
7739 lstrcpyA(path
, "kiwi");
7740 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7741 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7744 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7745 ok(size
== 0, "Expected 0, got %d\n", size
);
7748 r
= MsiDoActionA(hpkg
, "CostInitialize");
7749 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7751 /* SourceDir after CostInitialize */
7753 lstrcpyA(path
, "kiwi");
7754 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7755 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7758 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7759 ok(size
== 0, "Expected 0, got %d\n", size
);
7763 lstrcpyA(path
, "kiwi");
7764 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7765 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7766 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7767 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7769 /* SourceDir after MsiGetSourcePath */
7771 lstrcpyA(path
, "kiwi");
7772 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7773 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7774 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7775 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7777 /* SOURCEDIR after CostInitialize */
7779 lstrcpyA(path
, "kiwi");
7780 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7781 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7782 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7783 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7785 /* SOURCEDIR source path still does not exist */
7787 lstrcpyA(path
, "kiwi");
7788 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7789 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7790 ok(!lstrcmpA(path
, "kiwi"),
7791 "Expected path to be unchanged, got \"%s\"\n", path
);
7792 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7794 r
= MsiDoActionA(hpkg
, "FileCost");
7795 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7797 /* SourceDir after FileCost */
7799 lstrcpyA(path
, "kiwi");
7800 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7801 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7802 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7803 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7805 /* SOURCEDIR after FileCost */
7807 lstrcpyA(path
, "kiwi");
7808 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7809 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7810 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7811 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7813 /* SOURCEDIR source path still does not exist */
7815 lstrcpyA(path
, "kiwi");
7816 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7817 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7818 ok(!lstrcmpA(path
, "kiwi"),
7819 "Expected path to be unchanged, got \"%s\"\n", path
);
7820 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7822 r
= MsiDoActionA(hpkg
, "CostFinalize");
7823 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7825 /* SourceDir after CostFinalize */
7827 lstrcpyA(path
, "kiwi");
7828 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7829 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7830 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7831 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7833 /* SOURCEDIR after CostFinalize */
7835 lstrcpyA(path
, "kiwi");
7836 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7837 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7838 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7839 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7841 /* SOURCEDIR source path still does not exist */
7843 lstrcpyA(path
, "kiwi");
7844 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7845 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7846 ok(!lstrcmpA(path
, "kiwi"),
7847 "Expected path to be unchanged, got \"%s\"\n", path
);
7848 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7850 r
= MsiDoActionA(hpkg
, "ResolveSource");
7851 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7853 /* SourceDir after ResolveSource */
7855 lstrcpyA(path
, "kiwi");
7856 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7857 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7858 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7859 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7861 /* SOURCEDIR after ResolveSource */
7863 lstrcpyA(path
, "kiwi");
7864 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7865 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7866 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7867 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7869 /* SOURCEDIR source path still does not exist */
7871 lstrcpyA(path
, "kiwi");
7872 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7873 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7874 ok(!lstrcmpA(path
, "kiwi"),
7875 "Expected path to be unchanged, got \"%s\"\n", path
);
7876 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7878 MsiCloseHandle(hpkg
);
7881 MsiCloseHandle(hdb
);
7882 DeleteFileA(msifile
);
7892 static const struct access_res create
[16] =
7894 { TRUE
, ERROR_SUCCESS
, TRUE
},
7895 { TRUE
, ERROR_SUCCESS
, TRUE
},
7896 { TRUE
, ERROR_SUCCESS
, FALSE
},
7897 { TRUE
, ERROR_SUCCESS
, FALSE
},
7898 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7899 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7900 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7901 { TRUE
, ERROR_SUCCESS
, FALSE
},
7902 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7903 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7904 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7905 { TRUE
, ERROR_SUCCESS
, TRUE
},
7906 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7907 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7908 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7909 { TRUE
, ERROR_SUCCESS
, TRUE
}
7912 static const struct access_res create_commit
[16] =
7914 { TRUE
, ERROR_SUCCESS
, TRUE
},
7915 { TRUE
, ERROR_SUCCESS
, TRUE
},
7916 { TRUE
, ERROR_SUCCESS
, FALSE
},
7917 { TRUE
, ERROR_SUCCESS
, FALSE
},
7918 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7919 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7920 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7921 { TRUE
, ERROR_SUCCESS
, FALSE
},
7922 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7923 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7924 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7925 { TRUE
, ERROR_SUCCESS
, TRUE
},
7926 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7927 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7928 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7929 { TRUE
, ERROR_SUCCESS
, TRUE
}
7932 static const struct access_res create_close
[16] =
7934 { TRUE
, ERROR_SUCCESS
, FALSE
},
7935 { TRUE
, ERROR_SUCCESS
, FALSE
},
7936 { TRUE
, ERROR_SUCCESS
, FALSE
},
7937 { TRUE
, ERROR_SUCCESS
, FALSE
},
7938 { TRUE
, ERROR_SUCCESS
, FALSE
},
7939 { TRUE
, ERROR_SUCCESS
, FALSE
},
7940 { TRUE
, ERROR_SUCCESS
, FALSE
},
7941 { TRUE
, ERROR_SUCCESS
, FALSE
},
7942 { TRUE
, ERROR_SUCCESS
, FALSE
},
7943 { TRUE
, ERROR_SUCCESS
, FALSE
},
7944 { TRUE
, ERROR_SUCCESS
, FALSE
},
7945 { TRUE
, ERROR_SUCCESS
, FALSE
},
7946 { TRUE
, ERROR_SUCCESS
, FALSE
},
7947 { TRUE
, ERROR_SUCCESS
, FALSE
},
7948 { TRUE
, ERROR_SUCCESS
, FALSE
},
7949 { TRUE
, ERROR_SUCCESS
}
7952 static void _test_file_access(LPCSTR file
, const struct access_res
*ares
, DWORD line
)
7954 DWORD access
= 0, share
= 0;
7959 for (i
= 0; i
< 4; i
++)
7961 if (i
== 0) access
= 0;
7962 if (i
== 1) access
= GENERIC_READ
;
7963 if (i
== 2) access
= GENERIC_WRITE
;
7964 if (i
== 3) access
= GENERIC_READ
| GENERIC_WRITE
;
7966 for (j
= 0; j
< 4; j
++)
7968 if (ares
[idx
].ignore
)
7971 if (j
== 0) share
= 0;
7972 if (j
== 1) share
= FILE_SHARE_READ
;
7973 if (j
== 2) share
= FILE_SHARE_WRITE
;
7974 if (j
== 3) share
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
7976 SetLastError(0xdeadbeef);
7977 hfile
= CreateFileA(file
, access
, share
, NULL
, OPEN_EXISTING
,
7978 FILE_ATTRIBUTE_NORMAL
, 0);
7979 lasterr
= GetLastError();
7981 ok((hfile
!= INVALID_HANDLE_VALUE
) == ares
[idx
].gothandle
,
7982 "(%d, handle, %d): Expected %d, got %d\n",
7983 line
, idx
, ares
[idx
].gothandle
,
7984 (hfile
!= INVALID_HANDLE_VALUE
));
7986 ok(lasterr
== ares
[idx
].lasterr
, "(%d, lasterr, %d): Expected %d, got %d\n",
7987 line
, idx
, ares
[idx
].lasterr
, lasterr
);
7995 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
7997 static void test_access(void)
8002 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
8003 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8005 test_file_access(msifile
, create
);
8007 r
= MsiDatabaseCommit(hdb
);
8008 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8010 test_file_access(msifile
, create_commit
);
8011 MsiCloseHandle(hdb
);
8013 test_file_access(msifile
, create_close
);
8014 DeleteFileA(msifile
);
8016 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATEDIRECT
, &hdb
);
8017 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8019 test_file_access(msifile
, create
);
8021 r
= MsiDatabaseCommit(hdb
);
8022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8024 test_file_access(msifile
, create_commit
);
8025 MsiCloseHandle(hdb
);
8027 test_file_access(msifile
, create_close
);
8028 DeleteFileA(msifile
);
8031 static void test_emptypackage(void)
8033 MSIHANDLE hpkg
= 0, hdb
= 0, hsuminfo
= 0;
8034 MSIHANDLE hview
= 0, hrec
= 0;
8035 MSICONDITION condition
;
8036 CHAR buffer
[MAX_PATH
];
8040 r
= MsiOpenPackageA("", &hpkg
);
8041 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8043 skip("Not enough rights to perform tests\n");
8048 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8051 hdb
= MsiGetActiveDatabase(hpkg
);
8054 ok(hdb
!= 0, "Expected a valid database handle\n");
8057 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Tables`", &hview
);
8060 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8062 r
= MsiViewExecute(hview
, 0);
8065 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8068 r
= MsiViewFetch(hview
, &hrec
);
8071 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8076 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
8079 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8080 ok(!lstrcmpA(buffer
, "_Property"),
8081 "Expected \"_Property\", got \"%s\"\n", buffer
);
8084 MsiCloseHandle(hrec
);
8086 r
= MsiViewFetch(hview
, &hrec
);
8089 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8093 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
8096 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8097 ok(!lstrcmpA(buffer
, "#_FolderCache"),
8098 "Expected \"_Property\", got \"%s\"\n", buffer
);
8101 MsiCloseHandle(hrec
);
8102 MsiViewClose(hview
);
8103 MsiCloseHandle(hview
);
8105 condition
= MsiDatabaseIsTablePersistentA(hdb
, "_Property");
8108 ok(condition
== MSICONDITION_FALSE
,
8109 "Expected MSICONDITION_FALSE, got %d\n", condition
);
8112 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
8115 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8117 r
= MsiViewExecute(hview
, 0);
8120 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8123 /* _Property table is not empty */
8124 r
= MsiViewFetch(hview
, &hrec
);
8127 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8130 MsiCloseHandle(hrec
);
8131 MsiViewClose(hview
);
8132 MsiCloseHandle(hview
);
8134 condition
= MsiDatabaseIsTablePersistentA(hdb
, "#_FolderCache");
8137 ok(condition
== MSICONDITION_FALSE
,
8138 "Expected MSICONDITION_FALSE, got %d\n", condition
);
8141 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `#_FolderCache`", &hview
);
8144 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8146 r
= MsiViewExecute(hview
, 0);
8149 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8152 /* #_FolderCache is not empty */
8153 r
= MsiViewFetch(hview
, &hrec
);
8156 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8159 MsiCloseHandle(hrec
);
8160 MsiViewClose(hview
);
8161 MsiCloseHandle(hview
);
8163 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Streams`", &hview
);
8166 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8167 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8170 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Storages`", &hview
);
8173 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8174 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8177 r
= MsiGetSummaryInformationA(hdb
, NULL
, 0, &hsuminfo
);
8180 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
8181 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
8184 MsiCloseHandle(hsuminfo
);
8186 r
= MsiDatabaseCommit(hdb
);
8189 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8192 MsiCloseHandle(hdb
);
8193 MsiCloseHandle(hpkg
);
8196 static void test_MsiGetProductProperty(void)
8198 MSIHANDLE hprod
, hdb
;
8200 CHAR path
[MAX_PATH
];
8201 CHAR query
[MAX_PATH
];
8202 CHAR keypath
[MAX_PATH
*2];
8203 CHAR prodcode
[MAX_PATH
];
8204 CHAR prod_squashed
[MAX_PATH
];
8205 HKEY prodkey
, userkey
, props
;
8209 REGSAM access
= KEY_ALL_ACCESS
;
8211 GetCurrentDirectoryA(MAX_PATH
, path
);
8212 lstrcatA(path
, "\\");
8214 create_test_guid(prodcode
, prod_squashed
);
8217 access
|= KEY_WOW64_64KEY
;
8219 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
8220 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8222 r
= MsiDatabaseCommit(hdb
);
8223 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8225 r
= set_summary_info(hdb
);
8226 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8229 "CREATE TABLE `Directory` ( "
8230 "`Directory` CHAR(255) NOT NULL, "
8231 "`Directory_Parent` CHAR(255), "
8232 "`DefaultDir` CHAR(255) NOT NULL "
8233 "PRIMARY KEY `Directory`)");
8234 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8237 "CREATE TABLE `Property` ( "
8238 "`Property` CHAR(72) NOT NULL, "
8239 "`Value` CHAR(255) "
8240 "PRIMARY KEY `Property`)");
8241 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8243 sprintf(query
, "INSERT INTO `Property` "
8244 "(`Property`, `Value`) "
8245 "VALUES( 'ProductCode', '%s' )", prodcode
);
8246 r
= run_query(hdb
, query
);
8247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8249 r
= MsiDatabaseCommit(hdb
);
8250 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8252 MsiCloseHandle(hdb
);
8254 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
8255 lstrcatA(keypath
, prod_squashed
);
8257 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8258 if (res
== ERROR_ACCESS_DENIED
)
8260 skip("Not enough rights to perform tests\n");
8261 DeleteFileA(msifile
);
8264 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8266 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8267 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
8268 lstrcatA(keypath
, prod_squashed
);
8270 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8271 if (res
== ERROR_ACCESS_DENIED
)
8273 skip("Not enough rights to perform tests\n");
8274 RegDeleteKeyA(prodkey
, "");
8275 RegCloseKey(prodkey
);
8278 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8280 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8281 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8283 lstrcpyA(val
, path
);
8284 lstrcatA(val
, "\\");
8285 lstrcatA(val
, msifile
);
8286 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
8287 (const BYTE
*)val
, lstrlenA(val
) + 1);
8288 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8291 r
= MsiOpenProductA(prodcode
, &hprod
);
8292 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8293 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8295 /* hProduct is invalid */
8297 lstrcpyA(val
, "apple");
8298 r
= MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val
, &size
);
8299 ok(r
== ERROR_INVALID_HANDLE
,
8300 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8301 ok(!lstrcmpA(val
, "apple"),
8302 "Expected val to be unchanged, got \"%s\"\n", val
);
8303 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8305 /* szProperty is NULL */
8307 lstrcpyA(val
, "apple");
8308 r
= MsiGetProductPropertyA(hprod
, NULL
, val
, &size
);
8309 ok(r
== ERROR_INVALID_PARAMETER
,
8310 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8311 ok(!lstrcmpA(val
, "apple"),
8312 "Expected val to be unchanged, got \"%s\"\n", val
);
8313 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8315 /* szProperty is empty */
8317 lstrcpyA(val
, "apple");
8318 r
= MsiGetProductPropertyA(hprod
, "", val
, &size
);
8319 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8320 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8321 ok(size
== 0, "Expected 0, got %d\n", size
);
8323 /* get the property */
8325 lstrcpyA(val
, "apple");
8326 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8327 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8328 ok(!lstrcmpA(val
, prodcode
),
8329 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8330 ok(size
== lstrlenA(prodcode
),
8331 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8333 /* lpValueBuf is NULL */
8335 r
= MsiGetProductPropertyA(hprod
, "ProductCode", NULL
, &size
);
8336 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8337 ok(size
== lstrlenA(prodcode
),
8338 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8340 /* pcchValueBuf is NULL */
8341 lstrcpyA(val
, "apple");
8342 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, NULL
);
8343 ok(r
== ERROR_INVALID_PARAMETER
,
8344 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8345 ok(!lstrcmpA(val
, "apple"),
8346 "Expected val to be unchanged, got \"%s\"\n", val
);
8347 ok(size
== lstrlenA(prodcode
),
8348 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8350 /* pcchValueBuf is too small */
8352 lstrcpyA(val
, "apple");
8353 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8354 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8355 ok(!strncmp(val
, prodcode
, 3),
8356 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8357 ok(size
== lstrlenA(prodcode
),
8358 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8360 /* pcchValueBuf does not leave room for NULL terminator */
8361 size
= lstrlenA(prodcode
);
8362 lstrcpyA(val
, "apple");
8363 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8364 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8365 ok(!strncmp(val
, prodcode
, lstrlenA(prodcode
) - 1),
8366 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8367 ok(size
== lstrlenA(prodcode
),
8368 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8370 /* pcchValueBuf has enough room for NULL terminator */
8371 size
= lstrlenA(prodcode
) + 1;
8372 lstrcpyA(val
, "apple");
8373 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8374 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8375 ok(!lstrcmpA(val
, prodcode
),
8376 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8377 ok(size
== lstrlenA(prodcode
),
8378 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8380 /* nonexistent property */
8382 lstrcpyA(val
, "apple");
8383 r
= MsiGetProductPropertyA(hprod
, "IDontExist", val
, &size
);
8384 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8385 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8386 ok(size
== 0, "Expected 0, got %d\n", size
);
8388 r
= MsiSetPropertyA(hprod
, "NewProperty", "value");
8389 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8391 /* non-product property set */
8393 lstrcpyA(val
, "apple");
8394 r
= MsiGetProductPropertyA(hprod
, "NewProperty", val
, &size
);
8395 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8396 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8397 ok(size
== 0, "Expected 0, got %d\n", size
);
8399 r
= MsiSetPropertyA(hprod
, "ProductCode", "value");
8400 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8402 /* non-product property that is also a product property set */
8404 lstrcpyA(val
, "apple");
8405 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8406 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8407 ok(!lstrcmpA(val
, prodcode
),
8408 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8409 ok(size
== lstrlenA(prodcode
),
8410 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8412 MsiCloseHandle(hprod
);
8414 RegDeleteValueA(props
, "LocalPackage");
8415 delete_key(props
, "", access
);
8417 delete_key(userkey
, "", access
);
8418 RegCloseKey(userkey
);
8419 delete_key(prodkey
, "", access
);
8420 RegCloseKey(prodkey
);
8421 DeleteFileA(msifile
);
8424 static void test_MsiSetProperty(void)
8426 MSIHANDLE hpkg
, hdb
, hrec
;
8432 r
= package_from_db(create_package_db(), &hpkg
);
8433 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8435 skip("Not enough rights to perform tests\n");
8436 DeleteFileA(msifile
);
8439 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
8441 /* invalid hInstall */
8442 r
= MsiSetPropertyA(0, "Prop", "Val");
8443 ok(r
== ERROR_INVALID_HANDLE
,
8444 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8446 /* invalid hInstall */
8447 r
= MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8448 ok(r
== ERROR_INVALID_HANDLE
,
8449 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8451 /* szName is NULL */
8452 r
= MsiSetPropertyA(hpkg
, NULL
, "Val");
8453 ok(r
== ERROR_INVALID_PARAMETER
,
8454 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8456 /* both szName and szValue are NULL */
8457 r
= MsiSetPropertyA(hpkg
, NULL
, NULL
);
8458 ok(r
== ERROR_INVALID_PARAMETER
,
8459 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8461 /* szName is empty */
8462 r
= MsiSetPropertyA(hpkg
, "", "Val");
8463 ok(r
== ERROR_FUNCTION_FAILED
,
8464 "Expected ERROR_FUNCTION_FAILED, got %d\n", r
);
8466 /* szName is empty and szValue is NULL */
8467 r
= MsiSetPropertyA(hpkg
, "", NULL
);
8468 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8470 /* set a property */
8471 r
= MsiSetPropertyA(hpkg
, "Prop", "Val");
8472 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8474 /* get the property */
8476 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8477 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8478 ok(!lstrcmpA(buf
, "Val"), "Expected \"Val\", got \"%s\"\n", buf
);
8479 ok(size
== 3, "Expected 3, got %d\n", size
);
8481 /* update the property */
8482 r
= MsiSetPropertyA(hpkg
, "Prop", "Nuvo");
8483 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8485 /* get the property */
8487 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8488 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8489 ok(!lstrcmpA(buf
, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf
);
8490 ok(size
== 4, "Expected 4, got %d\n", size
);
8492 hdb
= MsiGetActiveDatabase(hpkg
);
8493 ok(hdb
!= 0, "Expected a valid database handle\n");
8495 /* set prop is not in the _Property table */
8496 query
= "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8497 r
= do_query(hdb
, query
, &hrec
);
8498 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8499 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8501 /* set prop is not in the Property table */
8502 query
= "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8503 r
= do_query(hdb
, query
, &hrec
);
8504 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8505 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8507 MsiCloseHandle(hdb
);
8509 /* szValue is an empty string */
8510 r
= MsiSetPropertyA(hpkg
, "Prop", "");
8511 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8513 /* try to get the property */
8515 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8516 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8517 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8518 ok(size
== 0, "Expected 0, got %d\n", size
);
8520 /* reset the property */
8521 r
= MsiSetPropertyA(hpkg
, "Prop", "BlueTap");
8522 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8524 /* delete the property */
8525 r
= MsiSetPropertyA(hpkg
, "Prop", NULL
);
8526 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8528 /* try to get the property */
8530 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8531 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8532 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8533 ok(size
== 0, "Expected 0, got %d\n", size
);
8535 MsiCloseHandle(hpkg
);
8536 DeleteFileA(msifile
);
8539 static void test_MsiApplyMultiplePatches(void)
8541 UINT r
, type
= GetDriveTypeW(NULL
);
8543 if (!pMsiApplyMultiplePatchesA
) {
8544 win_skip("MsiApplyMultiplePatchesA not found\n");
8548 r
= pMsiApplyMultiplePatchesA(NULL
, NULL
, NULL
);
8549 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8551 r
= pMsiApplyMultiplePatchesA("", NULL
, NULL
);
8552 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8554 r
= pMsiApplyMultiplePatchesA(";", NULL
, NULL
);
8555 if (type
== DRIVE_FIXED
)
8556 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8558 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8560 r
= pMsiApplyMultiplePatchesA(" ;", NULL
, NULL
);
8561 if (type
== DRIVE_FIXED
)
8562 todo_wine
ok(r
== ERROR_PATCH_PACKAGE_OPEN_FAILED
, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r
);
8564 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8566 r
= pMsiApplyMultiplePatchesA(";;", NULL
, NULL
);
8567 if (type
== DRIVE_FIXED
)
8568 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8570 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8572 r
= pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL
, NULL
);
8573 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8575 r
= pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL
, NULL
);
8576 if (type
== DRIVE_FIXED
)
8577 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8579 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8581 r
= pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL
, NULL
);
8582 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8584 r
= pMsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL
, NULL
);
8585 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8588 static void test_MsiApplyPatch(void)
8592 r
= MsiApplyPatchA(NULL
, NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8593 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8595 r
= MsiApplyPatchA("", NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8596 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8599 static void test_MsiEnumComponentCosts(void)
8601 MSIHANDLE hdb
, hpkg
;
8602 char package
[12], drive
[3];
8607 hdb
= create_package_db();
8608 ok( hdb
, "failed to create database\n" );
8610 r
= create_property_table( hdb
);
8611 ok( r
== ERROR_SUCCESS
, "cannot create Property table %u\n", r
);
8613 r
= add_property_entry( hdb
, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8614 ok( r
== ERROR_SUCCESS
, "cannot add property entry %u\n", r
);
8616 r
= add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
8617 ok( r
== ERROR_SUCCESS
, "cannot add property entry %u\n", r
);
8619 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
8620 ok( r
== ERROR_SUCCESS
, "failed to add directory entry %u\n" , r
);
8622 r
= create_media_table( hdb
);
8623 ok( r
== ERROR_SUCCESS
, "cannot create Media table %u\n", r
);
8625 r
= add_media_entry( hdb
, "'1', '2', 'cabinet', '', '', ''");
8626 ok( r
== ERROR_SUCCESS
, "cannot add media entry %u\n", r
);
8628 r
= create_file_table( hdb
);
8629 ok( r
== ERROR_SUCCESS
, "cannot create File table %u\n", r
);
8631 r
= add_file_entry( hdb
, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8632 ok( r
== ERROR_SUCCESS
, "cannot add file %u\n", r
);
8634 r
= create_component_table( hdb
);
8635 ok( r
== ERROR_SUCCESS
, "cannot create Component table %u\n", r
);
8637 r
= add_component_entry( hdb
, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8638 ok( r
== ERROR_SUCCESS
, "cannot add component %u\n", r
);
8640 r
= add_component_entry( hdb
, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8641 ok( r
== ERROR_SUCCESS
, "cannot add component %u\n", r
);
8643 r
= create_feature_table( hdb
);
8644 ok( r
== ERROR_SUCCESS
, "cannot create Feature table %u\n", r
);
8646 r
= add_feature_entry( hdb
, "'one', '', '', '', 0, 1, '', 0" );
8647 ok( r
== ERROR_SUCCESS
, "cannot add feature %u\n", r
);
8649 r
= add_feature_entry( hdb
, "'two', '', '', '', 0, 1, '', 0" );
8650 ok( r
== ERROR_SUCCESS
, "cannot add feature %u\n", r
);
8652 r
= create_feature_components_table( hdb
);
8653 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table %u\n", r
);
8655 r
= add_feature_components_entry( hdb
, "'one', 'one'" );
8656 ok( r
== ERROR_SUCCESS
, "cannot add feature/component pair %u\n", r
);
8658 r
= add_feature_components_entry( hdb
, "'two', 'two'" );
8659 ok( r
== ERROR_SUCCESS
, "cannot add feature/component pair %u\n", r
);
8661 r
= create_install_execute_sequence_table( hdb
);
8662 ok( r
== ERROR_SUCCESS
, "cannot create InstallExecuteSequence table %u\n", r
);
8664 r
= add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
8665 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8667 r
= add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
8668 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8670 r
= add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
8671 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8673 r
= add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1100'" );
8674 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8676 MsiDatabaseCommit( hdb
);
8678 sprintf( package
, "#%u", hdb
);
8679 r
= MsiOpenPackageA( package
, &hpkg
);
8680 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8682 skip("Not enough rights to perform tests\n");
8685 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8687 r
= MsiEnumComponentCostsA( 0, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8688 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8690 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8691 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8693 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8694 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8696 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8697 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8699 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8700 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8702 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, NULL
, NULL
, NULL
);
8703 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8705 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, NULL
, NULL
, NULL
);
8706 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8708 len
= sizeof(drive
);
8709 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, NULL
, NULL
);
8710 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8712 len
= sizeof(drive
);
8713 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, NULL
);
8714 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8716 len
= sizeof(drive
);
8717 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8718 todo_wine
ok( r
== ERROR_INVALID_HANDLE_STATE
, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r
);
8720 len
= sizeof(drive
);
8721 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, &len
, &cost
, &temp
);
8722 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8724 MsiSetInternalUI( INSTALLUILEVEL_NONE
, NULL
);
8726 r
= MsiDoActionA( hpkg
, "CostInitialize" );
8727 ok( r
== ERROR_SUCCESS
, "CostInitialize failed %u\n", r
);
8729 r
= MsiDoActionA( hpkg
, "FileCost" );
8730 ok( r
== ERROR_SUCCESS
, "FileCost failed %u\n", r
);
8732 len
= sizeof(drive
);
8733 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8734 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8736 r
= MsiDoActionA( hpkg
, "CostFinalize" );
8737 ok( r
== ERROR_SUCCESS
, "CostFinalize failed %u\n", r
);
8739 /* contrary to what msdn says InstallValidate must be called too */
8740 len
= sizeof(drive
);
8741 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8742 todo_wine
ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8744 r
= MsiDoActionA( hpkg
, "InstallValidate" );
8745 ok( r
== ERROR_SUCCESS
, "InstallValidate failed %u\n", r
);
8748 r
= MsiEnumComponentCostsA( hpkg
, "three", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8749 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
8752 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8753 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8754 ok( len
== 2, "expected len == 2, got %u\n", len
);
8757 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8758 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8759 ok( len
== 2, "expected len == 2, got %u\n", len
);
8762 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8763 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8764 ok( len
== 2, "expected len == 2, got %u\n", len
);
8766 /* install state doesn't seem to matter */
8767 len
= sizeof(drive
);
8768 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8769 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8771 len
= sizeof(drive
);
8772 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_ABSENT
, drive
, &len
, &cost
, &temp
);
8773 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8775 len
= sizeof(drive
);
8776 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_SOURCE
, drive
, &len
, &cost
, &temp
);
8777 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8779 len
= sizeof(drive
);
8781 cost
= temp
= 0xdead;
8782 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8783 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8784 ok( len
== 2, "expected len == 2, got %u\n", len
);
8785 ok( drive
[0], "expected a drive\n" );
8786 ok( cost
&& cost
!= 0xdead, "expected cost > 0, got %d\n", cost
);
8787 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8789 len
= sizeof(drive
);
8791 cost
= temp
= 0xdead;
8792 r
= MsiEnumComponentCostsA( hpkg
, "two", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8793 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8794 ok( len
== 2, "expected len == 2, got %u\n", len
);
8795 ok( drive
[0], "expected a drive\n" );
8796 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8797 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8799 len
= sizeof(drive
);
8801 cost
= temp
= 0xdead;
8802 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8803 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8804 ok( len
== 2, "expected len == 2, got %u\n", len
);
8805 ok( drive
[0], "expected a drive\n" );
8806 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8807 ok( temp
&& temp
!= 0xdead, "expected temp > 0, got %d\n", temp
);
8809 /* increased index */
8810 len
= sizeof(drive
);
8811 r
= MsiEnumComponentCostsA( hpkg
, "one", 1, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8812 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8814 len
= sizeof(drive
);
8815 r
= MsiEnumComponentCostsA( hpkg
, "", 1, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8816 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8818 MsiCloseHandle( hpkg
);
8820 MsiCloseHandle( hdb
);
8821 DeleteFileA( msifile
);
8824 static void test_MsiDatabaseCommit(void)
8827 MSIHANDLE hdb
, hpkg
= 0;
8828 char buf
[32], package
[12];
8831 hdb
= create_package_db();
8832 ok( hdb
, "failed to create database\n" );
8834 r
= create_property_table( hdb
);
8835 ok( r
== ERROR_SUCCESS
, "can't create Property table %u\n", r
);
8837 sprintf( package
, "#%u", hdb
);
8838 r
= MsiOpenPackageA( package
, &hpkg
);
8839 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8841 skip("Not enough rights to perform tests\n");
8844 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8846 r
= MsiSetPropertyA( hpkg
, "PROP", "value" );
8847 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8851 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8852 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8853 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8855 r
= MsiDatabaseCommit( hdb
);
8856 ok( r
== ERROR_SUCCESS
, "MsiDatabaseCommit returned %u\n", r
);
8860 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8861 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8862 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8864 MsiCloseHandle( hpkg
);
8866 MsiCloseHandle( hdb
);
8867 DeleteFileA( msifile
);
8872 STATEMGRSTATUS status
;
8875 init_functionpointers();
8877 if (pIsWow64Process
)
8878 pIsWow64Process(GetCurrentProcess(), &is_wow64
);
8880 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
8882 /* Create a restore point ourselves so we circumvent the multitude of restore points
8883 * that would have been created by all the installation and removal tests.
8885 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
8886 * creation of restore points.
8888 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
)
8890 memset(&status
, 0, sizeof(status
));
8891 ret
= notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE
, &status
);
8894 test_createpackage();
8896 test_gettargetpath_bad();
8897 test_settargetpath();
8899 test_property_table();
8902 test_formatrecord2();
8907 test_appsearch_complocator();
8908 test_appsearch_reglocator();
8909 test_appsearch_inilocator();
8910 test_appsearch_drlocator();
8911 test_featureparents();
8912 test_installprops();
8913 test_launchconditions();
8916 test_MsiGetSourcePath();
8917 test_shortlongsource();
8920 test_emptypackage();
8921 test_MsiGetProductProperty();
8922 test_MsiSetProperty();
8923 test_MsiApplyMultiplePatches();
8924 test_MsiApplyPatch();
8925 test_MsiEnumComponentCosts();
8926 test_MsiDatabaseCommit();
8928 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
&& ret
)
8930 ret
= notify_system_change(END_NESTED_SYSTEM_CHANGE
, &status
);
8932 remove_restore_point(status
.llSequenceNumber
);