diff options
author | Piotrek Zadroga <piotrek@isc.org> | 2024-04-24 18:33:17 +0200 |
---|---|---|
committer | Piotrek Zadroga <piotrek@isc.org> | 2024-04-26 14:42:46 +0200 |
commit | 9d154be00c6f27075e621bdd790a14b8b0046bba (patch) | |
tree | b15c4ad194ff90d2520e93d22113202d179b76bb | |
parent | [#2820] add tid in some ddns logs (diff) | |
download | kea-9d154be00c6f27075e621bdd790a14b8b0046bba.tar.xz kea-9d154be00c6f27075e621bdd790a14b8b0046bba.zip |
[#2820] add tid in all eval logs
-rw-r--r-- | src/bin/dhcp4/dhcp4_srv.cc | 4 | ||||
-rw-r--r-- | src/bin/dhcp6/dhcp6_srv.cc | 4 | ||||
-rw-r--r-- | src/lib/dhcpsrv/client_class_def.cc | 7 | ||||
-rw-r--r-- | src/lib/eval/eval_messages.cc | 94 | ||||
-rw-r--r-- | src/lib/eval/eval_messages.mes | 94 | ||||
-rw-r--r-- | src/lib/eval/tests/token_unittest.cc | 1031 | ||||
-rw-r--r-- | src/lib/eval/token.cc | 95 | ||||
-rw-r--r-- | src/lib/testutils/log_utils.cc | 6 | ||||
-rw-r--r-- | src/lib/testutils/log_utils.h | 9 |
9 files changed, 734 insertions, 610 deletions
diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index a0d6c96b24..d7df95d8af 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -4700,21 +4700,25 @@ void Dhcpv4Srv::requiredClassify(Dhcpv4Exchange& ex) { bool status = evaluateBool(*expr_ptr, *query); if (status) { LOG_INFO(dhcp4_logger, EVAL_RESULT) + .arg(query->getLabel()) .arg(cclass) .arg("true"); // Matching: add the class query->addClass(cclass); } else { LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, EVAL_RESULT) + .arg(query->getLabel()) .arg(cclass) .arg("false"); } } catch (const Exception& ex) { LOG_ERROR(dhcp4_logger, EVAL_RESULT) + .arg(query->getLabel()) .arg(cclass) .arg(ex.what()); } catch (...) { LOG_ERROR(dhcp4_logger, EVAL_RESULT) + .arg(query->getLabel()) .arg(cclass) .arg("get exception?"); } diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index f091d512a3..1bfe099b1c 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -4476,21 +4476,25 @@ Dhcpv6Srv::requiredClassify(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx bool status = evaluateBool(*expr_ptr, *pkt); if (status) { LOG_INFO(dhcp6_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(cclass) .arg("true"); // Matching: add the class pkt->addClass(cclass); } else { LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(cclass) .arg("false"); } } catch (const Exception& ex) { LOG_ERROR(dhcp6_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(cclass) .arg(ex.what()); } catch (...) { LOG_ERROR(dhcp6_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(cclass) .arg("get exception?"); } diff --git a/src/lib/dhcpsrv/client_class_def.cc b/src/lib/dhcpsrv/client_class_def.cc index 5030960c22..d9b69f14b8 100644 --- a/src/lib/dhcpsrv/client_class_def.cc +++ b/src/lib/dhcpsrv/client_class_def.cc @@ -148,21 +148,25 @@ ClientClassDef::test(PktPtr pkt, const ExpressionPtr& expr_ptr) { bool status = evaluateBool(*expr_ptr, *pkt); if (status) { LOG_INFO(dhcpsrv_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(getName()) .arg("true"); // Matching: add the class pkt->addClass(getName()); } else { LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(getName()) .arg("false"); } } catch (const Exception& ex) { LOG_ERROR(dhcpsrv_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(getName()) .arg(ex.what()); } catch (...) { LOG_ERROR(dhcpsrv_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(getName()) .arg("get exception?"); } @@ -184,6 +188,7 @@ TemplateClientClassDef::test(PktPtr pkt, const ExpressionPtr& expr_ptr) { std::string subclass = evaluateString(*expr_ptr, *pkt); if (!subclass.empty()) { LOG_INFO(dhcpsrv_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(getName()) .arg(subclass); // Matching: add the subclass @@ -195,10 +200,12 @@ TemplateClientClassDef::test(PktPtr pkt, const ExpressionPtr& expr_ptr) { } } catch (const Exception& ex) { LOG_ERROR(dhcpsrv_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(getName()) .arg(ex.what()); } catch (...) { LOG_ERROR(dhcpsrv_logger, EVAL_RESULT) + .arg(pkt->getLabel()) .arg(getName()) .arg("get exception?"); } diff --git a/src/lib/eval/eval_messages.cc b/src/lib/eval/eval_messages.cc index cd9aae000e..04e7931b88 100644 --- a/src/lib/eval/eval_messages.cc +++ b/src/lib/eval/eval_messages.cc @@ -61,53 +61,53 @@ extern const isc::log::MessageID EVAL_RESULT = "EVAL_RESULT"; namespace { const char* values[] = { - "EVAL_DEBUG_AND", "Popping %1 and %2 pushing %3", - "EVAL_DEBUG_CONCAT", "Popping %1 and %2 pushing %3", - "EVAL_DEBUG_EQUAL", "Popping %1 and %2 pushing result %3", - "EVAL_DEBUG_HEXSTRING", "Pushing hex string %1", - "EVAL_DEBUG_IFELSE_FALSE", "Popping %1 (false) and %2, leaving %3", - "EVAL_DEBUG_IFELSE_TRUE", "Popping %1 (true) and %2, leaving %3", - "EVAL_DEBUG_INT16TOTEXT", "Pushing Int16 %1", - "EVAL_DEBUG_INT32TOTEXT", "Pushing Int32 %1", - "EVAL_DEBUG_INT8TOTEXT", "Pushing Int8 %1", - "EVAL_DEBUG_IPADDRESS", "Pushing IPAddress %1", - "EVAL_DEBUG_IPADDRESSTOTEXT", "Pushing IPAddress %1", - "EVAL_DEBUG_LCASE", "Poping string %1 and pushing converted value to lower case %2", - "EVAL_DEBUG_MEMBER", "Checking membership of '%1', pushing result %2", - "EVAL_DEBUG_NOT", "Popping %1 pushing %2", - "EVAL_DEBUG_OPTION", "Pushing option %1 with value %2", - "EVAL_DEBUG_OR", "Popping %1 and %2 pushing %3", - "EVAL_DEBUG_PKT", "Pushing PKT meta data %1 with value %2", - "EVAL_DEBUG_PKT4", "Pushing PKT4 field %1 with value %2", - "EVAL_DEBUG_PKT6", "Pushing PKT6 field %1 with value %2", - "EVAL_DEBUG_RELAY6", "Pushing PKT6 relay field %1 nest %2 with value %3", - "EVAL_DEBUG_RELAY6_RANGE", "Pushing PKT6 relay field %1 nest %2 with value %3", - "EVAL_DEBUG_SPLIT", "Popping field %1, delimiters %2, string %3, pushing result %4", - "EVAL_DEBUG_SPLIT_DELIM_EMPTY", "Popping field %1, delimiters %2, string %3, pushing result %4", - "EVAL_DEBUG_SPLIT_EMPTY", "Popping field %1, delimiters %2, string %3, pushing result %4", - "EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE", "Popping field %1, delimiters %2, string %3, pushing result %4", - "EVAL_DEBUG_STRING", "Pushing text string %1", - "EVAL_DEBUG_SUBSTRING", "Popping length %1, start %2, string %3 pushing result %4", - "EVAL_DEBUG_SUBSTRING_EMPTY", "Popping length %1, start %2, string %3 pushing result %4", - "EVAL_DEBUG_SUBSTRING_RANGE", "Popping length %1, start %2, string %3 pushing result %4", - "EVAL_DEBUG_SUB_OPTION", "Pushing option %1 sub-option %2 with value %3", - "EVAL_DEBUG_SUB_OPTION_NO_OPTION", "Requested option %1 sub-option %2, but the parent option is not present, pushing result %3", - "EVAL_DEBUG_TOHEXSTRING", "Popping binary value %1 and separator %2, pushing result %3", - "EVAL_DEBUG_UCASE", "Poping string %1 and pushing converted value to upper case %2", - "EVAL_DEBUG_UINT16TOTEXT", "Pushing UInt16 %1", - "EVAL_DEBUG_UINT32TOTEXT", "Pushing UInt32 %1", - "EVAL_DEBUG_UINT8TOTEXT", "Pushing UInt8 %1", - "EVAL_DEBUG_VENDOR_CLASS_DATA", "Data %1 (out of %2 received) in vendor class found, pushing result '%3'", - "EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", "Requested data index %1, but option with enterprise-id %2 has only %3 data tuple(s), pushing result '%4'", - "EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID", "Pushing enterprise-id %1 as result 0x%2", - "EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", "Was looking for %1, option had %2, pushing result '%3'", - "EVAL_DEBUG_VENDOR_CLASS_EXISTS", "Option with enterprise-id %1 found, pushing result '%2'", - "EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", "Option with code %1 missing, pushing result '%2'", - "EVAL_DEBUG_VENDOR_ENTERPRISE_ID", "Pushing enterprise-id %1 as result 0x%2", - "EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", "Was looking for %1, option had %2, pushing result '%3'", - "EVAL_DEBUG_VENDOR_EXISTS", "Option with enterprise-id %1 found, pushing result '%2'", - "EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code %1 missing, pushing result '%2'", - "EVAL_RESULT", "Expression %1 evaluated to %2", + "EVAL_DEBUG_AND", "%1: Popping %2 and %3 pushing %4", + "EVAL_DEBUG_CONCAT", "%1: Popping %2 and %3 pushing %4", + "EVAL_DEBUG_EQUAL", "%1: Popping %2 and %3 pushing result %4", + "EVAL_DEBUG_HEXSTRING", "%1: Pushing hex string %2", + "EVAL_DEBUG_IFELSE_FALSE", "%1: Popping %2 (false) and %3, leaving %4", + "EVAL_DEBUG_IFELSE_TRUE", "%1: Popping %2 (true) and %3, leaving %4", + "EVAL_DEBUG_INT16TOTEXT", "%1: Pushing Int16 %2", + "EVAL_DEBUG_INT32TOTEXT", "%1: Pushing Int32 %2", + "EVAL_DEBUG_INT8TOTEXT", "%1: Pushing Int8 %2", + "EVAL_DEBUG_IPADDRESS", "%1: Pushing IPAddress %2", + "EVAL_DEBUG_IPADDRESSTOTEXT", "%1: Pushing IPAddress %2", + "EVAL_DEBUG_LCASE", "%1: Popping string %2 and pushing converted value to lower case %3", + "EVAL_DEBUG_MEMBER", "%1: Checking membership of '%2', pushing result %3", + "EVAL_DEBUG_NOT", "%1: Popping %2 pushing %3", + "EVAL_DEBUG_OPTION", "%1: Pushing option %2 with value %3", + "EVAL_DEBUG_OR", "%1: Popping %2 and %3 pushing %4", + "EVAL_DEBUG_PKT", "%1: Pushing PKT meta data %2 with value %3", + "EVAL_DEBUG_PKT4", "%1: Pushing PKT4 field %2 with value %3", + "EVAL_DEBUG_PKT6", "%1: Pushing PKT6 field %2 with value %3", + "EVAL_DEBUG_RELAY6", "%1: Pushing PKT6 relay field %2 nest %3 with value %4", + "EVAL_DEBUG_RELAY6_RANGE", "%1: Pushing PKT6 relay field %2 nest %3 with value %4", + "EVAL_DEBUG_SPLIT", "%1: Popping field %2, delimiters %3, string %4, pushing result %5", + "EVAL_DEBUG_SPLIT_DELIM_EMPTY", "%1: Popping field %2, delimiters %3, string %4, pushing result %5", + "EVAL_DEBUG_SPLIT_EMPTY", "%1: Popping field %2, delimiters %3, string %4, pushing result %5", + "EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE", "%1: Popping field %2, delimiters %3, string %4, pushing result %5", + "EVAL_DEBUG_STRING", "%1: Pushing text string %2", + "EVAL_DEBUG_SUBSTRING", "%1: Popping length %2, start %3, string %4 pushing result %5", + "EVAL_DEBUG_SUBSTRING_EMPTY", "%1: Popping length %2, start %3, string %4 pushing result %5", + "EVAL_DEBUG_SUBSTRING_RANGE", "%1: Popping length %2, start %3, string %4 pushing result %5", + "EVAL_DEBUG_SUB_OPTION", "%1: Pushing option %2 sub-option %3 with value %4", + "EVAL_DEBUG_SUB_OPTION_NO_OPTION", "%1: Requested option %2 sub-option %3, but the parent option is not present, pushing result %4", + "EVAL_DEBUG_TOHEXSTRING", "%1: Popping binary value %2 and separator %3, pushing result %4", + "EVAL_DEBUG_UCASE", "%1: Popping string %2 and pushing converted value to upper case %3", + "EVAL_DEBUG_UINT16TOTEXT", "%1: Pushing UInt16 %2", + "EVAL_DEBUG_UINT32TOTEXT", "%1: Pushing UInt32 %2", + "EVAL_DEBUG_UINT8TOTEXT", "%1: Pushing UInt8 %2", + "EVAL_DEBUG_VENDOR_CLASS_DATA", "%1: Data %2 (out of %3 received) in vendor class found, pushing result '%4'", + "EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", "%1: Requested data index %2, but option with enterprise-id %3 has only %4 data tuple(s), pushing result '%5'", + "EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID", "%1: Pushing enterprise-id %2 as result 0x%3", + "EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", "%1: Was looking for %2, option had %3, pushing result '%4'", + "EVAL_DEBUG_VENDOR_CLASS_EXISTS", "%1: Option with enterprise-id %2 found, pushing result '%3'", + "EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", "%1: Option with code %2 missing, pushing result '%3'", + "EVAL_DEBUG_VENDOR_ENTERPRISE_ID", "%1: Pushing enterprise-id %2 as result 0x%3", + "EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", "%1: Was looking for %2, option had %3, pushing result '%4'", + "EVAL_DEBUG_VENDOR_EXISTS", "%1: Option with enterprise-id %2 found, pushing result '%3'", + "EVAL_DEBUG_VENDOR_NO_OPTION", "%1: Option with code %2 missing, pushing result '%3'", + "EVAL_RESULT", "%1: Expression %2 evaluated to %3", NULL }; diff --git a/src/lib/eval/eval_messages.mes b/src/lib/eval/eval_messages.mes index f000f298eb..01b31dfd32 100644 --- a/src/lib/eval/eval_messages.mes +++ b/src/lib/eval/eval_messages.mes @@ -8,14 +8,14 @@ $NAMESPACE isc::dhcp # For use with TokenAnd -% EVAL_DEBUG_AND Popping %1 and %2 pushing %3 +% EVAL_DEBUG_AND %1: Popping %2 and %3 pushing %4 This debug message indicates that two values are popped from the value stack. Then are then combined via logical and and the result is pushed onto the value stack. # For use with TokenConcat -% EVAL_DEBUG_CONCAT Popping %1 and %2 pushing %3 +% EVAL_DEBUG_CONCAT %1: Popping %2 and %3 pushing %4 This debug message indicates that the two strings are being popped off of the stack. They are then concatenated and the resulting string is pushed onto the stack. The strings are displayed in hex. @@ -23,76 +23,76 @@ pushed onto the stack. The strings are displayed in hex. # For use with TokenEqual # Start with binary for the inputs for now, we may add text in the future. -% EVAL_DEBUG_EQUAL Popping %1 and %2 pushing result %3 +% EVAL_DEBUG_EQUAL %1: Popping %2 and %3 pushing result %4 This debug message indicates that the two strings are being popped off of the value stack and the result of comparing them is being pushed onto the value stack. The strings are displayed in hex. # For use with TokenHexString -% EVAL_DEBUG_HEXSTRING Pushing hex string %1 +% EVAL_DEBUG_HEXSTRING %1: Pushing hex string %2 This debug message indicates that the given binary string is being pushed onto the value stack. The string is displayed in hex. # For use with TokenLowerCase -% EVAL_DEBUG_IFELSE_FALSE Popping %1 (false) and %2, leaving %3 +% EVAL_DEBUG_IFELSE_FALSE %1: Popping %2 (false) and %3, leaving %4 This debug message indicates that the condition is false so the iftrue branch value is removed and the ifelse branch value is left on the value stack. -% EVAL_DEBUG_IFELSE_TRUE Popping %1 (true) and %2, leaving %3 +% EVAL_DEBUG_IFELSE_TRUE %1: Popping %2 (true) and %3, leaving %4 This debug message indicates that the condition is true so the ifelse branch value is removed and the iftrue branch value is left on the value stack. # For use with TokenIpAddress -% EVAL_DEBUG_INT16TOTEXT Pushing Int16 %1 +% EVAL_DEBUG_INT16TOTEXT %1: Pushing Int16 %2 This debug message indicates that the given address string representation is being pushed onto the value stack. This represents a 16 bit integer. # For use with TokenInt32ToText -% EVAL_DEBUG_INT32TOTEXT Pushing Int32 %1 +% EVAL_DEBUG_INT32TOTEXT %1: Pushing Int32 %2 This debug message indicates that the given address string representation is being pushed onto the value stack. This represents a 32 bit integer. # For use with TokenUInt8ToText -% EVAL_DEBUG_INT8TOTEXT Pushing Int8 %1 +% EVAL_DEBUG_INT8TOTEXT %1: Pushing Int8 %2 This debug message indicates that the given address string representation is being pushed onto the value stack. This represents an 8 bit integer. # For use with TokenInt16ToText -% EVAL_DEBUG_IPADDRESS Pushing IPAddress %1 +% EVAL_DEBUG_IPADDRESS %1: Pushing IPAddress %2 This debug message indicates that the given binary string is being pushed onto the value stack. This represents either an IPv4 or IPv6 address. The string is displayed in hex. # For use with TokenIpAddressToText -% EVAL_DEBUG_IPADDRESSTOTEXT Pushing IPAddress %1 +% EVAL_DEBUG_IPADDRESSTOTEXT %1: Pushing IPAddress %2 This debug message indicates that the given address string representation is being pushed onto the value stack. This represents either an IPv4 or IPv6 address. # For use with TokenInt8ToText -% EVAL_DEBUG_LCASE Poping string %1 and pushing converted value to lower case %2 +% EVAL_DEBUG_LCASE %1: Popping string %2 and pushing converted value to lower case %3 This debug message indicates that the given string representation is being converted to lower case and pushed onto the value stack. # For use with TokenUpperCase -% EVAL_DEBUG_MEMBER Checking membership of '%1', pushing result %2 +% EVAL_DEBUG_MEMBER %1: Checking membership of '%2', pushing result %3 This debug message indicates that the membership of the packet for the client class was checked. # For use with TokenNot -% EVAL_DEBUG_NOT Popping %1 pushing %2 +% EVAL_DEBUG_NOT %1: Popping %2 pushing %3 This debug message indicates that the first value is popped from the value stack, negated and then pushed onto the value stack. The string is displayed in text. @@ -100,7 +100,7 @@ The string is displayed in text. # For use with TokenOption based classes. These include TokenOption, # TokenRelay4Option and TokenRelay6Option. -% EVAL_DEBUG_OPTION Pushing option %1 with value %2 +% EVAL_DEBUG_OPTION %1: Pushing option %2 with value %3 This debug message indicates that the given string representing the value of the requested option is being pushed onto the value stack. The string may be the text or binary value of the string based on the @@ -110,7 +110,7 @@ option or a sub-option as requested in the classification statement. # For use with TokenOr -% EVAL_DEBUG_OR Popping %1 and %2 pushing %3 +% EVAL_DEBUG_OR %1: Popping %2 and %3 pushing %4 This debug message indicates that two values are popped from the value stack. Then are then combined via logical or and the result is pushed onto the value stack. The string is displayed @@ -118,80 +118,80 @@ in text. # For use with TokenPkt -% EVAL_DEBUG_PKT Pushing PKT meta data %1 with value %2 +% EVAL_DEBUG_PKT %1: Pushing PKT meta data %2 with value %3 This debug message indicates that the given binary string representing the value of the requested meta data is being pushed onto the value stack. The string is displayed in hex at the exception of interface name. # For use with TokenPkt4 -% EVAL_DEBUG_PKT4 Pushing PKT4 field %1 with value %2 +% EVAL_DEBUG_PKT4 %1: Pushing PKT4 field %2 with value %3 This debug message indicates that the given binary string representing the value of the requested field is being pushed onto the value stack. The string is displayed in hex. # For use with TokenPkt6 -% EVAL_DEBUG_PKT6 Pushing PKT6 field %1 with value %2 +% EVAL_DEBUG_PKT6 %1: Pushing PKT6 field %2 with value %3 This debug message indicates that the given binary string representing the value of the requested field is being pushed onto the value stack. The string is displayed in hex. # For use with TokenRelay6Field -% EVAL_DEBUG_RELAY6 Pushing PKT6 relay field %1 nest %2 with value %3 +% EVAL_DEBUG_RELAY6 %1: Pushing PKT6 relay field %2 nest %3 with value %4 This debug message indicates that the given binary string representing the value of the requested field is being pushed onto the value stack. The string is displayed in hex. -% EVAL_DEBUG_RELAY6_RANGE Pushing PKT6 relay field %1 nest %2 with value %3 +% EVAL_DEBUG_RELAY6_RANGE %1: Pushing PKT6 relay field %2 nest %3 with value %4 This debug message is generated if the nest field is out of range. The empty string will always be the value pushed onto the stack. # For use with TokenString -% EVAL_DEBUG_SPLIT Popping field %1, delimiters %2, string %3, pushing result %4 +% EVAL_DEBUG_SPLIT %1: Popping field %2, delimiters %3, string %4, pushing result %5 This debug message indicates that three values are being popped from the stack and a result is being pushed onto the stack. The values being popped are the field, delimiter and string. The result is the extracted field which is pushed onto the stack. The strings are displayed in hex. -% EVAL_DEBUG_SPLIT_DELIM_EMPTY Popping field %1, delimiters %2, string %3, pushing result %4 +% EVAL_DEBUG_SPLIT_DELIM_EMPTY %1: Popping field %2, delimiters %3, string %4, pushing result %5 This debug message indicates that the delimiter popped from the stack was empty and so the result will be the entire string. The field, delimiter and string are still popped from the stack and the result is still pushed. -% EVAL_DEBUG_SPLIT_EMPTY Popping field %1, delimiters %2, string %3, pushing result %4 +% EVAL_DEBUG_SPLIT_EMPTY %1: Popping field %2, delimiters %3, string %4, pushing result %5 This debug message indicates that the string popped from the stack was empty and so the result will also be empty. The field, delimiter and string are still popped from the stack and the result is still pushed. -% EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE Popping field %1, delimiters %2, string %3, pushing result %4 +% EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE %1: Popping field %2, delimiters %3, string %4, pushing result %5 This debug message indicates that the field is either less than one or larger than the number of fields in the string popped from the stack. The result will be empty. The field, delimiter and string are still popped from the stack and the result is still pushed. -% EVAL_DEBUG_STRING Pushing text string %1 +% EVAL_DEBUG_STRING %1: Pushing text string %2 This debug message indicates that the given text string is being pushed onto the value stack. The string is displayed in text. # For use with TokenSubstring # Start with binary for the strings for now, we may add text in the future. -% EVAL_DEBUG_SUBSTRING Popping length %1, start %2, string %3 pushing result %4 +% EVAL_DEBUG_SUBSTRING %1: Popping length %2, start %3, string %4 pushing result %5 This debug message indicates that three values are being popped from the value stack and a result is being pushed onto the value stack. The values being popped are the starting point and length of a substring to extract from the given string. The resulting string is pushed onto the stack. The strings are displayed in hex. -% EVAL_DEBUG_SUBSTRING_EMPTY Popping length %1, start %2, string %3 pushing result %4 +% EVAL_DEBUG_SUBSTRING_EMPTY %1: Popping length %2, start %3, string %4 pushing result %5 This debug message indicates that the string popped from the stack was empty and so the result will also be empty. The start, length and string are still popped from the stack and the result is still pushed. -% EVAL_DEBUG_SUBSTRING_RANGE Popping length %1, start %2, string %3 pushing result %4 +% EVAL_DEBUG_SUBSTRING_RANGE %1: Popping length %2, start %3, string %4 pushing result %5 This debug message indicates that the value of start is outside of the string and an empty result will be pushed onto the stack. The start, length and string are still popped from the stack and the result is @@ -199,7 +199,7 @@ still pushed. The strings are displayed in hex. # For use with TokenSubOption -% EVAL_DEBUG_SUB_OPTION Pushing option %1 sub-option %2 with value %3 +% EVAL_DEBUG_SUB_OPTION %1: Pushing option %2 sub-option %3 with value %4 This debug message indicates that the given string representing the value of the requested sub-option of the requested parent option is being pushed onto the value stack. The string may be the text or @@ -208,90 +208,90 @@ binary value of the string based on the representation type requested The codes are the parent option and the sub-option codes as requested in the classification statement. -% EVAL_DEBUG_SUB_OPTION_NO_OPTION Requested option %1 sub-option %2, but the parent option is not present, pushing result %3 +% EVAL_DEBUG_SUB_OPTION_NO_OPTION %1: Requested option %2 sub-option %3, but the parent option is not present, pushing result %4 This debug message indicates that the parent option was not found. The codes are the parent option and the sub-option codes as requested in the classification statement. # For use with TokenToHexString -% EVAL_DEBUG_TOHEXSTRING Popping binary value %1 and separator %2, pushing result %3 +% EVAL_DEBUG_TOHEXSTRING %1: Popping binary value %2 and separator %3, pushing result %4 This debug message indicates that two values are being popped from the value stack and a result is being pushed onto the value stack. The values being popped are the binary value to convert and the separator. The binary value is converted to its hexadecimal string representation and pushed onto the stack. The binary value is displayed in hex. -% EVAL_DEBUG_UCASE Poping string %1 and pushing converted value to upper case %2 +% EVAL_DEBUG_UCASE %1: Popping string %2 and pushing converted value to upper case %3 This debug message indicates that the given string representation is being converted to upper case and pushed onto the value stack. # For use with TokenIfElse -% EVAL_DEBUG_UINT16TOTEXT Pushing UInt16 %1 +% EVAL_DEBUG_UINT16TOTEXT %1: Pushing UInt16 %2 This debug message indicates that the given address string representation is being pushed onto the value stack. This represents a 16 bit unsigned integer. # For use with TokenUInt32ToText -% EVAL_DEBUG_UINT32TOTEXT Pushing UInt32 %1 +% EVAL_DEBUG_UINT32TOTEXT %1: Pushing UInt32 %2 This debug message indicates that the given address string representation is being pushed onto the value stack. This represents a 32 bit unsigned integer. # For use with TokenMember -% EVAL_DEBUG_UINT8TOTEXT Pushing UInt8 %1 +% EVAL_DEBUG_UINT8TOTEXT %1: Pushing UInt8 %2 This debug message indicates that the given address string representation is being pushed onto the value stack. This represents an 8 bit unsigned integer. # For use with TokenUInt16ToText -% EVAL_DEBUG_VENDOR_CLASS_DATA Data %1 (out of %2 received) in vendor class found, pushing result '%3' +% EVAL_DEBUG_VENDOR_CLASS_DATA %1: Data %2 (out of %3 received) in vendor class found, pushing result '%4' This debug message indicates that vendor class option was found and passed enterprise-id checks and has sufficient number of data chunks. The total number of chunks and value pushed are reported as debugging aid. -% EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index %1, but option with enterprise-id %2 has only %3 data tuple(s), pushing result '%4' +% EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND %1: Requested data index %2, but option with enterprise-id %3 has only %4 data tuple(s), pushing result '%5' This debug message indicates that vendor class option was found and passed enterprise-id checks, but does not have sufficient number of data chunks. Note that the index starts at 0, so there has to be at least (index + 1) data chunks. -% EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID Pushing enterprise-id %1 as result 0x%2 +% EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID %1: Pushing enterprise-id %2 as result 0x%3 This debug message indicates that the expression has been evaluated and vendor class option was found and its enterprise-id is being reported. -% EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for %1, option had %2, pushing result '%3' +% EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH %1: Was looking for %2, option had %3, pushing result '%4' This debug message indicates that the expression has been evaluated and vendor class option was found, but has different enterprise-id than specified in the expression. -% EVAL_DEBUG_VENDOR_CLASS_EXISTS Option with enterprise-id %1 found, pushing result '%2' +% EVAL_DEBUG_VENDOR_CLASS_EXISTS %1: Option with enterprise-id %2 found, pushing result '%3' This debug message indicates that the expression has been evaluated and vendor class option was found. -% EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code %1 missing, pushing result '%2' +% EVAL_DEBUG_VENDOR_CLASS_NO_OPTION %1: Option with code %2 missing, pushing result '%3' This debug message indicates that the expression has been evaluated and vendor class option was not found. -% EVAL_DEBUG_VENDOR_ENTERPRISE_ID Pushing enterprise-id %1 as result 0x%2 +% EVAL_DEBUG_VENDOR_ENTERPRISE_ID %1: Pushing enterprise-id %2 as result 0x%3 This debug message indicates that the expression has been evaluated and vendor option was found and its enterprise-id is being reported. -% EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for %1, option had %2, pushing result '%3' +% EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH %1: Was looking for %2, option had %3, pushing result '%4' This debug message indicates that the expression has been evaluated and vendor option was found, but has different enterprise-id than specified in the expression. -% EVAL_DEBUG_VENDOR_EXISTS Option with enterprise-id %1 found, pushing result '%2' +% EVAL_DEBUG_VENDOR_EXISTS %1: Option with enterprise-id %2 found, pushing result '%3' This debug message indicates that the expression has been evaluated and vendor option was found. -% EVAL_DEBUG_VENDOR_NO_OPTION Option with code %1 missing, pushing result '%2' +% EVAL_DEBUG_VENDOR_NO_OPTION %1: Option with code %2 missing, pushing result '%3' This debug message indicates that the expression has been evaluated and vendor option was not found. -% EVAL_RESULT Expression %1 evaluated to %2 +% EVAL_RESULT %1: Expression %2 evaluated to %3 This debug message indicates that the expression has been evaluated to said value. This message is mostly useful during debugging of the client classification expressions. diff --git a/src/lib/eval/tests/token_unittest.cc b/src/lib/eval/tests/token_unittest.cc index 4ff90d8718..39296ea423 100644 --- a/src/lib/eval/tests/token_unittest.cc +++ b/src/lib/eval/tests/token_unittest.cc @@ -585,7 +585,7 @@ TEST_F(TokenTest, string4) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_STRING Pushing text string 'foo'"); + addString("EVAL_DEBUG_STRING", "Pushing text string 'foo'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -593,7 +593,7 @@ TEST_F(TokenTest, string4) { // can be used in Pkt4 evaluation. (The actual packet is not used) TEST_F(TokenTest, string4Complex) { char data[] = "12345~!@#$%^&*()_+{}[];:<>/?\\67890\t \0\b\r\f'\"" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; string data_str(data, sizeof(data) - 1); // Store constant string in the TokenString object. ASSERT_NO_THROW(t_.reset(new TokenString(data_str))); @@ -608,11 +608,11 @@ TEST_F(TokenTest, string4Complex) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - char expected[] = "EVAL_DEBUG_STRING Pushing text string '" - "12345~!@#$%^&*()_+{}[];:<>/?\\67890\t \0\b\r\f'\"" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'"; + char expected[] = "Pushing text string '" + "12345~!@#$%^&*()_+{}[];:<>/?\\67890\t \0\b\r\f'\"" + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'"; string expected_str(expected, sizeof(expected) - 1); - addString(expected_str); + addString("EVAL_DEBUG_STRING", expected_str, *pkt4_); EXPECT_TRUE(checkFile()); } @@ -633,7 +633,7 @@ TEST_F(TokenTest, string6) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_STRING Pushing text string 'foo'"); + addString("EVAL_DEBUG_STRING", "Pushing text string 'foo'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -641,7 +641,7 @@ TEST_F(TokenTest, string6) { // can be used in Pkt6 evaluation. (The actual packet is not used) TEST_F(TokenTest, string6Complex) { char data[] = "12345~!@#$%^&*()_+{}[];:<>/?\\67890\t \0\b\r\f'\"" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; string data_str(data, sizeof(data) - 1); // Store constant string in the TokenString object. ASSERT_NO_THROW(t_.reset(new TokenString(data_str))); @@ -656,11 +656,11 @@ TEST_F(TokenTest, string6Complex) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - char expected[] = "EVAL_DEBUG_STRING Pushing text string '" - "12345~!@#$%^&*()_+{}[];:<>/?\\67890\t \0\b\r\f'\"" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'"; + char expected[] = "Pushing text string '" + "12345~!@#$%^&*()_+{}[];:<>/?\\67890\t \0\b\r\f'\"" + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'"; string expected_str(expected, sizeof(expected) - 1); - addString(expected_str); + addString("EVAL_DEBUG_STRING", expected_str, *pkt6_); EXPECT_TRUE(checkFile()); } @@ -722,13 +722,13 @@ TEST_F(TokenTest, hexstring4) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x07"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x666F6F"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x63825363"); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt4_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt4_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt4_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt4_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x07", *pkt4_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x666F6F", *pkt4_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x63825363", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -789,13 +789,13 @@ TEST_F(TokenTest, hexstring6) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x07"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x666F6F"); - addString("EVAL_DEBUG_HEXSTRING Pushing hex string 0x63825363"); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt6_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt6_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt6_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x", *pkt6_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x07", *pkt6_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x666F6F", *pkt6_); + addString("EVAL_DEBUG_HEXSTRING", "Pushing hex string 0x63825363", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -816,7 +816,8 @@ TEST_F(TokenTest, lcase) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_LCASE Poping string 'LoWeR' and pushing converted value to lower case 'lower'"); + addString("EVAL_DEBUG_LCASE", + "Popping string 'LoWeR' and pushing converted value to lower case 'lower'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -841,12 +842,12 @@ TEST_F(TokenTest, lcaseComplex) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - char expected[] = "EVAL_DEBUG_LCASE Poping string '" - "12345~!@#$%^&*()_+LoWeR{}[];:<>/?\\67890\t \0\b\r\f' " - "and pushing converted value to lower case '" - "12345~!@#$%^&*()_+lower{}[];:<>/?\\67890\t \0\b\r\f'"; + char expected[] = "Popping string '" + "12345~!@#$%^&*()_+LoWeR{}[];:<>/?\\67890\t \0\b\r\f' " + "and pushing converted value to lower case '" + "12345~!@#$%^&*()_+lower{}[];:<>/?\\67890\t \0\b\r\f'"; string expected_str(expected, sizeof(expected) - 1); - addString(expected_str); + addString("EVAL_DEBUG_LCASE", expected_str, *pkt6_); EXPECT_TRUE(checkFile()); } @@ -867,7 +868,8 @@ TEST_F(TokenTest, ucase) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_UCASE Poping string 'uPpEr' and pushing converted value to upper case 'UPPER'"); + addString("EVAL_DEBUG_UCASE", + "Popping string 'uPpEr' and pushing converted value to upper case 'UPPER'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -892,12 +894,12 @@ TEST_F(TokenTest, ucaseComplex) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - char expected[] = "EVAL_DEBUG_UCASE Poping string '" - "12345~!@#$%^&*()_+uPpEr{}[];:<>/?\\67890\t \0\b\r\f' " - "and pushing converted value to upper case '" - "12345~!@#$%^&*()_+UPPER{}[];:<>/?\\67890\t \0\b\r\f'"; + char expected[] = "Popping string '" + "12345~!@#$%^&*()_+uPpEr{}[];:<>/?\\67890\t \0\b\r\f' " + "and pushing converted value to upper case '" + "12345~!@#$%^&*()_+UPPER{}[];:<>/?\\67890\t \0\b\r\f'"; string expected_str(expected, sizeof(expected) - 1); - addString(expected_str); + addString("EVAL_DEBUG_UCASE", expected_str, *pkt6_); EXPECT_TRUE(checkFile()); } @@ -948,11 +950,11 @@ TEST_F(TokenTest, ipaddress) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_IPADDRESS Pushing IPAddress 0x0A000001"); - addString("EVAL_DEBUG_IPADDRESS Pushing IPAddress " - "0x20010DB8000000000000000000000001"); - addString("EVAL_DEBUG_IPADDRESS Pushing IPAddress 0x"); - addString("EVAL_DEBUG_IPADDRESS Pushing IPAddress 0x"); + addString("EVAL_DEBUG_IPADDRESS", "Pushing IPAddress 0x0A000001", *pkt4_); + addString("EVAL_DEBUG_IPADDRESS", "Pushing IPAddress 0x20010DB8000000000000000000000001", + *pkt6_); + addString("EVAL_DEBUG_IPADDRESS", "Pushing IPAddress 0x", *pkt4_); + addString("EVAL_DEBUG_IPADDRESS", "Pushing IPAddress 0x", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -1010,8 +1012,8 @@ TEST_F(TokenTest, addressToText) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_IPADDRESSTOTEXT Pushing IPAddress 10.0.0.1"); - addString("EVAL_DEBUG_IPADDRESSTOTEXT Pushing IPAddress 2001:db8::1"); + addString("EVAL_DEBUG_IPADDRESSTOTEXT", "Pushing IPAddress 10.0.0.1", *pkt4_); + addString("EVAL_DEBUG_IPADDRESSTOTEXT", "Pushing IPAddress 2001:db8::1", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1045,7 +1047,8 @@ TEST_F(TokenTest, integerToText) { uint64_t data = -1; - values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(int8_t))); + values_.push( + std::string(const_cast<const char*>(reinterpret_cast<char*>(&data)), sizeof(int8_t))); EXPECT_NO_THROW(int8token->evaluate(*pkt4_, values_)); @@ -1054,7 +1057,8 @@ TEST_F(TokenTest, integerToText) { int16_t i16 = 0; memcpy(&i16, &data, sizeof(int16_t)); - values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&i16)), sizeof(int16_t))); + values_.push( + std::string(const_cast<const char*>(reinterpret_cast<char*>(&i16)), sizeof(int16_t))); EXPECT_NO_THROW(int16token->evaluate(*pkt4_, values_)); @@ -1063,14 +1067,16 @@ TEST_F(TokenTest, integerToText) { int32_t i32 = 0; memcpy(&i32, &data, sizeof(int32_t)); - values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&i32)), sizeof(int32_t))); + values_.push( + std::string(const_cast<const char*>(reinterpret_cast<char*>(&i32)), sizeof(int32_t))); EXPECT_NO_THROW(int32token->evaluate(*pkt4_, values_)); // Check that the evaluation put its value on the values stack. ASSERT_EQ(3, values_.size()); - values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(uint8_t))); + values_.push( + std::string(const_cast<const char*>(reinterpret_cast<char*>(&data)), sizeof(uint8_t))); EXPECT_NO_THROW(uint8token->evaluate(*pkt4_, values_)); @@ -1079,7 +1085,8 @@ TEST_F(TokenTest, integerToText) { uint16_t ui16 = 0; memcpy(&ui16, &data, sizeof(uint16_t)); - values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&ui16)), sizeof(uint16_t))); + values_.push( + std::string(const_cast<const char*>(reinterpret_cast<char*>(&ui16)), sizeof(uint16_t))); EXPECT_NO_THROW(uint16token->evaluate(*pkt4_, values_)); @@ -1088,7 +1095,8 @@ TEST_F(TokenTest, integerToText) { uint32_t ui32 = 0; memcpy(&ui32, &data, sizeof(uint32_t)); - values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&ui32)), sizeof(uint32_t))); + values_.push( + std::string(const_cast<const char*>(reinterpret_cast<char*>(&ui32)), sizeof(uint32_t))); EXPECT_NO_THROW(uint32token->evaluate(*pkt4_, values_)); @@ -1196,12 +1204,12 @@ TEST_F(TokenTest, integerToText) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_INT8TOTEXT Pushing Int8 -1"); - addString("EVAL_DEBUG_INT16TOTEXT Pushing Int16 -1"); - addString("EVAL_DEBUG_INT32TOTEXT Pushing Int32 -1"); - addString("EVAL_DEBUG_UINT8TOTEXT Pushing UInt8 255"); - addString("EVAL_DEBUG_UINT16TOTEXT Pushing UInt16 65535"); - addString("EVAL_DEBUG_UINT32TOTEXT Pushing UInt32 4294967295"); + addString("EVAL_DEBUG_INT8TOTEXT", "Pushing Int8 -1", *pkt4_); + addString("EVAL_DEBUG_INT16TOTEXT", "Pushing Int16 -1", *pkt4_); + addString("EVAL_DEBUG_INT32TOTEXT", "Pushing Int32 -1", *pkt4_); + addString("EVAL_DEBUG_UINT8TOTEXT", "Pushing UInt8 255", *pkt4_); + addString("EVAL_DEBUG_UINT16TOTEXT", "Pushing UInt16 65535", *pkt4_); + addString("EVAL_DEBUG_UINT32TOTEXT", "Pushing UInt32 4294967295", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1235,8 +1243,8 @@ TEST_F(TokenTest, optionString4) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'hundred4'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value ''"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'hundred4'", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value ''", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1271,8 +1279,8 @@ TEST_F(TokenTest, optionHexString4) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 0x68756E6472656434"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value 0x"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 0x68756E6472656434", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value 0x", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1300,8 +1308,8 @@ TEST_F(TokenTest, optionExistsString4) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'true'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value 'false'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'true'", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value 'false'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1335,8 +1343,8 @@ TEST_F(TokenTest, optionString6) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'hundred6'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value ''"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'hundred6'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value ''", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -1371,8 +1379,8 @@ TEST_F(TokenTest, optionHexString6) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 0x68756E6472656436"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value 0x"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 0x68756E6472656436", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value 0x", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -1400,8 +1408,8 @@ TEST_F(TokenTest, optionExistsString6) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'true'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value 'false'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'true'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value 'false'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -1427,7 +1435,7 @@ TEST_F(TokenTest, relay4Option) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 13 with value 'thirteen'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 13 with value 'thirteen'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1454,7 +1462,7 @@ TEST_F(TokenTest, relay4OptionNoSuboption) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 15 with value ''"); + addString("EVAL_DEBUG_OPTION", "Pushing option 15 with value ''", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1480,7 +1488,7 @@ TEST_F(TokenTest, relay4OptionNoRai) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 13 with value ''"); + addString("EVAL_DEBUG_OPTION", "Pushing option 13 with value ''", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1542,11 +1550,11 @@ TEST_F(TokenTest, relay4RAIOnly) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 13 with value 'thirteen'"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 'one'"); - addString("EVAL_DEBUG_OPTION Pushing option 70 with value ''"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 'true'"); - addString("EVAL_DEBUG_OPTION Pushing option 70 with value 'false'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 13 with value 'thirteen'", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 'one'", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 70 with value ''", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 'true'", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 70 with value 'false'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1600,29 +1608,29 @@ TEST_F(TokenTest, relay6Option) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'hundred.zero'"); - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'true'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value 'hundredone.zero'"); - addString("EVAL_DEBUG_OPTION Pushing option 102 with value ''"); - addString("EVAL_DEBUG_OPTION Pushing option 102 with value 'false'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'hundred.zero'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'true'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value 'hundredone.zero'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 102 with value ''", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 102 with value 'false'", *pkt6_); - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'hundred.one'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value ''"); - addString("EVAL_DEBUG_OPTION Pushing option 102 with value 'hundredtwo.one'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'hundred.one'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value ''", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 102 with value 'hundredtwo.one'", *pkt6_); - addString("EVAL_DEBUG_OPTION Pushing option 100 with value ''"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value ''", *pkt6_); - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'hundred.one'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value ''"); - addString("EVAL_DEBUG_OPTION Pushing option 102 with value 'hundredtwo.one'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'hundred.one'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value ''", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 102 with value 'hundredtwo.one'", *pkt6_); - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'hundred.zero'"); - addString("EVAL_DEBUG_OPTION Pushing option 100 with value 'true'"); - addString("EVAL_DEBUG_OPTION Pushing option 101 with value 'hundredone.zero'"); - addString("EVAL_DEBUG_OPTION Pushing option 102 with value ''"); - addString("EVAL_DEBUG_OPTION Pushing option 102 with value 'false'"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'hundred.zero'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value 'true'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 101 with value 'hundredone.zero'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 102 with value ''", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 102 with value 'false'", *pkt6_); - addString("EVAL_DEBUG_OPTION Pushing option 100 with value ''"); + addString("EVAL_DEBUG_OPTION", "Pushing option 100 with value ''", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -1683,10 +1691,10 @@ TEST_F(TokenTest, pkt4MetaData) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_PKT Pushing PKT meta data iface with value eth0"); - addString("EVAL_DEBUG_PKT Pushing PKT meta data src with value 0x0A000002"); - addString("EVAL_DEBUG_PKT Pushing PKT meta data dst with value 0x0A000001"); - addString("EVAL_DEBUG_PKT Pushing PKT meta data len with value 0x000000F9"); + addString("EVAL_DEBUG_PKT", "Pushing PKT meta data iface with value eth0", *pkt4_); + addString("EVAL_DEBUG_PKT", "Pushing PKT meta data src with value 0x0A000002", *pkt4_); + addString("EVAL_DEBUG_PKT", "Pushing PKT meta data dst with value 0x0A000001", *pkt4_); + addString("EVAL_DEBUG_PKT", "Pushing PKT meta data len with value 0x000000F9", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1742,12 +1750,12 @@ TEST_F(TokenTest, pkt6MetaData) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_PKT Pushing PKT meta data iface with value eth0"); - addString("EVAL_DEBUG_PKT Pushing PKT meta data src with value " - "0xFE800000000000000000000000001234"); - addString("EVAL_DEBUG_PKT Pushing PKT meta data dst with value " - "0xFF020000000000000000000000010002"); - addString("EVAL_DEBUG_PKT Pushing PKT meta data len with value 0x00000010"); + addString("EVAL_DEBUG_PKT", "Pushing PKT meta data iface with value eth0", *pkt6_); + addString("EVAL_DEBUG_PKT", + "Pushing PKT meta data src with value 0xFE800000000000000000000000001234", *pkt6_); + addString("EVAL_DEBUG_PKT", + "Pushing PKT meta data dst with value 0xFF020000000000000000000000010002", *pkt6_); + addString("EVAL_DEBUG_PKT", "Pushing PKT meta data len with value 0x00000010", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -1856,15 +1864,15 @@ TEST_F(TokenTest, pkt4Fields) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field mac with value 0x01020304050607"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field hlen with value 0x00000007"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field htype with value 0x0000007B"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field giaddr with value 0xC0000201"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field ciaddr with value 0xC0000202"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field yiaddr with value 0xC0000203"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field siaddr with value 0xC0000204"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field msgtype with value 0x00000001"); - addString("EVAL_DEBUG_PKT4 Pushing PKT4 field transid with value 0x00003039"); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field mac with value 0x01020304050607", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field hlen with value 0x00000007", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field htype with value 0x0000007B", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field giaddr with value 0xC0000201", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field ciaddr with value 0xC0000202", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field yiaddr with value 0xC0000203", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field siaddr with value 0xC0000204", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field msgtype with value 0x00000001", *pkt4_); + addString("EVAL_DEBUG_PKT4", "Pushing PKT4 field transid with value 0x00003039", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -1901,8 +1909,8 @@ TEST_F(TokenTest, pkt6Fields) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_PKT6 Pushing PKT6 field msgtype with value 0x00000001"); - addString("EVAL_DEBUG_PKT6 Pushing PKT6 field transid with value 0x00003039"); + addString("EVAL_DEBUG_PKT6", "Pushing PKT6 field msgtype with value 0x00000001", *pkt6_); + addString("EVAL_DEBUG_PKT6", "Pushing PKT6 field transid with value 0x00003039", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -1973,34 +1981,54 @@ TEST_F(TokenTest, relay6Field) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field linkaddr nest 0 " - "with value 0x00000000000000000000000000000000"); - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field peeraddr nest 0 " - "with value 0x00000000000000000000000000000000"); - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field linkaddr nest 1 " - "with value 0x00010000000000000000000000000001"); - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field peeraddr nest 1 " - "with value 0x00010000000000000000000000000002"); - addString("EVAL_DEBUG_RELAY6_RANGE Pushing PKT6 relay field linkaddr " - "nest 2 with value 0x"); - - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field linkaddr nest -1 " - "with value 0x00010000000000000000000000000001"); - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field peeraddr nest -1 " - "with value 0x00010000000000000000000000000002"); - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field linkaddr nest -2 " - "with value 0x00000000000000000000000000000000"); - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field peeraddr nest -2 " - "with value 0x00000000000000000000000000000000"); - addString("EVAL_DEBUG_RELAY6_RANGE Pushing PKT6 relay field linkaddr " - "nest -3 with value 0x"); - - addString("EVAL_DEBUG_RELAY6 Pushing PKT6 relay field linkaddr nest 1 " - "with value 0x00010000000000000000000000000001"); - addString("EVAL_DEBUG_IPADDRESS Pushing IPAddress " - "0x00010000000000000000000000000001"); - addString("EVAL_DEBUG_EQUAL Popping 0x00010000000000000000000000000001 " - "and 0x00010000000000000000000000000001 pushing result 'true'"); + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field linkaddr nest 0 with value " + "0x00000000000000000000000000000000", + *pkt6_); + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field peeraddr nest 0 with value " + "0x00000000000000000000000000000000", + *pkt6_); + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field linkaddr nest 1 with value " + "0x00010000000000000000000000000001", + *pkt6_); + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field peeraddr nest 1 with value " + "0x00010000000000000000000000000002", + *pkt6_); + addString("EVAL_DEBUG_RELAY6_RANGE", "Pushing PKT6 relay field linkaddr nest 2 with value 0x", + *pkt6_); + + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field linkaddr nest -1 with value " + "0x00010000000000000000000000000001", + *pkt6_); + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field peeraddr nest -1 with value " + "0x00010000000000000000000000000002", + *pkt6_); + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field linkaddr nest -2 with value " + "0x00000000000000000000000000000000", + *pkt6_); + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field peeraddr nest -2 with value " + "0x00000000000000000000000000000000", + *pkt6_); + addString("EVAL_DEBUG_RELAY6_RANGE", "Pushing PKT6 relay field linkaddr nest -3 with value 0x", + *pkt6_); + + addString("EVAL_DEBUG_RELAY6", + "Pushing PKT6 relay field linkaddr nest 1 with value " + "0x00010000000000000000000000000001", + *pkt6_); + addString("EVAL_DEBUG_IPADDRESS", "Pushing IPAddress 0x00010000000000000000000000000001", + *pkt6_); + addString("EVAL_DEBUG_EQUAL", + "Popping 0x00010000000000000000000000000001 and 0x00010000000000000000000000000001 " + "pushing result 'true'", + *pkt6_); EXPECT_TRUE(checkFile()); } @@ -2049,8 +2077,7 @@ TEST_F(TokenTest, optionEqualFalse) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_EQUAL Popping 0x626172 and 0x666F6F " - "pushing result 'false'"); + addString("EVAL_DEBUG_EQUAL", "Popping 0x626172 and 0x666F6F pushing result 'false'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2072,8 +2099,7 @@ TEST_F(TokenTest, optionEqualTrue) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_EQUAL Popping 0x666F6F and 0x666F6F " - "pushing result 'true'"); + addString("EVAL_DEBUG_EQUAL", "Popping 0x666F6F and 0x666F6F pushing result 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2106,8 +2132,8 @@ TEST_F(TokenTest, substringNotEnoughValues) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING_EMPTY Popping length 0, start 0, " - "string 0x pushing result 0x"); + addString("EVAL_DEBUG_SUBSTRING_EMPTY", + "Popping length 0, start 0, string 0x pushing result 0x", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2128,14 +2154,18 @@ TEST_F(TokenTest, substringWholeString) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING Popping length 6, start 0, " - "string 0x666F6F626172 pushing result 0x666F6F626172"); - addString("EVAL_DEBUG_SUBSTRING Popping length all, start 0, " - "string 0x666F6F626172 pushing result 0x666F6F626172"); - addString("EVAL_DEBUG_SUBSTRING Popping length 123456, start 0, " - "string 0x666F6F626172 pushing result 0x666F6F626172"); - addString("EVAL_DEBUG_SUBSTRING Popping length all, start -6, " - "string 0x666F6F626172 pushing result 0x666F6F626172"); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 6, start 0, string 0x666F6F626172 pushing result 0x666F6F626172", + *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length all, start 0, string 0x666F6F626172 pushing result 0x666F6F626172", + *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 123456, start 0, string 0x666F6F626172 pushing result 0x666F6F626172", + *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length all, start -6, string 0x666F6F626172 pushing result 0x666F6F626172", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2149,14 +2179,16 @@ TEST_F(TokenTest, substringTrailer) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING Popping length 3, start 3, " - "string 0x666F6F626172 pushing result 0x626172"); - addString("EVAL_DEBUG_SUBSTRING Popping length all, start 3, " - "string 0x666F6F626172 pushing result 0x626172"); - addString("EVAL_DEBUG_SUBSTRING Popping length all, start -3, " - "string 0x666F6F626172 pushing result 0x626172"); - addString("EVAL_DEBUG_SUBSTRING Popping length 123, start -3, " - "string 0x666F6F626172 pushing result 0x626172"); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 3, start 3, string 0x666F6F626172 pushing result 0x626172", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length all, start 3, string 0x666F6F626172 pushing result 0x626172", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length all, start -3, string 0x666F6F626172 pushing result 0x626172", + *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 123, start -3, string 0x666F6F626172 pushing result 0x626172", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2170,14 +2202,17 @@ TEST_F(TokenTest, substringMiddle) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING Popping length 4, start 1, " - "string 0x666F6F626172 pushing result 0x6F6F6261"); - addString("EVAL_DEBUG_SUBSTRING Popping length 4, start -5, " - "string 0x666F6F626172 pushing result 0x6F6F6261"); - addString("EVAL_DEBUG_SUBSTRING Popping length -4, start -1, " - "string 0x666F6F626172 pushing result 0x6F6F6261"); - addString("EVAL_DEBUG_SUBSTRING Popping length -4, start 5, " - "string 0x666F6F626172 pushing result 0x6F6F6261"); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 4, start 1, string 0x666F6F626172 pushing result 0x6F6F6261", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 4, start -5, string 0x666F6F626172 pushing result 0x6F6F6261", + *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length -4, start -1, string 0x666F6F626172 pushing result 0x6F6F6261", + *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length -4, start 5, string 0x666F6F626172 pushing result 0x6F6F6261", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2193,18 +2228,18 @@ TEST_F(TokenTest, substringLastLetter) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING Popping length all, start 5, " - "string 0x666F6F626172 pushing result 0x72"); - addString("EVAL_DEBUG_SUBSTRING Popping length 1, start 5, " - "string 0x666F6F626172 pushing result 0x72"); - addString("EVAL_DEBUG_SUBSTRING Popping length 5, start 5, " - "string 0x666F6F626172 pushing result 0x72"); - addString("EVAL_DEBUG_SUBSTRING Popping length all, start -1, " - "string 0x666F6F626172 pushing result 0x72"); - addString("EVAL_DEBUG_SUBSTRING Popping length 1, start -1, " - "string 0x666F6F626172 pushing result 0x72"); - addString("EVAL_DEBUG_SUBSTRING Popping length 5, start -1, " - "string 0x666F6F626172 pushing result 0x72"); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length all, start 5, string 0x666F6F626172 pushing result 0x72", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 1, start 5, string 0x666F6F626172 pushing result 0x72", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 5, start 5, string 0x666F6F626172 pushing result 0x72", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length all, start -1, string 0x666F6F626172 pushing result 0x72", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 1, start -1, string 0x666F6F626172 pushing result 0x72", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 5, start -1, string 0x666F6F626172 pushing result 0x72", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2225,22 +2260,22 @@ TEST_F(TokenTest, substringLength) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING Popping length -4, start 0, " - "string 0x666F6F626172 pushing result 0x"); - addString("EVAL_DEBUG_SUBSTRING Popping length -4, start 1, " - "string 0x666F6F626172 pushing result 0x66"); - addString("EVAL_DEBUG_SUBSTRING Popping length -4, start 2, " - "string 0x666F6F626172 pushing result 0x666F"); - addString("EVAL_DEBUG_SUBSTRING Popping length -4, start 3, " - "string 0x666F6F626172 pushing result 0x666F6F"); - addString("EVAL_DEBUG_SUBSTRING Popping length 4, start 3, " - "string 0x666F6F626172 pushing result 0x626172"); - addString("EVAL_DEBUG_SUBSTRING Popping length 4, start 4, " - "string 0x666F6F626172 pushing result 0x6172"); - addString("EVAL_DEBUG_SUBSTRING Popping length 4, start 5, " - "string 0x666F6F626172 pushing result 0x72"); - addString("EVAL_DEBUG_SUBSTRING_RANGE Popping length 4, start 6, " - "string 0x666F6F626172 pushing result 0x"); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length -4, start 0, string 0x666F6F626172 pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length -4, start 1, string 0x666F6F626172 pushing result 0x66", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length -4, start 2, string 0x666F6F626172 pushing result 0x666F", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length -4, start 3, string 0x666F6F626172 pushing result 0x666F6F", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 4, start 3, string 0x666F6F626172 pushing result 0x626172", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 4, start 4, string 0x666F6F626172 pushing result 0x6172", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 4, start 5, string 0x666F6F626172 pushing result 0x72", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING_RANGE", + "Popping length 4, start 6, string 0x666F6F626172 pushing result 0x", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2259,18 +2294,18 @@ TEST_F(TokenTest, substringStartingPosition) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING_RANGE Popping length 1, start -7, " - "string 0x666F6F626172 pushing result 0x"); - addString("EVAL_DEBUG_SUBSTRING_RANGE Popping length -11, start -7, " - "string 0x666F6F626172 pushing result 0x"); - addString("EVAL_DEBUG_SUBSTRING_RANGE Popping length all, start -7, " - "string 0x666F6F626172 pushing result 0x"); - addString("EVAL_DEBUG_SUBSTRING_RANGE Popping length 1, start 6, " - "string 0x666F6F626172 pushing result 0x"); - addString("EVAL_DEBUG_SUBSTRING_RANGE Popping length -11, start 6, " - "string 0x666F6F626172 pushing result 0x"); - addString("EVAL_DEBUG_SUBSTRING_RANGE Popping length all, start 6, " - "string 0x666F6F626172 pushing result 0x"); + addString("EVAL_DEBUG_SUBSTRING_RANGE", + "Popping length 1, start -7, string 0x666F6F626172 pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING_RANGE", + "Popping length -11, start -7, string 0x666F6F626172 pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING_RANGE", + "Popping length all, start -7, string 0x666F6F626172 pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING_RANGE", + "Popping length 1, start 6, string 0x666F6F626172 pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING_RANGE", + "Popping length -11, start 6, string 0x666F6F626172 pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING_RANGE", + "Popping length all, start 6, string 0x666F6F626172 pushing result 0x", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2298,10 +2333,10 @@ TEST_F(TokenTest, substringReturnEmpty) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING_EMPTY Popping length all, start 0, " - "string 0x pushing result 0x"); - addString("EVAL_DEBUG_SUBSTRING Popping length 0, start 0, " - "string 0x666F6F626172 pushing result 0x"); + addString("EVAL_DEBUG_SUBSTRING_EMPTY", + "Popping length all, start 0, string 0x pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 0, start 0, string 0x666F6F626172 pushing result 0x", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2361,14 +2396,14 @@ TEST_F(TokenTest, substringEquals) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUBSTRING Popping length 4, start 1, " - "string 0x666F6F626172 pushing result 0x6F6F6261"); - addString("EVAL_DEBUG_EQUAL Popping 0x6F6F6261 and 0x6F6F6261 " - "pushing result 'true'"); - addString("EVAL_DEBUG_SUBSTRING Popping length 4, start 1, " - "string 0x666F6F626172 pushing result 0x6F6F6261"); - addString("EVAL_DEBUG_EQUAL Popping 0x6F6F6261 and 0x666F6F62 " - "pushing result 'false'"); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 4, start 1, string 0x666F6F626172 pushing result 0x6F6F6261", *pkt4_); + addString("EVAL_DEBUG_EQUAL", "Popping 0x6F6F6261 and 0x6F6F6261 pushing result 'true'", + *pkt4_); + addString("EVAL_DEBUG_SUBSTRING", + "Popping length 4, start 1, string 0x666F6F626172 pushing result 0x6F6F6261", *pkt4_); + addString("EVAL_DEBUG_EQUAL", "Popping 0x6F6F6261 and 0x666F6F62 pushing result 'false'", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2396,8 +2431,7 @@ TEST_F(TokenTest, concat) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_CONCAT Popping 0x626172 and 0x666F6F " - "pushing 0x666F6F626172"); + addString("EVAL_DEBUG_CONCAT", "Popping 0x626172 and 0x666F6F pushing 0x666F6F626172", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2425,8 +2459,8 @@ TEST_F(TokenTest, tohexstring) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_TOHEXSTRING Popping binary value 0x666F6F and " - "separator -, pushing result 66-6f-6f"); + addString("EVAL_DEBUG_TOHEXSTRING", + "Popping binary value 0x666F6F and separator -, pushing result 66-6f-6f", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2504,8 +2538,8 @@ TEST_F(TokenTest, operatorNot) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_NOT Popping 'true' pushing 'false'"); - addString("EVAL_DEBUG_NOT Popping 'false' pushing 'true'"); + addString("EVAL_DEBUG_NOT", "Popping 'true' pushing 'false'", *pkt4_); + addString("EVAL_DEBUG_NOT", "Popping 'false' pushing 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2562,9 +2596,9 @@ TEST_F(TokenTest, operatorAndFalse) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_AND Popping 'false' and 'true' pushing 'false'"); - addString("EVAL_DEBUG_AND Popping 'true' and 'false' pushing 'false'"); - addString("EVAL_DEBUG_AND Popping 'false' and 'false' pushing 'false'"); + addString("EVAL_DEBUG_AND", "Popping 'false' and 'true' pushing 'false'", *pkt4_); + addString("EVAL_DEBUG_AND", "Popping 'true' and 'false' pushing 'false'", *pkt4_); + addString("EVAL_DEBUG_AND", "Popping 'false' and 'false' pushing 'false'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2585,7 +2619,7 @@ TEST_F(TokenTest, operatorAndTrue) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_AND Popping 'true' and 'true' pushing 'true'"); + addString("EVAL_DEBUG_AND", "Popping 'true' and 'true' pushing 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2630,7 +2664,7 @@ TEST_F(TokenTest, operatorOrFalse) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OR Popping 'false' and 'false' pushing 'false'"); + addString("EVAL_DEBUG_OR", "Popping 'false' and 'false' pushing 'false'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2663,9 +2697,9 @@ TEST_F(TokenTest, operatorOrTrue) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_OR Popping 'true' and 'false' pushing 'true'"); - addString("EVAL_DEBUG_OR Popping 'false' and 'true' pushing 'true'"); - addString("EVAL_DEBUG_OR Popping 'true' and 'true' pushing 'true'"); + addString("EVAL_DEBUG_OR", "Popping 'true' and 'false' pushing 'true'", *pkt4_); + addString("EVAL_DEBUG_OR", "Popping 'false' and 'true' pushing 'true'", *pkt4_); + addString("EVAL_DEBUG_OR", "Popping 'true' and 'true' pushing 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2711,12 +2745,12 @@ TEST_F(TokenTest, vendor4SpecificVendorExists) { testVendorExists(Option::V4, 4491, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 125 missing, " - "pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 125 missing, pushing result 'false'", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2732,12 +2766,12 @@ TEST_F(TokenTest, vendor6SpecificVendorExists) { testVendorExists(Option::V6, 4491, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 17 missing, " - "pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 17 missing, pushing result 'false'", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -2753,12 +2787,12 @@ TEST_F(TokenTest, vendor4AnyVendorExists) { testVendorExists(Option::V4, 0, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 125 missing, " - "pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_EXISTS Option with enterprise-id 1234 " - "found, pushing result 'true'"); - addString("EVAL_DEBUG_VENDOR_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 125 missing, pushing result 'false'", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_EXISTS", + "Option with enterprise-id 1234 found, pushing result 'true'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2774,12 +2808,12 @@ TEST_F(TokenTest, vendor6AnyVendorExists) { testVendorExists(Option::V6, 0, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 17 missing, " - "pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_EXISTS Option with enterprise-id 1234 " - "found, pushing result 'true'"); - addString("EVAL_DEBUG_VENDOR_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 17 missing, pushing result 'false'", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_EXISTS", + "Option with enterprise-id 1234 found, pushing result 'true'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -2796,12 +2830,12 @@ TEST_F(TokenTest, vendor4enterprise) { testVendorEnterprise(Option::V4, 4294967295, encode(4294967295)); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 125 missing, pushing" - " result ''"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID Pushing enterprise-id 1234 as " - "result 0x000004D2"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID Pushing enterprise-id 4294967295" - " as result 0xFFFFFFFF"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 125 missing, pushing result ''", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID", "Pushing enterprise-id 1234 as result 0x000004D2", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID", + "Pushing enterprise-id 4294967295 as result 0xFFFFFFFF", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2818,12 +2852,12 @@ TEST_F(TokenTest, vendor6enterprise) { testVendorEnterprise(Option::V6, 4294967295, encode(4294967295)); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 17 missing, pushing" - " result ''"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID Pushing enterprise-id 1234 as " - "result 0x000004D2"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID Pushing enterprise-id 4294967295 " - "as result 0xFFFFFFFF"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 17 missing, pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID", "Pushing enterprise-id 1234 as result 0x000004D2", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID", + "Pushing enterprise-id 4294967295 as result 0xFFFFFFFF", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -2852,14 +2886,14 @@ TEST_F(TokenTest, vendor4SuboptionExists) { testVendorSuboption(Option::V4, 4491, 1, 4491, 1, TokenOption::EXISTS, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 125 missing, pushing " - "result 'false'"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 'false'"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 'true'"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 125 missing, pushing result 'false'", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 'false'", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2886,14 +2920,14 @@ TEST_F(TokenTest, vendor6SuboptionExists) { testVendorSuboption(Option::V6, 4491, 1, 4491, 1, TokenOption::EXISTS, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 17 missing, pushing " - "result 'false'"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 'false'"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 'true'"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 17 missing, pushing result 'false'", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 'false'", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 'true'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -2918,14 +2952,14 @@ TEST_F(TokenTest, vendor4SuboptionHex) { testVendorSuboption(Option::V4, 4491, 1, 4491, 1, TokenOption::HEXADECIMAL, "alpha"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 125 missing, pushing " - "result ''"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result ''"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 0x"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 0x616C706861"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 125 missing, pushing result ''", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 0x", *pkt4_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 0x616C706861", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2950,14 +2984,14 @@ TEST_F(TokenTest, vendor6SuboptionHex) { testVendorSuboption(Option::V6, 4491, 1, 4491, 1, TokenOption::HEXADECIMAL, "alpha"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_NO_OPTION Option with code 17 missing, pushing " - "result ''"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH Was looking for 4491, " - "option had 1234, pushing result ''"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 0x"); - addString("EVAL_DEBUG_OPTION Pushing option 1 with value 0x616C706861"); + addString("EVAL_DEBUG_VENDOR_NO_OPTION", "Option with code 17 missing, pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt6_); + addString("EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 0x", *pkt6_); + addString("EVAL_DEBUG_OPTION", "Pushing option 1 with value 0x616C706861", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -2974,12 +3008,12 @@ TEST_F(TokenTest, vendorClass4SpecificVendorExists) { testVendorClassExists(Option::V4, 4491, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 124 missing, " - "pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 124 missing, pushing result 'false'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -2996,12 +3030,12 @@ TEST_F(TokenTest, vendorClass6SpecificVendorExists) { testVendorClassExists(Option::V6, 4491, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 16 missing, pushing " - "result 'false'"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 16 missing, pushing result 'false'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result 'false'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -3018,12 +3052,12 @@ TEST_F(TokenTest, vendorClass4AnyVendorExists) { testVendorClassExists(Option::V4, 0, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 124 missing, " - "pushing result 'false'"); - addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS Option with enterprise-id 1234 " - "found, pushing result 'true'"); - addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 124 missing, pushing result 'false'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS", + "Option with enterprise-id 1234 found, pushing result 'true'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3040,12 +3074,12 @@ TEST_F(TokenTest, vendorClass6AnyVendorExists) { testVendorClassExists(Option::V6, 0, 4491, "true"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 16 missing, pushing " - "result 'false'"); - addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS Option with enterprise-id 1234 " - "found, pushing result 'true'"); - addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS Option with enterprise-id 4491 " - "found, pushing result 'true'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 16 missing, pushing result 'false'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS", + "Option with enterprise-id 1234 found, pushing result 'true'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_EXISTS", + "Option with enterprise-id 4491 found, pushing result 'true'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -3062,12 +3096,12 @@ TEST_F(TokenTest, vendorClass4enterprise) { testVendorClassEnterprise(Option::V4, 4294967295, encode(4294967295)); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 124 missing, pushing " - "result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID Pushing enterprise-id " - "1234 as result 0x000004D2"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID Pushing enterprise-id " - "4294967295 as result 0xFFFFFFFF"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 124 missing, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID", + "Pushing enterprise-id 1234 as result 0x000004D2", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID", + "Pushing enterprise-id 4294967295 as result 0xFFFFFFFF", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3084,12 +3118,12 @@ TEST_F(TokenTest, vendorClass6enterprise) { testVendorClassEnterprise(Option::V6, 4294967295, encode(4294967295)); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 16 missing, pushing " - "result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID Pushing enterprise-id " - "1234 as result 0x000004D2"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID Pushing enterprise-id " - "4294967295 as result 0xFFFFFFFF"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", "Option with code 16 missing, pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID", + "Pushing enterprise-id 1234 as result 0x000004D2", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID", + "Pushing enterprise-id 4294967295 as result 0xFFFFFFFF", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -3122,16 +3156,16 @@ TEST_F(TokenTest, vendorClass4SpecificVendorData) { testVendorClassData(Option::V4, 4491, 0, 4491, 1, "alpha"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 124 missing, " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in vendor " - "class found, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in vendor " - "class found, pushing result 'alpha'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 124 missing, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result 'alpha'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3160,17 +3194,18 @@ TEST_F(TokenTest, vendorClass6SpecificVendorData) { testVendorClassData(Option::V6, 4491, 0, 4491, 1, "alpha"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 16 missing, " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index 0, " - "but option with enterprise-id 4491 has only 0 data tuple(s), " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in vendor " - "class found, pushing result 'alpha'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", "Option with code 16 missing, pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", + "Requested data index 0, but option with enterprise-id 4491 has only 0 data " + "tuple(s), pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result 'alpha'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -3202,16 +3237,16 @@ TEST_F(TokenTest, vendorClass4AnyVendorData) { testVendorClassData(Option::V4, 0, 0, 4491, 1, "alpha"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 124 missing, " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in " - "vendor class found, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in " - "vendor class found, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in " - "vendor class found, pushing result 'alpha'"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in " - "vendor class found, pushing result 'alpha'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 124 missing, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result 'alpha'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result 'alpha'", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3241,18 +3276,20 @@ TEST_F(TokenTest, vendorClass6AnyVendorData) { testVendorClassData(Option::V6, 0, 0, 4491, 1, "alpha"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 16 missing, " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index 0, " - "but option with enterprise-id 1234 has only 0 data tuple(s), " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index 0, " - "but option with enterprise-id 4491 has only 0 data tuple(s), " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in vendor " - "class found, pushing result 'alpha'"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 0 (out of 1 received) in vendor " - "class found, pushing result 'alpha'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", "Option with code 16 missing, pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", + "Requested data index 0, but option with enterprise-id 1234 has only 0 data " + "tuple(s), pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", + "Requested data index 0, but option with enterprise-id 4491 has only 0 data " + "tuple(s), pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result 'alpha'", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 0 (out of 1 received) in vendor class found, pushing result 'alpha'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -3291,22 +3328,24 @@ TEST_F(TokenTest, vendorClass4DataIndex) { testVendorClassData(Option::V4, 4491, 3, 1234, 5, ""); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 124 missing, " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index 3, " - "but option with enterprise-id 4491 has only 1 data tuple(s), " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index 3, " - "but option with enterprise-id 4491 has only 3 data tuple(s), " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 3 (out of 5 received) in vendor " - "class found, pushing result 'gamma'"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", + "Option with code 124 missing, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", + "Requested data index 3, but option with enterprise-id 4491 has only 1 data " + "tuple(s), pushing result ''", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", + "Requested data index 3, but option with enterprise-id 4491 has only 3 data " + "tuple(s), pushing result ''", + *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 3 (out of 5 received) in vendor class found, pushing result 'gamma'", *pkt4_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3340,20 +3379,22 @@ TEST_F(TokenTest, vendorClass6DataIndex) { testVendorClassData(Option::V6, 4491, 3, 4491, 5, "gamma"); // Check if the logged messages are correct. - addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION Option with code 16 missing, " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index 3, " - "but option with enterprise-id 4491 has only 0 data tuple(s), " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH Was looking for " - "4491, option had 1234, pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND Requested data index 3, " - "but option with enterprise-id 4491 has only 3 data tuple(s), " - "pushing result ''"); - addString("EVAL_DEBUG_VENDOR_CLASS_DATA Data 3 (out of 5 received) in vendor" - " class found, pushing result 'gamma'"); + addString("EVAL_DEBUG_VENDOR_CLASS_NO_OPTION", "Option with code 16 missing, pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", + "Requested data index 3, but option with enterprise-id 4491 has only 0 data " + "tuple(s), pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH", + "Was looking for 4491, option had 1234, pushing result ''", *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", + "Requested data index 3, but option with enterprise-id 4491 has only 3 data " + "tuple(s), pushing result ''", + *pkt6_); + addString("EVAL_DEBUG_VENDOR_CLASS_DATA", + "Data 3 (out of 5 received) in vendor class found, pushing result 'gamma'", *pkt6_); EXPECT_TRUE(checkFile()); } @@ -3364,8 +3405,7 @@ TEST_F(TokenTest, subOption) { insertRelay4Option(); // Creating the token should be safe. - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 13, TokenOption::TEXTUAL))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 13, TokenOption::TEXTUAL))); // We should be able to evaluate it. EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); @@ -3380,8 +3420,8 @@ TEST_F(TokenTest, subOption) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUB_OPTION Pushing option 82 " - "sub-option 13 with value 'thirteen'"); + addString("EVAL_DEBUG_SUB_OPTION", "Pushing option 82 sub-option 13 with value 'thirteen'", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3394,8 +3434,7 @@ TEST_F(TokenTest, subOptionNoSubOption) { // Creating the token should be safe. - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 15, TokenOption::TEXTUAL))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 15, TokenOption::TEXTUAL))); // We should be able to evaluate it. EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); @@ -3410,8 +3449,7 @@ TEST_F(TokenTest, subOptionNoSubOption) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUB_OPTION Pushing option 82 " - "sub-option 15 with value ''"); + addString("EVAL_DEBUG_SUB_OPTION", "Pushing option 82 sub-option 15 with value ''", *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3422,8 +3460,7 @@ TEST_F(TokenTest, subOptionNoOption) { // We didn't call insertRelay4Option(), so there's no RAI option. // Creating the token should be safe. - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 13, TokenOption::TEXTUAL))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 13, TokenOption::TEXTUAL))); // We should be able to evaluate it. EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); @@ -3438,9 +3475,10 @@ TEST_F(TokenTest, subOptionNoOption) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUB_OPTION_NO_OPTION Requested option 82 " - "sub-option 13, but the parent option is not present, " - "pushing result ''"); + addString("EVAL_DEBUG_SUB_OPTION_NO_OPTION", + "Requested option 82 sub-option 13, but the parent option is not present, pushing " + "result ''", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3465,16 +3503,14 @@ TEST_F(TokenTest, subOptionOptionOnly) { // - option 13 (containing "thirteen") // Let's try to get option 13. It should get the one from RAI - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 13, TokenOption::TEXTUAL))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 13, TokenOption::TEXTUAL))); EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); ASSERT_EQ(1, values_.size()); EXPECT_EQ("thirteen", values_.top()); // Try to get option 1. It should get the one from RAI clearStack(); - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 1, TokenOption::TEXTUAL))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 1, TokenOption::TEXTUAL))); EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); ASSERT_EQ(1, values_.size()); EXPECT_EQ("one", values_.top()); @@ -3482,24 +3518,21 @@ TEST_F(TokenTest, subOptionOptionOnly) { // Try to get option 70. It should fail, as there's no such // sub option in RAI. clearStack(); - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 70, TokenOption::TEXTUAL))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 70, TokenOption::TEXTUAL))); EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); ASSERT_EQ(1, values_.size()); EXPECT_EQ("", values_.top()); // Try to check option 1. It should return "true" clearStack(); - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 1, TokenOption::EXISTS))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 1, TokenOption::EXISTS))); EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); ASSERT_EQ(1, values_.size()); EXPECT_EQ("true", values_.top()); // Try to check option 70. It should return "false" clearStack(); - ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, - 70, TokenOption::EXISTS))); + ASSERT_NO_THROW(t_.reset(new TokenSubOption(DHO_DHCP_AGENT_OPTIONS, 70, TokenOption::EXISTS))); EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); ASSERT_EQ(1, values_.size()); EXPECT_EQ("false", values_.top()); @@ -3507,16 +3540,13 @@ TEST_F(TokenTest, subOptionOptionOnly) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SUB_OPTION Pushing option 82 " - "sub-option 13 with value 'thirteen'"); - addString("EVAL_DEBUG_SUB_OPTION Pushing option 82 " - "sub-option 1 with value 'one'"); - addString("EVAL_DEBUG_SUB_OPTION Pushing option 82 " - "sub-option 70 with value ''"); - addString("EVAL_DEBUG_SUB_OPTION Pushing option 82 " - "sub-option 1 with value 'true'"); - addString("EVAL_DEBUG_SUB_OPTION Pushing option 82 " - "sub-option 70 with value 'false'"); + addString("EVAL_DEBUG_SUB_OPTION", "Pushing option 82 sub-option 13 with value 'thirteen'", + *pkt4_); + addString("EVAL_DEBUG_SUB_OPTION", "Pushing option 82 sub-option 1 with value 'one'", *pkt4_); + addString("EVAL_DEBUG_SUB_OPTION", "Pushing option 82 sub-option 70 with value ''", *pkt4_); + addString("EVAL_DEBUG_SUB_OPTION", "Pushing option 82 sub-option 1 with value 'true'", *pkt4_); + addString("EVAL_DEBUG_SUB_OPTION", "Pushing option 82 sub-option 70 with value 'false'", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3562,28 +3592,35 @@ TEST_F(TokenTest, split) { // Check that the debug output was correct. Add the strings // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SPLIT_EMPTY Popping field 1, delimiters .," - " string , pushing result 0x"); - addString("EVAL_DEBUG_SPLIT_DELIM_EMPTY Popping field 1, delimiters ," - " string .two.three..five., pushing result 0x2E74776F2E74687265652E2E666976652E"); - addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE Popping field 0, delimiters .," - " string .two.three..five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 1, delimiters .," - " string .two.three..five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 2, delimiters .," - " string .two.three..five., pushing result 0x74776F"); - addString("EVAL_DEBUG_SPLIT Popping field 3, delimiters .," - " string .two.three..five., pushing result 0x7468726565"); - addString("EVAL_DEBUG_SPLIT Popping field 4, delimiters .," - " string .two.three..five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 5, delimiters .," - " string .two.three..five., pushing result 0x66697665"); - addString("EVAL_DEBUG_SPLIT Popping field 6, delimiters .," - " string .two.three..five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE Popping field 7, delimiters .," - " string .two.three..five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 1, delimiters .," - " string just_one, pushing result 0x6A7573745F6F6E65"); + addString("EVAL_DEBUG_SPLIT_EMPTY", "Popping field 1, delimiters ., string , pushing result 0x", + *pkt4_); + addString("EVAL_DEBUG_SPLIT_DELIM_EMPTY", + "Popping field 1, delimiters , string .two.three..five., pushing result " + "0x2E74776F2E74687265652E2E666976652E", + *pkt4_); + addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE", + "Popping field 0, delimiters ., string .two.three..five., pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 1, delimiters ., string .two.three..five., pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 2, delimiters ., string .two.three..five., pushing result 0x74776F", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 3, delimiters ., string .two.three..five., pushing result " + "0x7468726565", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 4, delimiters ., string .two.three..five., pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 5, delimiters ., string .two.three..five., pushing result 0x66697665", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 6, delimiters ., string .two.three..five., pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE", + "Popping field 7, delimiters ., string .two.three..five., pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 1, delimiters ., string just_one, pushing result 0x6A7573745F6F6E65", + *pkt4_); EXPECT_TRUE(checkFile()); } @@ -3617,26 +3654,36 @@ TEST_F(TokenTest, splitMultipleDelims) { // to the test vector in the class and then call checkFile // for comparison - addString("EVAL_DEBUG_SPLIT_EMPTY Popping field 1, delimiters .:," - " string , pushing result 0x"); - addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE Popping field 0, delimiters .:," - " string .two:three.:five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 1, delimiters .:," - " string .two:three.:five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 2, delimiters .:," - " string .two:three.:five., pushing result 0x74776F"); - addString("EVAL_DEBUG_SPLIT Popping field 3, delimiters .:," - " string .two:three.:five., pushing result 0x7468726565"); - addString("EVAL_DEBUG_SPLIT Popping field 4, delimiters .:," - " string .two:three.:five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 5, delimiters .:," - " string .two:three.:five., pushing result 0x66697665"); - addString("EVAL_DEBUG_SPLIT Popping field 6, delimiters .:," - " string .two:three.:five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE Popping field 7, delimiters .:," - " string .two:three.:five., pushing result 0x"); - addString("EVAL_DEBUG_SPLIT Popping field 1, delimiters .:," - " string just_one, pushing result 0x6A7573745F6F6E65"); + addString("EVAL_DEBUG_SPLIT_EMPTY", + "Popping field 1, delimiters .:, string , pushing result 0x", *pkt4_); + addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE", + "Popping field 0, delimiters .:, string .two:three.:five., pushing result 0x", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 1, delimiters .:, string .two:three.:five., pushing result 0x", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 2, delimiters .:, string .two:three.:five., pushing result 0x74776F", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 3, delimiters .:, string .two:three.:five., pushing result " + "0x7468726565", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 4, delimiters .:, string .two:three.:five., pushing result 0x", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 5, delimiters .:, string .two:three.:five., pushing result 0x66697665", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 6, delimiters .:, string .two:three.:five., pushing result 0x", + *pkt4_); + addString("EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE", + "Popping field 7, delimiters .:, string .two:three.:five., pushing result 0x", + *pkt4_); + addString("EVAL_DEBUG_SPLIT", + "Popping field 1, delimiters .:, string just_one, pushing result 0x6A7573745F6F6E65", + *pkt4_); EXPECT_TRUE(checkFile()); } diff --git a/src/lib/eval/token.cc b/src/lib/eval/token.cc index ed0984415c..b453119487 100644 --- a/src/lib/eval/token.cc +++ b/src/lib/eval/token.cc @@ -37,12 +37,13 @@ using namespace std; using isc::util::encode::toHex; void -TokenString::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenString::evaluate(Pkt& pkt, ValueStack& values) { // Literals only push, nothing to pop values.push(value_); // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_STRING) + .arg(pkt.getLabel()) .arg('\'' + value_ + '\''); } @@ -75,17 +76,18 @@ TokenHexString::TokenHexString(const string& str) : value_("") { } void -TokenHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenHexString::evaluate(Pkt& pkt, ValueStack& values) { // Literals only push, nothing to pop values.push(value_); // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_HEXSTRING) + .arg(pkt.getLabel()) .arg(toHex(value_)); } void -TokenLowerCase::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenLowerCase::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -98,12 +100,13 @@ TokenLowerCase::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_LCASE) + .arg(pkt.getLabel()) .arg('\'' + op + '\'') .arg('\'' + result + '\''); } void -TokenUpperCase::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenUpperCase::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -116,6 +119,7 @@ TokenUpperCase::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_UCASE) + .arg(pkt.getLabel()) .arg('\'' + op + '\'') .arg('\'' + result + '\''); } @@ -136,17 +140,18 @@ TokenIpAddress::TokenIpAddress(const string& addr) : value_("") { } void -TokenIpAddress::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenIpAddress::evaluate(Pkt& pkt, ValueStack& values) { // Literals only push, nothing to pop values.push(value_); // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_IPADDRESS) + .arg(pkt.getLabel()) .arg(toHex(value_)); } void -TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenIpAddressToText::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -176,11 +181,12 @@ TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_IPADDRESSTOTEXT) + .arg(pkt.getLabel()) .arg(op); } void -TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenInt8ToText::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -205,11 +211,12 @@ TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_INT8TOTEXT) + .arg(pkt.getLabel()) .arg(op); } void -TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenInt16ToText::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -235,11 +242,12 @@ TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_INT16TOTEXT) + .arg(pkt.getLabel()) .arg(op); } void -TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenInt32ToText::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -265,11 +273,12 @@ TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_INT32TOTEXT) + .arg(pkt.getLabel()) .arg(op); } void -TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenUInt8ToText::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -294,11 +303,12 @@ TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_UINT8TOTEXT) + .arg(pkt.getLabel()) .arg(op); } void -TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenUInt16ToText::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -324,11 +334,12 @@ TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_UINT16TOTEXT) + .arg(pkt.getLabel()) .arg(op); } void -TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenUInt32ToText::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -354,6 +365,7 @@ TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_UINT32TOTEXT) + .arg(pkt.getLabel()) .arg(op); } @@ -391,10 +403,12 @@ TokenOption::evaluate(Pkt& pkt, ValueStack& values) { // of the requested option. if (representation_type_ == HEXADECIMAL) { LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_OPTION) + .arg(pkt.getLabel()) .arg(option_code_) .arg(toHex(opt_str)); } else { LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_OPTION) + .arg(pkt.getLabel()) .arg(option_code_) .arg('\'' + opt_str + '\''); } @@ -507,6 +521,7 @@ TokenPkt::evaluate(Pkt& pkt, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_PKT) + .arg(pkt.getLabel()) .arg(type_str) .arg(print_hex ? toHex(value) : value); } @@ -585,6 +600,7 @@ TokenPkt4::evaluate(Pkt& pkt, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_PKT4) + .arg(pkt.getLabel()) .arg(type_str) .arg(toHex(value)); } @@ -624,6 +640,7 @@ TokenPkt6::evaluate(Pkt& pkt, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_PKT6) + .arg(pkt.getLabel()) .arg(type_str) .arg(toHex(value)); } @@ -667,9 +684,10 @@ TokenRelay6Field::evaluate(Pkt& pkt, ValueStack& values) { values.push(""); // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_RELAY6_RANGE) - .arg(type_str) - .arg(int(nest_level_)) - .arg("0x"); + .arg(pkt.getLabel()) + .arg(type_str) + .arg(int(nest_level_)) + .arg("0x"); return; } } catch (const std::bad_cast&) { @@ -685,13 +703,14 @@ TokenRelay6Field::evaluate(Pkt& pkt, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_RELAY6) + .arg(pkt.getLabel()) .arg(type_str) .arg(int(nest_level_)) .arg(toHex(value)); } void -TokenEqual::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenEqual::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 2) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "2 values for == operator, got " << values.size()); @@ -709,13 +728,14 @@ TokenEqual::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_EQUAL) + .arg(pkt.getLabel()) .arg(toHex(op1)) .arg(toHex(op2)) .arg('\'' + values.top() + '\''); } void -TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenSubstring::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 3) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "3 values for substring operator, got " << values.size()); @@ -734,6 +754,7 @@ TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_SUBSTRING_EMPTY) + .arg(pkt.getLabel()) .arg(len_str) .arg(start_str) .arg("0x") @@ -774,6 +795,7 @@ TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_SUBSTRING_RANGE) + .arg(pkt.getLabel()) .arg(len_str) .arg(start_str) .arg(toHex(string_str)) @@ -803,6 +825,7 @@ TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_SUBSTRING) + .arg(pkt.getLabel()) .arg(len_str) .arg(start_str) .arg(toHex(string_str)) @@ -810,7 +833,7 @@ TokenSubstring::evaluate(Pkt& /*pkt*/, ValueStack& values) { } void -TokenSplit::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenSplit::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 3) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "3 values for split operator, got " << values.size()); @@ -830,6 +853,7 @@ TokenSplit::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_SPLIT_EMPTY) + .arg(pkt.getLabel()) .arg(field_str) .arg(delim_str) .arg(string_str) @@ -854,6 +878,7 @@ TokenSplit::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_SPLIT_DELIM_EMPTY) + .arg(pkt.getLabel()) .arg(field_str) .arg(delim_str) .arg(string_str) @@ -873,6 +898,7 @@ TokenSplit::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE) + .arg(pkt.getLabel()) .arg(field_str) .arg(delim_str) .arg(string_str) @@ -885,6 +911,7 @@ TokenSplit::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_SPLIT) + .arg(pkt.getLabel()) .arg(field_str) .arg(delim_str) .arg(string_str) @@ -892,7 +919,7 @@ TokenSplit::evaluate(Pkt& /*pkt*/, ValueStack& values) { } void -TokenConcat::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenConcat::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 2) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "2 values for concat, got " << values.size()); @@ -908,13 +935,14 @@ TokenConcat::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_CONCAT) + .arg(pkt.getLabel()) .arg(toHex(op1)) .arg(toHex(op2)) .arg(toHex(values.top())); } void -TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenIfElse::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 3) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "3 values for ifelse, got " << values.size()); @@ -937,11 +965,13 @@ TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed if (val) { LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_IFELSE_TRUE) + .arg(pkt.getLabel()) .arg('\'' + cond + '\'') .arg(toHex(iffalse)) .arg(toHex(iftrue)); } else { LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_IFELSE_FALSE) + .arg(pkt.getLabel()) .arg('\'' +cond + '\'') .arg(toHex(iftrue)) .arg(toHex(iffalse)); @@ -949,7 +979,7 @@ TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) { } void -TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenToHexString::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 2) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "2 values for hexstring, got " << values.size()); @@ -976,13 +1006,14 @@ TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_TOHEXSTRING) + .arg(pkt.getLabel()) .arg(toHex(binary)) .arg(separator) .arg(tmp.str()); } void -TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenNot::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() == 0) { isc_throw(EvalBadStack, "Incorrect empty stack."); } @@ -999,12 +1030,13 @@ TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_NOT) + .arg(pkt.getLabel()) .arg('\'' + op + '\'') .arg('\'' + values.top() + '\''); } void -TokenAnd::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenAnd::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 2) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "2 values for and operator, got " << values.size()); @@ -1025,13 +1057,14 @@ TokenAnd::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_AND) + .arg(pkt.getLabel()) .arg('\'' + op1 + '\'') .arg('\'' + op2 + '\'') .arg('\'' + values.top() + '\''); } void -TokenOr::evaluate(Pkt& /*pkt*/, ValueStack& values) { +TokenOr::evaluate(Pkt& pkt, ValueStack& values) { if (values.size() < 2) { isc_throw(EvalBadStack, "Incorrect stack order. Expected at least " "2 values for or operator, got " << values.size()); @@ -1052,6 +1085,7 @@ TokenOr::evaluate(Pkt& /*pkt*/, ValueStack& values) { // Log what we popped and pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_OR) + .arg(pkt.getLabel()) .arg('\'' + op1 + '\'') .arg('\'' + op2 + '\'') .arg('\'' + values.top() + '\''); @@ -1067,6 +1101,7 @@ TokenMember::evaluate(Pkt& pkt, ValueStack& values) { // Log what we pushed LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_MEMBER) + .arg(pkt.getLabel()) .arg(client_class_) .arg('\'' + values.top() + '\''); } @@ -1111,6 +1146,7 @@ void TokenVendor::evaluate(Pkt& pkt, ValueStack& values) { // There's no vendor option, give up. std::string txt = pushFailure(values); LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_NO_OPTION) + .arg(pkt.getLabel()) .arg(code) .arg(txt); return; @@ -1121,6 +1157,7 @@ void TokenVendor::evaluate(Pkt& pkt, ValueStack& values) { // than we're looking for. (0 means accept any vendor-id) std::string txt = pushFailure(values); LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH) + .arg(pkt.getLabel()) .arg(vendor_id_) .arg(vendor->getVendorId()) .arg(txt); @@ -1136,6 +1173,7 @@ void TokenVendor::evaluate(Pkt& pkt, ValueStack& values) { memcpy(&txt[0], &value, sizeof(uint32_t)); values.push(txt); LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_ENTERPRISE_ID) + .arg(pkt.getLabel()) .arg(vendor->getVendorId()) .arg(util::encode::encodeHex(std::vector<uint8_t>(txt.begin(), txt.end()))); @@ -1150,6 +1188,7 @@ void TokenVendor::evaluate(Pkt& pkt, ValueStack& values) { // We already passed all the checks: the option is there and has specified // enterprise-id. LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_EXISTS) + .arg(pkt.getLabel()) .arg(vendor->getVendorId()) .arg("true"); values.push("true"); @@ -1216,6 +1255,7 @@ void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) { // There's no vendor class option, give up. std::string txt = pushFailure(values); LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_NO_OPTION) + .arg(pkt.getLabel()) .arg(code) .arg(txt); return; @@ -1226,6 +1266,7 @@ void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) { // than we're looking for. (0 means accept any vendor-id) std::string txt = pushFailure(values); LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH) + .arg(pkt.getLabel()) .arg(vendor_id_) .arg(vendor->getVendorId()) .arg(txt); @@ -1241,6 +1282,7 @@ void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) { memcpy(&txt[0], &value, sizeof(uint32_t)); values.push(txt); LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID) + .arg(pkt.getLabel()) .arg(vendor->getVendorId()) .arg(util::encode::encodeHex(std::vector<uint8_t>(txt.begin(), txt.end()))); @@ -1254,6 +1296,7 @@ void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) { // We already passed all the checks: the option is there and has specified // enterprise-id. LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_EXISTS) + .arg(pkt.getLabel()) .arg(vendor->getVendorId()) .arg("true"); values.push("true"); @@ -1265,6 +1308,7 @@ void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) { // The index specified is out of bounds, e.g. there are only // 2 tuples and index specified is 5. LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND) + .arg(pkt.getLabel()) .arg(index_) .arg(vendor->getVendorId()) .arg(max) @@ -1278,6 +1322,7 @@ void TokenVendorClass::evaluate(Pkt& pkt, ValueStack& values) { string txt(buf.begin(), buf.end()); LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_VENDOR_CLASS_DATA) + .arg(pkt.getLabel()) .arg(index_) .arg(max) .arg(txt); @@ -1344,11 +1389,13 @@ TokenSubOption::evaluate(Pkt& pkt, ValueStack& values) { // of the requested parent option and sub-option. if (representation_type_ == HEXADECIMAL) { LOG_DEBUG(eval_logger, EVAL_DBG_STACK, msgid) + .arg(pkt.getLabel()) .arg(option_code_) .arg(sub_option_code_) .arg(toHex(txt)); } else { LOG_DEBUG(eval_logger, EVAL_DBG_STACK, msgid) + .arg(pkt.getLabel()) .arg(option_code_) .arg(sub_option_code_) .arg('\'' + txt + '\''); diff --git a/src/lib/testutils/log_utils.cc b/src/lib/testutils/log_utils.cc index 56b6d333d5..4bbdf580f3 100644 --- a/src/lib/testutils/log_utils.cc +++ b/src/lib/testutils/log_utils.cc @@ -118,6 +118,12 @@ void LogContentTest::addString(const string& new_string) { exp_strings_.push_back(new_string); } +void LogContentTest::addString(const string& logger_msg, const string& new_string, Pkt& pkt) { + std::ostringstream stream; + stream << logger_msg << " " << pkt.getLabel() << ": " << new_string; + exp_strings_.push_back(stream.str()); +} + // Set up the name of the LOG_FILE for use in checking // the debug statements. // Must not be the same file name used by test shell scripts. diff --git a/src/lib/testutils/log_utils.h b/src/lib/testutils/log_utils.h index 7191e0eede..3a3d10e435 100644 --- a/src/lib/testutils/log_utils.h +++ b/src/lib/testutils/log_utils.h @@ -20,6 +20,8 @@ //#include <boost/scoped_ptr.hpp> #include <gtest/gtest.h> +#include "dhcp/pkt.h" + using namespace std; using namespace isc::log; @@ -84,6 +86,13 @@ public: /// @param new_string the string to add to the end of the vector void addString(const string& new_string); + /// @brief Generates and adds a string to the vector of expected strings + /// + /// @param logger_msg logger message that will be prepended to the string + /// @param new_string the string used to generate the outcome + /// @param pkt reference to the packet for which the message is generated + void addString(const string& logger_msg, const string& new_string, Pkt& pkt); + vector<string> exp_strings_; static const char* LOG_FILE; static const char* KEA_LOG_CHECK_VERBOSE; |