From 63370b4441458b8dc4dbfa9441bc35531aa7b508 Mon Sep 17 00:00:00 2001 From: Mike Ellery Date: Tue, 26 Jun 2018 14:15:13 -0700 Subject: [PATCH] Default to ipv4 for unit tests, add ipv6 option --- .travis.yml | 4 ++-- Builds/Test.py | 11 ++++++++++- Jenkinsfile | 1 + src/ripple/app/main/Main.cpp | 9 ++++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97dc691f95..3eb5967d89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ matrix: include: - compiler: gcc - env: GCC_VER=5 TARGET=debug APP_ARGS="--unittest-ipv4" + env: GCC_VER=5 TARGET=debug # - compiler: gcc # env: GCC_VER=5 TARGET=debug.nounity @@ -45,7 +45,7 @@ matrix: # env: GCC_VER=5 TARGET=coverage PATH=$PWD/cmake/bin:$PATH - compiler: clang - env: GCC_VER=5 TARGET=debug APP_ARGS="--unittest-ipv4" + env: GCC_VER=5 TARGET=debug # - compiler: clang # env: GCC_VER=5 TARGET=debug.nounity diff --git a/Builds/Test.py b/Builds/Test.py index 5c6a9b3e40..1a321c4b9b 100755 --- a/Builds/Test.py +++ b/Builds/Test.py @@ -130,6 +130,12 @@ parser.add_argument( help='Run tests in parallel' ) +parser.add_argument( + '--ipv6', + action='store_true', + help='Use IPv6 localhost when running unit tests.', +) + parser.add_argument( '--clean', '-c', action='store_true', @@ -292,13 +298,16 @@ def run_cmake_tests(directory, target, config): testflag = '--unittest' quiet = '' testjobs = '' + ipv6 = '' if ARGS.test: testflag += ('=' + ARGS.test) if ARGS.quiet: quiet = '-q' + if ARGS.ipv6: + ipv6 = '--unittest-ipv6' if ARGS.testjobs: testjobs = ('--unittest-jobs=' + str(ARGS.testjobs)) - resultcode, lines = shell(executable, (testflag, quiet, testjobs,)) + resultcode, lines = shell(executable, (testflag, quiet, testjobs, ipv6)) if resultcode: if not ARGS.verbose: diff --git a/Jenkinsfile b/Jenkinsfile index d3628e5eb3..1237531d1f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -200,6 +200,7 @@ try { 'NINJA_BUILD=false', "CCACHE_BASEDIR=${cdir}", 'PLANTUML_JAR=/opt/plantuml/plantuml.jar', + 'APP_ARGS=--unittest-ipv6', 'CCACHE_NOHASHDIR=true', "CC=${cc}", "CXX=${cxx}", diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index fd81bff21d..5641e83cd9 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -216,7 +216,7 @@ static int runUnitTests( bool quiet, bool log, bool child, - bool ipv4, + bool ipv6, std::size_t num_jobs, int argc, char** argv) @@ -224,8 +224,7 @@ static int runUnitTests( using namespace beast::unit_test; using namespace ripple::test; - if (ipv4) - ripple::test::envUseIPv4 = true; + ripple::test::envUseIPv4 = (! ipv6); if (!child && num_jobs == 1) { @@ -376,7 +375,7 @@ int run (int argc, char** argv) "argument is handled individually by any suite that accesses it -- " "as such, it typically only make sense to provide this when running " "a single suite.") - ("unittest-ipv4", "Use IPv4 localhost when running unittests (default is IPv6).") + ("unittest-ipv6", "Use IPv6 localhost when running unittests (default is IPv4).") ("unittest-log", "Force unit test log message output. Only useful in combination with " "--quiet, in which case log messages will print but suite/case names " @@ -457,7 +456,7 @@ int run (int argc, char** argv) bool (vm.count ("quiet")), bool (vm.count ("unittest-log")), unittestChild, - bool (vm.count ("unittest-ipv4")), + bool (vm.count ("unittest-ipv6")), numJobs, argc, argv);