https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56c14436f41cb975ee18e…
commit 56c14436f41cb975ee18ee99181e5615287a9280
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:12:14 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:44 2022 +0100
[WINESYNC] msi/tests: More accurately calculate estimated size.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 40b211b6c2d61effba333cb64fb30289d3a18ee1 by Zebediah Figura
<z.figura12(a)gmail.com>
---
modules/rostests/winetests/msi/action.c | 113 ++++++++------------------------
1 file changed, 26 insertions(+), 87 deletions(-)
diff --git a/modules/rostests/winetests/msi/action.c
b/modules/rostests/winetests/msi/action.c
index 8e72ff4e36e..849975d997e 100644
--- a/modules/rostests/winetests/msi/action.c
+++ b/modules/rostests/winetests/msi/action.c
@@ -2321,45 +2321,6 @@ static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD
expected, DWORD lin
ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected,
val);
}
-static void check_reg_dword4(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2,
DWORD expected3,
- DWORD expected4, DWORD line)
-{
- DWORD val, size, type;
- LONG res;
-
- size = sizeof(DWORD);
- res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
-
- if (res != ERROR_SUCCESS || type != REG_DWORD)
- {
- ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
- return;
- }
-
- ok_(__FILE__, line)(val == expected1 || val == expected2 || val == expected3 || val
== expected4,
- "Expected %d, %d, %d or %d, got %d\n", expected1, expected2, expected3,
expected4, val);
-}
-
-static void check_reg_dword5(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2,
DWORD expected3,
- DWORD expected4, DWORD expected5, DWORD line)
-{
- DWORD val, size, type;
- LONG res;
-
- size = sizeof(DWORD);
- res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
-
- if (res != ERROR_SUCCESS || type != REG_DWORD)
- {
- ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
- return;
- }
-
- ok_(__FILE__, line)(val == expected1 || val == expected2 || val == expected3 || val
== expected4 ||
- val == expected5,
- "Expected %d, %d, %d, %d or %d, got %d\n", expected1, expected2,
expected3, expected4, expected5, val);
-}
-
#define CHECK_REG_STR(prodkey, name, expected) \
check_reg_str(prodkey, name, expected, TRUE, __LINE__);
@@ -2387,24 +2348,6 @@ static void check_reg_dword5(HKEY prodkey, LPCSTR name, DWORD
expected1, DWORD e
RegDeleteValueA(prodkey, name); \
} while(0)
-#define CHECK_REG_DWORD2(prodkey, name, expected1, expected2) \
- check_reg_dword2(prodkey, name, expected1, expected2, __LINE__);
-
-#define CHECK_DEL_REG_DWORD2(prodkey, name, expected1, expected2) \
- do { \
- check_reg_dword2(prodkey, name, expected1, expected2, __LINE__); \
- RegDeleteValueA(prodkey, name); \
- } while(0)
-
-#define CHECK_REG_DWORD4(prodkey, name, expected1, expected2, expected3, expected4) \
- check_reg_dword4(prodkey, name, expected1, expected2, expected3, expected4,
__LINE__);
-
-#define CHECK_DEL_REG_DWORD5(prodkey, name, expected1, expected2, expected3, expected4
,expected5) \
- do { \
- check_reg_dword5(prodkey, name, expected1, expected2, expected3, expected4,
expected5, __LINE__); \
- RegDeleteValueA(prodkey, name); \
- } while(0)
-
static void get_date_str(LPSTR date)
{
SYSTEMTIME systime;
@@ -2414,6 +2357,22 @@ static void get_date_str(LPSTR date)
sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
}
+/* EstimatedSize is the size in KiB of .msi + installed files, rounded up to page size.
*/
+static DWORD get_estimated_size(void)
+{
+ SYSTEM_INFO si;
+ HANDLE file;
+ DWORD size;
+
+ GetSystemInfo(&si);
+
+ file = CreateFileA(msifile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
+ size = ((GetFileSize(file, NULL) + si.dwPageSize - 1) / si.dwPageSize + 1);
+ size = size * si.dwPageSize / 1024;
+ CloseHandle(file);
+ return size;
+}
+
static void test_register_product(void)
{
UINT r;
@@ -2505,9 +2464,7 @@ static void test_register_product(void)
CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_DEL_REG_DWORD5(hkey, "EstimatedSize", 12, -12, 4, 10, 24);
- }
+ CHECK_DEL_REG_DWORD(hkey, "EstimatedSize", get_estimated_size());
delete_key(hkey, "", access);
RegCloseKey(hkey);
@@ -2547,9 +2504,7 @@ static void test_register_product(void)
CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_DEL_REG_DWORD5(props, "EstimatedSize", 12, -12, 4, 10, 24);
- }
+ CHECK_DEL_REG_DWORD(props, "EstimatedSize", get_estimated_size());
delete_key(props, "", access);
RegCloseKey(props);
@@ -2616,9 +2571,7 @@ static void test_register_product(void)
CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_DEL_REG_DWORD5(hkey, "EstimatedSize", 12, -12, 4, 10, 24);
- }
+ CHECK_DEL_REG_DWORD(hkey, "EstimatedSize", get_estimated_size());
delete_key(hkey, "", access);
RegCloseKey(hkey);
@@ -2658,9 +2611,7 @@ static void test_register_product(void)
CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_DEL_REG_DWORD5(props, "EstimatedSize", 12, -12, 4, 10, 24);
- }
+ CHECK_DEL_REG_DWORD(props, "EstimatedSize", get_estimated_size());
delete_key(props, "", access);
RegCloseKey(props);
@@ -3525,9 +3476,7 @@ static void test_publish(void)
CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24);
- }
+ CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size());
RegCloseKey(prodkey);
@@ -3631,9 +3580,7 @@ static void test_publish(void)
CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24);
- }
+ CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size());
RegCloseKey(prodkey);
@@ -3714,9 +3661,7 @@ static void test_publish(void)
CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24);
- }
+ CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size());
RegCloseKey(prodkey);
@@ -3774,9 +3719,7 @@ static void test_publish(void)
CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24);
- }
+ CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size());
RegCloseKey(prodkey);
@@ -3834,9 +3777,7 @@ static void test_publish(void)
CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -20, 10, 24);
- }
+ CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size());
RegCloseKey(prodkey);
@@ -3917,9 +3858,7 @@ static void test_publish(void)
CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
todo_wine
- {
- CHECK_REG_DWORD4(prodkey, "EstimatedSize", 12, -12, 10, 24);
- }
+ CHECK_REG_DWORD(prodkey, "EstimatedSize", get_estimated_size());
RegCloseKey(prodkey);