msi/tests: Factor out success checks into table building functions.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2017-09-19 10:50:14 -05:00 committed by Alexandre Julliard
parent 4a75c37b41
commit b91a274892
2 changed files with 729 additions and 1589 deletions

View File

@ -203,7 +203,7 @@ static UINT run_queryW( MSIHANDLE hdb, MSIHANDLE hrec, const WCHAR *query )
static UINT create_component_table( MSIHANDLE hdb ) static UINT create_component_table( MSIHANDLE hdb )
{ {
return run_query( hdb, 0, UINT r = run_query( hdb, 0,
"CREATE TABLE `Component` ( " "CREATE TABLE `Component` ( "
"`Component` CHAR(72) NOT NULL, " "`Component` CHAR(72) NOT NULL, "
"`ComponentId` CHAR(38), " "`ComponentId` CHAR(38), "
@ -212,87 +212,99 @@ static UINT create_component_table( MSIHANDLE hdb )
"`Condition` CHAR(255), " "`Condition` CHAR(255), "
"`KeyPath` CHAR(72) " "`KeyPath` CHAR(72) "
"PRIMARY KEY `Component`)" ); "PRIMARY KEY `Component`)" );
ok(r == ERROR_SUCCESS, "Failed to create Component table: %u\n", r);
return r;
} }
static UINT create_custom_action_table( MSIHANDLE hdb ) static UINT create_custom_action_table( MSIHANDLE hdb )
{ {
return run_query( hdb, 0, UINT r = run_query( hdb, 0,
"CREATE TABLE `CustomAction` ( " "CREATE TABLE `CustomAction` ( "
"`Action` CHAR(72) NOT NULL, " "`Action` CHAR(72) NOT NULL, "
"`Type` SHORT NOT NULL, " "`Type` SHORT NOT NULL, "
"`Source` CHAR(72), " "`Source` CHAR(72), "
"`Target` CHAR(255) " "`Target` CHAR(255) "
"PRIMARY KEY `Action`)" ); "PRIMARY KEY `Action`)" );
ok(r == ERROR_SUCCESS, "Failed to create CustomAction table: %u\n", r);
return r;
} }
static UINT create_directory_table( MSIHANDLE hdb ) static UINT create_directory_table( MSIHANDLE hdb )
{ {
return run_query( hdb, 0, UINT r = run_query( hdb, 0,
"CREATE TABLE `Directory` ( " "CREATE TABLE `Directory` ( "
"`Directory` CHAR(255) NOT NULL, " "`Directory` CHAR(255) NOT NULL, "
"`Directory_Parent` CHAR(255), " "`Directory_Parent` CHAR(255), "
"`DefaultDir` CHAR(255) NOT NULL " "`DefaultDir` CHAR(255) NOT NULL "
"PRIMARY KEY `Directory`)" ); "PRIMARY KEY `Directory`)" );
ok(r == ERROR_SUCCESS, "Failed to create Directory table: %u\n", r);
return r;
} }
static UINT create_feature_components_table( MSIHANDLE hdb ) static UINT create_feature_components_table( MSIHANDLE hdb )
{ {
return run_query( hdb, 0, UINT r = run_query( hdb, 0,
"CREATE TABLE `FeatureComponents` ( " "CREATE TABLE `FeatureComponents` ( "
"`Feature_` CHAR(38) NOT NULL, " "`Feature_` CHAR(38) NOT NULL, "
"`Component_` CHAR(72) NOT NULL " "`Component_` CHAR(72) NOT NULL "
"PRIMARY KEY `Feature_`, `Component_` )" ); "PRIMARY KEY `Feature_`, `Component_` )" );
ok(r == ERROR_SUCCESS, "Failed to create FeatureComponents table: %u\n", r);
return r;
} }
static UINT create_std_dlls_table( MSIHANDLE hdb ) static UINT create_std_dlls_table( MSIHANDLE hdb )
{ {
return run_query( hdb, 0, UINT r = run_query( hdb, 0,
"CREATE TABLE `StdDlls` ( " "CREATE TABLE `StdDlls` ( "
"`File` CHAR(255) NOT NULL, " "`File` CHAR(255) NOT NULL, "
"`Binary_` CHAR(72) NOT NULL " "`Binary_` CHAR(72) NOT NULL "
"PRIMARY KEY `File` )" ); "PRIMARY KEY `File` )" );
ok(r == ERROR_SUCCESS, "Failed to create StdDlls table: %u\n", r);
return r;
} }
static UINT create_binary_table( MSIHANDLE hdb ) static UINT create_binary_table( MSIHANDLE hdb )
{ {
return run_query( hdb, 0, UINT r = run_query( hdb, 0,
"CREATE TABLE `Binary` ( " "CREATE TABLE `Binary` ( "
"`Name` CHAR(72) NOT NULL, " "`Name` CHAR(72) NOT NULL, "
"`Data` CHAR(72) NOT NULL " "`Data` CHAR(72) NOT NULL "
"PRIMARY KEY `Name` )" ); "PRIMARY KEY `Name` )" );
ok(r == ERROR_SUCCESS, "Failed to create Binary table: %u\n", r);
return r;
} }
#define make_add_entry(type, qtext) \ static inline UINT add_entry(const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \ {
{ \ char *query;
char insert[] = qtext; \ UINT sz, r;
char *query; \
UINT sz, r; \
sz = strlen(values) + sizeof insert; \
query = HeapAlloc(GetProcessHeap(),0,sz); \
sprintf(query,insert,values); \
r = run_query( hdb, 0, query ); \
HeapFree(GetProcessHeap(), 0, query); \
return r; \
}
make_add_entry(component, sz = strlen(values) + strlen(insert) + 1;
"INSERT INTO `Component` " query = HeapAlloc(GetProcessHeap(), 0, sz);
"(`Component`, `ComponentId`, `Directory_`, " sprintf(query, insert, values);
r = run_query(hdb, 0, query);
HeapFree(GetProcessHeap(), 0, query);
ok_(file, line)(r == ERROR_SUCCESS, "failed to insert into %s table: %u\n", type, r);
return r;
}
#define add_component_entry(hdb, values) add_entry(__FILE__, __LINE__, "Component", hdb, values, \
"INSERT INTO `Component` " \
"(`Component`, `ComponentId`, `Directory_`, " \
"`Attributes`, `Condition`, `KeyPath`) VALUES( %s )") "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
make_add_entry(custom_action, #define add_custom_action_entry(hdb, values) add_entry(__FILE__, __LINE__, "CustomAction", hdb, values, \
"INSERT INTO `CustomAction` " "INSERT INTO `CustomAction` " \
"(`Action`, `Type`, `Source`, `Target`) VALUES( %s )") "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
make_add_entry(feature_components, #define add_feature_components_entry(hdb, values) add_entry(__FILE__, __LINE__, "FeatureComponents", hdb, values, \
"INSERT INTO `FeatureComponents` " "INSERT INTO `FeatureComponents` " \
"(`Feature_`, `Component_`) VALUES( %s )") "(`Feature_`, `Component_`) VALUES( %s )")
make_add_entry(std_dlls, #define add_std_dlls_entry(hdb, values) add_entry(__FILE__, __LINE__, "StdDlls", hdb, values, \
"INSERT INTO `StdDlls` (`File`, `Binary_`) VALUES( %s )") "INSERT INTO `StdDlls` (`File`, `Binary_`) VALUES( %s )")
make_add_entry(binary, #define add_binary_entry(hdb, values) add_entry(__FILE__, __LINE__, "Binary", hdb, values, \
"INSERT INTO `Binary` (`Name`, `Data`) VALUES( %s )") "INSERT INTO `Binary` (`Name`, `Data`) VALUES( %s )")
static void test_msiinsert(void) static void test_msiinsert(void)
@ -3127,8 +3139,7 @@ static MSIHANDLE create_package_db(const WCHAR *filename)
res = set_summary_info(hdb); res = set_summary_info(hdb);
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" ); ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = create_directory_table(hdb); create_directory_table(hdb);
ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
return hdb; return hdb;
} }
@ -3457,62 +3468,28 @@ static void test_join(void)
hdb = create_db(); hdb = create_db();
ok( hdb, "failed to create db\n"); ok( hdb, "failed to create db\n");
r = create_component_table( hdb ); create_component_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r ); add_component_entry( hdb, "'zygomatic', 'malar', 'INSTALLDIR', 0, '', ''" );
add_component_entry( hdb, "'maxilla', 'alveolar', 'INSTALLDIR', 0, '', ''" );
add_component_entry( hdb, "'nasal', 'septum', 'INSTALLDIR', 0, '', ''" );
add_component_entry( hdb, "'mandible', 'ramus', 'INSTALLDIR', 0, '', ''" );
r = add_component_entry( hdb, "'zygomatic', 'malar', 'INSTALLDIR', 0, '', ''" ); create_feature_components_table( hdb );
ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r ); add_feature_components_entry( hdb, "'procerus', 'maxilla'" );
add_feature_components_entry( hdb, "'procerus', 'nasal'" );
add_feature_components_entry( hdb, "'nasalis', 'nasal'" );
add_feature_components_entry( hdb, "'nasalis', 'mandible'" );
add_feature_components_entry( hdb, "'nasalis', 'notacomponent'" );
add_feature_components_entry( hdb, "'mentalis', 'zygomatic'" );
r = add_component_entry( hdb, "'maxilla', 'alveolar', 'INSTALLDIR', 0, '', ''" ); create_std_dlls_table( hdb );
ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r ); add_std_dlls_entry( hdb, "'msvcp.dll', 'msvcp.dll.01234'" );
add_std_dlls_entry( hdb, "'msvcr.dll', 'msvcr.dll.56789'" );
r = add_component_entry( hdb, "'nasal', 'septum', 'INSTALLDIR', 0, '', ''" ); create_binary_table( hdb );
ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r ); add_binary_entry( hdb, "'msvcp.dll.01234', 'abcdefgh'" );
add_binary_entry( hdb, "'msvcr.dll.56789', 'ijklmnop'" );
r = add_component_entry( hdb, "'mandible', 'ramus', 'INSTALLDIR', 0, '', ''" ); add_binary_entry( hdb, "'single.dll.31415', 'msvcp.dll'" );
ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
r = create_feature_components_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
r = add_feature_components_entry( hdb, "'procerus', 'maxilla'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = add_feature_components_entry( hdb, "'procerus', 'nasal'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = add_feature_components_entry( hdb, "'nasalis', 'nasal'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = add_feature_components_entry( hdb, "'nasalis', 'mandible'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = add_feature_components_entry( hdb, "'nasalis', 'notacomponent'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = add_feature_components_entry( hdb, "'mentalis', 'zygomatic'" );
ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
r = create_std_dlls_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create StdDlls table: %d\n", r );
r = add_std_dlls_entry( hdb, "'msvcp.dll', 'msvcp.dll.01234'" );
ok( r == ERROR_SUCCESS, "cannot add std dlls: %d\n", r );
r = add_std_dlls_entry( hdb, "'msvcr.dll', 'msvcr.dll.56789'" );
ok( r == ERROR_SUCCESS, "cannot add std dlls: %d\n", r );
r = create_binary_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create Binary table: %d\n", r );
r = add_binary_entry( hdb, "'msvcp.dll.01234', 'abcdefgh'" );
ok( r == ERROR_SUCCESS, "cannot add binary: %d\n", r );
r = add_binary_entry( hdb, "'msvcr.dll.56789', 'ijklmnop'" );
ok( r == ERROR_SUCCESS, "cannot add binary: %d\n", r );
r = add_binary_entry( hdb, "'single.dll.31415', 'msvcp.dll'" );
ok( r == ERROR_SUCCESS, "cannot add binary: %d\n", r );
query = "CREATE TABLE `One` (`A` SHORT, `B` SHORT PRIMARY KEY `A`)"; query = "CREATE TABLE `One` (`A` SHORT, `B` SHORT PRIMARY KEY `A`)";
r = run_query( hdb, 0, query); r = run_query( hdb, 0, query);
@ -7667,14 +7644,10 @@ static void test_dbtopackage(void)
set_summary_info(hdb); set_summary_info(hdb);
r = create_directory_table(hdb); create_directory_table(hdb);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = create_custom_action_table(hdb); create_custom_action_table(hdb);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
r = add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sprintf(package, "#%u", hdb); sprintf(package, "#%u", hdb);
r = MsiOpenPackageA(package, &hpkg); r = MsiOpenPackageA(package, &hpkg);
@ -7731,14 +7704,10 @@ static void test_dbtopackage(void)
set_summary_info(hdb); set_summary_info(hdb);
r = create_directory_table(hdb); create_directory_table(hdb);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = create_custom_action_table(hdb); create_custom_action_table(hdb);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
r = add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sprintf(package, "#%u", hdb); sprintf(package, "#%u", hdb);
r = MsiOpenPackageA(package, &hpkg); r = MsiOpenPackageA(package, &hpkg);

File diff suppressed because it is too large Load Diff