Commit 88677129 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

msi/tests: Test self-registration of a valid DLL.

parent d3023ad3
...@@ -16,6 +16,8 @@ SOURCES = \ ...@@ -16,6 +16,8 @@ SOURCES = \
patch.c \ patch.c \
record.c \ record.c \
rsrc.rc \ rsrc.rc \
selfreg.c \
selfreg.spec \
source.c \ source.c \
suminfo.c \ suminfo.c \
typelib.idl typelib.idl
...@@ -733,30 +733,55 @@ static const char cf_custom_action_dat[] = ...@@ -733,30 +733,55 @@ static const char cf_custom_action_dat[] =
"rf_immediate\t1\tcustom.dll\tcf_present\n" "rf_immediate\t1\tcustom.dll\tcf_present\n"
"rf_deferred\t1025\tcustom.dll\tcf_absent\n"; "rf_deferred\t1025\tcustom.dll\tcf_absent\n";
static const char sr_file_dat[] =
"File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
"s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
"File\tFile\n"
"selfreg.dll\tselfreg\tselfreg.dll\t1000\t\t\t8192\t1\n";
static const char sr_feature_dat[] =
"Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
"s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
"Feature\tFeature\n"
"selfreg\t\t\tselfreg feature\t1\t2\tMSITESTDIR\t0\n";
static const char sr_feature_comp_dat[] =
"Feature_\tComponent_\n"
"s38\ts72\n"
"FeatureComponents\tFeature_\tComponent_\n"
"selfreg\tselfreg\n";
static const char sr_component_dat[] =
"Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
"s72\tS38\ts72\ti2\tS255\tS72\n"
"Component\tComponent\n"
"selfreg\t{BB4C26FD-89D8-4E49-AF1C-DB4DCB5BF1B0}\tMSITESTDIR\t0\t\tselfreg.dll\n";
static const char sr_selfreg_dat[] = static const char sr_selfreg_dat[] =
"File_\tCost\n" "File_\tCost\n"
"s72\tI2\n" "s72\tI2\n"
"SelfReg\tFile_\n" "SelfReg\tFile_\n"
"one.txt\t1\n"; "selfreg.dll\t\n";
static const char sr_install_exec_seq_dat[] = static const char sr_install_exec_seq_dat[] =
"Action\tCondition\tSequence\n" "Action\tCondition\tSequence\n"
"s72\tS255\tI2\n" "s72\tS255\tI2\n"
"InstallExecuteSequence\tAction\n" "InstallExecuteSequence\tAction\n"
"CostFinalize\t\t1000\n"
"CostInitialize\t\t800\n" "CostInitialize\t\t800\n"
"FileCost\t\t900\n" "FileCost\t\t900\n"
"ResolveSource\t\t950\n" "CostFinalize\t\t1000\n"
"MoveFiles\t\t1700\n" "InstallValidate\t\t1400\n"
"SelfUnregModules\t\t3900\n" "InstallInitialize\t\t1500\n"
"ProcessComponents\t\t1600\n"
"SelfUnregModules\t\t3800\n"
"RemoveFiles\t\t3900\n"
"InstallFiles\t\t4000\n" "InstallFiles\t\t4000\n"
"DuplicateFiles\t\t4500\n" "SelfRegModules\t\t4100\n"
"WriteEnvironmentStrings\t\t4550\n"
"CreateShortcuts\t\t4600\n" "CreateShortcuts\t\t4600\n"
"InstallFinalize\t\t6600\n" "RegisterProduct\t\t5100\n"
"InstallInitialize\t\t1500\n" "PublishFeatures\t\t5200\n"
"InstallValidate\t\t1400\n" "PublishProduct\t\t5300\n"
"LaunchConditions\t\t100\n"; "InstallFinalize\t\t6600\n";
static const char font_media_dat[] = static const char font_media_dat[] =
"DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n" "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
...@@ -2096,11 +2121,11 @@ static const msi_table sis_tables[] = ...@@ -2096,11 +2121,11 @@ static const msi_table sis_tables[] =
static const msi_table sr_tables[] = static const msi_table sr_tables[] =
{ {
ADD_TABLE(component), ADD_TABLE(sr_component),
ADD_TABLE(directory), ADD_TABLE(directory),
ADD_TABLE(feature), ADD_TABLE(sr_feature),
ADD_TABLE(feature_comp), ADD_TABLE(sr_feature_comp),
ADD_TABLE(file), ADD_TABLE(sr_file),
ADD_TABLE(sr_selfreg), ADD_TABLE(sr_selfreg),
ADD_TABLE(sr_install_exec_seq), ADD_TABLE(sr_install_exec_seq),
ADD_TABLE(media), ADD_TABLE(media),
...@@ -5395,6 +5420,7 @@ error: ...@@ -5395,6 +5420,7 @@ error:
static void test_self_registration(void) static void test_self_registration(void)
{ {
HKEY key;
UINT r; UINT r;
if (is_process_limited()) if (is_process_limited())
...@@ -5404,6 +5430,7 @@ static void test_self_registration(void) ...@@ -5404,6 +5430,7 @@ static void test_self_registration(void)
} }
create_test_files(); create_test_files();
extract_resource("selfreg.dll", "TESTDLL", "msitest\\selfreg.dll");
create_database(msifile, sr_tables, sizeof(sr_tables) / sizeof(msi_table)); create_database(msifile, sr_tables, sizeof(sr_tables) / sizeof(msi_table));
MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
...@@ -5416,21 +5443,21 @@ static void test_self_registration(void) ...@@ -5416,21 +5443,21 @@ static void test_self_registration(void)
} }
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n"); r = RegOpenKeyA(HKEY_CLASSES_ROOT, "selfreg_test", &key);
ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n"); ok(!r, "got %u\n", r);
ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n"); RegCloseKey(key);
ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n"); r = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n"); ok(!r, "got %u\n", r);
ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\first", FALSE), "Directory not created\n"); r = RegOpenKeyA(HKEY_CLASSES_ROOT, "selfreg_test", &key);
ok(delete_pf("msitest\\filename", TRUE), "File not installed\n"); ok(r == ERROR_FILE_NOT_FOUND, "got %u\n", r);
ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n"); ok(!delete_pf("msitest\\selfreg.dll", TRUE), "file not removed\n");
ok(delete_pf("msitest\\service2.exe", TRUE), "File not installed\n"); ok(!delete_pf("msitest", FALSE), "directory not removed\n");
ok(delete_pf("msitest", FALSE), "Directory not created\n");
error: error:
DeleteFileA("msitest\\selfreg.dll");
delete_test_files(); delete_test_files();
DeleteFileA(msifile); DeleteFileA(msifile);
} }
......
/*
* DLL for testing self-registration
*
* Copyright 2018 Zebediah Figura
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
HRESULT WINAPI DllRegisterServer(void)
{
HKEY key;
RegCreateKeyA(HKEY_CLASSES_ROOT, "selfreg_test", &key);
RegCloseKey(key);
return S_OK;
}
HRESULT WINAPI DllUnregisterServer(void)
{
RegDeleteKeyA(HKEY_CLASSES_ROOT, "selfreg_test");
return S_OK;
}
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment