MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pfs_user-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_user.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= 0;
54  param.m_user_sizing= 1000;
55  param.m_account_sizing= 0;
56  param.m_stage_class_sizing= 50;
59  param.m_statement_class_sizing= 50;
62 
63  /* Setup */
64 
65  stub_alloc_always_fails= false;
66  stub_alloc_fails_after_count= 1000;
67 
68  init_event_name_sizing(& param);
70  ok(rc == 0, "init stage class");
72  ok(rc == 0, "init statement class");
73 
74  /* Tests */
75 
76  stub_alloc_fails_after_count= 1;
77  rc= init_user(& param);
78  ok(rc == 1, "oom (user)");
79  cleanup_user();
80 
81  stub_alloc_fails_after_count= 2;
82  rc= init_user(& param);
83  ok(rc == 1, "oom (user waits)");
84  cleanup_user();
85 
86  stub_alloc_fails_after_count= 3;
87  rc= init_user(& param);
88  ok(rc == 1, "oom (user stages)");
89  cleanup_user();
90 
91  stub_alloc_fails_after_count= 4;
92  rc= init_user(& param);
93  ok(rc == 1, "oom (user statements)");
94  cleanup_user();
95 
98 }
99 
100 void do_all_tests()
101 {
103 
104  test_oom();
105 
107 }
108 
109 int main(int, char **)
110 {
111  plan(6);
112  MY_INIT("pfs_user-oom-t");
113  do_all_tests();
114  return 0;
115 }
116