Signed-off-by: Alistair Leslie-Hughes leslie_alistair@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..e3e5dcfc012 --- /dev/null +++ b/dlls/odbc32/tests/connection.c @@ -0,0 +1,130 @@ +/* + * 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 "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 || length == 0, "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 || length == 0, "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(); +}
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=81583
Your paranoid android.
=== debiant (32 bit report) ===
odbc32: connection.c:119: Test succeeded inside todo block: got 100 connection.c:122: Test succeeded inside todo block: got 0
=== debiant (32 bit French report) ===
odbc32: connection.c:119: Test succeeded inside todo block: got 100 connection.c:122: Test succeeded inside todo block: got 0
=== debiant (32 bit Japanese:Japan report) ===
odbc32: connection.c:119: Test succeeded inside todo block: got 100 connection.c:122: Test succeeded inside todo block: got 0
=== debiant (32 bit Chinese:China report) ===
odbc32: connection.c:119: Test succeeded inside todo block: got 100 connection.c:122: Test succeeded inside todo block: got 0
=== debiant (build log) ===
0100:err:winediag:SQLDrivers No ODBC drivers could be found. Check the settings for your libodbc provider. 00d4:err:winediag:SQLDrivers No ODBC drivers could be found. Check the settings for your libodbc provider. 00d8:err:winediag:SQLDrivers No ODBC drivers could be found. Check the settings for your libodbc provider. 00d8:err:winediag:SQLDrivers No ODBC drivers could be found. Check the settings for your libodbc provider.
=== debiant (32 bit WoW report) ===
odbc32: connection.c:119: Test succeeded inside todo block: got 100 connection.c:122: Test succeeded inside todo block: got 0
=== debiant (64 bit WoW report) ===
odbc32: connection.c:119: Test succeeded inside todo block: got 100 connection.c:122: Test succeeded inside todo block: got 0
=== debiant (build log) ===
0100:err:winediag:SQLDrivers No ODBC drivers could be found. Check the settings for your libodbc provider. 00dc:err:winediag:SQLDrivers No ODBC drivers could be found. Check the settings for your libodbc provider.