https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4d2ae66cd17d021723cd5…
commit 4d2ae66cd17d021723cd5959e1cd889028aebfd9
Author:     Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Tue Jan 29 13:15:00 2019 +0100
Commit:     Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Tue Jan 29 13:15:00 2019 +0100
    [ODBCCP32_WINETEST] Sync with Wine Staging 4.0. CORE-15682
---
 modules/rostests/winetests/odbccp32/CMakeLists.txt |  2 +-
 modules/rostests/winetests/odbccp32/misc.c         | 78 +++++++++++++++++++++-
 .../rostests/winetests/odbccp32/odbccp32.manifest  | 18 +++++
 modules/rostests/winetests/odbccp32/odbccp32.rc    | 22 ++++++
 4 files changed, 116 insertions(+), 4 deletions(-)
diff --git a/modules/rostests/winetests/odbccp32/CMakeLists.txt
b/modules/rostests/winetests/odbccp32/CMakeLists.txt
index 88b9e81824..71cdb05a2e 100644
--- a/modules/rostests/winetests/odbccp32/CMakeLists.txt
+++ b/modules/rostests/winetests/odbccp32/CMakeLists.txt
@@ -1,5 +1,5 @@
-add_executable(odbccp32_winetest misc.c testlist.c)
+add_executable(odbccp32_winetest misc.c testlist.c odbccp32.rc)
 set_module_type(odbccp32_winetest win32cui)
 add_importlibs(odbccp32_winetest odbccp32 advapi32 msvcrt kernel32)
 add_rostests_file(TARGET odbccp32_winetest)
diff --git a/modules/rostests/winetests/odbccp32/misc.c
b/modules/rostests/winetests/odbccp32/misc.c
index c12ff4961b..dc65bdf3f9 100644
--- a/modules/rostests/winetests/odbccp32/misc.c
+++ b/modules/rostests/winetests/odbccp32/misc.c
@@ -171,6 +171,9 @@ static void test_SQLWritePrivateProfileString(void)
    {
         HKEY hkey;
+        ret = SQLWritePrivateProfileString("wineodbc", "testing" ,
NULL, "odbc.ini");
+        ok(ret, "SQLWritePrivateProfileString failed\n");
+
         reg_ret = RegOpenKeyExW(HKEY_CURRENT_USER, odbc_key, 0, KEY_READ, &hkey);
         ok(reg_ret == ERROR_SUCCESS, "RegOpenKeyExW failed\n");
         if(reg_ret == ERROR_SUCCESS)
@@ -618,11 +621,19 @@ static void test_SQLGetInstalledDrivers(void)
 {
     char buffer[1000], *p;
     WORD written, len;
+    BOOL ret, sql_ret;
+    DWORD error_code;
     int found = 0;
-    BOOL ret;
-    SQLInstallDriverEx("Wine test\0Driver=test.dll\0\0", NULL, buffer,
-                       sizeof(buffer), &written, ODBC_INSTALL_COMPLETE, NULL);
+    ret = SQLInstallDriverEx("Wine test\0Driver=test.dll\0\0", NULL, buffer,
+        sizeof(buffer), &written, ODBC_INSTALL_COMPLETE, NULL);
+    ok(ret, "SQLInstallDriverEx failed: %d\n", ret);
+    sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
+    if (sql_ret && error_code == ODBC_ERROR_WRITING_SYSINFO_FAILED)
+    {
+        skip("not enough privileges\n");
+        return;
+    }
     ret = SQLGetInstalledDrivers(NULL, sizeof(buffer), &written);
     ok(!ret, "got %d\n", ret);
@@ -671,6 +682,65 @@ static void test_SQLGetInstalledDrivers(void)
     SQLRemoveDriver("Wine test", TRUE, NULL);
 }
+static void test_SQLValidDSN(void)
+{
+    static const char *invalid = "[]{}(),;?*=!@\\";
+    char str[10];
+    int i;
+    BOOL ret;
+
+    strcpy(str, "wine10");
+    for(i = 0; i < strlen(invalid); i++)
+    {
+        str[4] = invalid[i];
+        ret = SQLValidDSN(str);
+        ok(!ret, "got %d\n", ret);
+    }
+
+    /* Too large */
+    ret = SQLValidDSN("Wine123456789012345678901234567890");
+    ok(!ret, "got %d\n", ret);
+
+    /* Valid with a space */
+    ret = SQLValidDSN("Wine Vinegar");
+    ok(ret, "got %d\n", ret);
+
+    /* Max DSN name value */
+    ret = SQLValidDSN("12345678901234567890123456789012");
+    ok(ret, "got %d\n", ret);
+}
+
+static void test_SQLValidDSNW(void)
+{
+    static const WCHAR invalid[] =
{'[',']','{','}','(',')',',',';','?','*','=','!','@','\\',0};
+    static const WCHAR value[] = {
'w','i','n','e','1','0',0};
+    static const WCHAR too_large[] = {
'W','i','n','e','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5',
+
'6','7','8','9','0','1','2','3','4','5','6','7','8','9','0',
0};
+    static const WCHAR with_space[] = {
'W','i','n','e','
','V','i','n','e','g','a','r',
0};
+    static const WCHAR max_dsn[] = {
'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0',
+
'1','2','3','4','5','6','7','8','9','0','1','2',
0};
+    WCHAR str[10];
+    int i;
+    BOOL ret;
+
+    lstrcpyW(str, value);
+    for(i = 0; i < lstrlenW(invalid); i++)
+    {
+        str[4] = invalid[i];
+        ret = SQLValidDSNW(str);
+        ok(!ret, "got %d\n", ret);
+    }
+
+    ret = SQLValidDSNW(too_large);
+    ok(!ret, "got %d\n", ret);
+
+    ret = SQLValidDSNW(with_space);
+    ok(ret, "got %d\n", ret);
+
+    ret = SQLValidDSNW(max_dsn);
+    ok(ret, "got %d\n", ret);
+}
+
 START_TEST(misc)
 {
     test_SQLConfigMode();
@@ -682,4 +752,6 @@ START_TEST(misc)
     test_SQLInstallDriverEx();
     test_SQLInstallTranslatorEx();
     test_SQLGetInstalledDrivers();
+    test_SQLValidDSN();
+    test_SQLValidDSNW();
 }
diff --git a/modules/rostests/winetests/odbccp32/odbccp32.manifest
b/modules/rostests/winetests/odbccp32/odbccp32.manifest
new file mode 100644
index 0000000000..cd879cc776
--- /dev/null
+++ b/modules/rostests/winetests/odbccp32/odbccp32.manifest
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
+    <assemblyIdentity
+        type="win32"
+        name="Wine.odbccp32.Test"
+        version="1.0.0.0"
+        processorArchitecture="*"
+    />
+    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+        <security>
+            <requestedPrivileges>
+                <requestedExecutionLevel
+                    level="asInvoker"
+                />
+            </requestedPrivileges>
+        </security>
+    </trustInfo>
+</assembly>
diff --git a/modules/rostests/winetests/odbccp32/odbccp32.rc
b/modules/rostests/winetests/odbccp32/odbccp32.rc
new file mode 100644
index 0000000000..15299093f7
--- /dev/null
+++ b/modules/rostests/winetests/odbccp32/odbccp32.rc
@@ -0,0 +1,22 @@
+/*
+ * 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 "winuser.h"
+
+/* @makedep: odbccp32.manifest */
+1 RT_MANIFEST odbccp32.manifest