summaryrefslogtreecommitdiffstats
path: root/security/nss/mach
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-12-17 14:12:04 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-12-17 14:12:04 +0100
commit51b821b3fdc5a7eab2369cb6a6680598a6264b08 (patch)
treef3608a518bbb9e31b0a42b9a10742fb11ef5b39b /security/nss/mach
parent8e44bbb43789e585fab9fc1ce8becc94b45d566c (diff)
parent680c3eadb6aaec1f3653636db081a519e0f62ef5 (diff)
downloadUXP-51b821b3fdc5a7eab2369cb6a6680598a6264b08.tar
UXP-51b821b3fdc5a7eab2369cb6a6680598a6264b08.tar.gz
UXP-51b821b3fdc5a7eab2369cb6a6680598a6264b08.tar.lz
UXP-51b821b3fdc5a7eab2369cb6a6680598a6264b08.tar.xz
UXP-51b821b3fdc5a7eab2369cb6a6680598a6264b08.zip
Merge branch 'master' into Sync-weave
Diffstat (limited to 'security/nss/mach')
-rw-r--r--security/nss/mach95
1 files changed, 79 insertions, 16 deletions
diff --git a/security/nss/mach b/security/nss/mach
index 715f1a9e3..178cfeb74 100644
--- a/security/nss/mach
+++ b/security/nss/mach
@@ -10,13 +10,32 @@
import sys
import argparse
+import fnmatch
import subprocess
import os
import platform
+import tempfile
+
from hashlib import sha256
+DEVNULL = open(os.devnull, 'wb')
cwd = os.path.dirname(os.path.abspath(__file__))
+def run_tests(test, cycles="standard", env={}, silent=False):
+ domsuf = os.getenv('DOMSUF', "localdomain")
+ host = os.getenv('HOST', "localhost")
+ env = env.copy()
+ env.update({
+ "NSS_TESTS": test,
+ "NSS_CYCLES": cycles,
+ "DOMSUF": domsuf,
+ "HOST": host
+ })
+ os_env = os.environ
+ os_env.update(env)
+ command = cwd + "/tests/all.sh"
+ stdout = stderr = DEVNULL if silent else None
+ subprocess.check_call(command, env=os_env, stdout=stdout, stderr=stderr)
class cfAction(argparse.Action):
docker_command = ["docker"]
@@ -103,7 +122,7 @@ class cfAction(argparse.Action):
files = []
if os.path.exists(os.path.join(cwd, '.hg')):
st = subprocess.Popen(['hg', 'status', '-m', '-a'],
- cwd=cwd, stdout=subprocess.PIPE)
+ cwd=cwd, stdout=subprocess.PIPE, universal_newlines=True)
for line in iter(st.stdout.readline, ''):
files += [line[2:].rstrip()]
elif os.path.exists(os.path.join(cwd, '.git')):
@@ -127,29 +146,63 @@ class cfAction(argparse.Action):
class buildAction(argparse.Action):
def __call__(self, parser, args, values, option_string=None):
- cwd = os.path.dirname(os.path.abspath(__file__))
subprocess.check_call([cwd + "/build.sh"] + values)
class testAction(argparse.Action):
- def runTest(self, test, cycles="standard"):
- cwd = os.path.dirname(os.path.abspath(__file__))
- domsuf = os.getenv('DOMSUF', "localdomain")
- host = os.getenv('HOST', "localhost")
+ def __call__(self, parser, args, values, option_string=None):
+ run_tests(values)
+
+
+class covAction(argparse.Action):
+
+ def runSslGtests(self, outdir):
env = {
- "NSS_TESTS": test,
- "NSS_CYCLES": cycles,
- "DOMSUF": domsuf,
- "HOST": host
+ "GTESTFILTER": "*", # Prevent parallel test runs.
+ "ASAN_OPTIONS": "coverage=1:coverage_dir=" + outdir
}
- os_env = os.environ
- os_env.update(env)
- command = cwd + "/tests/all.sh"
- subprocess.check_call(command, env=os_env)
+
+ run_tests("ssl_gtests", env=env, silent=True)
+
+ def findSanCovFile(self, outdir):
+ for file in os.listdir(outdir):
+ if fnmatch.fnmatch(file, 'ssl_gtest.*.sancov'):
+ return os.path.join(outdir, file)
+
+ return None
def __call__(self, parser, args, values, option_string=None):
- self.runTest(values)
+ outdir = args.outdir
+ print("Output directory: " + outdir)
+
+ print("\nBuild with coverage sanitizers...\n")
+ sancov_args = "edge,no-prune,trace-pc-guard,trace-cmp"
+ subprocess.check_call([
+ os.path.join(cwd, "build.sh"), "-c", "--clang", "--asan",
+ "--sancov=" + sancov_args
+ ])
+
+ print("\nRun ssl_gtests to get a coverage report...")
+ self.runSslGtests(outdir)
+ print("Done.")
+
+ sancov_file = self.findSanCovFile(outdir)
+ if not sancov_file:
+ print("Couldn't find .sancov file.")
+ sys.exit(1)
+
+ symcov_file = os.path.join(outdir, "ssl_gtest.symcov")
+ out = open(symcov_file, 'wb')
+ subprocess.check_call([
+ "sancov",
+ "-blacklist=" + os.path.join(cwd, ".sancov-blacklist"),
+ "-symbolize", sancov_file,
+ os.path.join(cwd, "../dist/Debug/bin/ssl_gtest")
+ ], stdout=out)
+ out.close()
+
+ print("\nCoverage report: " + symcov_file)
class commandsAction(argparse.Action):
@@ -194,11 +247,21 @@ def parse_arguments():
tests = [
"cipher", "lowhash", "chains", "cert", "dbtests", "tools", "fips",
"sdr", "crmf", "smime", "ssl", "ocsp", "merge", "pkits", "ec",
- "gtests", "ssl_gtests"
+ "gtests", "ssl_gtests", "bogo", "interop", "policy"
]
parser_test.add_argument(
'test', choices=tests, help="Available tests", action=testAction)
+ parser_cov = subparsers.add_parser(
+ 'coverage', help='Generate coverage report')
+ cov_modules = ["ssl_gtests"]
+ parser_cov.add_argument(
+ '--outdir', help='Output directory for coverage report data.',
+ default=tempfile.mkdtemp())
+ parser_cov.add_argument(
+ 'module', choices=cov_modules, help="Available coverage modules",
+ action=covAction)
+
parser_commands = subparsers.add_parser(
'mach-commands',
help="list commands")