MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pfs_host-oom-t.cc
1 /* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 
16 #include <my_global.h>
17 #include <my_pthread.h>
18 #include <pfs_instr.h>
19 #include <pfs_stat.h>
20 #include <pfs_global.h>
21 #include <pfs_host.h>
22 #include <tap.h>
23 
24 #include "stub_pfs_global.h"
25 #include "stub_server_misc.h"
26 
27 #include <string.h> /* memset */
28 
29 void test_oom()
30 {
31  int rc;
32  PFS_global_param param;
33 
34  memset(& param, 0xFF, sizeof(param));
35  param.m_enabled= true;
36  param.m_mutex_class_sizing= 0;
37  param.m_rwlock_class_sizing= 0;
38  param.m_cond_class_sizing= 0;
39  param.m_thread_class_sizing= 10;
40  param.m_table_share_sizing= 0;
41  param.m_file_class_sizing= 0;
42  param.m_mutex_sizing= 0;
43  param.m_rwlock_sizing= 0;
44  param.m_cond_sizing= 0;
45  param.m_thread_sizing= 1000;
46  param.m_table_sizing= 0;
47  param.m_file_sizing= 0;
48  param.m_file_handle_sizing= 0;
51  param.m_setup_actor_sizing= 0;
52  param.m_setup_object_sizing= 0;
53  param.m_host_sizing= 1000;
54  param.m_user_sizing= 0;
55  param.m_account_sizing= 0;
56  param.m_stage_class_sizing= 50;
59  param.m_statement_class_sizing= 50;
63 
64  /* Setup */
65 
66  stub_alloc_always_fails= false;
67  stub_alloc_fails_after_count= 1000;
68 
69  init_event_name_sizing(& param);
71  ok(rc == 0, "init stage class");
73  ok(rc == 0, "init statement class");
74 
75  /* Tests */
76 
77  stub_alloc_fails_after_count= 1;
78  rc= init_host(& param);
79  ok(rc == 1, "oom (host)");
80  cleanup_host();
81 
82  stub_alloc_fails_after_count= 2;
83  rc= init_host(& param);
84  ok(rc == 1, "oom (host waits)");
85  cleanup_host();
86 
87  stub_alloc_fails_after_count= 3;
88  rc= init_host(& param);
89  ok(rc == 1, "oom (host stages)");
90  cleanup_host();
91 
92  stub_alloc_fails_after_count= 4;
93  rc= init_host(& param);
94  ok(rc == 1, "oom (host statements)");
95  cleanup_host();
96 
99 }
100 
101 void do_all_tests()
102 {
104 
105  test_oom();
106 
108 }
109 
110 int main(int, char **)
111 {
112  plan(6);
113  MY_INIT("pfs_host-oom-t");
114  do_all_tests();
115  return 0;
116 }
117