Updated Branches: refs/heads/master 4a4c517e0 -> 7c2867454
TS-1249: hook up the ESI unit tests Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7c286745 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7c286745 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7c286745 Branch: refs/heads/master Commit: 7c28674544b45afaea2ffa98d354f8f275a5d835 Parents: 4a4c517 Author: James Peach <[email protected]> Authored: Fri Aug 17 21:56:06 2012 -0700 Committer: James Peach <[email protected]> Committed: Fri Aug 17 21:56:06 2012 -0700 ---------------------------------------------------------------------- plugins/experimental/esi/Makefile.am | 28 ++++++++- plugins/experimental/esi/test/docnode_test.cc | 3 + plugins/experimental/esi/test/parser_test.cc | 3 + plugins/experimental/esi/test/print_funcs.cc | 47 +++++++++++++++ plugins/experimental/esi/test/print_funcs.h | 31 ++++++++++ plugins/experimental/esi/test/processor_test.cc | 3 + plugins/experimental/esi/test/utils_test.cc | 3 + plugins/experimental/esi/test/vars_test.cc | 3 + .../experimental/esi/test_helper/print_funcs.cc | 47 --------------- plugins/experimental/esi/test_helper/print_funcs.h | 31 ---------- 10 files changed, 118 insertions(+), 81 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/Makefile.am ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/Makefile.am b/plugins/experimental/esi/Makefile.am index 3b95bf4..210bee5 100644 --- a/plugins/experimental/esi/Makefile.am +++ b/plugins/experimental/esi/Makefile.am @@ -19,13 +19,16 @@ pkglibdir = ${pkglibexecdir} AM_CXXFLAGS = \ -I$(srcdir)/lib \ -I$(srcdir)/fetcher \ + -I$(srcdir)/test \ -I$(top_builddir)/proxy/api \ -I$(top_srcdir)/proxy/api pkglib_LTLIBRARIES = esi.la +lib_LTLIBRARIES = libesi.la -esi_la_SOURCES = \ - fetcher/HttpDataFetcherImpl.cc \ +check_PROGRAMS = docnode_test parser_test processor_test utils_test vars_test + +libesi_la_SOURCES = \ lib/DocNode.cc \ lib/EsiParser.cc \ lib/EsiProcessor.cc \ @@ -35,9 +38,28 @@ esi_la_SOURCES = \ lib/Stats.cc \ lib/Utils.cc \ lib/Variables.cc \ - lib/gzip.cc \ + lib/gzip.cc + +esi_la_SOURCES = \ + fetcher/HttpDataFetcherImpl.cc \ plugin.cc \ serverIntercept.cc +esi_la_LIBADD = libesi.la esi_la_LDFLAGS = -module -avoid-version -shared +docnode_test_SOURCES = test/docnode_test.cc test/print_funcs.cc +docnode_test_LDADD = libesi.la +parser_test_SOURCES = test/parser_test.cc test/print_funcs.cc +parser_test_LDADD = libesi.la +processor_test_SOURCES = test/processor_test.cc test/HandlerMap.cc test/StubIncludeHandler.cc test/print_funcs.cc +processor_test_LDADD = libesi.la +utils_test_SOURCES = test/utils_test.cc test/print_funcs.cc +utils_test_LDADD = libesi.la +vars_test_SOURCES = test/vars_test.cc test/print_funcs.cc +vars_test_LDADD = libesi.la + +TESTS = $(check_PROGRAMS) + +test:: $(TESTS) + for f in $(TESTS) ; do $$f ; done http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/test/docnode_test.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/test/docnode_test.cc b/plugins/experimental/esi/test/docnode_test.cc index 319eb19..a2ac995 100644 --- a/plugins/experimental/esi/test/docnode_test.cc +++ b/plugins/experimental/esi/test/docnode_test.cc @@ -142,8 +142,11 @@ void checkNodeList2(const DocNodeList &node_list) { check_node_attr(list_iter3->attr_list.front(), "src", "bar3"); } +pthread_key_t threadKey; + int main() { + pthread_key_create(&threadKey, NULL); Utils::init(&Debug, &Error); { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/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 0278435..e4b593a 100644 --- a/plugins/experimental/esi/test/parser_test.cc +++ b/plugins/experimental/esi/test/parser_test.cc @@ -44,8 +44,11 @@ void check_node_attr(const Attribute &attr, const char *name, const char *value) assert(strncmp(attr.value, value, value_len) == 0); } +pthread_key_t threadKey; + int main() { + pthread_key_create(&threadKey, NULL); Utils::init(&Debug, &Error); { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/test/print_funcs.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/test/print_funcs.cc b/plugins/experimental/esi/test/print_funcs.cc new file mode 100644 index 0000000..7acc06f --- /dev/null +++ b/plugins/experimental/esi/test/print_funcs.cc @@ -0,0 +1,47 @@ +/** @file + + A brief file description + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include <stdio.h> +#include <stdarg.h> + +#include "print_funcs.h" + +static const int LINE_SIZE = 1024 * 1024; + +void Debug(const char *tag, const char *fmt, ...) { + char buf[LINE_SIZE]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, LINE_SIZE, fmt, ap); + printf("Debug (%s): %s\n", tag, buf); + va_end(ap); +} + +void Error(const char *fmt, ...) { + char buf[LINE_SIZE]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, LINE_SIZE, fmt, ap); + printf("Error: %s\n", buf); + va_end(ap); +} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/test/print_funcs.h ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/test/print_funcs.h b/plugins/experimental/esi/test/print_funcs.h new file mode 100644 index 0000000..81b6383 --- /dev/null +++ b/plugins/experimental/esi/test/print_funcs.h @@ -0,0 +1,31 @@ +/** @file + + A brief file description + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#ifndef _PRINT_FUNCS_H +#define _PRINT_FUNCS_H + +void Debug(const char *tag, const char *fmt, ...); + +void Error(const char *fmt, ...); + +#endif // _PRINT_FUNCS_H http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/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 c0147ea..bf85742 100644 --- a/plugins/experimental/esi/test/processor_test.cc +++ b/plugins/experimental/esi/test/processor_test.cc @@ -37,6 +37,8 @@ using std::endl; using std::string; using namespace EsiLib; +pthread_key_t threadKey; + static const int FETCHER_STATIC_DATA_SIZE = 30; int main() @@ -44,6 +46,7 @@ int main() Variables esi_vars("vars", &Debug, &Error); HandlerManager handler_mgr("handler_mgr", &Debug, &Error); + pthread_key_create(&threadKey, NULL); Utils::init(&Debug, &Error); { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/test/utils_test.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/test/utils_test.cc b/plugins/experimental/esi/test/utils_test.cc index 0fc9ccb..469d5a8 100644 --- a/plugins/experimental/esi/test/utils_test.cc +++ b/plugins/experimental/esi/test/utils_test.cc @@ -46,8 +46,11 @@ void checkAttributes(const char *check_id, const AttributeList &attr_list, const assert(iter == attr_list.end()); } +pthread_key_t threadKey; + int main() { + pthread_key_create(&threadKey, NULL); Utils::init(&Debug, &Error); AttributeList attr_list; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/test/vars_test.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/test/vars_test.cc b/plugins/experimental/esi/test/vars_test.cc index d15f953..70ffa79 100644 --- a/plugins/experimental/esi/test/vars_test.cc +++ b/plugins/experimental/esi/test/vars_test.cc @@ -37,6 +37,8 @@ using std::endl; using std::string; using namespace EsiLib; +pthread_key_t threadKey; + void addToHeaderList(const char *strings[], HttpHeaderList &headers) { for (int i = 0; strings[i]; i += 2) { @@ -66,6 +68,7 @@ fakeDebug(const char *tag, const char *fmt, ...) { int main() { + pthread_key_create(&threadKey, NULL); Utils::init(&Debug, &Error); { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/test_helper/print_funcs.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/test_helper/print_funcs.cc b/plugins/experimental/esi/test_helper/print_funcs.cc deleted file mode 100644 index 7acc06f..0000000 --- a/plugins/experimental/esi/test_helper/print_funcs.cc +++ /dev/null @@ -1,47 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#include <stdio.h> -#include <stdarg.h> - -#include "print_funcs.h" - -static const int LINE_SIZE = 1024 * 1024; - -void Debug(const char *tag, const char *fmt, ...) { - char buf[LINE_SIZE]; - va_list ap; - va_start(ap, fmt); - vsnprintf(buf, LINE_SIZE, fmt, ap); - printf("Debug (%s): %s\n", tag, buf); - va_end(ap); -} - -void Error(const char *fmt, ...) { - char buf[LINE_SIZE]; - va_list ap; - va_start(ap, fmt); - vsnprintf(buf, LINE_SIZE, fmt, ap); - printf("Error: %s\n", buf); - va_end(ap); -} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7c286745/plugins/experimental/esi/test_helper/print_funcs.h ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/test_helper/print_funcs.h b/plugins/experimental/esi/test_helper/print_funcs.h deleted file mode 100644 index 81b6383..0000000 --- a/plugins/experimental/esi/test_helper/print_funcs.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#ifndef _PRINT_FUNCS_H -#define _PRINT_FUNCS_H - -void Debug(const char *tag, const char *fmt, ...); - -void Error(const char *fmt, ...); - -#endif // _PRINT_FUNCS_H
