1 /*
2 Copyright (c) 2011, 2021, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include "blocks/dbdih/Dbdih.hpp"
26 #include "GlobalData.hpp"
27 #include "ndbapi/NdbApi.hpp"
28 #include "ndbd_malloc_impl.hpp"
29 #include "NdbTick.h"
30 #include "SimBlockList.hpp"
31 #include "SimulatedBlock.hpp"
32 #include "test_context.hpp"
33
34 #define JAM_FILE_ID 250
35
36
37 struct DummyBlock : public SimulatedBlock
38 {
DummyBlockDummyBlock39 DummyBlock(int no, Block_context& ctx) : SimulatedBlock(no, ctx) {}
40 //~DummyBlock() { }
41 };
42
43 static Ndbd_mem_manager mm;
44 static Configuration cfg;
45 static Block_context ctx(cfg, mm);
46 static DummyBlock block(DBACC, ctx);
47
48 // Force enough modules from libkernel that libsched need
49 static SimulatedBlock::MutexManager mxm(block);
50 static SafeCounterManager scm(block);
51
52 Pool_context
test_context(Uint32 pages)53 test_context(Uint32 pages)
54 {
55 ndb_init();
56
57 Pool_context pc;
58 pc.m_block = █
59
60 Resource_limit rl;
61 for (Uint32 resid = 1; resid < RG_COUNT; resid++)
62 {
63 rl.m_min = 0;
64 rl.m_max = 0;
65 rl.m_resource_id = resid;
66 mm.set_resource_limit(rl);
67 }
68 rl.m_min = 0;
69 rl.m_max = pages;
70 rl.m_resource_id = 0;
71 mm.set_resource_limit(rl);
72
73 if (!mm.init(NULL /* watchCounter */))
74 {
75 abort();
76 }
77
78 mm.map(NULL /* watchCounter */, 0 /* memlock */); // Map all
79
80 return pc;
81 }
82
dummy_calls_to_force_some_modules_from_libkernel_needed_by_libsched()83 void dummy_calls_to_force_some_modules_from_libkernel_needed_by_libsched()
84 {
85 globalData.getBlock(0,0);
86 Ndbinfo::getNumTables();
87 }
88
89 // Some undefined globals needed
90
91 Uint32 g_currentStartPhase;
92 Uint32 g_start_type;
93 NdbNodeBitmask g_nowait_nodes;
94
95 void
unload()96 SimBlockList::unload()
97 {
98
99 }
100
101 void
NdbShutdown(int error_code,NdbShutdownType type,NdbRestartType restartType)102 NdbShutdown(int error_code,
103 NdbShutdownType type,
104 NdbRestartType restartType)
105 {
106 abort();
107 }
108
109 Uint32
dihGetInstanceKey(Uint32 tabId,Uint32 fragId)110 Dbdih::dihGetInstanceKey(Uint32 tabId, Uint32 fragId)
111 {
112 abort();
113 return 0;
114 }
115