1 | /* |
2 | Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
3 | |
4 | The MySQL Connector/C is licensed under the terms of the GPLv2 |
5 | <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most |
6 | MySQL Connectors. There are special exceptions to the terms and |
7 | conditions of the GPLv2 as it is applied to this software, see the |
8 | FLOSS License Exception |
9 | <http://www.mysql.com/about/legal/licensing/foss-exception.html>. |
10 | |
11 | This program is free software; you can redistribute it and/or modify |
12 | it under the terms of the GNU General Public License as published |
13 | by the Free Software Foundation; version 2 of the License. |
14 | |
15 | This program is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
18 | for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License along |
21 | with this program; if not, write to the Free Software Foundation, Inc., |
22 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
23 | */ |
24 | /** |
25 | Some basic tests of the client API. |
26 | */ |
27 | |
28 | #include "my_test.h" |
29 | |
30 | static int test_conc_173(MYSQL *unused __attribute__((unused))) |
31 | { |
32 | MYSQL mysql; |
33 | int arg; |
34 | int i=0; |
35 | |
36 | for (;;) |
37 | { |
38 | mysql_init(&mysql); |
39 | mysql_options(&mysql, MYSQL_READ_DEFAULT_GROUP, "client" ); |
40 | mysql_options(&mysql, MYSQL_OPT_COMPRESS, 0); |
41 | |
42 | mysql_options(&mysql, MYSQL_OPT_NAMED_PIPE, 0); |
43 | |
44 | arg = MYSQL_PROTOCOL_SOCKET; |
45 | |
46 | mysql_options(&mysql, MYSQL_OPT_PROTOCOL, &arg); |
47 | |
48 | if(!mysql_real_connect(&mysql, hostname, username, password, schema, 0, 0, 0)) { |
49 | fprintf(stderr, "Failed to connect to database after %d iterations: Error: %s\n" , i, mysql_error(&mysql)); |
50 | return 1; |
51 | } |
52 | mysql_close(&mysql); |
53 | } |
54 | return OK; |
55 | } |
56 | |
57 | struct my_tests_st my_tests[] = { |
58 | {"test_conc_173" , test_conc_173, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, |
59 | }; |
60 | |
61 | |
62 | int main(int argc, char **argv) |
63 | { |
64 | if (argc > 1) |
65 | get_options(argc, argv); |
66 | |
67 | get_envvars(); |
68 | |
69 | run_tests(my_tests); |
70 | |
71 | return(exit_status()); |
72 | } |
73 | |