From e60e3b251e7a083186b6226fcf14db85323b4e75 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Wed, 26 Oct 2016 14:35:36 +0200 Subject: [PATCH] Bug 1312964 - Add linux64-fuzz to TC and run *Fuzz* gtests r=franziskus Differential Revision: https://nss-dev.phacility.com/D122 --HG-- extra : amend_source : 997356ad17f255caa646a2498e20ea56f91cf9ea --- automation/taskcluster/graph/src/extend.js | 61 +++++++++++++++++++ .../taskcluster/graph/src/try_syntax.js | 9 ++- automation/taskcluster/scripts/build_gyp.sh | 4 +- external_tests/der_gtest/der_gtest.gyp | 5 -- external_tests/util_gtest/util_gtest.gyp | 5 -- lib/freebl/loader.c | 2 +- tests/gtests/gtests.sh | 3 +- 7 files changed, 73 insertions(+), 16 deletions(-) diff --git a/automation/taskcluster/graph/src/extend.js b/automation/taskcluster/graph/src/extend.js index 65cf4a76e5..16395f8198 100644 --- a/automation/taskcluster/graph/src/extend.js +++ b/automation/taskcluster/graph/src/extend.js @@ -158,6 +158,8 @@ export default async function main() { collection: "debug" }); + await scheduleFuzzing(); + await scheduleTools(); await scheduleLinux("Linux 32 (ARM, debug)", { @@ -256,6 +258,65 @@ async function scheduleLinux(name, base) { /*****************************************************************************/ +async function scheduleFuzzing() { + let base = { + env: { + ASAN_OPTIONS: "allocator_may_return_null=1", + UBSAN_OPTIONS: "print_stacktrace=1", + CC: "clang", + CCC: "clang++", + USE_64: "1" + }, + platform: "linux64", + collection: "fuzz", + image: LINUX_IMAGE + }; + + // Build base definition. + let build_base = merge({ + command: [ + "/bin/bash", + "-c", + "bin/checkout.sh && " + + "nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz" + ], + artifacts: { + public: { + expires: 24 * 7, + type: "directory", + path: "/home/worker/artifacts" + } + }, + kind: "build", + symbol: "B" + }, base); + + // The task that builds NSPR+NSS. + let task_build = queue.scheduleTask(merge(build_base, { + name: "Linux x64 (debug, fuzz)" + })); + + // Schedule tests. + queue.scheduleTask(merge(base, { + parent: task_build, + name: "Gtests", + command: [ + "/bin/bash", + "-c", + "bin/checkout.sh && nss/automation/taskcluster/scripts/run_tests.sh" + ], + env: {GTESTFILTER: "*Fuzz*"}, + symbol: "Gtest", + tests: "gtests", + cycle: "standard", + kind: "test" + })); + + return queue.submit(); +} + +/*****************************************************************************/ + async function scheduleWindows(name, base) { base = merge(base, { workerType: "nss-win2012r2", diff --git a/automation/taskcluster/graph/src/try_syntax.js b/automation/taskcluster/graph/src/try_syntax.js index 9845b1f32f..8a6d118b0c 100644 --- a/automation/taskcluster/graph/src/try_syntax.js +++ b/automation/taskcluster/graph/src/try_syntax.js @@ -22,7 +22,8 @@ function parseOptions(opts) { } // Parse platforms. - let allPlatforms = ["linux", "linux64", "linux64-asan", "win64", "arm", "linux64-gyp"]; + let allPlatforms = ["linux", "linux64", "linux64-asan", "win64", "arm", + "linux64-gyp", "linux64-fuzz"]; let platforms = intersect(opts.platform.split(/\s*,\s*/), allPlatforms); // If the given value is nonsense or "none" default to all platforms. @@ -101,6 +102,7 @@ function filter(opts) { let aliases = { "linux": "linux32", "linux64-asan": "linux64", + "linux64-fuzz": "linux64", "linux64-gyp": "linux64", "win64": "windows2012-64", "arm": "linux32" @@ -116,6 +118,8 @@ function filter(opts) { keep &= coll("arm-opt") || coll("arm-debug"); } else if (platform == "linux64-gyp") { keep &= coll("gyp"); + } else if (platform == "linux64-fuzz") { + keep &= coll("fuzz"); } else { keep &= coll("opt") || coll("debug"); } @@ -128,7 +132,8 @@ function filter(opts) { } // Finally, filter by build type. - let isDebug = coll("debug") || coll("asan") || coll("ubsan") || coll("arm-debug") || coll("gyp"); + let isDebug = coll("debug") || coll("asan") || coll("ubsan") || + coll("arm-debug") || coll("gyp") || coll("fuzz"); return (isDebug && opts.builds.includes("d")) || (!isDebug && opts.builds.includes("o")); } diff --git a/automation/taskcluster/scripts/build_gyp.sh b/automation/taskcluster/scripts/build_gyp.sh index 78f75c2d72..4f52573665 100755 --- a/automation/taskcluster/scripts/build_gyp.sh +++ b/automation/taskcluster/scripts/build_gyp.sh @@ -4,14 +4,14 @@ source $(dirname $0)/tools.sh if [[ $(id -u) -eq 0 ]]; then # Drop privileges by re-running this script. - exec su worker $0 + exec su worker -c "$0 $*" fi # Clone NSPR if needed. hg_clone https://hg.mozilla.org/projects/nspr nspr default # Build. -nss/build.sh -g -v +nss/build.sh ${*-"-g -v"} # Package. mkdir artifacts diff --git a/external_tests/der_gtest/der_gtest.gyp b/external_tests/der_gtest/der_gtest.gyp index 6c2f5116fe..2d60bb6ac7 100644 --- a/external_tests/der_gtest/der_gtest.gyp +++ b/external_tests/der_gtest/der_gtest.gyp @@ -16,12 +16,7 @@ ], 'dependencies': [ '<(DEPTH)/exports.gyp:nss_exports', - '<(DEPTH)/lib/nss/nss.gyp:nss3', - '<(DEPTH)/lib/util/util.gyp:nssutil3', - '<(DEPTH)/lib/smime/smime.gyp:smime3', - '<(DEPTH)/lib/ssl/ssl.gyp:ssl3', '<(DEPTH)/external_tests/google_test/google_test.gyp:gtest', - '<(DEPTH)/cmd/lib/lib.gyp:sectool' ] } ], diff --git a/external_tests/util_gtest/util_gtest.gyp b/external_tests/util_gtest/util_gtest.gyp index e10840a179..bd99b35da2 100644 --- a/external_tests/util_gtest/util_gtest.gyp +++ b/external_tests/util_gtest/util_gtest.gyp @@ -16,13 +16,8 @@ ], 'dependencies': [ '<(DEPTH)/exports.gyp:nss_exports', - '<(DEPTH)/lib/nss/nss.gyp:nss3', - '<(DEPTH)/lib/util/util.gyp:nssutil3', - '<(DEPTH)/lib/smime/smime.gyp:smime3', - '<(DEPTH)/lib/ssl/ssl.gyp:ssl3', '<(DEPTH)/external_tests/google_test/google_test.gyp:gtest', '<(DEPTH)/lib/util/util.gyp:nssutil', - '<(DEPTH)/cmd/lib/lib.gyp:sectool' ] } ], diff --git a/lib/freebl/loader.c b/lib/freebl/loader.c index 3239d73a6d..84876c12cb 100644 --- a/lib/freebl/loader.c +++ b/lib/freebl/loader.c @@ -814,7 +814,7 @@ BL_Unload(void) char *disableUnload = NULL; vector = NULL; disableUnload = PR_GetEnvSecure("NSS_DISABLE_UNLOAD"); - if (!disableUnload) { + if (blLib && !disableUnload) { #ifdef DEBUG PRStatus status = PR_UnloadLibrary(blLib); PORT_Assert(PR_SUCCESS == status); diff --git a/tests/gtests/gtests.sh b/tests/gtests/gtests.sh index 1bf784428b..f91349b9e7 100755 --- a/tests/gtests/gtests.sh +++ b/tests/gtests/gtests.sh @@ -55,7 +55,8 @@ gtest_start() GTESTREPORT="$GTESTDIR/report.xml" PARSED_REPORT="$GTESTDIR/report.parsed" echo "executing $i" - ${BINDIR}/$i -d "$GTESTDIR" --gtest_output=xml:"${GTESTREPORT}" + ${BINDIR}/$i -d "$GTESTDIR" --gtest_output=xml:"${GTESTREPORT}" \ + --gtest_filter="${GTESTFILTER-*}" html_msg $? 0 "$i run successfully" echo "test output dir: ${GTESTREPORT}" echo "executing sed to parse the xml report"