[ODBCCP32_WINETEST] Sync with Wine Staging 4.0. CORE-15682
authorAmine Khaldi <amine.khaldi@reactos.org>
Tue, 29 Jan 2019 12:15:00 +0000 (13:15 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Tue, 29 Jan 2019 12:15:00 +0000 (13:15 +0100)
modules/rostests/winetests/odbccp32/CMakeLists.txt
modules/rostests/winetests/odbccp32/misc.c
modules/rostests/winetests/odbccp32/odbccp32.manifest [new file with mode: 0644]
modules/rostests/winetests/odbccp32/odbccp32.rc [new file with mode: 0644]

index 88b9e81..71cdb05 100644 (file)
@@ -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)
index c12ff49..dc65bdf 100644 (file)
@@ -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 (file)
index 0000000..cd879cc
--- /dev/null
@@ -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 (file)
index 0000000..1529909
--- /dev/null
@@ -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