wine-staging/patches/odbc-remove-unixodbc/0004-odbc32-Add-initial-tests.patch

224 lines
6.9 KiB
Diff
Raw Normal View History

2024-01-13 11:33:21 -08:00
From 9491dc2b72947bef59d8fb191fdc27a96bcc1c68 Mon Sep 17 00:00:00 2001
2023-02-16 15:44:46 -08:00
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 14:16:21 +1100
2024-01-13 11:33:21 -08:00
Subject: [PATCH] odbc32: Add initial tests
2023-02-16 15:44:46 -08:00
---
configure | 1 +
configure.ac | 1 +
2024-01-13 11:33:21 -08:00
dlls/odbc32/tests/Makefile.in | 5 +
2023-02-16 15:44:46 -08:00
dlls/odbc32/tests/connection.c | 165 +++++++++++++++++++++++++++++++++
2024-01-13 11:33:21 -08:00
4 files changed, 172 insertions(+)
2023-02-16 15:44:46 -08:00
create mode 100644 dlls/odbc32/tests/Makefile.in
create mode 100644 dlls/odbc32/tests/connection.c
diff --git a/configure b/configure
2024-01-13 11:33:21 -08:00
index ca6e87d4740..027f3fbe53d 100755
2023-02-16 15:44:46 -08:00
--- a/configure
+++ b/configure
2024-01-13 11:33:21 -08:00
@@ -22137,6 +22137,7 @@ wine_fn_config_makefile dlls/ntprint enable_ntprint
2023-02-16 15:44:46 -08:00
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
2024-01-13 11:33:21 -08:00
index cba55126869..fc09d145ee7 100644
2023-02-16 15:44:46 -08:00
--- a/configure.ac
+++ b/configure.ac
2024-01-13 11:33:21 -08:00
@@ -2954,6 +2954,7 @@ WINE_CONFIG_MAKEFILE(dlls/ntprint)
2023-02-16 15:44:46 -08:00
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
2024-01-13 11:33:21 -08:00
index 00000000000..d7a300417a0
2023-02-16 15:44:46 -08:00
--- /dev/null
+++ b/dlls/odbc32/tests/Makefile.in
2024-01-13 11:33:21 -08:00
@@ -0,0 +1,5 @@
2023-02-16 15:44:46 -08:00
+TESTDLL = odbc32.dll
+IMPORTS = odbc32
+
2024-01-13 11:33:21 -08:00
+SOURCES = \
+ connection.c
2023-02-16 15:44:46 -08:00
diff --git a/dlls/odbc32/tests/connection.c b/dlls/odbc32/tests/connection.c
new file mode 100644
index 00000000000..b04d93c42c5
--- /dev/null
+++ b/dlls/odbc32/tests/connection.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2018 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 "sqlucode.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);
+ todo_wine ok(ret == SQL_INVALID_HANDLE, "got %d\n", ret);
+
+ ret = SQLFreeEnv(SQL_NULL_HENV);
+ todo_wine 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);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(value == 0, "got %d\n", value);
+ todo_wine ok(length == 12, "got %d\n", length);
+
+ value = 5;
+ length = 13;
+ ret = SQLGetEnvAttr(SQL_NULL_HENV, SQL_ATTR_CONNECTION_POOLING, &value, 0, &length);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(value == 0, "got %d\n", value);
+ todo_wine 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);
+ 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);
+
+ 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);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+}
+
+static void test_SQLGetDiagRec(void)
+{
+ SQLHENV henv = SQL_NULL_HENV;
+ SQLHDBC connection;
+ SQLRETURN ret;
+ WCHAR version[11];
+ WCHAR SqlState[6], Msg[SQL_MAX_MESSAGE_LENGTH];
+ SQLINTEGER NativeError;
+ SQLSMALLINT MsgLen;
+
+ ret = SQLAllocEnv(&henv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ ok(henv != SQL_NULL_HENV, "NULL handle\n");
+
+ ret = SQLAllocConnect(henv, &connection);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ ret = SQLGetInfoW(connection, SQL_ODBC_VER, version, 22, NULL);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+ trace("ODBC_VER=%s\n", wine_dbgstr_w(version));
+
+ ret = SQLFreeConnect(connection);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+
+ NativeError = 88;
+ ret = SQLGetDiagRecW( SQL_HANDLE_ENV, henv, 1, SqlState, &NativeError, Msg, sizeof(Msg), &MsgLen);
+ todo_wine ok(ret == SQL_NO_DATA, "got %d\n", ret);
+ ok(NativeError == 88, "got %d\n", NativeError);
+
+ ret = SQLFreeEnv(henv);
+ ok(ret == SQL_SUCCESS, "got %d\n", ret);
+}
+
+START_TEST(connection)
+{
+ test_SQLAllocEnv();
+ test_SQLGetEnvAttr();
+ test_SQLDriver();
+ test_SQLGetDiagRec();
+}
--
2024-01-13 11:33:21 -08:00
2.43.0
2023-02-16 15:44:46 -08:00