59 #if CXX0X_UP_SUPPORTED == 0
60 #define static_assert(x, y)
115 if (hasName(attr, attr_name))
124 diag.unexpectedNode(node, std::string(
"Duplicated attribute: ") + attr_name);
140 std::stringstream(val) >> dst;
146 "pugixml cannot handle int32_t natively. custom string conversion required");
152 bool parse<std::vector<etiss::fault::Fault>>(
pugi::xml_node node, std::vector<etiss::fault::Fault> &dst,
156 std::string(
"> >(node, vector<Fault>, Diagnostics) called. "));
161 if (hasName(cnode,
"fault"))
164 if (parse<etiss::fault::Fault>(cnode, f, diag))
175 diag.ignoredNode(cnode,
"non \"fault\" node in fault list.");
182 bool write<std::vector<etiss::fault::Fault>>(
pugi::xml_node node,
const std::vector<etiss::fault::Fault> &src,
186 std::string(
"> >(node, vector<Fault>, Diagnostics) called. "));
189 for (
size_t i = 0; i < src.size(); ++i)
191 ret = ret && write(node.append_child(
"fault"), src[i], diag);
202 static std::mutex mu;
203 std::lock_guard<std::mutex> lock(mu);
217 doc.
load(
"<?xml version=\"1.0\"?>");
219 etiss::fault::xml::Diagnostics diag;
221 etiss::fault::xml::write<etiss::fault::Fault>(doc.
append_child(
"fault"), *
this, diag);
223 std::stringstream ss;
233 std::string(
") called. "));
234 for (std::vector<Trigger>::iterator iter =
triggers.begin(); iter !=
triggers.end(); ++iter)
236 iter->resolveTime(time);
241 for (std::vector<Trigger>::const_iterator iter =
triggers.begin(); iter !=
triggers.end(); ++iter)
243 if (!iter->isResolved())
251 bool parseXML(std::vector<Fault> &vec, std::istream &input, std::ostream &diagnostics_out)
260 diagnostics_out <<
"failed to load xml from stream: " << pr.
description() << std::endl;
264 etiss::fault::xml::Diagnostics diag;
268 diag.print(diagnostics_out);
273 bool writeXML(
const std::vector<Fault> &vec, std::ostream &out, std::ostream &diagnostics_out)
277 doc.
load(
"<?xml version=\"1.0\"?>");
279 etiss::fault::xml::Diagnostics diag;
281 bool ret = write(doc.
append_child(
"faults"), vec, diag);
285 diag.print(diagnostics_out);
297 std::string(
"(node, Fault, Diagnostics) called. "));
303 if (hasName(cnode,
"triggers"))
307 if (hasName(ccnode,
"trigger"))
310 if (parse<etiss::fault::Trigger>(ccnode, t, diag))
321 diag.ignoredNode(ccnode,
"\"trigger\" node expected");
325 else if (hasName(cnode,
"actions"))
329 if (hasName(ccnode,
"action"))
332 if (parse<etiss::fault::Action>(ccnode, t, diag))
343 diag.ignoredNode(ccnode,
"\"trigger\" node expected");
349 diag.ignoredNode(cnode,
"unknown node");
359 std::string(
"(node, Fault, Diagnostics) called. "));
364 for (std::vector<etiss::fault::Trigger>::const_iterator iter = f.
triggers.begin(); iter != f.
triggers.end(); ++iter)
366 ok = ok && write<etiss::fault::Trigger>(triggers.
append_child(
"trigger"), *iter, diag);
369 for (std::vector<etiss::fault::Action>::const_iterator iter = f.
actions.begin(); iter != f.
actions.end(); ++iter)
371 ok = ok && write<etiss::fault::Action>(actions.
append_child(
"action"), *iter, diag);
#define static_assert(x, y)
contains the fault container class that stores triggers and actions for fault injection
contains the fault injector interface class.
contains the Trigger class that defines conditions under which actions of a Fault need to be applied.
static __inline__ uint64_t
static __inline__ int32_t
bool isResoved() const
check all Triggers if they are resolved.
Fault()
Constructor: Generates a new Fault with unique ID.
std::string toString() const
operator<< can be used.
void resolveTime(uint64_t time)
Resolves time for all its Triggers.
std::vector< Trigger > triggers
contains the triggers for this fault
std::vector< Action > actions
contains the actions for this fault
xml_attribute next_attribute() const
bool set_value(const char_t *rhs)
xml_parse_result load(std::basic_istream< char, std::char_traits< char > > &stream, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
xml_node document_element() const
void save(xml_writer &writer, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto) const
xml_node append_child(xml_node_type type=node_element)
xml_node first_child() const
xml_attribute append_attribute(const char_t *name)
xml_node next_sibling() const
xml_attribute first_attribute() const
static bool setAttribute(pugi::xml_node &node, const std::string &attr_name, const std::string &src, Diagnostics &diag)
static bool getAttribute(const pugi::xml_node &node, const std::string &attr_name, std::string &dst, Diagnostics &diag)
Parser/writer structure:
static int32_t uniqueFaultId()
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
void log(Verbosity level, std::string msg)
write log message at the given level.
const char * description() const