diff --git a/.gitignore b/.gitignore index f03cfb49963..d46c2aa78a9 100644 --- a/.gitignore +++ b/.gitignore @@ -193,6 +193,8 @@ RELEASE # autest tests/env-test/ tests/Pipfile.lock +tests/gold_tests/chunked_encoding/smuggle-client +tests/gold_tests/tls/ssl-post iocore/cache/test_* iocore/cache/test/var/trafficserver/cache.db diff --git a/Makefile.am b/Makefile.am index abcc9710f9d..f8d5599e6b7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,7 +27,7 @@ export CCACHE_BASEDIR # and mgmt, hence we have to build proxy/hdrs first. # depends on the generates ts/ts.h include file. -SUBDIRS = src/tscpp/util lib src/tscore iocore proxy mgmt src plugins tools example rc configs include +SUBDIRS = src/tscpp/util lib src/tscore iocore proxy mgmt src plugins tools example rc configs include tests if BUILD_DOCS SUBDIRS += doc include diff --git a/configure.ac b/configure.ac index f00e40e0ea9..af6a7eda6ef 100644 --- a/configure.ac +++ b/configure.ac @@ -2216,6 +2216,7 @@ AC_CONFIG_FILES([ tools/trafficserver.pc tools/tsxs tests/unit_tests/Makefile + tests/Makefile ]) # ----------------------------------------------------------------------------- diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 00000000000..d936e1d45c9 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,42 @@ +# 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 $(top_srcdir)/build/plugins.mk +include $(top_srcdir)/build/tidy.mk + +noinst_LTLIBRARIES = +noinst_PROGRAMS = + +SUBDIRS = + +AM_LDFLAGS += $(TS_PLUGIN_LD_FLAGS) + +# Automake is pretty draconian about not creating shared object (.so) files for +# non-installed files. However we do not want to install our test plugins so +# we prefix them with noinst_. The following -rpath argument coerces the +# generation of so objects for these test files. +AM_LDFLAGS += -rpath $(abs_builddir) + +include gold_tests/continuations/plugins/Makefile.inc +include gold_tests/chunked_encoding/Makefile.inc +include gold_tests/tls/Makefile.inc +include tools/plugins/Makefile.inc + +TESTS = $(check_PROGRAMS) + +clang-tidy-local: $(DIST_SOURCES) + $(CXX_Clang_Tidy) + $(CC_Clang_Tidy) diff --git a/tests/gold_tests/autest-site/build.test.ext b/tests/gold_tests/autest-site/build.test.ext deleted file mode 100644 index ef8aa422e66..00000000000 --- a/tests/gold_tests/autest-site/build.test.ext +++ /dev/null @@ -1,53 +0,0 @@ -''' -Build random code for running as part of a test -''' -# 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. - -import re -import autest.common.is_a as is_a - - -def Build(Test, target, sources, CPPFLAGS='', LDFLAGS='', LIBS='', CC=None): - if is_a.OrderedSequence(sources): - sources = " ".join(sources) - tr = Test.AddTestRun("Build", "Build test files: {0}".format(sources)) - vars = Test.ComposeVariables() - if CC is None: - cc = vars.CXX - else: - cc = CC - - tr.Processes.Default.Command = '{cc} -o {target} {cppflags} {sources} {ldflags} {libs}'.format( - cppflags="{0} {1}".format(vars.CPPFLAGS, CPPFLAGS), - ldflags="{0} {1}".format(vars.LDFLAGS, LDFLAGS), - libs="{0} {1}".format(vars.LIBS, LIBS), - target=target, - sources=sources, - cc=cc - ) - tr.Processes.Default.ForceUseShell = True - tr.ReturnCode = 0 - tr.Streams.All = Testers.ExcludesExpression( - r'(\A|\s)error?\s?(([?!: ])|(\.\s))\D', - "Build should not contain errors", - reflags=re.IGNORECASE - ) - - return tr - - -ExtendTest(Build, name="Build") diff --git a/tests/gold_tests/autest-site/setup.cli.ext b/tests/gold_tests/autest-site/setup.cli.ext index d0f1e6412de..6045f31d688 100644 --- a/tests/gold_tests/autest-site/setup.cli.ext +++ b/tests/gold_tests/autest-site/setup.cli.ext @@ -80,6 +80,7 @@ if ENV['ATS_BIN'] is not None: Variables.update(out) Variables.AtsExampleDir = os.path.join(AutestSitePath, '../../../example') Variables.AtsTestToolsDir = os.path.join(AutestSitePath, '../../tools') +Variables.AtsTestPluginsDir = os.path.join(AutestSitePath, '../../tools/plugins/.libs') # modify delay times as we always have to kill Trafficserver # no need to wait diff --git a/tests/gold_tests/autest-site/trafficserver_plugins.test.ext b/tests/gold_tests/autest-site/trafficserver_plugins.test.ext index e6e3087af7a..ed3baf66425 100644 --- a/tests/gold_tests/autest-site/trafficserver_plugins.test.ext +++ b/tests/gold_tests/autest-site/trafficserver_plugins.test.ext @@ -19,47 +19,33 @@ Builds, installs, and enables an ATS plugin in the sandbox environment import os -def prepare_plugin(self, path, tsproc, plugin_args = "", extra_build_args=''): - """Builds, installs, and enables an ATS plugin in the sandbox environment - The source file at the given path is copied to the sandbox directory of the - given traffic server process and compiled into a binary with the file - extensioned replaced with '.so'. An entry for this plugin is added to - the 'plugin.config' file.""" +def prepare_plugin(self, so_path, tsproc, plugin_args=""): + """ + Installs and enables an ATS plugin in the sandbox environment. - # Copy the source to the sandbox directory. - plugin_dir = tsproc.Env['PROXY_CONFIG_PLUGIN_PLUGIN_DIR'] - tsproc.Setup.Copy(path, plugin_dir) + Args: + so_path (str): The path to a built .so file. + + tsproc (Process): The Traffic Server process whose plugin.config should + be configured to use the provided plugin. - tsxs = os.path.join(self.Variables.BINDIR,'tsxs') - # get the top level object ( ie Test) to add a condition - # need to change this API in AuTest to be a better name as it now has value - # to be called by user API - dragon512 - self._RootRunable.SkipUnless( - Condition.HasProgram(tsxs, "tsxs needs be installed with trafficserver package for this test to run") - ) + plugin_args (str): The arguments to provide the plugin in the + plugin.config. + """ - link_gxx="export CC=c++ &&" - # Compile the plugin. - in_basename = os.path.basename(path) - if in_basename.endswith(".c"): - link_gxx = '' - in_path = os.path.join(plugin_dir, in_basename) - out_basename = os.path.splitext(in_basename)[0] + '.so' - out_path = os.path.join(plugin_dir, out_basename) - tsproc.Setup.RunCommand( - "{pre_args} {tsxs} {args} -c {0} -o {1}".format( - in_path, - out_path, - tsxs=tsxs, - args=" -L {0} {1}".format(self.Variables.LIBDIR, extra_build_args), - pre_args=link_gxx) - ) + filename, extension = os.path.splitext(so_path) + if extension != ".so": + raise ValueError('so_path argument must have a ".so" extension. ' + 'Received: {}'.format(so_path)) + + # Copy the shared object to the sandbox directory. + plugin_dir = tsproc.Env['PROXY_CONFIG_PLUGIN_PLUGIN_DIR'] + tsproc.Setup.Copy(so_path, plugin_dir) # Add an entry to plugin.config. - tsproc.Disk.plugin_config.AddLine("{0} {1}".format(out_basename,plugin_args)) + basename = os.path.basename(so_path) + tsproc.Disk.plugin_config.AddLine("{0} {1}".format(basename, plugin_args)) -# remove this later -ExtendTest(prepare_plugin, name="prepare_plugin") ExtendTest(prepare_plugin, name="PreparePlugin") diff --git a/tests/gold_tests/body_factory/http204_response_plugin.test.py b/tests/gold_tests/body_factory/http204_response_plugin.test.py index 189077004d8..f7ed9dc7a15 100644 --- a/tests/gold_tests/body_factory/http204_response_plugin.test.py +++ b/tests/gold_tests/body_factory/http204_response_plugin.test.py @@ -37,7 +37,7 @@ ) ts.Disk.MakeConfigFile(regex_remap_conf_file).AddLine('//.*/ http://donotcare.test @status=204') -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'custom204plugin.cc'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'custom204plugin.so'), ts) Test.Setup.Copy(os.path.join(os.pardir, os.pardir, 'tools', 'tcp_client.py')) Test.Setup.Copy('data') diff --git a/tests/gold_tests/chunked_encoding/Makefile.inc b/tests/gold_tests/chunked_encoding/Makefile.inc new file mode 100644 index 00000000000..b316b4b41fd --- /dev/null +++ b/tests/gold_tests/chunked_encoding/Makefile.inc @@ -0,0 +1,19 @@ +# 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. + +noinst_PROGRAMS += gold_tests/chunked_encoding/smuggle-client +gold_tests_chunked_encoding_smuggle_client_SOURCES = gold_tests/chunked_encoding/smuggle-client.c +gold_tests_chunked_encoding_smuggle_client_LDADD = -lssl diff --git a/tests/gold_tests/chunked_encoding/chunked_encoding.test.py b/tests/gold_tests/chunked_encoding/chunked_encoding.test.py index 91d3a53f62c..1ee80d09f5b 100644 --- a/tests/gold_tests/chunked_encoding/chunked_encoding.test.py +++ b/tests/gold_tests/chunked_encoding/chunked_encoding.test.py @@ -90,10 +90,9 @@ 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' ) -# build test code -tr = Test.Build(target='smuggle-client', sources=['smuggle-client.c']) -tr.TimeOut = 5 -tr.Setup.Copy('smuggle-client.c') +# smuggle-client is built via `make`. Here we copy the built binary down to the +# test directory so that the test runs in this file can use it. +Test.Setup.Copy('smuggle-client') # HTTP1.1 GET: www.example.com tr = Test.AddTestRun() diff --git a/tests/gold_tests/command_argument/verify_global_plugin.test.py b/tests/gold_tests/command_argument/verify_global_plugin.test.py index e7bfae34a2d..7becc84110c 100644 --- a/tests/gold_tests/command_argument/verify_global_plugin.test.py +++ b/tests/gold_tests/command_argument/verify_global_plugin.test.py @@ -86,8 +86,8 @@ def create_ts_process(): tr = Test.AddTestRun("Verify the requirement of our Plugin API.") ts = create_ts_process() Test.PreparePlugin( - os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'missing_ts_plugin_init.cc'), + os.path.join(Test.Variables.AtsTestPluginsDir, + 'missing_ts_plugin_init.so'), ts) tr.Processes.Default.Env = ts.Env tr.Processes.Default.Command = \ @@ -98,7 +98,8 @@ def create_ts_process(): tr.Processes.Default.Streams.stderr = Testers.ContainsExpression( "ERROR: .*unable to find TSPluginInit function in", "Should warn about the need for the TSPluginInit symbol") -ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR", +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "ERROR", "ERROR: .*unable to find TSPluginInit function in") @@ -109,8 +110,8 @@ def create_ts_process(): tr = Test.AddTestRun("Verify a properly formed plugin works as expected.") ts = create_ts_process() Test.PreparePlugin( - os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'conf_remap_stripped.cc'), + os.path.join(Test.Variables.AtsTestPluginsDir, + 'conf_remap_stripped.so'), ts) tr.Processes.Default.Env = ts.Env tr.Processes.Default.Command = \ @@ -121,7 +122,8 @@ def create_ts_process(): tr.Processes.Default.Streams.stderr = Testers.ContainsExpression( "ERROR: .*unable to find TSPluginInit function in", "Should warn about the need for the TSPluginInit symbol") -ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR", +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "ERROR", "ERROR: .*unable to find TSPluginInit function in") @@ -132,8 +134,8 @@ def create_ts_process(): tr = Test.AddTestRun("Verify a properly formed plugin works as expected.") ts = create_ts_process() Test.PreparePlugin( - os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'ssl_hook_test.cc'), + os.path.join(Test.Variables.AtsTestPluginsDir, + 'ssl_hook_test.so'), ts) tr.Processes.Default.Env = ts.Env tr.Processes.Default.Command = \ @@ -146,32 +148,6 @@ def create_ts_process(): "Verification should succeed") -def prepare_undefined_symbol_plugin(tsproc, path_c, path_cpp, path_h): - """ - Intentionally create an SO file with an undefined symbol. - - We've seen issues where a plugin is created in which a C++ file - includes a function declaration and then expects a definition - of the mangled version of that function. However, the definition - was created with a c-compiler and thus is not mangled. This - builds a plugin with just such an undefined mangled symbol. - """ - plugin_dir = tsproc.Env['PROXY_CONFIG_PLUGIN_PLUGIN_DIR'] - tsproc.Setup.Copy(path_c, plugin_dir) - tsproc.Setup.Copy(path_cpp, plugin_dir) - tsproc.Setup.Copy(path_h, plugin_dir) - - in_basename = os.path.basename(path_c) - out_basename = os.path.splitext(in_basename)[0] + '.so' - out_path = os.path.join(plugin_dir, out_basename) - tsproc.Setup.RunCommand( - ("gcc -c -fPIC {path_c} -o {path_c}_o; " - "g++ -c -fPIC {path_cpp} -o {path_cpp}_o; " - "g++ {path_c}_o {path_cpp}_o -shared -o {out_path}").format( - **locals()) - ) - - """ TEST: This is a regression test for a shared object file that doesn't have all of the required symbols defined because of a malformed interaction between C @@ -179,20 +155,19 @@ def prepare_undefined_symbol_plugin(tsproc, path_c, path_cpp, path_h): """ tr = Test.AddTestRun("Regression test for an undefined, mangled C++ symbol.") ts = create_ts_process() -plugins_dir = os.path.join(Test.Variables.AtsTestToolsDir, 'plugins') -prepare_undefined_symbol_plugin( - ts, - os.path.join(plugins_dir, 'missing_mangled_definition.c'), - os.path.join(plugins_dir, 'missing_mangled_definition.cc'), - os.path.join(plugins_dir, 'missing_mangled_definition.h')) +plugin_filename = 'missing_mangled_definition.so' +built_plugin_path = os.path.join(Test.Variables.AtsTestPluginsDir, plugin_filename) +ats_plugin_dir = ts.Env['PROXY_CONFIG_PLUGIN_PLUGIN_DIR'] +ts.Setup.Copy(built_plugin_path, ats_plugin_dir) tr.Processes.Default.Env = ts.Env tr.Processes.Default.Command = \ - "traffic_server -C 'verify_global_plugin {filename}'".format( - filename="${PROXY_CONFIG_PLUGIN_PLUGIN_DIR}/missing_mangled_definition.so") + "traffic_server -C 'verify_global_plugin {plugin_path}'".format( + plugin_path=os.path.join(ats_plugin_dir, plugin_filename)) tr.Processes.Default.ReturnCode = 1 tr.Processes.Default.StartBefore(ts) tr.Processes.Default.Streams.stderr = Testers.ContainsExpression( "ERROR: .*: undefined symbol: .*foo.*", "Should warn about the need for the TSPluginInit symbol") -ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR", +ts.Disk.diags_log.Content = Testers.ContainsExpression( + "ERROR", "ERROR: .*: undefined symbol: .*foo.*") diff --git a/tests/gold_tests/command_argument/verify_remap_plugin.test.py b/tests/gold_tests/command_argument/verify_remap_plugin.test.py index 004c9c86ee6..84114255a53 100644 --- a/tests/gold_tests/command_argument/verify_remap_plugin.test.py +++ b/tests/gold_tests/command_argument/verify_remap_plugin.test.py @@ -86,8 +86,8 @@ def create_ts_process(): tr = Test.AddTestRun("Verify the requirement of our Plugin API.") ts = create_ts_process() Test.PreparePlugin( - os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'missing_ts_plugin_init.cc'), + os.path.join(Test.Variables.AtsTestPluginsDir, + 'missing_ts_plugin_init.so'), ts) tr.Processes.Default.Env = ts.Env tr.Processes.Default.Command = \ @@ -109,8 +109,8 @@ def create_ts_process(): tr = Test.AddTestRun("Verify a global plugin argument produces warning.") ts = create_ts_process() Test.PreparePlugin( - os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'ssl_hook_test.cc'), + os.path.join(Test.Variables.AtsTestPluginsDir, + 'ssl_hook_test.so'), ts) tr.Processes.Default.Env = ts.Env tr.Processes.Default.Command = \ @@ -132,8 +132,8 @@ def create_ts_process(): tr = Test.AddTestRun("Verify a properly formed plugin works as expected.") ts = create_ts_process() Test.PreparePlugin( - os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'conf_remap_stripped.cc'), + os.path.join(Test.Variables.AtsTestPluginsDir, + 'conf_remap_stripped.so'), ts) tr.Processes.Default.Env = ts.Env tr.Processes.Default.Command = \ diff --git a/tests/gold_tests/cont_schedule/schedule_on_pool.test.py b/tests/gold_tests/cont_schedule/schedule_on_pool.test.py index 23a737391dd..b700649bccf 100644 --- a/tests/gold_tests/cont_schedule/schedule_on_pool.test.py +++ b/tests/gold_tests/cont_schedule/schedule_on_pool.test.py @@ -38,7 +38,7 @@ }) # Load plugin -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'cont_schedule.cc'), ts, 'pool') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'pool') # www.example.com Host tr = Test.AddTestRun() diff --git a/tests/gold_tests/cont_schedule/schedule_on_thread.test.py b/tests/gold_tests/cont_schedule/schedule_on_thread.test.py index 59e5a81a6fb..8d625ac00af 100644 --- a/tests/gold_tests/cont_schedule/schedule_on_thread.test.py +++ b/tests/gold_tests/cont_schedule/schedule_on_thread.test.py @@ -38,7 +38,7 @@ }) # Load plugin -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'cont_schedule.cc'), ts, 'thread') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'thread') # www.example.com Host tr = Test.AddTestRun() diff --git a/tests/gold_tests/cont_schedule/thread_affinity.test.py b/tests/gold_tests/cont_schedule/thread_affinity.test.py index 619a3d871fe..cc40be4dd7f 100644 --- a/tests/gold_tests/cont_schedule/thread_affinity.test.py +++ b/tests/gold_tests/cont_schedule/thread_affinity.test.py @@ -38,7 +38,7 @@ }) # Load plugin -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'cont_schedule.cc'), ts, 'affinity') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'cont_schedule.so'), ts, 'affinity') # www.example.com Host tr = Test.AddTestRun() diff --git a/tests/gold_tests/continuations/double.test.py b/tests/gold_tests/continuations/double.test.py index 2f403155d19..897be36bae0 100644 --- a/tests/gold_tests/continuations/double.test.py +++ b/tests/gold_tests/continuations/double.test.py @@ -54,8 +54,8 @@ }) # add plugin to assist with test metrics -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'continuations_verify.cc'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, + 'continuations_verify.so'), ts) comparator_command = ''' if test "`traffic_ctl metric get continuations_verify.{0}.close.1 | cut -d ' ' -f 2`" -eq "`traffic_ctl metric get continuations_verify.{0}.close.2 | cut -d ' ' -f 2`" ; then\ diff --git a/tests/gold_tests/continuations/double_h2.test.py b/tests/gold_tests/continuations/double_h2.test.py index 0ff6655ee10..f26856785b6 100644 --- a/tests/gold_tests/continuations/double_h2.test.py +++ b/tests/gold_tests/continuations/double_h2.test.py @@ -64,8 +64,8 @@ }) # add plugin to assist with test metrics -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'continuations_verify.cc'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, + 'continuations_verify.so'), ts) comparator_command = ''' if test "`traffic_ctl metric get continuations_verify.{0}.close.1 | cut -d ' ' -f 2`" -eq "`traffic_ctl metric get continuations_verify.{0}.close.2 | cut -d ' ' -f 2`" ; then\ diff --git a/tests/gold_tests/continuations/openclose.test.py b/tests/gold_tests/continuations/openclose.test.py index 471bdfba0f7..c99be2364e1 100644 --- a/tests/gold_tests/continuations/openclose.test.py +++ b/tests/gold_tests/continuations/openclose.test.py @@ -35,8 +35,8 @@ response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length:0\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'ssntxnorder_verify.cc'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, + 'ssntxnorder_verify.so'), ts) # add response to the server dictionary server.addResponse("sessionfile.log", request_header, response_header) diff --git a/tests/gold_tests/continuations/openclose_h2.test.py b/tests/gold_tests/continuations/openclose_h2.test.py index 6f3e73a2eed..b00d4bba739 100644 --- a/tests/gold_tests/continuations/openclose_h2.test.py +++ b/tests/gold_tests/continuations/openclose_h2.test.py @@ -43,8 +43,8 @@ ts.addSSLfile("ssl/server.pem") ts.addSSLfile("ssl/server.key") -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, - 'plugins', 'ssntxnorder_verify.cc'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, + 'ssntxnorder_verify.so'), ts) # add response to the server dictionary server.addResponse("sessionfile.log", request_header, response_header) diff --git a/tests/gold_tests/continuations/plugins/Makefile.inc b/tests/gold_tests/continuations/plugins/Makefile.inc new file mode 100644 index 00000000000..f39c9af6f39 --- /dev/null +++ b/tests/gold_tests/continuations/plugins/Makefile.inc @@ -0,0 +1,18 @@ +# 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. + +noinst_LTLIBRARIES += gold_tests/continuations/plugins/session_id_verify.la +gold_tests_continuations_plugins_session_id_verify_la_SOURCES = gold_tests/continuations/plugins/session_id_verify.cc diff --git a/tests/gold_tests/continuations/plugins/session_id_verify.cc b/tests/gold_tests/continuations/plugins/session_id_verify.cc index ad11342389f..72c336b5cfb 100644 --- a/tests/gold_tests/continuations/plugins/session_id_verify.cc +++ b/tests/gold_tests/continuations/plugins/session_id_verify.cc @@ -21,6 +21,7 @@ limitations under the License. */ #include // for debug +#include // for abort #include // for PRIu64 #include @@ -83,7 +84,7 @@ TSPluginInit(int argc, const char *argv[]) if (contp == nullptr) { // Continuation initialization failed. Unrecoverable, report and exit. TSError("[%s] could not create continuation.", PLUGIN_NAME); - abort(); + std::abort(); } else { // Add all hooks. TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, contp); diff --git a/tests/gold_tests/continuations/session_id.test.py b/tests/gold_tests/continuations/session_id.test.py index 5fd5ae132dd..ff2553ae3a6 100644 --- a/tests/gold_tests/continuations/session_id.test.py +++ b/tests/gold_tests/continuations/session_id.test.py @@ -39,7 +39,7 @@ ts.addSSLfile("ssl/server.pem") ts.addSSLfile("ssl/server.key") -Test.PreparePlugin(os.path.join(Test.TestDirectory, 'plugins', 'session_id_verify.cc'), ts) +Test.PreparePlugin(os.path.join(Test.TestDirectory, 'plugins', '.libs', 'session_id_verify.so'), ts) ts.Disk.records_config.update({ 'proxy.config.diags.debug.enabled': 1, diff --git a/tests/gold_tests/logging/log_retention.test.py b/tests/gold_tests/logging/log_retention.test.py index d9763190e6a..692951f6432 100644 --- a/tests/gold_tests/logging/log_retention.test.py +++ b/tests/gold_tests/logging/log_retention.test.py @@ -250,7 +250,7 @@ def get_command_to_rotate_thrice(self): # test = TestLogRetention(twelve_meg_log_space, "Verify log rotation and deletion of plugin logs.") -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'test_log_interface.cc'), test.ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_log_interface.so'), test.ts) # Verify that the plugin's logs and other core logs were registered for deletion. test.ts.Streams.stderr = Testers.ContainsExpression( diff --git a/tests/gold_tests/null_transform/null_transform.test.py b/tests/gold_tests/null_transform/null_transform.test.py index 17f9bad1913..26ab4a9b0f6 100644 --- a/tests/gold_tests/null_transform/null_transform.test.py +++ b/tests/gold_tests/null_transform/null_transform.test.py @@ -51,7 +51,7 @@ ) # Load plugin -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'null_transform.c'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'null_transform.so'), ts) # www.example.com Host tr = Test.AddTestRun() diff --git a/tests/gold_tests/pluginTest/cert_update/cert_update.test.py b/tests/gold_tests/pluginTest/cert_update/cert_update.test.py index 3eefe7dca2b..790caadb988 100644 --- a/tests/gold_tests/pluginTest/cert_update/cert_update.test.py +++ b/tests/gold_tests/pluginTest/cert_update/cert_update.test.py @@ -17,6 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import ports Test.Summary = ''' @@ -72,7 +73,7 @@ ]) # Set up plugin -Test.PreparePlugin(Test.Variables.AtsExampleDir + '/plugins/c-api/cert_update/cert_update.cc', ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsExampleDir, 'plugins', 'c-api', '.libs', 'cert_update.so'), ts) # Server-Cert-Pre # curl should see that Traffic Server presents bar.com cert from alice diff --git a/tests/gold_tests/pluginTest/client_context_dump/client_context_dump.test.py b/tests/gold_tests/pluginTest/client_context_dump/client_context_dump.test.py index 89d676f0f3c..69adfaf9beb 100644 --- a/tests/gold_tests/pluginTest/client_context_dump/client_context_dump.test.py +++ b/tests/gold_tests/pluginTest/client_context_dump/client_context_dump.test.py @@ -17,6 +17,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + + Test.Summary = ''' Test client_context_dump plugin ''' @@ -50,7 +53,7 @@ ]) # Set up plugin -Test.PreparePlugin(Test.Variables.AtsExampleDir + '/plugins/c-api/client_context_dump/client_context_dump.cc', ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsExampleDir, 'plugins', 'c-api', '.libs', 'client_context_dump.so'), ts) # custom log comparison. Verify the two certs we have loaded are dumped log = Test.Disk.File(ts.Variables.LOGDIR + '/client_context_dump.log', exists=True) diff --git a/tests/gold_tests/pluginTest/cppapi/cppapi.test.py b/tests/gold_tests/pluginTest/cppapi/cppapi.test.py index 809eb2a7c40..07eb80fa125 100644 --- a/tests/gold_tests/pluginTest/cppapi/cppapi.test.py +++ b/tests/gold_tests/pluginTest/cppapi/cppapi.test.py @@ -14,13 +14,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + + Test.Summary = ''' Execute plugin with cppapi tests. ''' ts = Test.MakeATSProcess("ts") -Test.PreparePlugin(Test.Variables.AtsTestToolsDir + '/plugins/test_cppapi.cc', ts, extra_build_args='-l tscppapi') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_cppapi.so'), ts) tr = Test.AddTestRun() tr.Processes.Default.StartBefore(Test.Processes.ts) diff --git a/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py b/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py index c05997d7db3..c934b09b12f 100644 --- a/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py +++ b/tests/gold_tests/pluginTest/test_hooks/hook_add.test.py @@ -14,6 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + + Test.Summary = ''' Test adding hooks ''' @@ -35,7 +38,7 @@ 'proxy.config.url_remap.remap_required': 0, }) -Test.PreparePlugin(Test.Variables.AtsTestToolsDir + '/plugins/hook_add_plugin.cc', ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'hook_add_plugin.so'), ts) ts.Disk.remap_config.AddLine( "map http://one http://127.0.0.1:{0}".format(server.Variables.Port) diff --git a/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py b/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py index 4993de06d29..db92f350213 100644 --- a/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py +++ b/tests/gold_tests/pluginTest/test_hooks/test_hooks.test.py @@ -14,6 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + + Test.Summary = ''' Test TS API Hooks. ''' @@ -53,7 +56,7 @@ 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' ) -Test.PreparePlugin(Test.Variables.AtsTestToolsDir + '/plugins/test_hooks.cc', ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_hooks.so'), ts) ts.Disk.remap_config.AddLine( "map http://one http://127.0.0.1:{0}".format(server.Variables.Port) diff --git a/tests/gold_tests/pluginTest/tsapi/tsapi.test.py b/tests/gold_tests/pluginTest/tsapi/tsapi.test.py index 0295ac43156..12e6c29b2a2 100644 --- a/tests/gold_tests/pluginTest/tsapi/tsapi.test.py +++ b/tests/gold_tests/pluginTest/tsapi/tsapi.test.py @@ -14,6 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + + Test.Summary = ''' Test TS API. ''' @@ -60,7 +63,7 @@ "map https://myhost.test:{0} http://127.0.0.1:{0}".format(server.Variables.Port) ) -Test.PreparePlugin(Test.Variables.AtsTestToolsDir + '/plugins/test_tsapi.cc', ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'test_tsapi.so'), ts) tr = Test.AddTestRun() # Probe server port to check if ready. diff --git a/tests/gold_tests/shutdown/emergency.test.py b/tests/gold_tests/shutdown/emergency.test.py index ab8a6b0d557..1f03690731b 100644 --- a/tests/gold_tests/shutdown/emergency.test.py +++ b/tests/gold_tests/shutdown/emergency.test.py @@ -38,7 +38,7 @@ }) # Load plugin -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'emergency_shutdown.cc'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'emergency_shutdown.so'), ts) # www.example.com Host tr = Test.AddTestRun() diff --git a/tests/gold_tests/shutdown/fatal.test.py b/tests/gold_tests/shutdown/fatal.test.py index 6ba763d922f..31051c40014 100644 --- a/tests/gold_tests/shutdown/fatal.test.py +++ b/tests/gold_tests/shutdown/fatal.test.py @@ -38,7 +38,7 @@ }) # Load plugin -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'fatal_shutdown.cc'), ts) +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'fatal_shutdown.so'), ts) # www.example.com Host tr = Test.AddTestRun() diff --git a/tests/gold_tests/slow_post/slow_post.test.py b/tests/gold_tests/slow_post/slow_post.test.py index d958708f9aa..d4ad7f5e17f 100644 --- a/tests/gold_tests/slow_post/slow_post.test.py +++ b/tests/gold_tests/slow_post/slow_post.test.py @@ -46,7 +46,7 @@ def setupTS(self): 'map / http://127.0.0.1:{0}'.format(self._server.Variables.Port) ) # This plugin can enable request buffer for POST. - Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'request_buffer.c'), self._ts) + Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'request_buffer.so'), self._ts) self._ts.Disk.records_config.update({ 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'http', diff --git a/tests/gold_tests/tls/Makefile.inc b/tests/gold_tests/tls/Makefile.inc new file mode 100644 index 00000000000..f0990ff8b0d --- /dev/null +++ b/tests/gold_tests/tls/Makefile.inc @@ -0,0 +1,19 @@ +# 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. + +noinst_PROGRAMS += gold_tests/tls/ssl-post +gold_tests_tls_ssl_post_SOURCES = gold_tests/tls/ssl-post.c +gold_tests_tls_ssl_post_LDADD = -lssl -lcrypto diff --git a/tests/gold_tests/tls/ssl-post.c b/tests/gold_tests/tls/ssl-post.c index bcac9d542c8..58376fdb6cf 100644 --- a/tests/gold_tests/tls/ssl-post.c +++ b/tests/gold_tests/tls/ssl-post.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -58,11 +59,18 @@ SSL_locking_callback(int mode, int type, const char *file, int line) } } +// In OpenSSL 1.1, locking and thread id logic was changed and the +// CRYPTO_THREADID_set_callback function became a macro defined to be 0. In +// later versions, therefore, static analysis tools flag the use of this as a +// problem. Thus in order to see whether CRYPTO_THREADID_set_callback is a +// valid function we check that it is not a defined macro. +#if !defined(CRYPTO_THREADID_set_callback) void SSL_pthreads_thread_id(CRYPTO_THREADID *id) { CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self()); } +#endif void * spawn_same_session_send(void *arg) @@ -280,7 +288,12 @@ main(int argc, char *argv[]) } CRYPTO_set_locking_callback(SSL_locking_callback); + +// See the '!defined(CRYPTO_THREADID_set_callback)' comment above for why we +// test for !defined here. +#if !defined(CRYPTO_THREADID_set_callback) CRYPTO_THREADID_set_callback(SSL_pthreads_thread_id); +#endif SSL_CTX *client_ctx = SSL_CTX_new(SSLv23_client_method()); SSL *ssl = SSL_new(client_ctx); @@ -291,6 +304,12 @@ main(int argc, char *argv[]) SSL_set_fd(ssl, sfd); int ret = SSL_connect(ssl); + if (ret <= 0) { + int error = SSL_get_error(ssl, ret); + printf("SSL_connect failed %d", error); + exit(1); + } + printf("Sent request\n"); if ((ret = SSL_write(ssl, req_buf, strlen(req_buf))) <= 0) { int error = SSL_get_error(ssl, ret); diff --git a/tests/gold_tests/tls/tls.test.py b/tests/gold_tests/tls/tls.test.py index 185ca7a8dae..85750f38bcd 100644 --- a/tests/gold_tests/tls/tls.test.py +++ b/tests/gold_tests/tls/tls.test.py @@ -24,9 +24,9 @@ ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True) server = Test.MakeOriginServer("server") -# build test code -tr=Test.Build(target='ssl-post',sources=['ssl-post.c']) -tr.Setup.Copy('ssl-post.c') +# ssl-post is built via `make`. Here we copy the built binary down to the test +# directory so that the test runs in this file can use it. +Test.Setup.Copy('ssl-post') requestLocation = "test2" reHost = "www.example.com" diff --git a/tests/gold_tests/tls/tls_hooks_client_verify.test.py b/tests/gold_tests/tls/tls_hooks_client_verify.test.py index becb6a9ace6..007b67fb2ec 100644 --- a/tests/gold_tests/tls/tls_hooks_client_verify.test.py +++ b/tests/gold_tests/tls/tls_hooks_client_verify.test.py @@ -70,7 +70,7 @@ ' verify_client: STRICT', ]) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_client_verify_test.cc'), ts, '-count=2 -good=foo.com') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_client_verify_test.so'), ts, '-count=2 -good=foo.com') tr = Test.AddTestRun("request good name") tr.Setup.Copy("ssl/signed-foo.pem") diff --git a/tests/gold_tests/tls/tls_hooks_verify.test.py b/tests/gold_tests/tls/tls_hooks_verify.test.py index 5b89fd45d5f..fec3b5823c7 100644 --- a/tests/gold_tests/tls/tls_hooks_verify.test.py +++ b/tests/gold_tests/tls/tls_hooks_verify.test.py @@ -65,7 +65,7 @@ ts.Disk.sni_yaml.AddLine( ' verify_server_policy: PERMISSIVE') -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_verify_test.cc'), ts, '-count=2 -bad=random.com -bad=bar.com') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_verify_test.so'), ts, '-count=2 -bad=random.com -bad=bar.com') tr = Test.AddTestRun("request good name") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls/tls_keepalive.test.py b/tests/gold_tests/tls/tls_keepalive.test.py index 11d39aa1f32..903cb4f1280 100644 --- a/tests/gold_tests/tls/tls_keepalive.test.py +++ b/tests/gold_tests/tls/tls_keepalive.test.py @@ -67,7 +67,7 @@ '''.split("\n") ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-preaccept=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-preaccept=1') tr = Test.AddTestRun("Test two HTTP/1.1 requests over one TLS connection") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks.test.py b/tests/gold_tests/tls_hooks/tls_hooks.test.py index 7383da232cb..ecceb4e2212 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks.test.py @@ -52,7 +52,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-preaccept=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-preaccept=1') tr = Test.AddTestRun("Test one preaccept hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks10.test.py b/tests/gold_tests/tls_hooks/tls_hooks10.test.py index 111280c4e0b..593b22ab2d2 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks10.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks10.test.py @@ -50,7 +50,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-cert=1 -i=2') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-cert=1 -i=2') tr = Test.AddTestRun("Test a combination of delayed and immediate cert hooks") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks11.test.py b/tests/gold_tests/tls_hooks/tls_hooks11.test.py index 587f630f24d..cb0143581be 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks11.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks11.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-d=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-d=1') tr = Test.AddTestRun("Test one delayed preaccept hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks12.test.py b/tests/gold_tests/tls_hooks/tls_hooks12.test.py index 4cb12d2e74a..b2913030528 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks12.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks12.test.py @@ -50,7 +50,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-p=2 -d=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-p=2 -d=1') tr = Test.AddTestRun("Test combination of delayed and immediate preaccept hook2") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks13.test.py b/tests/gold_tests/tls_hooks/tls_hooks13.test.py index aebe3fd46a6..a7953d3dfca 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks13.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks13.test.py @@ -50,7 +50,7 @@ 'map https://example.com:{0} https://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.SSL_Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-out_start=1 -out_close=2') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-out_start=1 -out_close=2') tr = Test.AddTestRun("Test outbound start and close") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks14.test.py b/tests/gold_tests/tls_hooks/tls_hooks14.test.py index 180f2a1645b..f1058c6d396 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks14.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks14.test.py @@ -50,7 +50,7 @@ 'map https://example.com:{0} https://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.SSL_Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-out_start_delay=2') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-out_start_delay=2') tr = Test.AddTestRun("Test outbound delay start") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks15.test.py b/tests/gold_tests/tls_hooks/tls_hooks15.test.py index 6220f4cff00..be22f81ac38 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks15.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks15.test.py @@ -50,7 +50,7 @@ 'map https://example.com:{0} https://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.SSL_Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-close=2 -out_close=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-close=2 -out_close=1') tr = Test.AddTestRun("Test one delayed preaccept hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks16.test.py b/tests/gold_tests/tls_hooks/tls_hooks16.test.py index 140fbb1bbf6..766e6b330fe 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks16.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks16.test.py @@ -54,7 +54,7 @@ 'map https://example.com:{1} http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-client_hello_imm=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-client_hello_imm=1') tr = Test.AddTestRun("Test one immediate client hello hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks17.test.py b/tests/gold_tests/tls_hooks/tls_hooks17.test.py index c3d0ed6ec24..9e32d5f2a77 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks17.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks17.test.py @@ -54,7 +54,7 @@ 'map https://example.com:{1} http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-client_hello=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-client_hello=1') tr = Test.AddTestRun("Test one delayed client hello hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks18.test.py b/tests/gold_tests/tls_hooks/tls_hooks18.test.py index ddc5cd73e17..732a429bfbd 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks18.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks18.test.py @@ -55,7 +55,7 @@ 'map https://example.com:{1} http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-client_hello=2') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-client_hello=2') tr = Test.AddTestRun("Test two client hello hooks") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks2.test.py b/tests/gold_tests/tls_hooks/tls_hooks2.test.py index 61803eb9f45..3e1fa1678ca 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks2.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks2.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-sni=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-sni=1') tr = Test.AddTestRun("Test one sni hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks3.test.py b/tests/gold_tests/tls_hooks/tls_hooks3.test.py index adf76ab6323..a7180fe50e1 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks3.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks3.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-cert=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-cert=1') tr = Test.AddTestRun("Test one cert hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks4.test.py b/tests/gold_tests/tls_hooks/tls_hooks4.test.py index 12b55ea4fe4..8247b89e0a7 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks4.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks4.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-cert=1 -sni=1 -preaccept=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-cert=1 -sni=1 -preaccept=1') tr = Test.AddTestRun("Test one sni, one preaccept, and one cert hook") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks6.test.py b/tests/gold_tests/tls_hooks/tls_hooks6.test.py index 200e4bd47de..54d28cfaee6 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks6.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks6.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-preaccept=2') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-preaccept=2') tr = Test.AddTestRun("Test two preaccept hooks") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks7.test.py b/tests/gold_tests/tls_hooks/tls_hooks7.test.py index f488cea1f3e..467570661ef 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks7.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks7.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-sni=2') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-sni=2') tr = Test.AddTestRun("Test two sni hooks") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks8.test.py b/tests/gold_tests/tls_hooks/tls_hooks8.test.py index 5af9a86efbe..88c3032aee9 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks8.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks8.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-cert=2') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-cert=2') tr = Test.AddTestRun("Test two cert hooks") tr.Processes.Default.StartBefore(server) diff --git a/tests/gold_tests/tls_hooks/tls_hooks9.test.py b/tests/gold_tests/tls_hooks/tls_hooks9.test.py index 8ad5c92ee99..95fd57caf0d 100644 --- a/tests/gold_tests/tls_hooks/tls_hooks9.test.py +++ b/tests/gold_tests/tls_hooks/tls_hooks9.test.py @@ -51,7 +51,7 @@ 'map https://example.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.ssl_port, server.Variables.Port) ) -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'ssl_hook_test.cc'), ts, '-i=1') +Test.PreparePlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 'ssl_hook_test.so'), ts, '-i=1') tr = Test.AddTestRun("Test one immediate cert hooks") tr.Processes.Default.StartBefore(server) diff --git a/tests/tools/plugins/Makefile.inc b/tests/tools/plugins/Makefile.inc new file mode 100644 index 00000000000..72824907328 --- /dev/null +++ b/tests/tools/plugins/Makefile.inc @@ -0,0 +1,85 @@ +# 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. + +noinst_LTLIBRARIES += tools/plugins/cert_update.la +tools_plugins_cert_update_la_SOURCES = tools/plugins/cert_update.cc + +noinst_LTLIBRARIES += tools/plugins/conf_remap_stripped.la +tools_plugins_conf_remap_stripped_la_SOURCES = tools/plugins/conf_remap_stripped.cc + +noinst_LTLIBRARIES += tools/plugins/continuations_verify.la +tools_plugins_continuations_verify_la_SOURCES = tools/plugins/continuations_verify.cc + +noinst_LTLIBRARIES += tools/plugins/cont_schedule.la +tools_plugins_cont_schedule_la_SOURCES = tools/plugins/cont_schedule.cc + +noinst_LTLIBRARIES += tools/plugins/custom204plugin.la +tools_plugins_custom204plugin_la_SOURCES = tools/plugins/custom204plugin.cc + +noinst_LTLIBRARIES += tools/plugins/emergency_shutdown.la +tools_plugins_emergency_shutdown_la_SOURCES = tools/plugins/emergency_shutdown.cc + +noinst_LTLIBRARIES += tools/plugins/fatal_shutdown.la +tools_plugins_fatal_shutdown_la_SOURCES = tools/plugins/fatal_shutdown.cc + +noinst_LTLIBRARIES += tools/plugins/hook_add_plugin.la +tools_plugins_hook_add_plugin_la_SOURCES = tools/plugins/hook_add_plugin.cc + +noinst_LTLIBRARIES += tools/plugins/missing_mangled_definition.la +tools_plugins_missing_mangled_definition_la_SOURCES = \ + tools/plugins/missing_mangled_definition_c.c \ + tools/plugins/missing_mangled_definition_cpp.cc \ + tools/plugins/missing_mangled_definition.h + +noinst_LTLIBRARIES += tools/plugins/missing_ts_plugin_init.la +tools_plugins_missing_ts_plugin_init_la_SOURCES = tools/plugins/missing_ts_plugin_init.cc + +noinst_LTLIBRARIES += tools/plugins/null_transform.la +tools_plugins_null_transform_la_SOURCES = tools/plugins/null_transform.c + +noinst_LTLIBRARIES += tools/plugins/request_buffer.la +tools_plugins_request_buffer_la_SOURCES = tools/plugins/request_buffer.cc + +noinst_LTLIBRARIES += tools/plugins/ssl_client_verify_test.la +tools_plugins_ssl_client_verify_test_la_SOURCES = tools/plugins/ssl_client_verify_test.cc + +noinst_LTLIBRARIES += tools/plugins/ssl_hook_test.la +tools_plugins_ssl_hook_test_la_SOURCES = tools/plugins/ssl_hook_test.cc + +noinst_LTLIBRARIES += tools/plugins/ssl_verify_test.la +tools_plugins_ssl_verify_test_la_SOURCES = tools/plugins/ssl_verify_test.cc + +noinst_LTLIBRARIES += tools/plugins/ssntxnorder_verify.la +tools_plugins_ssntxnorder_verify_la_SOURCES = tools/plugins/ssntxnorder_verify.cc + +noinst_LTLIBRARIES += tools/plugins/test_cppapi.la +tools_plugins_test_cppapi_la_SOURCES = tools/plugins/test_cppapi.cc +tools_plugins_test_cppapi_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -L$(top_builddir)/src/tscpp/api +tools_plugins_test_cppapi_la_LIBADD = -ltscppapi + +noinst_LTLIBRARIES += tools/plugins/test_hooks.la +tools_plugins_test_hooks_la_SOURCES = tools/plugins/test_hooks.cc + +noinst_LTLIBRARIES += tools/plugins/test_log_interface.la +tools_plugins_test_log_interface_la_SOURCES = tools/plugins/test_log_interface.cc + +noinst_LTLIBRARIES += tools/plugins/test_tsapi.la +tools_plugins_test_tsapi_la_SOURCES = tools/plugins/test_tsapi.cc + +noinst_LTLIBRARIES += tools/plugins/user_args.la +tools_plugins_user_args_la_SOURCES = tools/plugins/user_args.cc diff --git a/tests/tools/plugins/missing_mangled_definition.c b/tests/tools/plugins/missing_mangled_definition_c.c similarity index 100% rename from tests/tools/plugins/missing_mangled_definition.c rename to tests/tools/plugins/missing_mangled_definition_c.c diff --git a/tests/tools/plugins/missing_mangled_definition.cc b/tests/tools/plugins/missing_mangled_definition_cpp.cc similarity index 100% rename from tests/tools/plugins/missing_mangled_definition.cc rename to tests/tools/plugins/missing_mangled_definition_cpp.cc diff --git a/tests/tools/plugins/ssl_client_verify_test.cc b/tests/tools/plugins/ssl_client_verify_test.cc index c6967f799f2..17668b2c8ad 100644 --- a/tests/tools/plugins/ssl_client_verify_test.cc +++ b/tests/tools/plugins/ssl_client_verify_test.cc @@ -64,8 +64,12 @@ check_names(X509 *cert) X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, pos); ASN1_STRING *cn = X509_NAME_ENTRY_get_data(e); - char *subj_name = strndup(reinterpret_cast(ASN1_STRING_get0_data(cn)), ASN1_STRING_length(cn)); - retval = check_name(subj_name); +#if OPENSSL_VERSION_NUMBER >= 0x010100000 + char *subj_name = strndup(reinterpret_cast(ASN1_STRING_get0_data(cn)), ASN1_STRING_length(cn)); +#else + char *subj_name = strndup(reinterpret_cast(ASN1_STRING_data(cn)), ASN1_STRING_length(cn)); +#endif + retval = check_name(subj_name); free(subj_name); } } @@ -80,7 +84,11 @@ check_names(X509 *cert) name = sk_GENERAL_NAME_value(names, i); if (name->type == GEN_DNS) { char *dns = +#if OPENSSL_VERSION_NUMBER >= 0x010100000 strndup(reinterpret_cast(ASN1_STRING_get0_data(name->d.dNSName)), ASN1_STRING_length(name->d.dNSName)); +#else + strndup(reinterpret_cast(ASN1_STRING_data(name->d.dNSName)), ASN1_STRING_length(name->d.dNSName)); +#endif retval = check_name(dns); free(dns); } diff --git a/tests/tools/plugins/test_cppapi.cc b/tests/tools/plugins/test_cppapi.cc index c11865d7112..d87d0d1f5e7 100644 --- a/tests/tools/plugins/test_cppapi.cc +++ b/tests/tools/plugins/test_cppapi.cc @@ -115,9 +115,15 @@ f() ALWAYS_ASSERT(c2.asTSCont() != nullptr) ALWAYS_ASSERT(c2.mutex() == m) + // clang-analyzer warns about use-after-move for the following, but the + // atscppapi::Continuation API is designed to support use after move and this + // test intentionally exercises this behavior. Thus we disable clang-analyzer + // for this code. +#ifndef __clang_analyzer__ ALWAYS_ASSERT(!c) ALWAYS_ASSERT(c.asTSCont() == nullptr) ALWAYS_ASSERT(c.mutex() == nullptr) +#endif TestCont c3; @@ -131,9 +137,13 @@ f() ALWAYS_ASSERT(c3.asTSCont() != nullptr) ALWAYS_ASSERT(c3.mutex() == m) + // See the user-after-move comment above for the reason we disable + // clang-analyzer here. +#ifndef __clang_analyzer__ ALWAYS_ASSERT(!c2) ALWAYS_ASSERT(c2.asTSCont() == nullptr) ALWAYS_ASSERT(c2.mutex() == nullptr) +#endif c3.destroy();