7 #include <pugixml/pugixml.hpp>
8 #include <boost/uuid/uuid.hpp>
10 #include <test/test_cmn_util.h>
11 #include <pkt/test/test_pkt_util.h>
18 using namespace boost::uuids;
19 using namespace AgentUtXmlUtils;
26 if (strcmp(node.name(), node_name.c_str()) != 0) {
30 xml_attribute attr = node.attribute(
"name");
32 cout <<
"Attribute \"name\" not found for " << node_name
33 <<
". Skipping..." << endl;
37 *name = attr.as_string();
39 cout <<
"Invalid \"name\" for " << node_name <<
" Skipping" << endl;
53 xml_attribute attr = node.attribute(
"uuid");
55 cout <<
"Attribute \"uuid\" not found for " << node_name
56 <<
". Skipping..." << endl;
60 int x = attr.as_uint();
62 cout <<
"Invalid \"uuid\" (0) for " << node_name <<
" Skipping" << endl;
78 for (AgentUtXmlValidationList::iterator i =
node_list_.begin();
96 for (xml_node n =
node().first_child(); n; n = n.next_sibling()) {
104 if (fn.empty() ==
false)
105 val = fn(n.name(),
name, id, n);
112 cout <<
"Validate node " << val->
ToString() << endl;
114 cout <<
"Unknown node name <" << n.name() <<
">. Ignoring" << endl;
127 cout <<
"Running validation" <<
" <" <<
name() <<
">" << endl;
128 for (AgentUtXmlValidationList::iterator it =
node_list_.begin();
132 cout <<
"Validating " << node->
ToString() << endl;
135 while (i < node->wait_count()) {
146 cout <<
"Failed validation of " << node->
ToString() << endl;
157 const xml_node &node) :
158 name_(name), node_(node), present_(true), delete_marked_(false) {
167 if (str ==
"no" || str ==
"0")
boost::function< AgentUtXmlValidationNode *(const std::string &type, const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)> AgentUtXmlTestValidateCreateFn
AgentUtXmlValidate(const std::string &name, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
AgentUtXmlTestValidateCreateFn GetValidateCreateFn(const std::string &name)
static bool CheckValidateNode(const string &node_name, const xml_node &node, string *name)
virtual const std::string ToString()=0
virtual bool Validate()=0
static void WaitForIdle()
static bool CheckValidateNodeWithUuid(const string &node_name, const xml_node &node, uuid *id, string *name)
virtual std::string NodeType()
bool GetStringAttribute(const xml_node &node, const string &name, string *value)
virtual ~AgentUtXmlValidationNode()
AgentUtXmlValidationNode(const std::string &name, const pugi::xml_node &node)
virtual void ToString(std::string *str)
bool GetUintAttribute(const xml_node &node, const string &name, uint16_t *value)
virtual bool ToXml(pugi::xml_node *parent)
virtual uint32_t sleep_time() const
AgentUtXmlTestCase * test_case()
AgentUtXmlValidationList node_list_
const pugi::xml_node & node() const
virtual void ToString(std::string *str)
const std::string & name() const