26 #ifdef ENABLE_FAULT_INJECTION 44 unsigned int random_seed;
94 si.si_idx,
si.si_enb,
si.si_total_hit_cnt,
95 si.si_total_trigger_cnt,
si.si_hit_cnt,
96 si.si_trigger_cnt,
si.si_type,
si.si_data,
si.si_module,
97 si.si_file,
si.si_line_num,
si.si_func,
si.si_tag);
110 char *token_saveptr =
NULL;
111 char *subtoken_saveptr =
NULL;
118 const char **fp_map[] = { &func, &
tag, &
type, &data1, &data2 };
132 token = strtok_r(
s,
",", &token_saveptr);
137 for (
i = 0;
i <
sizeof fp_map; ++
i) {
138 subtoken = strtok_r(
token,
":", &subtoken_saveptr);
139 if (subtoken ==
NULL)
142 *fp_map[
i] = subtoken;
151 warn(
"Incorrect fault point specification\n");
158 warn(
"Incorrect fault point type '%s'\n",
type);
165 warn(
"No probability was specified" 166 " for 'random' FP type\n");
170 data.u.fpd_p = atoi(data1);
172 if (data1 ==
NULL || data2 ==
NULL) {
173 warn(
"No N or M was specified" 174 " for 'off_n_on_m' FP type\n");
178 data.u.s1.fpd_n = atoi(data1);
179 data.u.s1.fpd_m = atoi(data2);
192 static inline const char *
pair_key(yaml_document_t *doc, yaml_node_pair_t *
pair)
194 return (
const char*)yaml_document_get_node(doc,
pair->key)->data.scalar.value;
197 static inline const char *
pair_val(yaml_document_t *doc, yaml_node_pair_t *
pair)
199 return (
const char*)yaml_document_get_node(doc,
pair->value)->data.scalar.value;
203 const char **func,
const char **
tag,
206 yaml_node_pair_t *
pair;
208 for (
pair =
node->data.mapping.pairs.start;
212 if (strcmp(
key,
"func") == 0) {
214 }
else if (strcmp(
key,
"tag") == 0) {
216 }
else if (strcmp(
key,
"type") == 0) {
219 warn(
"Incorrect FP type '%s'\n",
val);
223 else if (strcmp(
key,
"p") == 0) {
225 }
else if (strcmp(
key,
"n") == 0) {
227 }
else if (strcmp(
key,
"m") == 0) {
230 warn(
"Incorrect key '%s' in yaml file\n",
key);
242 const char *func = 0;
248 if (
node->type == YAML_MAPPING_NODE) {
263 yaml_document_t document;
265 f = fopen(file_name,
"r");
267 warn(
"Failed to open fault point yaml file '%s'", file_name);
271 rc = yaml_parser_initialize(&
parser);
273 warn(
"Failed to init yaml parser\n");
278 yaml_parser_set_input_file(&
parser,
f);
280 rc = yaml_parser_load(&
parser, &document);
282 warn(
"Incorrect YAML file\n");
289 yaml_document_delete(&document);
291 yaml_parser_delete(&
parser);
321 fprintf(stderr,
"Fault injection is not available, because it was" 322 " disabled during build\n");
M0_INTERNAL void m0_fi_print_info(void)
static uint64_t tag(uint8_t code, uint64_t id)
static struct net_test_cmd_node * node
M0_INTERNAL const struct m0_fi_fpoint_state * m0_fi_states_get(void)
static const char * pair_val(yaml_document_t *doc, yaml_node_pair_t *pair)
M0_INTERNAL enum m0_fi_fpoint_type m0_fi_fpoint_type_from_str(const char *type_name)
M0_INTERNAL int m0_fi_init(void)
static const char * pair_key(yaml_document_t *doc, yaml_node_pair_t *pair)
m0_time_t m0_time_now(void)
static struct net_test_cmd_node nodes[NTC_MULTIPLE_NODES]
M0_INTERNAL void fi_states_init(void)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
static void token(struct ff2c_context *ctx, struct ff2c_term *term, struct ff2c_token *tok)
const char m0_fi_states_print_format[]
M0_INTERNAL int m0_fi_enable_fault_point(const char *str)
M0_INTERNAL uint32_t m0_fi_states_get_free_idx(void)
static int extract_fpoint_data(yaml_document_t *doc, yaml_node_t *node, const char **func, const char **tag, struct m0_fi_fpoint_data *data)
M0_INTERNAL void m0_fi_enable_generic(const char *fp_func, const char *fp_tag, const struct m0_fi_fpoint_data *fp_data)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL uint32_t fi_random(void)
M0_INTERNAL void fi_states_fini(void)
struct m0_mutex fi_states_mutex
M0_INTERNAL void m0_fi_states_get_state_info(const struct m0_fi_fpoint_state *s, struct m0_fi_fpoint_state_info *si)
const char * m0_fi_states_headline[]
static int process_yaml(yaml_document_t *doc)
M0_INTERNAL void m0_fi_fini(void)
static struct m0_addb2_source * s
M0_INTERNAL int m0_fi_enable_fault_points_from_file(const char *file_name)
static struct sync_interactions si