From: Hans Leidekker hans@codeweavers.com
--- dlls/msi/tests/automation.c | 85 +------------------ dlls/msi/tests/db.c | 73 ++++------------- dlls/msi/tests/package.c | 158 +++++++++--------------------------- dlls/msi/tests/patch.c | 68 ++-------------- 4 files changed, 65 insertions(+), 319 deletions(-)
diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c index d61ee82b1a2..1139571f32a 100644 --- a/dlls/msi/tests/automation.c +++ b/dlls/msi/tests/automation.c @@ -32,6 +32,7 @@ #include <oaidl.h>
#include "wine/test.h" +#include "utils.h"
static BOOL is_wow64;
@@ -42,7 +43,6 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static const char *msifile = "winetest-automation.msi"; static FILETIME systemtime; -static CHAR CURR_DIR[MAX_PATH]; static EXCEPINFO excepinfo;
/* @@ -152,13 +152,6 @@ static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_ "regdata\t1\tSOFTWARE\Wine\msitest\tblah\tbad\tdangler\n" "OrderTest\t1\tSOFTWARE\Wine\msitest\tOrderTestName\tOrderTestValue\tcomponent\n";
-typedef struct _msi_table -{ - const CHAR *filename; - const CHAR *data; - int size; -} msi_table; - #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
static const msi_table tables[] = @@ -214,42 +207,6 @@ static void init_functionpointers(void) #undef GET_PROC }
-static BOOL is_process_limited(void) -{ - SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group = NULL; - BOOL IsInGroup; - HANDLE token; - - if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || - !CheckTokenMembership(NULL, Group, &IsInGroup)) - { - trace("Could not check if the current user is an administrator\n"); - FreeSid(Group); - return FALSE; - } - FreeSid(Group); - - if (!IsInGroup) - { - /* Only administrators have enough privileges for these tests */ - return TRUE; - } - - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) - { - BOOL ret; - TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; - DWORD size; - - ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size); - CloseHandle(token); - return (ret && type == TokenElevationTypeLimited); - } - return FALSE; -} - static LONG delete_key_portable( HKEY key, LPCSTR subkey, REGSAM access ) { if (pRegDeleteKeyExA) @@ -297,8 +254,8 @@ static void write_msi_summary_info(MSIHANDLE db, const msi_summary_info *info, i MsiCloseHandle(summary); }
-static void create_database(const CHAR *name, const msi_table *tables, int num_tables, - const msi_summary_info *info, int num_info) +static void create_database_suminfo(const CHAR *name, const msi_table *tables, int num_tables, + const msi_summary_info *info, int num_info) { MSIHANDLE db; UINT r; @@ -339,7 +296,7 @@ static BOOL create_package(LPWSTR path) DWORD len;
/* Prepare package */ - create_database(msifile, tables, ARRAY_SIZE(tables), summary_info, ARRAY_SIZE(summary_info)); + create_database_suminfo(msifile, tables, ARRAY_SIZE(tables), summary_info, ARRAY_SIZE(summary_info));
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, CURR_DIR, -1, path, MAX_PATH); @@ -355,8 +312,6 @@ static BOOL create_package(LPWSTR path) * Installation helpers */
-static char PROG_FILES_DIR[MAX_PATH]; - static BOOL get_program_files_dir(LPSTR buf) { HKEY hkey; @@ -374,24 +329,6 @@ static BOOL get_program_files_dir(LPSTR buf) return TRUE; }
-static void create_file(const CHAR *name, DWORD size) -{ - HANDLE file; - DWORD written, left; - - file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name); - WriteFile(file, name, strlen(name), &written, NULL); - WriteFile(file, "\n", strlen("\n"), &written, NULL); - - left = size - lstrlenA(name) - 1; - - SetFilePointer(file, left, NULL, FILE_CURRENT); - SetEndOfFile(file); - - CloseHandle(file); -} - static void create_test_files(void) { CreateDirectoryA("msitest", NULL); @@ -407,20 +344,6 @@ static void create_test_files(void) create_file("msitest\filename", 100); }
-static BOOL delete_pf(const CHAR *rel_path, BOOL is_file) -{ - CHAR path[MAX_PATH]; - - lstrcpyA(path, PROG_FILES_DIR); - lstrcatA(path, "\"); - lstrcatA(path, rel_path); - - if (is_file) - return DeleteFileA(path); - else - return RemoveDirectoryA(path); -} - static void delete_test_files(void) { DeleteFileA("msitest\cabout\new\five.txt"); diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 22fe92688ad..56fff94c5df 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -29,6 +29,7 @@ #include <msiquery.h>
#include "wine/test.h" +#include "utils.h"
static const char *msifile = "winetest-db.msi"; static const char *msifile2 = "winetst2-db.msi"; @@ -212,22 +213,6 @@ static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec) return ret; }
-static UINT run_query( MSIHANDLE hdb, MSIHANDLE hrec, const char *query ) -{ - MSIHANDLE hview = 0; - UINT r; - - r = MsiDatabaseOpenViewA(hdb, query, &hview); - if( r != ERROR_SUCCESS ) - return r; - - r = MsiViewExecute(hview, hrec); - if( r == ERROR_SUCCESS ) - r = MsiViewClose(hview); - MsiCloseHandle(hview); - return r; -} - static UINT run_queryW( MSIHANDLE hdb, MSIHANDLE hrec, const WCHAR *query ) { MSIHANDLE hview = 0; @@ -1502,29 +1487,6 @@ static void test_longstrings(void) DeleteFileA(msifile); }
-static void create_file_data(LPCSTR name, LPCSTR data, DWORD size) -{ - HANDLE file; - DWORD written; - - file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - if (file == INVALID_HANDLE_VALUE) - return; - - WriteFile(file, data, strlen(data), &written, NULL); - WriteFile(file, "\n", strlen("\n"), &written, NULL); - - if (size) - { - SetFilePointer(file, size, NULL, FILE_BEGIN); - SetEndOfFile(file); - } - - CloseHandle(file); -} - -#define create_file(name) create_file_data(name, name, 0) - static void test_streamtable(void) { MSIHANDLE hdb = 0, rec, view, hsi; @@ -1607,7 +1569,7 @@ static void test_streamtable(void) MsiCloseHandle( view );
/* insert a file into the _Streams table */ - create_file( "test.txt" ); + create_file( "test.txt", 0 );
rec = MsiCreateRecord( 2 ); MsiRecordSetStringA( rec, 1, "data" ); @@ -1629,7 +1591,7 @@ static void test_streamtable(void) MsiCloseHandle( view );
/* insert another one */ - create_file( "test1.txt" ); + create_file( "test1.txt", 0 );
rec = MsiCreateRecord( 2 ); MsiRecordSetStringA( rec, 1, "data1" ); @@ -1651,7 +1613,7 @@ static void test_streamtable(void) MsiCloseHandle( view );
/* try again */ - create_file( "test1.txt" ); + create_file( "test1.txt", 0 );
rec = MsiCreateRecord( 2 ); MsiRecordSetStringA( rec, 1, "data1" ); @@ -1691,7 +1653,7 @@ static void test_streamtable(void) memset(buf, 0, MAX_PATH); r = MsiRecordReadStream( rec, 2, buf, &size ); ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r); - ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\n', got %s\n", buf); + ok( !lstrcmpA(buf, "test.txt"), "Expected 'test.txt', got %s\n", buf);
MsiCloseHandle( rec ); MsiViewClose( view ); @@ -1716,14 +1678,14 @@ static void test_streamtable(void) memset(buf, 0, MAX_PATH); r = MsiRecordReadStream( rec, 2, buf, &size ); ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r); - ok( !lstrcmpA(buf, "test1.txt\n"), "Expected 'test1.txt\n', got %s\n", buf); + ok( !lstrcmpA(buf, "test1.txt"), "Expected 'test1.txt', got %s\n", buf);
MsiCloseHandle( rec ); MsiViewClose( view ); MsiCloseHandle( view );
/* perform an update */ - create_file( "test2.txt" ); + create_file( "test2.txt", 0 ); rec = MsiCreateRecord( 1 );
r = MsiRecordSetStreamA( rec, 1, "test2.txt" ); @@ -1761,7 +1723,7 @@ static void test_streamtable(void) memset(buf, 0, MAX_PATH); r = MsiRecordReadStream( rec, 2, buf, &size ); ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r); - ok( !lstrcmpA(buf, "test2.txt\n"), "Expected 'test2.txt\n', got %s\n", buf); + ok( !lstrcmpA(buf, "test2.txt"), "Expected 'test2.txt', got %s\n", buf);
MsiCloseHandle( rec ); MsiViewClose( view ); @@ -1773,7 +1735,7 @@ static void test_streamtable(void) r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATEDIRECT, &hdb); ok(r == ERROR_SUCCESS, "Failed to create database\n"); ok( hdb, "failed to create db\n"); - create_file( "test.txt" ); + create_file( "test.txt", 0 ); rec = MsiCreateRecord( 2 ); MsiRecordSetStringA( rec, 1, "data" ); r = MsiRecordSetStreamA( rec, 2, "test.txt" ); @@ -1809,7 +1771,7 @@ static void test_streamtable(void) memset(buf, 0, MAX_PATH); r = MsiRecordReadStream( rec, 2, buf, &size ); ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r); - ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\n', got '%s' (%lu)\n", buf, size); + ok( !lstrcmpA(buf, "test.txt"), "Expected 'test.txt', got '%s' (%lu)\n", buf, size); MsiCloseHandle( rec );
/* open a handle to the "data" stream (and keep it open during removal) */ @@ -1865,7 +1827,7 @@ static void test_binary(void) r = run_query( hdb, 0, query ); ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
- create_file( "test.txt" ); + create_file( "test.txt", 0 ); rec = MsiCreateRecord( 1 ); r = MsiRecordSetStreamA( rec, 1, "test.txt" ); ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r); @@ -1892,7 +1854,7 @@ static void test_binary(void) r = run_query( hdb, 0, query ); ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
- create_file( "test.txt" ); + create_file( "test.txt", 0 ); rec = MsiCreateRecord( 1 ); r = MsiRecordSetStreamA( rec, 1, "test.txt" ); ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r ); @@ -1932,7 +1894,7 @@ static void test_binary(void) memset( buf, 0, MAX_PATH ); r = MsiRecordReadStream( rec, 2, buf, &size ); ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r ); - ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\n', got %s\n", buf ); + ok( !lstrcmpA(buf, "test.txt"), "Expected 'test.txt', got %s\n", buf );
r = MsiCloseHandle( rec ); ok( r == ERROR_SUCCESS , "Failed to close record handle\n" ); @@ -1951,7 +1913,7 @@ static void test_binary(void) memset( buf, 0, MAX_PATH ); r = MsiRecordReadStream( rec, 3, buf, &size ); ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r ); - ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\n', got %s\n", buf ); + ok( !lstrcmpA(buf, "test.txt"), "Expected 'test.txt', got %s\n", buf );
r = MsiCloseHandle( rec ); ok( r == ERROR_SUCCESS , "Failed to close record handle\n" ); @@ -2178,8 +2140,6 @@ static void test_where(void) DeleteFileA(msifile); }
-static CHAR CURR_DIR[MAX_PATH]; - static const CHAR test_data[] = "FirstPrimaryColumn\tSecondPrimaryColumn\tShortInt\tShortIntNullable\tLongInt\tLongIntNullable\tString\tLocalizableString\tLocalizableStringNullable\n" "s255\ti2\ti2\tI2\ti4\tI4\tS255\tS0\ts0\n" "TestTable\tFirstPrimaryColumn\n" @@ -7992,7 +7952,7 @@ static void test_dbmerge(void) r = run_query(href, 0, query); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- create_file("binary.dat"); + create_file("binary.dat", 0); hrec = MsiCreateRecord(1); MsiRecordSetStreamA(hrec, 1, "binary.dat");
@@ -8017,8 +7977,7 @@ static void test_dbmerge(void) ZeroMemory(buf, MAX_PATH); r = MsiRecordReadStream(hrec, 2, buf, &size); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - ok(!lstrcmpA(buf, "binary.dat\n"), - "Expected "binary.dat\n", got "%s"\n", buf); + ok(!lstrcmpA(buf, "binary.dat"), "Expected "binary.dat", got "%s"\n", buf);
MsiCloseHandle(hrec);
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 228fd91ef43..adc85d54b18 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -32,11 +32,11 @@ #include <sddl.h>
#include "wine/test.h" +#include "utils.h"
static BOOL is_wow64; static const char msifile[] = "winetest-package.msi"; static const WCHAR msifileW[] = L"winetest-package.msi"; -static char CURR_DIR[MAX_PATH];
static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
@@ -68,54 +68,6 @@ static void init_functionpointers(void) #undef GET_PROC }
-static BOOL is_process_limited(void) -{ - SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group = NULL; - BOOL IsInGroup; - HANDLE token; - - if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) || - !CheckTokenMembership(NULL, Group, &IsInGroup)) - { - trace("Could not check if the current user is an administrator\n"); - FreeSid(Group); - return FALSE; - } - FreeSid(Group); - - if (!IsInGroup) - { - if (!AllocateAndInitializeSid(&NtAuthority, 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_POWER_USERS, - 0, 0, 0, 0, 0, 0, &Group) || - !CheckTokenMembership(NULL, Group, &IsInGroup)) - { - trace("Could not check if the current user is a power user\n"); - return FALSE; - } - if (!IsInGroup) - { - /* Only administrators and power users can be powerful */ - return TRUE; - } - } - - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) - { - BOOL ret; - TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; - DWORD size; - - ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size); - CloseHandle(token); - return (ret && type == TokenElevationTypeLimited); - } - return FALSE; -} - static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access ) { if (pRegDeleteKeyExA) @@ -402,25 +354,9 @@ static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec) return ret; }
-static UINT run_query( MSIHANDLE hdb, const char *query ) -{ - MSIHANDLE hview = 0; - UINT r; - - r = MsiDatabaseOpenViewA(hdb, query, &hview); - if( r != ERROR_SUCCESS ) - return r; - - r = MsiViewExecute(hview, 0); - if( r == ERROR_SUCCESS ) - r = MsiViewClose(hview); - MsiCloseHandle(hview); - return r; -} - static UINT create_component_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `Component` ( " "`Component` CHAR(72) NOT NULL, " "`ComponentId` CHAR(38), " @@ -435,7 +371,7 @@ static UINT create_component_table( MSIHANDLE hdb )
static UINT create_feature_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `Feature` ( " "`Feature` CHAR(38) NOT NULL, " "`Feature_Parent` CHAR(38), " @@ -452,7 +388,7 @@ static UINT create_feature_table( MSIHANDLE hdb )
static UINT create_feature_components_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `FeatureComponents` ( " "`Feature_` CHAR(38) NOT NULL, " "`Component_` CHAR(72) NOT NULL " @@ -463,7 +399,7 @@ static UINT create_feature_components_table( MSIHANDLE hdb )
static UINT create_file_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `File` (" "`File` CHAR(72) NOT NULL, " "`Component_` CHAR(72) NOT NULL, " @@ -480,7 +416,7 @@ static UINT create_file_table( MSIHANDLE hdb )
static UINT create_remove_file_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `RemoveFile` (" "`FileKey` CHAR(72) NOT NULL, " "`Component_` CHAR(72) NOT NULL, " @@ -494,7 +430,7 @@ static UINT create_remove_file_table( MSIHANDLE hdb )
static UINT create_appsearch_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `AppSearch` (" "`Property` CHAR(72) NOT NULL, " "`Signature_` CHAR(72) NOT NULL " @@ -505,7 +441,7 @@ static UINT create_appsearch_table( MSIHANDLE hdb )
static UINT create_reglocator_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `RegLocator` (" "`Signature_` CHAR(72) NOT NULL, " "`Root` SHORT NOT NULL, " @@ -519,7 +455,7 @@ static UINT create_reglocator_table( MSIHANDLE hdb )
static UINT create_signature_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `Signature` (" "`Signature` CHAR(72) NOT NULL, " "`FileName` CHAR(255) NOT NULL, " @@ -537,7 +473,7 @@ static UINT create_signature_table( MSIHANDLE hdb )
static UINT create_launchcondition_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `LaunchCondition` (" "`Condition` CHAR(255) NOT NULL, " "`Description` CHAR(255) NOT NULL " @@ -548,7 +484,7 @@ static UINT create_launchcondition_table( MSIHANDLE hdb )
static UINT create_property_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `Property` (" "`Property` CHAR(72) NOT NULL, " "`Value` CHAR(0) " @@ -559,7 +495,7 @@ static UINT create_property_table( MSIHANDLE hdb )
static UINT create_install_execute_sequence_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `InstallExecuteSequence` (" "`Action` CHAR(72) NOT NULL, " "`Condition` CHAR(255), " @@ -571,7 +507,7 @@ static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
static UINT create_install_ui_sequence_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `InstallUISequence` (" "`Action` CHAR(72) NOT NULL, " "`Condition` CHAR(255), " @@ -583,7 +519,7 @@ static UINT create_install_ui_sequence_table( MSIHANDLE hdb )
static UINT create_media_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `Media` (" "`DiskId` SHORT NOT NULL, " "`LastSequence` SHORT NOT NULL, " @@ -598,7 +534,7 @@ static UINT create_media_table( MSIHANDLE hdb )
static UINT create_ccpsearch_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `CCPSearch` (" "`Signature_` CHAR(72) NOT NULL " "PRIMARY KEY `Signature_`)" ); @@ -608,7 +544,7 @@ static UINT create_ccpsearch_table( MSIHANDLE hdb )
static UINT create_drlocator_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `DrLocator` (" "`Signature_` CHAR(72) NOT NULL, " "`Parent` CHAR(72), " @@ -621,7 +557,7 @@ static UINT create_drlocator_table( MSIHANDLE hdb )
static UINT create_complocator_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `CompLocator` (" "`Signature_` CHAR(72) NOT NULL, " "`ComponentId` CHAR(38) NOT NULL, " @@ -633,7 +569,7 @@ static UINT create_complocator_table( MSIHANDLE hdb )
static UINT create_inilocator_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `IniLocator` (" "`Signature_` CHAR(72) NOT NULL, " "`FileName` CHAR(255) NOT NULL, " @@ -648,7 +584,7 @@ static UINT create_inilocator_table( MSIHANDLE hdb )
static UINT create_custom_action_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `CustomAction` (" "`Action` CHAR(72) NOT NULL, " "`Type` SHORT NOT NULL, " @@ -661,7 +597,7 @@ static UINT create_custom_action_table( MSIHANDLE hdb )
static UINT create_dialog_table( MSIHANDLE hdb ) { - UINT r = run_query(hdb, + UINT r = run_query(hdb, 0, "CREATE TABLE `Dialog` (" "`Dialog` CHAR(72) NOT NULL, " "`HCentering` SHORT NOT NULL, " @@ -680,7 +616,7 @@ static UINT create_dialog_table( MSIHANDLE hdb )
static UINT create_control_table( MSIHANDLE hdb ) { - UINT r = run_query(hdb, + UINT r = run_query(hdb, 0, "CREATE TABLE `Control` (" "`Dialog_` CHAR(72) NOT NULL, " "`Control` CHAR(50) NOT NULL, " @@ -701,7 +637,7 @@ static UINT create_control_table( MSIHANDLE hdb )
static UINT create_controlevent_table( MSIHANDLE hdb ) { - UINT r = run_query(hdb, + UINT r = run_query(hdb, 0, "CREATE TABLE `ControlEvent` (" "`Dialog_` CHAR(72) NOT NULL, " "`Control_` CHAR(50) NOT NULL, " @@ -716,7 +652,7 @@ static UINT create_controlevent_table( MSIHANDLE hdb )
static UINT create_actiontext_table( MSIHANDLE hdb ) { - UINT r = run_query(hdb, + UINT r = run_query(hdb, 0, "CREATE TABLE `ActionText` (" "`Action` CHAR(72) NOT NULL, " "`Description` CHAR(64) LOCALIZABLE, " @@ -728,7 +664,7 @@ static UINT create_actiontext_table( MSIHANDLE hdb )
static UINT create_upgrade_table( MSIHANDLE hdb ) { - UINT r = run_query( hdb, + UINT r = run_query( hdb, 0, "CREATE TABLE `Upgrade` (" "`UpgradeCode` CHAR(38) NOT NULL, " "`VersionMin` CHAR(20), " @@ -750,7 +686,7 @@ static inline UINT add_entry(const char *file, int line, const char *type, MSIHA sz = strlen(values) + strlen(insert) + 1; query = malloc(sz); sprintf(query, insert, values); - r = run_query(hdb, query); + r = run_query(hdb, 0, query); free(query); ok_(file, line)(r == ERROR_SUCCESS, "failed to insert into %s table: %u\n", type, r); return r; @@ -867,7 +803,7 @@ static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, con sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert ); query = malloc( sz ); sprintf( query, insert, sig, root, path, name, type ); - r = run_query( hdb, query ); + r = run_query( hdb, 0, query ); free( query ); ok(r == ERROR_SUCCESS, "failed to insert into reglocator table: %u\n", r); \ return r; @@ -937,7 +873,7 @@ static MSIHANDLE create_package_db(void) res = set_summary_info(hdb); ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
- res = run_query( hdb, + res = run_query( hdb, 0, "CREATE TABLE `Directory` ( " "`Directory` CHAR(255) NOT NULL, " "`Directory_Parent` CHAR(255), " @@ -973,25 +909,9 @@ static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle) return ERROR_SUCCESS; }
-static void create_file_data(LPCSTR name, LPCSTR data) -{ - HANDLE file; - DWORD written; - - file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name); - if (file == INVALID_HANDLE_VALUE) - return; - - WriteFile(file, data, strlen(data), &written, NULL); - WriteFile(file, "\n", strlen("\n"), &written, NULL); - - CloseHandle(file); -} - static void create_test_file(const CHAR *name) { - create_file_data(name, name); + create_file_data(name, name, strlen(name)); }
typedef struct _tagVS_VERSIONINFO @@ -2393,7 +2313,7 @@ static void test_property_table(void)
query = "CREATE TABLE `_Property` ( " "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)"; - r = run_query(hdb, query); + r = run_query(hdb, 0, query); ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
MsiCloseHandle(hdb); @@ -2405,19 +2325,19 @@ static void test_property_table(void)
query = "CREATE TABLE `_Property` ( " "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)"; - r = run_query(hdb, query); + r = run_query(hdb, 0, query); ok(r == ERROR_SUCCESS, "failed to create table\n");
query = "ALTER `_Property` ADD `foo` INTEGER"; - r = run_query(hdb, query); + r = run_query(hdb, 0, query); ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
query = "ALTER TABLE `_Property` ADD `foo` INTEGER"; - r = run_query(hdb, query); + r = run_query(hdb, 0, query); ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
query = "ALTER TABLE `_Property` ADD `extra` INTEGER"; - r = run_query(hdb, query); + r = run_query(hdb, 0, query); ok(r == ERROR_SUCCESS, "failed to add column\n");
sprintf(package, "#%lu", hdb); @@ -7995,7 +7915,7 @@ static void test_MsiGetProductProperty(void) r = set_summary_info(hdb); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- r = run_query(hdb, + r = run_query(hdb, 0, "CREATE TABLE `Directory` ( " "`Directory` CHAR(255) NOT NULL, " "`Directory_Parent` CHAR(255), " @@ -9125,13 +9045,13 @@ static void test_externalui_message(void) hdb = create_package_db(); ok(hdb, "failed to create database\n");
- create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n"); + create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n", sizeof("\r\n\r\n1252\t_ForceCodepage\r\n") - 1); r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- r = run_query(hdb, "CREATE TABLE `Error` (`Error` SHORT NOT NULL, `Message` CHAR(0) PRIMARY KEY `Error`)"); + r = run_query(hdb, 0, "CREATE TABLE `Error` (`Error` SHORT NOT NULL, `Message` CHAR(0) PRIMARY KEY `Error`)"); ok(r == ERROR_SUCCESS, "Failed to create Error table: %u\n", r); - r = run_query(hdb, "INSERT INTO `Error` (`Error`, `Message`) VALUES (5, 'internal error')"); + r = run_query(hdb, 0, "INSERT INTO `Error` (`Error`, `Message`) VALUES (5, 'internal error')"); ok(r == ERROR_SUCCESS, "Failed to insert into Error table: %u\n", r);
create_actiontext_table(hdb); @@ -9342,7 +9262,7 @@ static void test_controlevent(void) hdb = create_package_db(); ok(hdb, "failed to create database\n");
- create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n"); + create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n", sizeof("\r\n\r\n1252\t_ForceCodepage\r\n") - 1); r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
@@ -9565,7 +9485,7 @@ static void test_top_level_action(void) hdb = create_package_db(); ok(hdb, "failed to create database\n");
- create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n"); + create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n", sizeof("\r\n\r\n1252\t_ForceCodepage\r\n") -1 ); r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
diff --git a/dlls/msi/tests/patch.c b/dlls/msi/tests/patch.c index 9d46f493e08..0dbb8451ca3 100644 --- a/dlls/msi/tests/patch.c +++ b/dlls/msi/tests/patch.c @@ -30,6 +30,7 @@ #include <wtypes.h>
#include "wine/test.h" +#include "utils.h"
static UINT (WINAPI *pMsiApplyPatchA)( LPCSTR, LPCSTR, INSTALLTYPE, LPCSTR ); static UINT (WINAPI *pMsiGetPatchInfoExA)( LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, @@ -42,10 +43,6 @@ static const char *mspfile = "winetest-patch.msp"; static const WCHAR msifileW[] = L"winetest-patch.msi"; static const WCHAR mspfileW[] = L"winetest-patch.msp";
-static char CURR_DIR[MAX_PATH]; -static char PROG_FILES_DIR[MAX_PATH]; -static char COMMON_FILES_DIR[MAX_PATH]; - /* msi database data */
static const char property_dat[] = @@ -136,8 +133,6 @@ struct msi_table int size; };
-#define ADD_TABLE( x ) { #x".idt", x##_dat, sizeof(x##_dat) } - static const struct msi_table tables[] = { ADD_TABLE( directory ), @@ -167,23 +162,6 @@ static void init_function_pointers( void ) #undef GET_PROC }
-static BOOL is_process_limited(void) -{ - HANDLE token; - - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) - { - BOOL ret; - TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; - DWORD size; - - ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size); - CloseHandle(token); - return (ret && type == TokenElevationTypeLimited); - } - return FALSE; -} - static BOOL get_program_files_dir( char *buf, char *buf2 ) { HKEY hkey; @@ -209,40 +187,6 @@ static BOOL get_program_files_dir( char *buf, char *buf2 ) return TRUE; }
-static void create_file_data( const char *filename, const char *data, DWORD size ) -{ - HANDLE file; - DWORD written; - - file = CreateFileA( filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL ); - if (file == INVALID_HANDLE_VALUE) - return; - - WriteFile( file, data, strlen( data ), &written, NULL ); - if (size) - { - SetFilePointer( file, size, NULL, FILE_BEGIN ); - SetEndOfFile( file ); - } - CloseHandle( file ); -} - -#define create_file( name, size ) create_file_data( name, name, size ) - -static BOOL delete_pf( const char *rel_path, BOOL is_file ) -{ - char path[MAX_PATH]; - - strcpy( path, PROG_FILES_DIR ); - strcat( path, "\" ); - strcat( path, rel_path ); - - if (is_file) - return DeleteFileA( path ); - else - return RemoveDirectoryA( path ); -} - static DWORD get_pf_file_size( const char *filename ) { char path[MAX_PATH]; @@ -313,7 +257,7 @@ static void set_suminfo( const WCHAR *filename ) ok( r == ERROR_SUCCESS, "failed to close database %u\n", r ); }
-static void create_database( const char *filename, const struct msi_table *tables, UINT num_tables ) +static void create_database_suminfo( const char *filename, const struct msi_table *tables, UINT num_tables ) { MSIHANDLE hdb; UINT r, i; @@ -761,7 +705,7 @@ static void test_simple_patch( void ) CreateDirectoryA( "msitest", NULL ); create_file( "msitest\patch.txt", 1000 );
- create_database( msifile, tables, ARRAY_SIZE(tables) ); + create_database_suminfo( msifile, tables, ARRAY_SIZE(tables) ); create_patch( mspfile );
MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL ); @@ -962,7 +906,7 @@ static void test_MsiOpenDatabase( void ) MsiCloseHandle( hdb ); DeleteFileA( mspfile );
- create_database( msifile, tables, ARRAY_SIZE(tables) ); + create_database_suminfo( msifile, tables, ARRAY_SIZE(tables) ); create_patch( mspfile );
r = MsiOpenDatabaseW( msifileW, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &hdb ); @@ -1100,7 +1044,7 @@ static void test_system_tables( void ) CreateDirectoryA( "msitest", NULL ); create_file( "msitest\patch.txt", 1000 );
- create_database( msifile, tables, ARRAY_SIZE(tables) ); + create_database_suminfo( msifile, tables, ARRAY_SIZE(tables) ); create_patch( mspfile );
MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL ); @@ -1290,7 +1234,7 @@ static void test_patch_registration( void ) CreateDirectoryA( "msitest", NULL ); create_file( "msitest\patch.txt", 1000 );
- create_database( msifile, tables, ARRAY_SIZE(tables) ); + create_database_suminfo( msifile, tables, ARRAY_SIZE(tables) ); create_patch( mspfile );
MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );