[PATCH 2/2] odbc32: Add initial tests

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Mon Nov 9 03:00:25 CST 2020


Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 configure                      |   1 +
 configure.ac                   |   1 +
 dlls/odbc32/tests/Makefile.in  |   4 +
 dlls/odbc32/tests/connection.c | 130 +++++++++++++++++++++++++++++++++
 4 files changed, 136 insertions(+)
 create mode 100644 dlls/odbc32/tests/Makefile.in
 create mode 100644 dlls/odbc32/tests/connection.c

diff --git a/configure b/configure
index 943d4c5d8f4..b6915d03fa0 100755
--- a/configure
+++ b/configure
@@ -20851,6 +20851,7 @@ wine_fn_config_makefile dlls/ntprint enable_ntprint
 wine_fn_config_makefile dlls/ntprint/tests enable_tests
 wine_fn_config_makefile dlls/objsel enable_objsel
 wine_fn_config_makefile dlls/odbc32 enable_odbc32
+wine_fn_config_makefile dlls/odbc32/tests enable_tests
 wine_fn_config_makefile dlls/odbcbcp enable_odbcbcp
 wine_fn_config_makefile dlls/odbccp32 enable_odbccp32
 wine_fn_config_makefile dlls/odbccp32/tests enable_tests
diff --git a/configure.ac b/configure.ac
index 923d5e3b0f3..a7f2b876187 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3592,6 +3592,7 @@ WINE_CONFIG_MAKEFILE(dlls/ntprint)
 WINE_CONFIG_MAKEFILE(dlls/ntprint/tests)
 WINE_CONFIG_MAKEFILE(dlls/objsel)
 WINE_CONFIG_MAKEFILE(dlls/odbc32)
+WINE_CONFIG_MAKEFILE(dlls/odbc32/tests)
 WINE_CONFIG_MAKEFILE(dlls/odbcbcp)
 WINE_CONFIG_MAKEFILE(dlls/odbccp32)
 WINE_CONFIG_MAKEFILE(dlls/odbccp32/tests)
diff --git a/dlls/odbc32/tests/Makefile.in b/dlls/odbc32/tests/Makefile.in
new file mode 100644
index 00000000000..4d8716ed2ed
--- /dev/null
+++ b/dlls/odbc32/tests/Makefile.in
@@ -0,0 +1,4 @@
+TESTDLL   = odbc32.dll
+IMPORTS   = odbc32
+
+C_SRCS = connection.c
diff --git a/dlls/odbc32/tests/connection.c b/dlls/odbc32/tests/connection.c
new file mode 100644
index 00000000000..21bb609dd3c
--- /dev/null
+++ b/dlls/odbc32/tests/connection.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2020 Alistair Leslie-Hughes
+ *
+ * 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 <wine/test.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "sqlext.h"
+#include "odbcinst.h"
+
+static void test_SQLAllocEnv(void)
+{
+    SQLRETURN ret;
+    SQLHENV sqlenv, sqlenv2;
+
+    ret = SQLAllocEnv(NULL);
+    ok(ret == SQL_ERROR, "got %d\n", ret);
+
+    ret = SQLAllocEnv(&sqlenv);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+    ret = SQLAllocEnv(&sqlenv2);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+    ok(sqlenv != sqlenv2, "got %d\n", ret);
+
+    ret = SQLFreeEnv(sqlenv2);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+    ret = SQLFreeEnv(sqlenv);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+    ret = SQLFreeEnv(sqlenv);
+    ok(ret == SQL_INVALID_HANDLE, "got %d\n", ret);
+
+    ret = SQLFreeEnv(SQL_NULL_HENV);
+    ok(ret == SQL_INVALID_HANDLE, "got %d\n", ret);
+}
+
+void test_SQLGetEnvAttr(void)
+{
+    SQLRETURN ret;
+    SQLHENV sqlenv;
+    SQLINTEGER value, length;
+
+    ret = SQLAllocEnv(&sqlenv);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+    value = 5;
+    length = 12;
+    ret = SQLGetEnvAttr(SQL_NULL_HENV, SQL_ATTR_CONNECTION_POOLING, &value, sizeof(SQLINTEGER), &length);
+    todo_wine ok(ret == SQL_SUCCESS, "got %d\n", ret);
+    todo_wine ok(value == 0, "got %d\n", value);
+    ok(length == 12, "got %d\n", length);
+
+    value = 5;
+    length = 13;
+    ret = SQLGetEnvAttr(SQL_NULL_HENV, SQL_ATTR_CONNECTION_POOLING, &value, 0, &length);
+    todo_wine ok(ret == SQL_SUCCESS, "got %d\n", ret);
+    todo_wine ok(value == 0, "got %d\n", value);
+    ok(length == 13, "got %d\n", length);
+
+    value = 5;
+    length = 12;
+    ret = SQLGetEnvAttr(sqlenv, SQL_ATTR_CONNECTION_POOLING, &value, sizeof(SQLINTEGER), &length);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+    ok(value == 0, "got %d\n", value);
+    ok(length == 12, "got %d\n", length);
+
+    value = 5;
+    length = 12;
+    ret = SQLGetEnvAttr(sqlenv, SQL_ATTR_CONNECTION_POOLING, &value, 2, &length);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+    ok(value == 0, "got %d\n", value);
+    ok(length == 12, "got %d\n", length);
+
+    ret = SQLFreeEnv(sqlenv);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+}
+
+static void test_SQLDriver(void)
+{
+    SQLHENV henv = SQL_NULL_HENV;
+    SQLRETURN ret;
+    SQLCHAR driver[256];
+    SQLCHAR attr[256];
+    SQLSMALLINT driver_ret;
+    SQLSMALLINT attr_ret;
+    SQLUSMALLINT direction;
+
+    ret = SQLAllocEnv(&henv);
+    ok(ret == SQL_SUCCESS, "got %d\n", ret);
+    ok(henv != SQL_NULL_HENV, "NULL handle\n");
+
+    direction = SQL_FETCH_FIRST;
+
+    while(SQL_SUCCEEDED(ret = SQLDrivers(henv, direction, driver, sizeof(driver),
+            &driver_ret, attr, sizeof(attr), &attr_ret)))
+    {
+        direction = SQL_FETCH_NEXT;
+
+        trace("%s - %s\n", driver, attr);
+    }
+    todo_wine ok(ret == SQL_NO_DATA, "got %d\n", ret);
+
+    ret = SQLFreeEnv(henv);
+    todo_wine ok(ret == SQL_SUCCESS, "got %d\n", ret);
+}
+
+START_TEST(connection)
+{
+    test_SQLAllocEnv();
+    test_SQLGetEnvAttr();
+    test_SQLDriver();
+}
-- 
2.28.0




More information about the wine-devel mailing list