https://git.reactos.org/?p=reactos.git;a=commitdiff;h=11702b643d4b8ea17114b…
commit 11702b643d4b8ea17114ba54bf889309b563f825
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:11:48 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:35 2022 +0100
[WINESYNC] msi/tests: Test properties from custom actions.
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 5808f1ddd49930ad49aeab640fced8305db476ea by Zebediah Figura
<z.figura12(a)gmail.com>
---
modules/rostests/winetests/msi/custom.c | 192 +++++++++++++++++++++++++++++++
modules/rostests/winetests/msi/install.c | 2 +
2 files changed, 194 insertions(+)
diff --git a/modules/rostests/winetests/msi/custom.c
b/modules/rostests/winetests/msi/custom.c
index feb80615191..9cf90dc25ad 100644
--- a/modules/rostests/winetests/msi/custom.c
+++ b/modules/rostests/winetests/msi/custom.c
@@ -51,6 +51,196 @@ static void ok_(MSIHANDLE hinst, int todo, const char *file, int line,
int condi
#define ok(hinst, condition, ...) ok_(hinst, 0, __FILE__, __LINE__, condition,
__VA_ARGS__)
#define todo_wine_ok(hinst, condition, ...) ok_(hinst, 1, __FILE__, __LINE__, condition,
__VA_ARGS__)
+static const char *dbgstr_w(WCHAR *str)
+{
+ static char buffer[300], *p;
+
+ if (!str) return "(null)";
+
+ p = buffer;
+ *p++ = 'L';
+ *p++ = '"';
+ while ((*p++ = *str++));
+ *p++ = '"';
+ *p++ = 0;
+
+ return buffer;
+}
+
+static void check_prop(MSIHANDLE hinst, const char *prop, const char *expect)
+{
+ char buffer[10] = "x";
+ DWORD sz = sizeof(buffer);
+ UINT r = MsiGetPropertyA(hinst, prop, buffer, &sz);
+ ok(hinst, !r, "'%s': got %u\n", prop, r);
+ ok(hinst, sz == strlen(buffer), "'%s': expected %u, got %u\n",
prop, strlen(buffer), sz);
+ ok(hinst, !strcmp(buffer, expect), "expected '%s', got
'%s'\n", expect, buffer);
+}
+
+static void test_props(MSIHANDLE hinst)
+{
+ static const WCHAR booW[] = {'b','o','o',0};
+ static const WCHAR xyzW[] = {'x','y','z',0};
+ static const WCHAR xyW[] = {'x','y',0};
+ char buffer[10];
+ WCHAR bufferW[10];
+ DWORD sz;
+ UINT r;
+
+ /* test invalid values */
+ r = MsiGetPropertyA(hinst, NULL, NULL, NULL);
+ ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+ r = MsiGetPropertyA(hinst, "boo", NULL, NULL);
+ ok(hinst, !r, "got %u\n", r);
+
+ r = MsiGetPropertyA(hinst, "boo", buffer, NULL );
+ ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+ sz = 0;
+ r = MsiGetPropertyA(hinst, "boo", NULL, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, sz == 0, "got size %u\n", sz);
+
+ sz = 0;
+ strcpy(buffer,"x");
+ r = MsiGetPropertyA(hinst, "boo", buffer, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !strcmp(buffer, "x"), "got \"%s\"\n",
buffer);
+ ok(hinst, sz == 0, "got size %u\n", sz);
+
+ sz = 1;
+ strcpy(buffer,"x");
+ r = MsiGetPropertyA(hinst, "boo", buffer, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
+ ok(hinst, sz == 0, "got size %u\n", sz);
+
+ /* set the property to something */
+ r = MsiSetPropertyA(hinst, NULL, NULL);
+ ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+ r = MsiSetPropertyA(hinst, "", NULL);
+ ok(hinst, !r, "got %u\n", r);
+
+ r = MsiSetPropertyA(hinst, "", "asdf");
+ ok(hinst, r == ERROR_FUNCTION_FAILED, "got %u\n", r);
+
+ r = MsiSetPropertyA(hinst, "=", "asdf");
+ ok(hinst, !r, "got %u\n", r);
+ check_prop(hinst, "=", "asdf");
+
+ r = MsiSetPropertyA(hinst, " ", "asdf");
+ ok(hinst, !r, "got %u\n", r);
+ check_prop(hinst, " ", "asdf");
+
+ r = MsiSetPropertyA(hinst, "'", "asdf");
+ ok(hinst, !r, "got %u\n", r);
+ check_prop(hinst, "'", "asdf");
+
+ r = MsiSetPropertyA(hinst, "boo", NULL);
+ ok(hinst, !r, "got %u\n", r);
+ check_prop(hinst, "boo", "");
+
+ r = MsiSetPropertyA(hinst, "boo", "");
+ ok(hinst, !r, "got %u\n", r);
+ check_prop(hinst, "boo", "");
+
+ r = MsiSetPropertyA(hinst, "boo", "xyz");
+ ok(hinst, !r, "got %u\n", r);
+ check_prop(hinst, "boo", "xyz");
+
+ r = MsiGetPropertyA(hinst, "boo", NULL, NULL);
+ ok(hinst, !r, "got %u\n", r);
+
+ r = MsiGetPropertyA(hinst, "boo", buffer, NULL );
+ ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+ /* Returned size is in bytes, not chars, but only for custom actions.
+ * Seems to be a casualty of RPC... */
+
+ sz = 0;
+ r = MsiGetPropertyA(hinst, "boo", NULL, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, sz == 6, "got size %u\n", sz);
+
+ sz = 0;
+ strcpy(buffer,"q");
+ r = MsiGetPropertyA(hinst, "boo", buffer, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n",
buffer);
+ todo_wine_ok(hinst, sz == 6, "got size %u\n", sz);
+
+ sz = 1;
+ strcpy(buffer,"x");
+ r = MsiGetPropertyA(hinst, "boo", buffer, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
+ todo_wine_ok(hinst, sz == 6, "got size %u\n", sz);
+
+ sz = 3;
+ strcpy(buffer,"x");
+ r = MsiGetPropertyA(hinst, "boo", buffer, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !strcmp(buffer, "xy"), "got \"%s\"\n",
buffer);
+ todo_wine_ok(hinst, sz == 6, "got size %u\n", sz);
+
+ sz = 4;
+ strcpy(buffer,"x");
+ r = MsiGetPropertyA(hinst, "boo", buffer, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, !strcmp(buffer, "xyz"), "got \"%s\"\n",
buffer);
+ ok(hinst, sz == 3, "got size %u\n", sz);
+
+ sz = 0;
+ r = MsiGetPropertyW(hinst, booW, NULL, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, sz == 3, "got size %u\n", sz);
+
+ sz = 0;
+ lstrcpyW(bufferW, booW);
+ r = MsiGetPropertyW(hinst, booW, bufferW, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !lstrcmpW(bufferW, booW), "got %s\n", dbgstr_w(bufferW));
+ ok(hinst, sz == 3, "got size %u\n", sz);
+
+ sz = 1;
+ lstrcpyW(bufferW, booW);
+ r = MsiGetPropertyW(hinst, booW, bufferW, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !bufferW[0], "got %s\n", dbgstr_w(bufferW));
+ ok(hinst, sz == 3, "got size %u\n", sz);
+
+ sz = 3;
+ lstrcpyW(bufferW, booW);
+ r = MsiGetPropertyW(hinst, booW, bufferW, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !lstrcmpW(bufferW, xyW), "got %s\n", dbgstr_w(bufferW));
+ ok(hinst, sz == 3, "got size %u\n", sz);
+
+ sz = 4;
+ lstrcpyW(bufferW, booW);
+ r = MsiGetPropertyW(hinst, booW, bufferW, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, !lstrcmpW(bufferW, xyzW), "got %s\n", dbgstr_w(bufferW));
+ ok(hinst, sz == 3, "got size %u\n", sz);
+
+ r = MsiSetPropertyA(hinst, "boo", NULL);
+ ok(hinst, !r, "got %u\n", r);
+ check_prop(hinst, "boo", "");
+
+ sz = 0;
+ r = MsiGetPropertyA(hinst, "embednullprop", NULL, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, sz == 6, "got size %u\n", sz);
+
+ sz = 4;
+ memset(buffer, 0xcc, sizeof(buffer));
+ r = MsiGetPropertyA(hinst, "embednullprop", buffer, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, sz == 3, "got size %u\n", sz);
+ ok(hinst, !memcmp(buffer, "a\0\0\0\xcc", 5), "wrong data\n");
+}
/* Main test. Anything that doesn't depend on a specific install configuration
* or have undesired side effects should go here. */
@@ -70,6 +260,8 @@ UINT WINAPI main_test(MSIHANDLE hinst)
res = MsiGetDatabaseState(hinst);
todo_wine_ok(hinst, res == MSIDBSTATE_ERROR, "expected MSIDBSTATE_ERROR, got
%u\n", res);
+ test_props(hinst);
+
return ERROR_SUCCESS;
}
diff --git a/modules/rostests/winetests/msi/install.c
b/modules/rostests/winetests/msi/install.c
index 69095cd8f07..62fb81f9fc4 100644
--- a/modules/rostests/winetests/msi/install.c
+++ b/modules/rostests/winetests/msi/install.c
@@ -695,12 +695,14 @@ static const CHAR wrv_component_dat[] =
"Component\tComponentId\tDirectory_\tAtt
static const CHAR ca1_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
"s72\tS255\tI2\n"
"InstallExecuteSequence\tAction\n"
+ "embednull\t\t600\n"
"maintest\tMAIN_TEST\t700\n"
"testretval\tTEST_RETVAL\t710\n";
static const CHAR ca1_custom_action_dat[] = "Action\tType\tSource\tTarget\n"
"s72\ti2\tS64\tS0\n"
"CustomAction\tAction\n"
+
"embednull\t51\tembednullprop\ta[~]b\n"
"maintest\t1\tcustom.dll\tmain_test\n"
"testretval\t1\tcustom.dll\ttest_retval\n";