8 #include <pugixml/pugixml.hpp>
9 #include <boost/uuid/uuid.hpp>
11 #include <test/test_cmn_util.h>
12 #include <pkt/test/test_pkt_util.h>
19 using namespace boost::uuids;
27 if (strcmp(node.name(), node_name.c_str()) != 0) {
31 xml_attribute attr = node.attribute(
"name");
33 cout <<
"Attribute \"name\" not found for " << node_name
34 <<
". Skipping..." << endl;
38 *name = attr.as_string();
40 cout <<
"Invalid \"name\" for " << node_name <<
" Skipping" << endl;
54 xml_attribute attr = node.attribute(
"uuid");
56 cout <<
"Attribute \"uuid\" not found for " << node_name
57 <<
". Skipping..." << endl;
61 int x = attr.as_uint();
63 cout <<
"Invalid \"uuid\" (0) for " << node_name <<
" Skipping" << endl;
79 for (AgentUtXmlValidationList::iterator i =
node_list_.begin();
97 for (xml_node n =
node().first_child(); n; n = n.next_sibling()) {
105 if (fn.empty() ==
false)
106 val = fn(n.name(),
name,
id, n);
113 cout <<
"Validate node " << val->
ToString() << endl;
115 cout <<
"Unknown node name <" << n.name() <<
">. Ignoring" << endl;
128 cout <<
"Running validation" <<
" <" <<
name() <<
">" << endl;
129 for (AgentUtXmlValidationList::iterator it =
node_list_.begin();
133 cout <<
"Validating " <<
node->ToString() << endl;
136 while (i < node->wait_count()) {
138 if (
node->Validate() ==
true) {
142 usleep(
node->sleep_time());
147 cout <<
"Failed validation of " <<
node->ToString() << endl;
158 const xml_node &node) :
159 name_(name), node_(node), present_(true), delete_marked_(false) {
168 if (str ==
"no" || str ==
"0")
const pugi::xml_node & node() const
virtual void ToString(std::string *str)
AgentUtXmlTestCase * test_case()
const std::string & name() const
boost::function< AgentUtXmlValidationNode *(const std::string &type, const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)> AgentUtXmlTestValidateCreateFn
AgentUtXmlTestValidateCreateFn GetValidateCreateFn(const std::string &name)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
AgentUtXmlValidationList node_list_
virtual void ToString(std::string *str)
AgentUtXmlValidate(const std::string &name, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual bool Validate()=0
virtual ~AgentUtXmlValidationNode()
virtual const std::string ToString()=0
AgentUtXmlValidationNode(const std::string &name, const pugi::xml_node &node)
static void WaitForIdle()
bool GetUintAttribute(const xml_node &node, const string &name, uint16_t *value)
bool GetStringAttribute(const xml_node &node, const string &name, string *value)
static bool CheckValidateNode(const string &node_name, const xml_node &node, string *name)
static bool CheckValidateNodeWithUuid(const string &node_name, const xml_node &node, uuid *id, string *name)