CUBRID Engine  latest
fault_injection.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * fault_injection.h :
22  *
23  */
24 
25 #ifndef _FAULT_INJECTION_H_
26 #define _FAULT_INJECTION_H_
27 
28 #ident "$Id$"
29 
30 #include "error_manager.h"
31 #include "thread_compat.hpp"
32 
33 #if !defined(NDEBUG)
34 #define FI_INSERTED(code) fi_test_on(code)
35 #define FI_SET(th, code, state) fi_set(th, code, state)
36 #define FI_RESET(th, code) fi_reset(th, code)
37 #define FI_TEST(th, code, state) fi_test(th, code, NULL, state, ARG_FILE_LINE)
38 #define FI_TEST_ARG(th, code, arg, state) fi_test(th, code, arg, state, ARG_FILE_LINE)
39 #else
40 #define FI_INSERTED(code) 0
41 #define FI_SET(th, code, state)
42 #define FI_RESET(th, code)
43 #define FI_TEST(th, code, state) (NO_ERROR)
44 #define FI_TEST_ARG(th, code, arg, state) (NO_ERROR)
45 #endif
46 
47 
48 typedef enum
49 {
50  /* todo: if we want to do regression tests with fault-injection, we shouldn't set codes in system parameter.
51  * it's better to have a string that we can parse and offers us more flexibility into changing/extending
52  * functionality without worrying of backward compatibility.
53  */
54 
56 
57  /* common */
59 
60  /* IO & DISK MANAGER */
66 
67  /* FILE MANAGER */
69 
70  /* BTREE MANAGER */
73 
74  /* QUERY MANAGER (start number is 400000) */
75 
76  /* LOG MANAGER */
79 
80  /* etc .... */
81 
82 } FI_TEST_CODE;
83 
84 typedef enum
85 {
90 
91 #define FI_INIT_STATE 0
92 
93 
94 typedef int (*FI_HANDLER_FUNC) (THREAD_ENTRY * thread_p, void *arg, const char *caller_file, const int caller_line);
95 
96 typedef struct fi_test_item FI_TEST_ITEM;
98 {
101  int state;
102 };
103 
104 extern int fi_thread_init (THREAD_ENTRY * thread_p);
105 extern int fi_thread_final (THREAD_ENTRY * thread_p);
106 extern int fi_set (THREAD_ENTRY * thread_p, FI_TEST_CODE code, int state);
107 extern int fi_set_force (THREAD_ENTRY * thread_p, FI_TEST_CODE code, int state);
108 extern void fi_reset (THREAD_ENTRY * thread_p, FI_TEST_CODE code);
109 extern int fi_test (THREAD_ENTRY * thread_p, FI_TEST_CODE code, void *arg, int state, const char *caller_file,
110  const int caller_line);
111 extern int fi_state (THREAD_ENTRY * thread_p, FI_TEST_CODE code);
112 extern bool fi_test_on (FI_TEST_CODE code);
113 
114 extern FI_TEST_CODE *fi_Groups[FI_GROUP_MAX + 1];
115 
116 #endif /* _FAULT_INJECTION_H_ */
int fi_thread_final(THREAD_ENTRY *thread_p)
int fi_test(THREAD_ENTRY *thread_p, FI_TEST_CODE code, void *arg, int state, const char *caller_file, const int caller_line)
int(* FI_HANDLER_FUNC)(THREAD_ENTRY *thread_p, void *arg, const char *caller_file, const int caller_line)
int fi_set_force(THREAD_ENTRY *thread_p, FI_TEST_CODE code, int state)
void THREAD_ENTRY
void fi_reset(THREAD_ENTRY *thread_p, FI_TEST_CODE code)
FI_HANDLER_FUNC func
int fi_set(THREAD_ENTRY *thread_p, FI_TEST_CODE code, int state)
int fi_thread_init(THREAD_ENTRY *thread_p)
FI_TEST_CODE * fi_Groups[FI_GROUP_MAX+1]
FI_GROUP_CODE
int fi_state(THREAD_ENTRY *thread_p, FI_TEST_CODE code)
bool fi_test_on(FI_TEST_CODE code)
FI_TEST_CODE
FI_TEST_CODE code