You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by dr...@apache.org on 2017/11/20 17:30:29 UTC
[trafficserver] branch master updated: Clean up tls test
This is an automated email from the ASF dual-hosted git repository.
dragon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 9dd7597 Clean up tls test
9dd7597 is described below
commit 9dd7597d07844a40907ce8d99f1c16bce281acba
Author: Jason Kenny <dr...@live.com>
AuthorDate: Fri Nov 17 17:39:54 2017 -0600
Clean up tls test
Clean up some of the extension code
Add a general Build functions that gets flags from tsxs
---
tests/gold_tests/autest-site/build.test.ext | 53 ++++++++++++++++++++++
tests/gold_tests/autest-site/microDNS.test.ext | 4 +-
tests/gold_tests/autest-site/microserver.test.ext | 5 +-
tests/gold_tests/autest-site/setup.cli.ext | 41 +++++++++++++----
.../gold_tests/autest-site/trafficserver.test.ext | 2 +-
tests/gold_tests/tls/ssl-post.c | 4 +-
tests/gold_tests/tls/tls.test.py | 21 ++-------
7 files changed, 97 insertions(+), 33 deletions(-)
diff --git a/tests/gold_tests/autest-site/build.test.ext b/tests/gold_tests/autest-site/build.test.ext
new file mode 100644
index 0000000..ef8aa42
--- /dev/null
+++ b/tests/gold_tests/autest-site/build.test.ext
@@ -0,0 +1,53 @@
+'''
+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/microDNS.test.ext b/tests/gold_tests/autest-site/microDNS.test.ext
index fcae605..94cf299 100644
--- a/tests/gold_tests/autest-site/microDNS.test.ext
+++ b/tests/gold_tests/autest-site/microDNS.test.ext
@@ -100,5 +100,5 @@ def MakeDNServer(obj, name, filename="dns_file.json", port=False, IP='127.0.0.1'
return p
-AddTestRunSet(MakeDNServer, name="MakeDNServer")
-AddTestRunSet(MakeDNServer, name="MakeDNS")
+ExtendTest(MakeDNServer, name="MakeDNServer")
+ExtendTest(MakeDNServer, name="MakeDNS")
diff --git a/tests/gold_tests/autest-site/microserver.test.ext b/tests/gold_tests/autest-site/microserver.test.ext
index 4c7654c..0261789 100644
--- a/tests/gold_tests/autest-site/microserver.test.ext
+++ b/tests/gold_tests/autest-site/microserver.test.ext
@@ -131,5 +131,6 @@ def MakeOriginServer(obj, name, port=False, ip=False, delay=False, public_ip=Fal
return p
-AddTestRunSet(MakeOriginServer, name="MakeOriginServer")
-AddTestRunSet(MakeOriginServer, name="MakeOrigin")
+ExtendTest(MakeOriginServer, name="MakeOriginServer")
+ExtendTest(MakeOriginServer, name="MakeOrigin")
+
diff --git a/tests/gold_tests/autest-site/setup.cli.ext b/tests/gold_tests/autest-site/setup.cli.ext
index c5a2284..a67b9f1 100644
--- a/tests/gold_tests/autest-site/setup.cli.ext
+++ b/tests/gold_tests/autest-site/setup.cli.ext
@@ -16,37 +16,60 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import json, subprocess
+import json
+import subprocess
import pprint
if Arguments.ats_bin is not None:
# Add environment variables
ENV['ATS_BIN'] = Arguments.ats_bin
-
+
if ENV['ATS_BIN'] is not None:
# Add variables for Tests
traffic_layout = os.path.join(ENV['ATS_BIN'], "traffic_layout")
+ tsxs = os.path.join(ENV['ATS_BIN'], "tsxs")
if not os.path.isdir(ENV['ATS_BIN']):
host.WriteError("--ats-bin requires a directory", show_stack=False)
+ # setting up data from traffic_layout
+ # this is getting layout structure
if not os.path.isfile(traffic_layout):
host.WriteError("traffic_layout is not found. Aborting tests - Bad build or install.", show_stack=False)
try:
out = subprocess.check_output([traffic_layout, "--json"])
except subprocess.CalledProcessError:
- host.WriteError("traffic_layout is broken. Aborting tests - The build of traffic server is bad.", show_stack=False)
+ host.WriteError("traffic_layout is broken. Aborting tests - The build of traffic server is bad.", show_stack=False)
out = json.loads(out.decode("utf-8"))
- for k,v in out.items():
- out[k]=v[:-1] if v.endswith('/') else v
+ for k, v in out.items():
+ out[k] = v[:-1] if v.endswith('/') else v
Variables.update(out)
- host.WriteVerbose(['ats'],"Traffic server layout Data:\n",pprint.pformat(out))
+ host.WriteVerbose(['ats'], "Traffic server layout Data:\n", pprint.pformat(out))
# if the above worked this should as well
+ # this gets feature data
out = subprocess.check_output([traffic_layout, "-f", "--json"])
out = json.loads(out.decode("utf-8"))
Variables.update(out)
- host.WriteVerbose(['ats'],"Traffic server feature data:\n",pprint.pformat(out))
+ host.WriteVerbose(['ats'], "Traffic server feature data:\n", pprint.pformat(out))
-Variables.AtsTestToolsDir = os.path.join(AutestSitePath,'../../tools')
+ # this querys tsxs for build flags so we can build code for the tests and get certain
+ # useful flags as which openssl to use when we don't use the system version
+ out = {
+ 'CPPFLAGS': '',
+ 'LIBS': '',
+ 'LDFLAGS': '',
+ 'CXX': ''
+ }
+ if os.path.isfile(tsxs):
+ for flag in out.keys():
+ try:
+ data = subprocess.check_output([tsxs, "-q", flag])
+ out[flag] = data.decode("utf-8")[:-1]
+ except subprocess.CalledProcessError:
+ # error if something goes wrong as the test will break if this exists and is broken
+ host.WriteError("tsxs is broken. Aborting tests", show_stack=False)
+ host.WriteVerbose(['ats'], "Traffic server build flags:\n", pprint.pformat(out))
+ Variables.update(out)
+Variables.AtsTestToolsDir = os.path.join(AutestSitePath, '../../tools')
# modify delay times as we always have to kill Trafficserver
# no need to wait
-Variables.Autest.StopProcessLongDelaySeconds=0
+Variables.Autest.StopProcessLongDelaySeconds = 0
diff --git a/tests/gold_tests/autest-site/trafficserver.test.ext b/tests/gold_tests/autest-site/trafficserver.test.ext
index d678def..b0a7a3e 100755
--- a/tests/gold_tests/autest-site/trafficserver.test.ext
+++ b/tests/gold_tests/autest-site/trafficserver.test.ext
@@ -402,4 +402,4 @@ def addSSLfile(self, filename):
RegisterFileType(Config, "ats:config")
RegisterFileType(RecordsConfig, "ats:config:records")
-AddTestRunSet(MakeATSProcess, name="MakeATSProcess")
+ExtendTest(MakeATSProcess, name="MakeATSProcess")
diff --git a/tests/gold_tests/tls/ssl-post.c b/tests/gold_tests/tls/ssl-post.c
index b68f007..cc8ea13 100644
--- a/tests/gold_tests/tls/ssl-post.c
+++ b/tests/gold_tests/tls/ssl-post.c
@@ -231,7 +231,7 @@ main(int argc, char *argv[])
int thread_count = atoi(argv[2]);
- char *port = argc == 5 ? argv[4] : "443";
+ const char *port = argc == 5 ? argv[4] : "443";
/* Obtain address(es) matching host/port */
@@ -308,7 +308,7 @@ main(int argc, char *argv[])
struct thread_info tinfo;
tinfo.rp = rp;
tinfo.session = session;
- pthread_t *threads = malloc(thread_count * sizeof(pthread_t));
+ pthread_t *threads = (pthread_t *)malloc(thread_count * sizeof(pthread_t));
for (i = 0; i < thread_count; i++) {
pthread_create(threads + i, NULL, spawn_same_session_send, &tinfo);
}
diff --git a/tests/gold_tests/tls/tls.test.py b/tests/gold_tests/tls/tls.test.py
index 679209c..f1ef8cd 100644
--- a/tests/gold_tests/tls/tls.test.py
+++ b/tests/gold_tests/tls/tls.test.py
@@ -21,31 +21,18 @@ Test.Summary = '''
Test tls
'''
-
-def Build(Test, filename, host):
- tr = Test.AddTestRun("Build", "Build test file: {0}".format(filename))
- tr.Command = 'gcc -o ssl-post -O2 -g {0} -lssl -lpthread -lcrypto'.format(filename)
- tr.ReturnCode = 0
- tr = Test.addTestRun("Run-Test")
- tr.Command = './ssl-post {0} 40 378'.format(host)
-
-# ExtendTest(Build)
-
-
# need Curl
Test.SkipUnless(
Condition.HasProgram("curl", "Curl need to be installed on system for this test to work")
)
-Test.ContinueOnFail = True
+
# Define default ATS
ts = Test.MakeATSProcess("ts", select_ports=False)
server = Test.MakeOriginServer("server")
-
-tr = Test.AddTestRun("Build-Test", "build test file: ssl-post.c")
-tr.Command = 'gcc -o ssl-post -O2 -g {0}/ssl-post.c -lssl -lpthread -lcrypto'.format(Test.RunDirectory)
-tr.ReturnCode = 0
-tr.Setup.CopyAs('ssl-post.c', Test.RunDirectory)
+# build test code
+tr=Test.Build(target='ssl-post',sources=['ssl-post.c'])
+tr.Setup.Copy('ssl-post.c')
requestLocation = "test2"
reHost = "www.example.com"
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].