You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/01/21 00:08:08 UTC
[29/50] git commit: [TS-2488] uncomment all unit tests and patch code
to make them all pass
[TS-2488] uncomment all unit tests and patch code to make them all pass
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a82c80de
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a82c80de
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a82c80de
Branch: refs/heads/5.0.x
Commit: a82c80dee94157329ac8b4936ee195fbed29d424
Parents: 805c1fe
Author: Yu Qing <zh...@taobao.com>
Authored: Tue Jan 14 16:08:11 2014 +0000
Committer: Kit Chan <ki...@apache.org>
Committed: Tue Jan 14 16:08:11 2014 +0000
----------------------------------------------------------------------
plugins/experimental/esi/lib/EsiParser.cc | 5 ++-
plugins/experimental/esi/test/parser_test.cc | 32 ++++++--------------
plugins/experimental/esi/test/processor_test.cc | 2 --
3 files changed, 14 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a82c80de/plugins/experimental/esi/lib/EsiParser.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/lib/EsiParser.cc b/plugins/experimental/esi/lib/EsiParser.cc
index 7bd9b67..22b6856 100644
--- a/plugins/experimental/esi/lib/EsiParser.cc
+++ b/plugins/experimental/esi/lib/EsiParser.cc
@@ -310,6 +310,7 @@ EsiParser::_parse(const string &data, int &parse_start_pos,
_debugLog(_debug_tag, "[%s] Found html comment tag at position %d", __FUNCTION__, curr_pos);
data_ptr = data_start_ptr + curr_pos;
node_info = &HTML_COMMENT_NODE_INFO;
+ ++curr_pos;
} else {
curr_pos += ESI_TAG_PREFIX_LEN;
data_ptr = data_start_ptr + curr_pos;
@@ -329,11 +330,13 @@ EsiParser::_parse(const string &data, int &parse_start_pos,
__FUNCTION__, DocNode::type_names_[node_info->type], curr_pos - ESI_TAG_PREFIX_LEN);
++curr_pos; //skip the space char
break;
- } else if(ch == '/') {
+ } else if(ch == '/' || ch == '>') {
_debugLog(_debug_tag, "[%s] Found [%s] tag at position %d",
__FUNCTION__, DocNode::type_names_[node_info->type], curr_pos - ESI_TAG_PREFIX_LEN);
break;
}
+ } else {
+ goto lPartialMatch;
}
}
} else if (search_result == PARTIAL_MATCH) {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a82c80de/plugins/experimental/esi/test/parser_test.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/test/parser_test.cc b/plugins/experimental/esi/test/parser_test.cc
index 2e2baa1..a2e5eb0 100644
--- a/plugins/experimental/esi/test/parser_test.cc
+++ b/plugins/experimental/esi/test/parser_test.cc
@@ -157,7 +157,7 @@ int main()
string input_data = "<esi:comment></esi:comment>";
DocNodeList node_list;
- assert(parser.parseChunk(input_data, node_list) == false);
+ assert(parser.parseChunk(input_data, node_list) == true);
assert(parser.completeParse(node_list) == false);
assert(node_list.size() == 0);
}
@@ -340,12 +340,12 @@ int main()
char line1[] = "foo1 <esi:include";
char line2[] = "src=url2/>";
char line3[] = "bar3";
- assert(parser.parseChunk(line1, node_list) == false);
- assert(node_list.size() == 0);
+ assert(parser.parseChunk(line1, node_list) == true);
+ assert(node_list.size() == 1);
assert(parser.parseChunk(line2, node_list) == false);
- assert(node_list.size() == 0);
+ assert(node_list.size() == 1);
assert(parser.parseChunk(line3, node_list) == false);
- assert(node_list.size() == 0);
+ assert(node_list.size() == 1);
assert(parser.completeParse(node_list) == false);
assert(node_list.size() == 0);
}
@@ -434,7 +434,6 @@ int main()
{
cout << endl << "==================== Test 23: multi-chunk" << endl;
- /*
EsiParser parser("parser_test", &Debug, &Error);
DocNodeList node_list;
char line1[] = "foo1 <e";
@@ -448,10 +447,10 @@ int main()
assert(node_list.size() == 1);
assert(parser.parseChunk(line3, node_list) == true);
assert(node_list.size() == 2);
- assert(parser.parseChunk(line4, node_list) == false);
- assert(node_list.size() == 2);
+ assert(parser.parseChunk(line4, node_list) == true);
+ assert(node_list.size() == 5);
assert(parser.parseChunk(line5, node_list) == true);
- assert(node_list.size() == 0);
+ assert(node_list.size() == 6);
assert(parser.completeParse(node_list) == true);
assert(node_list.size() == 6);
@@ -478,7 +477,6 @@ int main()
++list_iter;
assert(list_iter->type == DocNode::TYPE_COMMENT);
assert(list_iter->data_len == 0);
- */
}
{
@@ -507,7 +505,6 @@ int main()
{
cout << endl << "==================== Test 25: final chunk" << endl;
- /*
EsiParser parser("parser_test", &Debug, &Error);
DocNodeList node_list;
char line1[] = "foo1 <e";
@@ -549,7 +546,6 @@ int main()
++list_iter;
assert(list_iter->type == DocNode::TYPE_COMMENT);
assert(list_iter->data_len == 0);
- */
}
{
@@ -852,7 +848,6 @@ int main()
{
cout << endl << "==================== Test 37: html comment tag " << endl;
- /*
EsiParser parser("parser_test", &Debug, &Error);
string input_data =
"foo <esi:comment text=\"blah\"/><!--esi <p><esi:vars>Hello, $(HTTP_COOKIE{name})!</esi:vars></p>-->"
@@ -887,12 +882,10 @@ int main()
assert(list_iter->data_len == static_cast<int>(strlen(" bar")));
assert(strncmp(list_iter->data, " bar", list_iter->data_len) == 0);
assert(list_iter->attr_list.size() == 0);
- */
}
{
cout << endl << "==================== Test 38: html comment tag - partial chunks " << endl;
- /*
EsiParser parser("parser_test", &Debug, &Error);
const char *lines[] = {
"foo ",
@@ -998,12 +991,10 @@ int main()
assert(list_iter->attr_list.size() == 1);
check_node_attr(list_iter->attr_list.front(), "src", "url3");
++list_iter;
- */
}
{
cout << endl << "==================== Test 39: opening tag corner cases" << endl;
- /*
EsiParser parser("parser_test", &Debug, &Error);
DocNodeList node_list;
DocNodeList::iterator list_iter;
@@ -1045,7 +1036,6 @@ int main()
assert(parser.parse(node_list, "<esi:<!--esi <esi:comment text=blah/>-->/>") == false);
assert(node_list.size() == 6);
- */
}
{
@@ -1072,7 +1062,6 @@ int main()
{
cout << endl << "==================== Test 42: Valid special include " << endl;
- /*
EsiParser parser("parser_test", &Debug, &Error);
string input_data = "<esi:special-include handler=ads pos=SKY />";
@@ -1082,11 +1071,10 @@ int main()
assert(node_list.size() == 1);
DocNode &node = node_list.back();
assert(node.type == DocNode::TYPE_SPECIAL_INCLUDE);
- assert(node.data_len == static_cast<int>(strlen(" handler=ads pos=SKY ")));
- assert(strncmp(node.data, " handler=ads pos=SKY ", node.data_len) == 0);
+ assert(node.data_len == static_cast<int>(strlen("handler=ads pos=SKY ")));
+ assert(strncmp(node.data, "handler=ads pos=SKY ", node.data_len) == 0);
assert(node.attr_list.size() == 1);
check_node_attr(node.attr_list.front(), "handler", "ads");
- */
}
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a82c80de/plugins/experimental/esi/test/processor_test.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/test/processor_test.cc b/plugins/experimental/esi/test/processor_test.cc
index 532bab9..cb9cf12 100644
--- a/plugins/experimental/esi/test/processor_test.cc
+++ b/plugins/experimental/esi/test/processor_test.cc
@@ -705,7 +705,6 @@ int main()
{
cout << endl << "===================== Test 32) html comment node" << endl;
- /*
TestHttpDataFetcher data_fetcher;
EsiProcessor esi_proc("processor", "parser", "expression", &Debug, &Error, data_fetcher, esi_vars,
handler_mgr);
@@ -722,7 +721,6 @@ int main()
assert(strncmp(output_data,
">>>>> Content for URL [helloworld] <<<<<fooblahbar",
output_data_len) == 0);
- */
}
{