From 10a32a0b7afa93b0c457d1ac09518fa09a06ad45 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Thu, 22 Jul 2010 11:48:28 +0200 Subject: [PATCH] msi/tests: Skip tests when the current user has insufficient rights. --- dlls/msi/tests/automation.c | 14 +- dlls/msi/tests/db.c | 24 +- dlls/msi/tests/format.c | 51 +++- dlls/msi/tests/install.c | 501 ++++++++++++++++++++++++++++++++++-- dlls/msi/tests/msi.c | 113 ++++++++ dlls/msi/tests/package.c | 186 ++++++++++++- 6 files changed, 851 insertions(+), 38 deletions(-) diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c index 35b660b7795..874c9aa813c 100644 --- a/dlls/msi/tests/automation.c +++ b/dlls/msi/tests/automation.c @@ -733,6 +733,12 @@ static void test_dispatch(void) V_VT(&vararg[0]) = VT_BSTR; V_BSTR(&vararg[0]) = SysAllocString(path); hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL); + if (hr == DISP_E_EXCEPTION) + { + skip("OpenPackage failed, insufficient rights?\n"); + DeleteFileW(path); + return; + } ok(hr == S_OK, "IDispatch::Invoke returned 0x%08x\n", hr); VariantClear(&vararg[0]); VariantClear(&varresult); @@ -2405,7 +2411,7 @@ static void test_Installer_InstallProduct(void) hr = Installer_InstallProduct(szMsifile, NULL); if (hr == DISP_E_EXCEPTION) { - skip("Installer object not supported.\n"); + skip("InstallProduct failed, insufficient rights?\n"); delete_test_files(); return; } @@ -2610,6 +2616,12 @@ static void test_Installer(void) /* Installer::OpenPackage */ hr = Installer_OpenPackage(szPath, 0, &pSession); + if (hr == DISP_E_EXCEPTION) + { + skip("OpenPackage failed, insufficient rights?\n"); + DeleteFileW(szPath); + return; + } ok(hr == S_OK, "Installer_OpenPackage failed, hresult 0x%08x\n", hr); if (hr == S_OK) { diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 7bbc6693d14..17c5c1fc5c8 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -3122,6 +3122,11 @@ static void test_try_transform(void) /* check that the property was added */ r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); sz = MAX_PATH; @@ -3130,8 +3135,9 @@ static void test_try_transform(void) ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer); MsiCloseHandle(hpkg); - MsiCloseHandle(hdb); +error: + MsiCloseHandle(hdb); DeleteFile(msifile); DeleteFile(mstfile); } @@ -7176,8 +7182,7 @@ static void test_storages_table(void) static void test_dbtopackage(void) { MSIHANDLE hdb, hpkg; - CHAR package[10]; - CHAR buf[MAX_PATH]; + CHAR package[12], buf[MAX_PATH]; DWORD size; UINT r; @@ -7196,8 +7201,13 @@ static void test_dbtopackage(void) r = add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - sprintf(package, "#%i", hdb); + sprintf(package, "#%u", hdb); r = MsiOpenPackage(package, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); /* property is not set yet */ @@ -7255,7 +7265,7 @@ static void test_dbtopackage(void) r = add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - sprintf(package, "#%i", hdb); + sprintf(package, "#%u", hdb); r = MsiOpenPackage(package, &hpkg); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); @@ -7296,8 +7306,10 @@ static void test_dbtopackage(void) ok(size == 0, "Expected 0, got %d\n", size); } - MsiCloseHandle(hdb); MsiCloseHandle(hpkg); + +error: + MsiCloseHandle(hdb); DeleteFileA(msifile); } diff --git a/dlls/msi/tests/format.c b/dlls/msi/tests/format.c index 84cc3d392f0..c82c3c658bd 100644 --- a/dlls/msi/tests/format.c +++ b/dlls/msi/tests/format.c @@ -201,15 +201,20 @@ static MSIHANDLE create_package_db(void) DeleteFile(msifile); /* create an empty database */ - res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb ); - ok( res == ERROR_SUCCESS , "Failed to create database\n" ); + res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATEDIRECT, &hdb ); + ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res ); if( res != ERROR_SUCCESS ) - return hdb; + return 0; res = MsiDatabaseCommit( hdb ); ok( res == ERROR_SUCCESS , "Failed to commit database\n" ); + if( res != ERROR_SUCCESS ) + return 0; res = set_summary_info(hdb); + ok( res == ERROR_SUCCESS , "Failed to set summary info %u\n", res ); + if( res != ERROR_SUCCESS ) + return 0; res = run_query( hdb, "CREATE TABLE `Directory` ( " @@ -217,7 +222,7 @@ static MSIHANDLE create_package_db(void) "`Directory_Parent` CHAR(255), " "`DefaultDir` CHAR(255) NOT NULL " "PRIMARY KEY `Directory`)" ); - ok( res == ERROR_SUCCESS , "Failed to create directory table\n" ); + ok( res == ERROR_SUCCESS , "Failed to create directory table %u\n", res ); return hdb; } @@ -264,11 +269,13 @@ static UINT helper_createpackage( const char *szName, MSIHANDLE *handle ) DeleteFile(szName); /* create an empty database */ - res = MsiOpenDatabase(szName, MSIDBOPEN_CREATE, &hdb ); - ok( res == ERROR_SUCCESS , "Failed to create database\n" ); + res = MsiOpenDatabase(szName, MSIDBOPEN_CREATEDIRECT, &hdb ); + ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res ); + if (res != ERROR_SUCCESS) + return res; res = MsiDatabaseCommit( hdb ); - ok( res == ERROR_SUCCESS , "Failed to commit database\n" ); + ok( res == ERROR_SUCCESS , "Failed to commit database %u\n", res ); /* build summary info */ res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo); @@ -307,9 +314,13 @@ static UINT helper_createpackage( const char *szName, MSIHANDLE *handle ) ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" ); res = package_from_db( hdb, &hPackage ); - ok( res == ERROR_SUCCESS, "failed to create package %u\n", res ); + MsiCloseHandle(hdb); + + if (res != ERROR_SUCCESS) + DeleteFileA( szName ); + else + *handle = hPackage; - *handle = hPackage; return res; } @@ -319,6 +330,11 @@ static void test_createpackage(void) UINT res; res = helper_createpackage( msifile, &hPackage ); + if (res == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok( res == ERROR_SUCCESS, "Failed to create package %u\n", res ); res = MsiCloseHandle( hPackage ); @@ -1626,6 +1642,11 @@ static void test_formatrecord_package(void) DWORD sz=100; r = helper_createpackage( msifile, &package ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok( r == ERROR_SUCCESS, "Unable to create package %u\n", r ); hrec = MsiCreateRecord(12); @@ -2198,6 +2219,13 @@ static void test_formatrecord_tables(void) ok( r == ERROR_SUCCESS, "cannt add custom action: %d\n", r); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + MsiCloseHandle( hdb ); + DeleteFile( msifile ); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r ); MsiCloseHandle( hdb ); @@ -2385,6 +2413,11 @@ static void test_processmessage(void) UINT r; r = helper_createpackage( msifile, &package ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok( r == ERROR_SUCCESS, "Unable to create package %u\n", r ); hrec = MsiCreateRecord(3); diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index d6fa3f0b735..82542d0fd8b 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -3499,6 +3499,11 @@ static void test_MsiInstallProduct(void) /* install, don't publish */ r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); @@ -3747,7 +3752,9 @@ static void test_MsiInstallProduct(void) r = MsiInstallProductA(msifile, "REMOVE=ALL"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); +error: delete_test_files(); + DeleteFileA(msifile); } static void test_MsiSetComponentState(void) @@ -3766,6 +3773,11 @@ static void test_MsiSetComponentState(void) lstrcat(path, msifile); r = MsiOpenPackage(path, &package); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); r = MsiDoAction(package, "CostInitialize"); @@ -3786,8 +3798,9 @@ static void test_MsiSetComponentState(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); MsiCloseHandle(package); - CoUninitialize(); +error: + CoUninitialize(); DeleteFileA(msifile); } @@ -3933,6 +3946,11 @@ static void test_continuouscabs(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n"); @@ -3940,6 +3958,7 @@ static void test_continuouscabs(void) ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: delete_cab_files(); DeleteFile(msifile); } @@ -3962,6 +3981,11 @@ static void test_caborder(void) create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0"); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n"); ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n"); @@ -4016,6 +4040,7 @@ static void test_caborder(void) ok(!delete_pf("msitest", FALSE), "File is installed\n"); } +error: delete_cab_files(); DeleteFile("imperator"); DeleteFile("maximus"); @@ -4040,12 +4065,18 @@ static void test_mixedmedia(void) create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0"); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n"); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: /* Delete the files in the temp (current) folder */ DeleteFile("msitest\\maximus"); DeleteFile("msitest\\augustus"); @@ -4142,11 +4173,17 @@ static void test_readonlyfile(void) CloseHandle(file); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(file_matches(path), "Expected file to be overwritten\n"); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: /* Delete the files in the temp (current) folder */ DeleteFile("msitest\\maximus"); RemoveDirectory("msitest"); @@ -4182,6 +4219,11 @@ static void test_readonlyfile_cab(void) CloseHandle(file); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); memset( buf, 0, sizeof(buf) ); @@ -4195,6 +4237,7 @@ static void test_readonlyfile_cab(void) ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: /* Delete the files in the temp (current) folder */ delete_cab_files(); DeleteFile("msitest\\maximus"); @@ -4274,6 +4317,11 @@ static void test_lastusedsource(void) ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value); r = MsiInstallProductA("msifile0.msi", "PUBLISH_PRODUCT=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); lstrcpyA(path, CURR_DIR); @@ -4357,6 +4405,7 @@ static void test_lastusedsource(void) ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r); ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value); +error: /* Delete the files in the temp (current) folder */ delete_cab_files(); DeleteFile("msitest\\maximus"); @@ -4377,10 +4426,16 @@ static void test_setdirproperty(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_cf("msitest", FALSE), "File not installed\n"); +error: /* Delete the files in the temp (current) folder */ DeleteFile(msifile); DeleteFile("msitest\\maximus"); @@ -4406,6 +4461,11 @@ static void test_cabisextracted(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); @@ -4413,6 +4473,7 @@ static void test_cabisextracted(void) ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: /* Delete the files in the temp (current) folder */ delete_cab_files(); DeleteFile(msifile); @@ -4442,6 +4503,12 @@ static void test_concurrentinstall(void) MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(path); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); if (!delete_pf("msitest\\augustus", TRUE)) trace("concurrent installs not supported\n"); @@ -4456,6 +4523,7 @@ static void test_concurrentinstall(void) ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: DeleteFile(msifile); DeleteFile("msitest\\msitest\\augustus"); DeleteFile("msitest\\maximus"); @@ -4480,6 +4548,11 @@ static void test_setpropertyfolder(void) MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); attr = GetFileAttributesA(path); if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY)) @@ -4495,6 +4568,7 @@ static void test_setpropertyfolder(void) ok(delete_pf("msitest", FALSE), "File not installed\n"); } +error: /* Delete the files in the temp (current) folder */ DeleteFile(msifile); DeleteFile("msitest\\maximus"); @@ -4698,6 +4772,11 @@ static void test_publish_registerproduct(void) /* RegisterProduct */ r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); @@ -4894,6 +4973,7 @@ static void test_publish_registerproduct(void) RegDeleteKeyA(hkey, ""); RegCloseKey(hkey); +error: DeleteFile(msifile); DeleteFile("msitest\\maximus"); RemoveDirectory("msitest"); @@ -4939,6 +5019,11 @@ static void test_publish_publishproduct(void) /* PublishProduct, current user */ r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); @@ -5115,6 +5200,7 @@ machprod: RegDeleteKeyA(hkey, ""); RegCloseKey(hkey); +error: DeleteFile(msifile); DeleteFile("msitest\\maximus"); RemoveDirectory("msitest"); @@ -5151,6 +5237,11 @@ static void test_publish_publishfeatures(void) /* PublishFeatures, current user */ r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); @@ -5219,6 +5310,7 @@ static void test_publish_publishfeatures(void) RegDeleteKeyA(hkey, ""); RegCloseKey(hkey); +error: DeleteFile(msifile); DeleteFile("msitest\\maximus"); RemoveDirectory("msitest"); @@ -5311,6 +5403,11 @@ static void test_publish_registeruser(void) /* RegisterUser, per-user */ r = MsiInstallProductA(msifile, "REGISTER_USER=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); @@ -5351,6 +5448,7 @@ static void test_publish_registeruser(void) RegDeleteKeyA(props, ""); RegCloseKey(props); +error: HeapFree(GetProcessHeap(), 0, company); HeapFree(GetProcessHeap(), 0, owner); @@ -5389,6 +5487,11 @@ static void test_publish_processcomponents(void) /* ProcessComponents, per-user */ r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); @@ -5479,6 +5582,7 @@ static void test_publish_processcomponents(void) RegDeleteKeyA(comp, ""); RegCloseKey(comp); +error: DeleteFile(msifile); DeleteFile("msitest\\maximus"); RemoveDirectory("msitest"); @@ -5535,6 +5639,11 @@ static void test_publish(void) /* nothing published */ r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\maximus"), "File not installed\n"); ok(pf_exists("msitest"), "File not installed\n"); @@ -5962,6 +6071,7 @@ static void test_publish(void) /* make sure 'Program Files\msitest' is removed */ delete_pfmsitest_files(); +error: RegCloseKey(uninstall); DeleteFile(msifile); DeleteFile("msitest\\maximus"); @@ -5990,6 +6100,11 @@ static void test_publishsourcelist(void) MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\maximus"), "File not installed\n"); ok(pf_exists("msitest"), "File not installed\n"); @@ -6159,6 +6274,7 @@ static void test_publishsourcelist(void) /* make sure 'Program Files\msitest' is removed */ delete_pfmsitest_files(); +error: DeleteFile(msifile); DeleteFile("msitest\\maximus"); RemoveDirectory("msitest"); @@ -6335,6 +6451,11 @@ static void test_transformprop(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(!delete_pf("msitest", FALSE), "File installed\n"); @@ -6349,6 +6470,7 @@ static void test_transformprop(void) ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: /* Delete the files in the temp (current) folder */ DeleteFile(msifile); DeleteFile(msifile2); @@ -6384,6 +6506,11 @@ static void test_currentworkingdir(void) sprintf(path, "%s\\%s", CURR_DIR, msifile); r = MsiInstallProductA(path, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); @@ -6405,8 +6532,8 @@ static void test_currentworkingdir(void) ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: SetCurrentDirectoryA(CURR_DIR); - DeleteFile(msifile); DeleteFile("msitest\\augustus"); RemoveDirectory("msitest"); @@ -6452,6 +6579,11 @@ static void test_admin(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(!delete_pf("msitest", FALSE), "File installed\n"); @@ -6468,6 +6600,7 @@ static void test_admin(void) ok(RemoveDirectory("c:\\msitest"), "File not installed\n"); } +error: DeleteFile(msifile); DeleteFile("msitest\\augustus"); RemoveDirectory("msitest"); @@ -6518,10 +6651,16 @@ static void test_adminprops(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(delete_pf("msitest", FALSE), "File installed\n"); +error: DeleteFile(msifile); DeleteFile("msitest\\augustus"); RemoveDirectory("msitest"); @@ -6557,6 +6696,11 @@ static void test_removefiles(void) MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\hydrogen"), "File not installed\n"); ok(!pf_exists("msitest\\helium"), "File installed\n"); @@ -6658,6 +6802,7 @@ static void test_removefiles(void) ok(!delete_pf("msitest\\cabout", FALSE), "Directory not deleted\n"); ok(delete_pf("msitest", FALSE), "Directory deleted\n"); +error: DeleteFile(msifile); DeleteFile("msitest\\hydrogen"); DeleteFile("msitest\\helium"); @@ -6710,6 +6855,11 @@ static void test_movefiles(void) CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR); r = MsiInstallProductA(msifile, props); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); ok(!delete_pf("msitest\\dest", TRUE), "File copied\n"); @@ -6771,7 +6921,32 @@ static void test_movefiles(void) ok(!DeleteFileA("bur"), "File not moved\n"); ok(DeleteFileA("bird"), "File moved\n"); +error: + DeleteFile("cameroon"); + DeleteFile("djibouti"); + DeleteFile("egypt"); + DeleteFile("finland"); + DeleteFile("gambai"); + DeleteFile("honduras"); + DeleteFile("japan"); + DeleteFile("kenya"); + DeleteFile("nauru"); + DeleteFile("peru"); + DeleteFile("apple"); + DeleteFile("application"); + DeleteFile("ape"); + DeleteFile("foo"); + DeleteFile("fao"); + DeleteFile("fbod"); + DeleteFile("budding"); + DeleteFile("buddy"); + DeleteFile("bud"); + DeleteFile("bar"); + DeleteFile("bur"); + DeleteFile("bird"); + DeleteFile("msitest\\india"); DeleteFile("msitest\\augustus"); + RemoveDirectory("latvia"); RemoveDirectory("msitest"); DeleteFile(msifile); } @@ -6794,6 +6969,11 @@ static void test_missingcab(void) create_pf_data("msitest\\caesar", "abcdefgh", TRUE); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS || broken(r == ERROR_INSTALL_FAILURE), /* win9x */ "Expected ERROR_SUCCESS, got %u\n", r); @@ -6821,6 +7001,9 @@ static void test_missingcab(void) ok(delete_pf("msitest\\gaius", TRUE), "File removed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: + delete_pf("msitest\\caesar", TRUE); + delete_pf("msitest", FALSE); DeleteFile("msitest\\augustus"); RemoveDirectory("msitest"); DeleteFile("maximus"); @@ -6841,6 +7024,11 @@ static void test_duplicatefiles(void) /* fails if the destination folder is not a valid property */ r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n"); @@ -6850,6 +7038,7 @@ static void test_duplicatefiles(void) ok(delete_pf("msitest\\this", FALSE), "File not duplicated\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: DeleteFile("msitest\\maximus"); RemoveDirectory("msitest"); DeleteFile(msifile); @@ -6871,6 +7060,11 @@ static void test_writeregistryvalues(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(delete_pf("msitest", FALSE), "File installed\n"); @@ -6887,12 +7081,13 @@ static void test_writeregistryvalues(void) ok(size == 15, "Expected 15, got %d\n", size); ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type); + RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest"); + RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine"); + +error: DeleteFile(msifile); DeleteFile("msitest\\augustus"); RemoveDirectory("msitest"); - - RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest"); - RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine"); } static void test_sourcefolder(void) @@ -6907,6 +7102,11 @@ static void test_sourcefolder(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n"); @@ -6926,6 +7126,7 @@ static void test_sourcefolder(void) ok(!delete_pf("msitest", FALSE), "File installed\n"); } +error: DeleteFile(msifile); DeleteFile("augustus"); } @@ -6942,10 +7143,16 @@ static void test_customaction51(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(delete_pf("msitest", FALSE), "File installed\n"); +error: DeleteFile(msifile); DeleteFile("msitest\\augustus"); RemoveDirectory("msitest"); @@ -6974,6 +7181,11 @@ static void test_installstate(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n"); ok(!delete_pf("msitest\\beta", TRUE), "File installed\n"); @@ -7037,6 +7249,7 @@ static void test_installstate(void) ok(!delete_pf("msitest\\mu", TRUE), "File installed\n"); ok(!delete_pf("msitest", FALSE), "File installed\n"); +error: DeleteFile(msifile); DeleteFile("msitest\\alpha"); DeleteFile("msitest\\beta"); @@ -7497,6 +7710,11 @@ static void test_MsiConfigureProductEx(void) /* install the product, per-user unmanaged */ r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\hydrogen"), "File not installed\n"); ok(pf_exists("msitest\\helium"), "File not installed\n"); @@ -7673,13 +7891,15 @@ static void test_MsiConfigureProductEx(void) ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n"); ok(!delete_pf("msitest", FALSE), "File not removed\n"); - DeleteFileA(msifile); RegCloseKey(source); RegCloseKey(props); + +error: DeleteFileA("msitest\\hydrogen"); DeleteFileA("msitest\\helium"); DeleteFileA("msitest\\lithium"); RemoveDirectoryA("msitest"); + DeleteFileA(msifile); } static void test_missingcomponent(void) @@ -7697,6 +7917,11 @@ static void test_missingcomponent(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\hydrogen"), "File not installed\n"); ok(pf_exists("msitest\\helium"), "File not installed\n"); @@ -7712,6 +7937,7 @@ static void test_missingcomponent(void) ok(!pf_exists("msitest\\beryllium"), "File installed\n"); ok(!delete_pf("msitest", FALSE), "Directory not removed\n"); +error: DeleteFileA(msifile); DeleteFileA("msitest\\hydrogen"); DeleteFileA("msitest\\helium"); @@ -7733,6 +7959,11 @@ static void test_sourcedirprop(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(delete_pf("msitest", FALSE), "File installed\n"); @@ -7751,10 +7982,14 @@ static void test_sourcedirprop(void) ok(delete_pf("msitest\\augustus", TRUE), "File installed\n"); ok(delete_pf("msitest", FALSE), "File installed\n"); - DeleteFile(msifile); DeleteFile("altsource\\msitest\\augustus"); RemoveDirectory("altsource\\msitest"); RemoveDirectory("altsource"); + +error: + DeleteFile("msitest\\augustus"); + RemoveDirectory("msitest"); + DeleteFile(msifile); } static void test_adminimage(void) @@ -7779,6 +8014,11 @@ static void test_adminimage(void) msidbSumInfoSourceTypeAdminImage); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); @@ -7794,7 +8034,8 @@ static void test_adminimage(void) ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); - DeleteFileA("msitest.msi"); +error: + DeleteFileA("msifile"); DeleteFileA("msitest\\cabout\\new\\five.txt"); DeleteFileA("msitest\\cabout\\four.txt"); DeleteFileA("msitest\\second\\three.txt"); @@ -7821,10 +8062,16 @@ static void test_propcase(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, "MyProp=42"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); +error: DeleteFile(msifile); DeleteFile("msitest\\augustus"); RemoveDirectory("msitest"); @@ -7899,6 +8146,11 @@ static void test_shortcut(void) create_database(msifile, sc_tables, sizeof(sc_tables) / sizeof(msi_table)); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); @@ -7930,7 +8182,10 @@ static void test_shortcut(void) delete_pf("msitest\\service.exe", TRUE); delete_pf("msitest\\Shortcut.lnk", TRUE); delete_pf("msitest", FALSE); + +error: delete_test_files(); + DeleteFile(msifile); } static void test_envvar(void) @@ -7961,6 +8216,11 @@ static void test_envvar(void) ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); type = REG_NONE; @@ -8028,8 +8288,6 @@ static void test_envvar(void) i++; } - - RegCloseKey(env); delete_pf("msitest\\cabout\\new\\five.txt", TRUE); delete_pf("msitest\\cabout\\new", FALSE); delete_pf("msitest\\cabout\\four.txt", TRUE); @@ -8042,7 +8300,14 @@ static void test_envvar(void) delete_pf("msitest\\one.txt", TRUE); delete_pf("msitest\\service.exe", TRUE); delete_pf("msitest", FALSE); + +error: + RegDeleteValueA(env, "MSITESTVAR1"); + RegDeleteValueA(env, "MSITESTVAR2"); + RegCloseKey(env); + delete_test_files(); + DeleteFile(msifile); } static void test_preselected(void) @@ -8053,6 +8318,11 @@ static void test_preselected(void) create_database(msifile, ps_tables, sizeof(ps_tables) / sizeof(msi_table)); r = MsiInstallProductA(msifile, "ADDLOCAL=One"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); @@ -8083,7 +8353,10 @@ static void test_preselected(void) ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "File not installed\n"); + +error: delete_test_files(); + DeleteFile(msifile); } static void test_installed_prop(void) @@ -8097,6 +8370,11 @@ static void test_installed_prop(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, "FULL=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); r = MsiInstallProductA(msifile, "FULL=1"); @@ -8121,7 +8399,9 @@ static void test_installed_prop(void) r = MsiInstallProductA(msifile, "REMOVE=ALL"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); +error: delete_test_files(); + DeleteFile(msifile); } static void test_allusers_prop(void) @@ -8135,6 +8415,11 @@ static void test_allusers_prop(void) /* ALLUSERS property unset */ r = MsiInstallProductA(msifile, "FULL=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); @@ -8241,6 +8526,10 @@ static void test_allusers_prop(void) } else ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + +error: + delete_test_files(); + DeleteFile(msifile); } static char session_manager[] = "System\\CurrentControlSet\\Control\\Session Manager"; @@ -8361,6 +8650,11 @@ static void test_file_in_use(void) file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r); ok(!file_matches_data(path, "msitest\\maximus"), "Expected file not to match\n"); CloseHandle(file); @@ -8376,8 +8670,14 @@ static void test_file_in_use(void) r = MsiInstallProductA(msifile, "REMOVE=ALL"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); +error: + RegCloseKey(hkey); + + delete_pf("msitest\\maximus", TRUE); + delete_pf("msitest", FALSE); DeleteFileA("msitest\\maximus"); delete_test_files(); + DeleteFile(msifile); } static void test_file_in_use_cab(void) @@ -8412,6 +8712,11 @@ static void test_file_in_use_cab(void) file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r); ok(!file_matches_data(path, "maximus"), "Expected file not to match\n"); CloseHandle(file); @@ -8427,8 +8732,15 @@ static void test_file_in_use_cab(void) r = MsiInstallProductA(msifile, "REMOVE=ALL"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); +error: + RegCloseKey(hkey); + + delete_pf("msitest\\maximus", TRUE); + delete_pf("msitest", FALSE); + DeleteFileA("msitest\\maximus"); delete_cab_files(); delete_test_files(); + DeleteFile(msifile); } static INT CALLBACK handler_a(LPVOID context, UINT type, LPCSTR msg) @@ -8520,6 +8832,11 @@ static void test_feature_override(void) create_database(msifile, fo_tables, sizeof(fo_tables) / sizeof(msi_table)); r = MsiInstallProductA(msifile, "ADDLOCAL=override"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\override.txt"), "file not installed\n"); @@ -8563,11 +8880,14 @@ static void test_feature_override(void) ok(delete_pf("msitest", FALSE), "directory removed\n"); } + RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest"); + +error: DeleteFileA("msitest\\override.txt"); DeleteFileA("msitest\\preselected.txt"); DeleteFileA("msitest\\notpreselected.txt"); - RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest"); delete_test_files(); + DeleteFile(msifile); } static void test_create_folder(void) @@ -8580,6 +8900,11 @@ static void test_create_folder(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); @@ -8611,7 +8936,9 @@ static void test_create_folder(void) ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); ok(!delete_pf("msitest", FALSE), "Directory created\n"); +error: delete_test_files(); + DeleteFile(msifile); } static void test_remove_folder(void) @@ -8624,6 +8951,11 @@ static void test_remove_folder(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); @@ -8655,7 +8987,9 @@ static void test_remove_folder(void) ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); ok(!delete_pf("msitest", FALSE), "Directory created\n"); +error: delete_test_files(); + DeleteFile(msifile); } static void test_start_services(void) @@ -8671,6 +9005,11 @@ static void test_start_services(void) return; } scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (!scm && GetLastError() == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok(scm != NULL, "Failed to open the SC Manager\n"); if (!scm) return; @@ -8721,6 +9060,7 @@ static void test_start_services(void) ok(delete_pf("msitest", FALSE), "Directory not created\n"); delete_test_files(); + DeleteFile(msifile); if (error == ERROR_SUCCESS) { @@ -8747,6 +9087,14 @@ static void test_delete_services(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + r = MsiInstallProductA(msifile, "REMOVE=ALL"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); @@ -8762,7 +9110,9 @@ static void test_delete_services(void) ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "Directory not created\n"); +error: delete_test_files(); + DeleteFile(msifile); } static void test_self_registration(void) @@ -8775,6 +9125,11 @@ static void test_self_registration(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); @@ -8790,7 +9145,9 @@ static void test_self_registration(void) ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "Directory not created\n"); +error: delete_test_files(); + DeleteFile(msifile); } static void test_register_font(void) @@ -8808,6 +9165,11 @@ static void test_register_font(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, regfont1, &key); @@ -8827,8 +9189,11 @@ static void test_register_font(void) RegDeleteValueA(key, "msi test font"); RegCloseKey(key); + +error: DeleteFileA("msitest\\font.ttf"); delete_test_files(); + DeleteFile(msifile); } static void test_validate_product_id(void) @@ -8841,6 +9206,11 @@ static void test_validate_product_id(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=1"); @@ -8865,7 +9235,9 @@ static void test_validate_product_id(void) ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n"); ok(delete_pf("msitest", FALSE), "Directory not created\n"); +error: delete_test_files(); + DeleteFile(msifile); } static void test_install_remove_odbc(void) @@ -8883,6 +9255,11 @@ static void test_install_remove_odbc(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\ODBCdriver.dll"), "file not created\n"); @@ -8901,12 +9278,14 @@ static void test_install_remove_odbc(void) ok(!delete_pf("msitest\\ODBCsetup.dll", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\ODBCdriver.dll"); DeleteFileA("msitest\\ODBCdriver2.dll"); DeleteFileA("msitest\\ODBCtranslator.dll"); DeleteFileA("msitest\\ODBCtranslator2.dll"); DeleteFileA("msitest\\ODBCsetup.dll"); delete_test_files(); + DeleteFile(msifile); } static void test_register_typelib(void) @@ -8920,6 +9299,11 @@ static void test_register_typelib(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, "REGISTER_TYPELIB=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); r = MsiInstallProductA(msifile, NULL); @@ -8931,8 +9315,10 @@ static void test_register_typelib(void) ok(!delete_pf("msitest\\typelib.dll", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\typelib.dll"); delete_test_files(); + DeleteFile(msifile); } static void test_create_remove_shortcut(void) @@ -8946,6 +9332,11 @@ static void test_create_remove_shortcut(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\target.txt"), "file not created\n"); @@ -8958,8 +9349,10 @@ static void test_create_remove_shortcut(void) ok(!delete_pf("msitest\\target.txt", TRUE), "file not removed\n"); todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\target.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_publish_components(void) @@ -8978,6 +9371,11 @@ static void test_publish_components(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key); @@ -8996,8 +9394,10 @@ static void test_publish_components(void) ok(!delete_pf("msitest\\english.txt", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\english.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_remove_duplicate_files(void) @@ -9013,6 +9413,11 @@ static void test_remove_duplicate_files(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(pf_exists("msitest\\original.txt"), "file not created\n"); @@ -9031,10 +9436,12 @@ static void test_remove_duplicate_files(void) ok(!delete_pf("msitest\\duplicate2.txt", TRUE), "file not removed\n"); ok(delete_pf("msitest", FALSE), "directory removed\n"); +error: DeleteFileA("msitest\\original.txt"); DeleteFileA("msitest\\original2.txt"); DeleteFileA("msitest\\original3.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_remove_registry_values(void) @@ -9069,6 +9476,11 @@ static void test_remove_registry_values(void) RegCloseKey(key); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", &key); @@ -9106,8 +9518,15 @@ static void test_remove_registry_values(void) ok(!delete_pf("msitest\\registry.txt", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: + RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1"); + RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2"); + RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA"); + RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyB"); + DeleteFileA("msitest\\registry.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_find_related_products(void) @@ -9121,6 +9540,11 @@ static void test_find_related_products(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); /* install again, so it finds the upgrade code */ @@ -9133,8 +9557,10 @@ static void test_find_related_products(void) ok(!delete_pf("msitest\\product.txt", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\product.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_remove_ini_values(void) @@ -9151,7 +9577,12 @@ static void test_remove_ini_values(void) lstrcpyA(inifile, PROG_FILES_DIR); lstrcatA(inifile, "\\msitest"); - CreateDirectoryA(inifile, NULL); + ret = CreateDirectoryA(inifile, NULL); + if (!ret && GetLastError() == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } lstrcatA(inifile, "\\test.ini"); file = CreateFileA(inifile, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, NULL); CloseHandle(file); @@ -9186,8 +9617,10 @@ static void test_remove_ini_values(void) ok(!delete_pf("msitest\\inifile.txt", TRUE), "file not removed\n"); ok(delete_pf("msitest", FALSE), "directory removed\n"); +error: DeleteFileA("msitest\\inifile.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_remove_env_strings(void) @@ -9222,6 +9655,11 @@ static void test_remove_env_strings(void) RegCloseKey(key); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); res = RegOpenKeyA(HKEY_CURRENT_USER, "Environment", &key); @@ -9302,13 +9740,20 @@ static void test_remove_env_strings(void) ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer); RegDeleteValueA(key, "MSITESTVAR5"); - RegCloseKey(key); - ok(!delete_pf("msitest\\envvar.txt", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: + RegDeleteValueA(key, "MSITESTVAR1"); + RegDeleteValueA(key, "MSITESTVAR2"); + RegDeleteValueA(key, "MSITESTVAR3"); + RegDeleteValueA(key, "MSITESTVAR4"); + RegDeleteValueA(key, "MSITESTVAR5"); + RegCloseKey(key); + DeleteFileA("msitest\\envvar.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_register_class_info(void) @@ -9324,6 +9769,11 @@ static void test_register_class_info(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey); @@ -9353,8 +9803,10 @@ static void test_register_class_info(void) ok(!delete_pf("msitest\\class.txt", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\class.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_register_extension_info(void) @@ -9370,6 +9822,11 @@ static void test_register_extension_info(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); res = RegOpenKeyA(HKEY_CLASSES_ROOT, ".extension", &hkey); @@ -9392,8 +9849,10 @@ static void test_register_extension_info(void) ok(!delete_pf("msitest\\extension.txt", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\extension.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_register_mime_info(void) @@ -9409,6 +9868,11 @@ static void test_register_mime_info(void) MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); r = MsiInstallProductA(msifile, NULL); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); res = RegOpenKeyA(HKEY_CLASSES_ROOT, "MIME\\Database\\Content Type\\mime/type", &hkey); @@ -9424,8 +9888,10 @@ static void test_register_mime_info(void) ok(!delete_pf("msitest\\mime.txt", TRUE), "file not removed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n"); +error: DeleteFileA("msitest\\mime.txt"); delete_test_files(); + DeleteFile(msifile); } static void test_icon_table(void) @@ -9464,6 +9930,12 @@ static void test_icon_table(void) /* per-user */ res = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1"); + if (res == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok(res == ERROR_SUCCESS, "Failed to do per-user install: %d\n", res); lstrcpyA(path, APP_DATA_DIR); @@ -9499,7 +9971,6 @@ static void test_icon_table(void) ok(res == ERROR_SUCCESS, "Failed to uninstall system-wide\n"); delete_pfmsitest_files(); - DeleteFile(msifile); } diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c index 99335a8d12a..06f85b58fdb 100644 --- a/dlls/msi/tests/msi.c +++ b/dlls/msi/tests/msi.c @@ -275,6 +275,11 @@ static void test_null(void) /* empty product string */ r = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, access, &hkey); + if (r == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok( r == ERROR_SUCCESS, "wrong error %d\n", r); r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData); @@ -614,6 +619,13 @@ static void test_MsiQueryProductState(void) lstrcatA(keypath, prodcode); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + RegDeleteKeyA(userkey, ""); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* local uninstall key exists */ @@ -914,6 +926,14 @@ static void test_MsiQueryFeatureState(void) lstrcatA(keypath, "\\Features"); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + RegDeleteKeyA(userkey, ""); + RegCloseKey(userkey); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* userdata features key exists */ @@ -1309,6 +1329,12 @@ static void test_MsiQueryComponentState(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); state = MAGIC_ERROR; @@ -1637,6 +1663,12 @@ static void test_MsiGetComponentPath(void) lstrcatA(keypath, comp_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* local system component key exists */ @@ -2155,6 +2187,12 @@ static void test_MsiGetProductCode(void) lstrcatA(keypath, comp_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* user unmanaged component key exists */ @@ -2397,6 +2435,12 @@ static void test_MsiEnumClients(void) lstrcatA(keypath, comp_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* user unmanaged component key exists */ @@ -2911,6 +2955,12 @@ static void test_MsiGetProductInfo(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* managed product code exists */ @@ -4222,6 +4272,12 @@ static void test_MsiGetProductInfoEx(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* local user product key exists */ @@ -7007,6 +7063,12 @@ static void test_MsiGetUserInfo(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* managed product key exists */ @@ -7483,6 +7545,12 @@ static void test_MsiOpenProduct(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* managed product key exists */ @@ -7745,6 +7813,11 @@ static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid, LPCSTR expectedsid r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED, MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod, &context, targetsid, &size); + if (r == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r); ok(!lstrcmpA(patchcode, "apple"), "Expected patchcode to be unchanged, got %s\n", patchcode); @@ -7762,6 +7835,11 @@ static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid, LPCSTR expectedsid lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* managed product key exists */ @@ -8510,6 +8588,11 @@ static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid, LPCSTR expecteds lstrcatA(keypath, patch_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* userdata patch key exists */ @@ -8759,6 +8842,8 @@ static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid, LPCSTR expecteds RegCloseKey(userkey); RegDeleteValueA(patches, patch_squashed); RegDeleteValueA(patches, "Patches"); + +error: RegDeleteKeyA(patches, ""); RegCloseKey(patches); RegDeleteKeyA(prodkey, ""); @@ -8811,6 +8896,11 @@ static void test_MsiEnumPatchesEx_machine(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* local product key exists */ @@ -9588,6 +9678,12 @@ static void test_MsiEnumPatches(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* managed product key exists */ @@ -10430,6 +10526,12 @@ static void test_MsiGetPatchInfoEx(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); /* local UserData product key exists */ @@ -11219,6 +11321,11 @@ static void test_MsiGetPatchInfo(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_product, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res); /* product key exists */ @@ -11386,6 +11493,12 @@ static void test_MsiEnumProducts(void) strcat(keypath1, product_squashed1); r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL); + if (r == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + LocalFree(usersid); + return; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); strcpy(keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\"); diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 4fc80ac5085..89be16eeeef 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -681,7 +681,7 @@ static MSIHANDLE create_package_db(void) /* create an empty database */ res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb ); - ok( res == ERROR_SUCCESS , "Failed to create database\n" ); + ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res ); if( res != ERROR_SUCCESS ) return hdb; @@ -710,7 +710,10 @@ static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle) sprintf(szPackage, "#%u", hdb); res = MsiOpenPackage(szPackage, &hPackage); if (res != ERROR_SUCCESS) + { + MsiCloseHandle(hdb); return res; + } res = MsiCloseHandle(hdb); if (res != ERROR_SUCCESS) @@ -825,6 +828,12 @@ static void test_createpackage(void) UINT res; res = package_from_db(create_package_db(), &hPackage); + if (res == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res ); res = MsiCloseHandle( hPackage); @@ -841,6 +850,12 @@ static void test_doaction( void ) ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n"); r = package_from_db(create_package_db(), &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r); r = MsiDoAction(hpkg, NULL); @@ -867,6 +882,12 @@ static void test_gettargetpath_bad(void) UINT r; r = package_from_db(create_package_db(), &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r); r = MsiGetTargetPath( 0, NULL, NULL, NULL ); @@ -987,6 +1008,12 @@ static void test_settargetpath(void) ok( r == S_OK, "cannot add file to the File table: %d\n", r ); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r); r = MsiDoAction( hpkg, "CostInitialize"); @@ -1079,6 +1106,12 @@ static void test_condition(void) MSIHANDLE hpkg; r = package_from_db(create_package_db(), &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r); r = MsiEvaluateCondition(0, NULL); @@ -1826,6 +1859,12 @@ static void test_props(void) ok( r == ERROR_SUCCESS , "Failed\n" ); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r); /* test invalid values */ @@ -2030,6 +2069,12 @@ static void test_property_table(void) ok( hdb, "failed to create package\n"); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r); MsiCloseHandle(hdb); @@ -2205,6 +2250,11 @@ static void test_msipackage(void) /* empty szPackagePath */ r = MsiOpenPackage("", &hpack); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + return; + } todo_wine { ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); @@ -2290,6 +2340,12 @@ static void test_formatrecord2(void) UINT r; r = package_from_db(create_package_db(), &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r); r = MsiSetProperty(hpkg, "Manufacturer", " " ); @@ -2712,6 +2768,12 @@ static void test_states(void) ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r ); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r ); MsiCloseHandle(hdb); @@ -7202,6 +7264,12 @@ static void test_getproperty(void) UINT r; r = package_from_db(create_package_db(), &hPackage); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r ); /* set the property */ @@ -7323,6 +7391,12 @@ static void test_removefiles(void) ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r ); MsiCloseHandle( hdb ); @@ -7411,6 +7485,12 @@ static void test_appsearch(void) ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r ); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r ); MsiCloseHandle( hdb ); @@ -7603,6 +7683,11 @@ static void test_appsearch_complocator(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r); r = MsiSetPropertyA(hpkg, "SIGPROP8", "october"); @@ -7701,6 +7786,9 @@ static void test_appsearch_complocator(void) delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", MSIINSTALLCONTEXT_MACHINE, NULL); + MsiCloseHandle(hpkg); + +error: DeleteFileA("FileName1"); DeleteFileA("FileName2"); DeleteFileA("FileName3"); @@ -7711,7 +7799,6 @@ static void test_appsearch_complocator(void) DeleteFileA("FileName8.dll"); DeleteFileA("FileName9.dll"); DeleteFileA("FileName10.dll"); - MsiCloseHandle(hpkg); DeleteFileA(msifile); LocalFree(usersid); } @@ -7740,6 +7827,11 @@ static void test_appsearch_reglocator(void) DeleteFileA("test.dll"); res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); res = RegSetValueExA(classes, "Value1", 0, REG_SZ, @@ -8570,6 +8662,11 @@ static void test_appsearch_inilocator(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r); r = MsiDoAction(hpkg, "AppSearch"); @@ -8647,12 +8744,14 @@ static void test_appsearch_inilocator(void) ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop); } + MsiCloseHandle(hpkg); + +error: delete_win_ini("IniFile.ini"); DeleteFileA("FileName1"); DeleteFileA("FileName2.dll"); DeleteFileA("FileName3.dll"); DeleteFileA("FileName4.dll"); - MsiCloseHandle(hpkg); DeleteFileA(msifile); } @@ -8866,6 +8965,11 @@ static void test_appsearch_drlocator(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r); r = MsiDoAction(hpkg, "AppSearch"); @@ -8942,6 +9046,9 @@ static void test_appsearch_drlocator(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(!prop[0], "Expected \"\", got \"%s\"\n", prop); + MsiCloseHandle(hpkg); + +error: DeleteFileA("FileName1"); DeleteFileA("FileName3.dll"); DeleteFileA("FileName4.dll"); @@ -8951,7 +9058,6 @@ static void test_appsearch_drlocator(void) RemoveDirectoryA("one\\two"); RemoveDirectoryA("one"); RemoveDirectoryA("another"); - MsiCloseHandle(hpkg); DeleteFileA(msifile); } @@ -9128,6 +9234,12 @@ static void test_featureparents(void) ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r ); MsiCloseHandle( hdb ); @@ -9380,6 +9492,12 @@ static void test_installprops(void) ok( hdb, "failed to create database\n"); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r ); MsiCloseHandle(hdb); @@ -9501,6 +9619,12 @@ static void test_launchconditions(void) ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r ); r = package_from_db( hdb, &hpkg ); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok( r == ERROR_SUCCESS, "failed to create package %u\n", r ); MsiCloseHandle( hdb ); @@ -9560,6 +9684,12 @@ static void test_ccpsearch(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok(r == ERROR_SUCCESS, "failed to create package %u\n", r); MsiCloseHandle(hdb); @@ -9716,6 +9846,12 @@ static void test_complocator(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok(r == ERROR_SUCCESS, "failed to create package %u\n", r); MsiCloseHandle(hdb); @@ -9947,6 +10083,12 @@ static void test_MsiGetSourcePath(void) ok(r == ERROR_SUCCESS , "Failed to commit database\n"); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok(r == ERROR_SUCCESS, "failed to create package %u\n", r); MsiCloseHandle(hdb); @@ -10637,6 +10779,12 @@ static void test_shortlongsource(void) MsiDatabaseCommit(hdb); r = package_from_db(hdb, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok(r == ERROR_SUCCESS, "failed to create package %u\n", r); MsiCloseHandle(hdb); @@ -10918,7 +11066,7 @@ static void test_shortlongsource(void) static void test_sourcedir(void) { MSIHANDLE hdb, hpkg; - CHAR package[10]; + CHAR package[12]; CHAR path[MAX_PATH]; CHAR cwd[MAX_PATH]; CHAR subsrc[MAX_PATH]; @@ -10938,8 +11086,13 @@ static void test_sourcedir(void) r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'"); ok(r == S_OK, "failed\n"); - sprintf(package, "#%i", hdb); + sprintf(package, "#%u", hdb); r = MsiOpenPackage(package, &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto error; + } ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); /* properties only */ @@ -11243,8 +11396,10 @@ static void test_sourcedir(void) "Expected path to be unchanged, got \"%s\"\n", path); ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size); - MsiCloseHandle(hdb); MsiCloseHandle(hpkg); + +error: + MsiCloseHandle(hdb); DeleteFileA(msifile); } @@ -11410,6 +11565,11 @@ static void test_emptypackage(void) UINT r; r = MsiOpenPackageA("", &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + return; + } todo_wine { ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); @@ -11632,6 +11792,12 @@ static void test_MsiGetProductProperty(void) lstrcatA(keypath, prod_squashed); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL); + if (res == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\"); @@ -11801,6 +11967,12 @@ static void test_MsiSetProperty(void) UINT r; r = package_from_db(create_package_db(), &hpkg); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + DeleteFile(msifile); + return; + } ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r); /* invalid hInstall */