Zebediah Figura : msi/tests: Use the custom DLL for testing deferred actions.

Alexandre Julliard julliard at winehq.org
Wed Feb 21 18:39:41 CST 2018


Module: wine
Branch: master
Commit: 9d7ac35e6d0d1d68be24c3fe7b6a54301002258c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9d7ac35e6d0d1d68be24c3fe7b6a54301002258c

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Tue Feb 20 09:03:19 2018 -0600

msi/tests: Use the custom DLL for testing deferred actions.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msi/tests/custom.c    | 35 +++++++++++++++++++++++++++++++++++
 dlls/msi/tests/custom.spec |  2 ++
 dlls/msi/tests/install.c   | 44 +++++++++++++++++++++++++++++++++-----------
 3 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c
index 0eedb8e..f504464 100644
--- a/dlls/msi/tests/custom.c
+++ b/dlls/msi/tests/custom.c
@@ -83,3 +83,38 @@ UINT WINAPI test_retval(MSIHANDLE hinst)
     sscanf(prop, "%u", &retval);
     return retval;
 }
+
+static void append_file(MSIHANDLE hinst, const char *filename, const char *text)
+{
+    DWORD size;
+    HANDLE file = CreateFileA(filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+    ok(hinst, file != INVALID_HANDLE_VALUE, "CreateFile failed, error %u\n", GetLastError());
+
+    SetFilePointer(file, 0, NULL, FILE_END);
+    WriteFile(file, text, strlen(text), &size, NULL);
+    CloseHandle(file);
+}
+
+UINT WINAPI da_immediate(MSIHANDLE hinst)
+{
+    char prop[300];
+    DWORD len = sizeof(prop);
+
+    MsiGetPropertyA(hinst, "TESTPATH", prop, &len);
+
+    append_file(hinst, prop, "one");
+
+    return ERROR_SUCCESS;
+}
+
+UINT WINAPI da_deferred(MSIHANDLE hinst)
+{
+    char prop[300];
+    DWORD len = sizeof(prop);
+
+    MsiGetPropertyA(hinst, "CustomActionData", prop, &len);
+
+    append_file(hinst, prop, "two");
+
+    return ERROR_SUCCESS;
+}
diff --git a/dlls/msi/tests/custom.spec b/dlls/msi/tests/custom.spec
index 9d1e821..bb400ff 100644
--- a/dlls/msi/tests/custom.spec
+++ b/dlls/msi/tests/custom.spec
@@ -1,2 +1,4 @@
 @ stdcall main_test(long)
 @ stdcall test_retval(long)
+@ stdcall da_immediate(long)
+@ stdcall da_deferred(long)
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 55d83d4..69095cd 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -1300,12 +1300,12 @@ static const char ft_install_exec_seq_dat[] =
     "InstallFinalize\t\t1500\n";
 
 static const char da_custom_action_dat[] =
-    "Action\tType\tSource\tTarget\tISComments\n"
-    "s72\ti2\tS64\tS0\tS255\n"
+    "Action\tType\tSource\tTarget\n"
+    "s72\ti2\tS64\tS0\n"
     "CustomAction\tAction\n"
-    "deferred\t1074\tCMDEXE\t/c if exist msitest (exit 0) else (exit 1)\t\n"
-    "immediate\t50\tCMDEXE\t/c mkdir msitest\t\n"
-    "cleanup\t50\tCMDEXE\t/c rmdir msitest\t\n";
+    "setprop\t51\tdeferred\t[TESTPATH]\n"
+    "immediate\t1\tcustom.dll\tda_immediate\n"
+    "deferred\t1025\tcustom.dll\tda_deferred\n";
 
 static const char da_install_exec_seq_dat[] =
     "Action\tCondition\tSequence\n"
@@ -1315,10 +1315,10 @@ static const char da_install_exec_seq_dat[] =
     "FileCost\t\t300\n"
     "CostFinalize\t\t400\n"
     "InstallInitialize\t\t500\n"
-    "deferred\t\t600\n"
-    "immediate\t\t700\n"
-    "InstallFinalize\t\t1100\n"
-    "cleanup\t\t1200\n";
+    "setprop\t\t600\n"
+    "deferred\t\t700\n"
+    "immediate\t\t800\n"
+    "InstallFinalize\t\t1100\n";
 
 typedef struct _msi_table
 {
@@ -6042,23 +6042,45 @@ static void test_feature_tree(void)
     DeleteFileA( msifile );
 }
 
+static void check_file_matches(const char *filename, const char *text)
+{
+    char buffer[200];
+    HANDLE file;
+    DWORD size;
+
+    file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
+    ReadFile(file, buffer, sizeof(buffer), &size, NULL);
+    ok(size == strlen(text) && !memcmp(buffer, text, size), "got %.*s\n", size, buffer);
+    CloseHandle(file);
+}
+
 static void test_deferred_action(void)
 {
+    char path[200], file[200], buffer[200];
     UINT r;
 
+    GetTempPathA(sizeof(path), path);
+    GetTempFileNameA(path, "da", 0, file);
+    sprintf(buffer, "TESTPATH=\"%s\"", file);
+
     create_database(msifile, da_tables, sizeof(da_tables) / sizeof(da_tables[0]));
+    add_custom_dll();
 
     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
 
-    r = MsiInstallProductA(msifile, "CMDEXE=\"cmd.exe\"");
+    r = MsiInstallProductA(msifile, buffer);
     if (r == ERROR_INSTALL_PACKAGE_REJECTED)
     {
         skip("Not enough rights to perform tests\n");
         goto error;
     }
-todo_wine
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
 
+todo_wine
+    check_file_matches(file, "onetwo");
+
+    ok(DeleteFileA(file), "Directory not created\n");
+
 error:
     DeleteFileA(msifile);
 }




More information about the wine-cvs mailing list