diff --git a/.travis.yml b/.travis.yml index d8c9e385bbc..d770e7261f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,11 @@ before_install: - sudo apt-get update -qq - sudo apt-get install -qq libgtest-dev libgflags-dev python-virtualenv script: - - ./tools/run_tests/run_tests.py -l c -t -j 16 -c dbg - - ./tools/run_tests/run_tests.py -l c++ -t -j 16 -c dbg + - ./tools/run_tests/run_tests.py -l c -t -j 16 -c dbg -s 2.0 + - ./tools/run_tests/run_tests.py -l c++ -t -j 16 -c dbg -s 2.0 - make clean - - ./tools/run_tests/run_tests.py -l c -t -j 16 -c opt - - ./tools/run_tests/run_tests.py -l c++ -t -j 16 -c opt + - ./tools/run_tests/run_tests.py -l c -t -j 16 -c opt -s 2.0 + - ./tools/run_tests/run_tests.py -l c++ -t -j 16 -c opt -s 2.0 - ./tools/run_tests/run_tests.py -l node -t -j 16 -c opt notifications: email: false diff --git a/Makefile b/Makefile index 2baf0d6ba2a..c850ec77533 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ LDXX_valgrind = g++ CPPFLAGS_valgrind = -O0 OPENSSL_CFLAGS_valgrind = -DPURIFY LDFLAGS_valgrind = -DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_FACTOR=20 +DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_tsan = 1 REQUIRE_CUSTOM_LIBRARIES_tsan = 1 @@ -87,7 +87,7 @@ LD_tsan = clang LDXX_tsan = clang++ CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer LDFLAGS_tsan = -fsanitize=thread -DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=10 +DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_asan = 1 REQUIRE_CUSTOM_LIBRARIES_asan = 1 @@ -97,7 +97,7 @@ LD_asan = clang LDXX_asan = clang++ CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer LDFLAGS_asan = -fsanitize=address -DEFINES_asan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=5 +DEFINES_asan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -108,7 +108,7 @@ LDXX_msan = clang++-libc++ CPPFLAGS_msan = -O1 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 OPENSSL_CFLAGS_msan = -DPURIFY LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=20 +DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_ubsan = 1 REQUIRE_CUSTOM_LIBRARIES_ubsan = 1 @@ -119,7 +119,7 @@ LDXX_ubsan = clang++ CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer OPENSSL_CFLAGS_ubsan = -DPURIFY LDFLAGS_ubsan = -fsanitize=undefined -DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=10 +DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_gcov = 1 CC_gcov = gcc @@ -178,6 +178,10 @@ CPPFLAGS += $(CPPFLAGS_$(CONFIG)) DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\" LDFLAGS += $(LDFLAGS_$(CONFIG)) +ifdef EXTRA_DEFINES +DEFINES += $(EXTRA_DEFINES) +endif + CFLAGS += -std=c89 -pedantic ifeq ($(HAS_CXX11),true) CXXFLAGS += -std=c++11 diff --git a/templates/Makefile.template b/templates/Makefile.template index 491f142142e..0413f19e44e 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -94,7 +94,7 @@ LDXX_valgrind = g++ CPPFLAGS_valgrind = -O0 OPENSSL_CFLAGS_valgrind = -DPURIFY LDFLAGS_valgrind = -DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_FACTOR=20 +DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_tsan = 1 REQUIRE_CUSTOM_LIBRARIES_tsan = 1 @@ -104,7 +104,7 @@ LD_tsan = clang LDXX_tsan = clang++ CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer LDFLAGS_tsan = -fsanitize=thread -DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=10 +DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_asan = 1 REQUIRE_CUSTOM_LIBRARIES_asan = 1 @@ -114,7 +114,7 @@ LD_asan = clang LDXX_asan = clang++ CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer LDFLAGS_asan = -fsanitize=address -DEFINES_asan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=5 +DEFINES_asan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -125,7 +125,7 @@ LDXX_msan = clang++-libc++ CPPFLAGS_msan = -O1 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 OPENSSL_CFLAGS_msan = -DPURIFY LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=20 +DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_ubsan = 1 REQUIRE_CUSTOM_LIBRARIES_ubsan = 1 @@ -136,7 +136,7 @@ LDXX_ubsan = clang++ CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer OPENSSL_CFLAGS_ubsan = -DPURIFY LDFLAGS_ubsan = -fsanitize=undefined -DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_FACTOR=10 +DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_gcov = 1 CC_gcov = gcc @@ -195,6 +195,10 @@ CPPFLAGS += $(CPPFLAGS_$(CONFIG)) DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\" LDFLAGS += $(LDFLAGS_$(CONFIG)) +ifdef EXTRA_DEFINES +DEFINES += EXTRA_DEFINES +endif + CFLAGS += -std=c89 -pedantic ifeq ($(HAS_CXX11),true) CXXFLAGS += -std=c++11 diff --git a/test/build/c++11.cc b/test/build/c++11.cc index 519395f20a4..4822a20e7f2 100644 --- a/test/build/c++11.cc +++ b/test/build/c++11.cc @@ -31,7 +31,7 @@ * */ -/* This is just a compilation test, to see if we have zlib installed. */ +/* This is just a compilation test, to see if we have C++11. */ #include #include diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 55150a7cedc..36f13e1b51e 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -117,9 +117,10 @@ int grpc_pick_unused_port(void) { for (;;) { int port; - if (try == 0) { + try++; + if (try == 1) { port = getpid() % (65536 - 30000) + 30000; - } else if (try < NUM_RANDOM_PORTS_TO_PICK) { + } else if (try <= NUM_RANDOM_PORTS_TO_PICK) { port = rand() % (65536 - 30000) + 30000; } else { port = 0; diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index 1c464073114..1f0f0175b1c 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -34,6 +34,7 @@ #include "test/core/util/test_config.h" #include +#include #include #include @@ -52,6 +53,9 @@ void grpc_test_init(int argc, char **argv) { /* disable SIGPIPE */ signal(SIGPIPE, SIG_IGN); #endif + gpr_log(GPR_DEBUG, "test slowdown: machine=%f build=%f total=%f", + GRPC_TEST_SLOWDOWN_MACHINE_FACTOR, GRPC_TEST_SLOWDOWN_BUILD_FACTOR, + GRPC_TEST_SLOWDOWN_FACTOR); /* seed rng with pid, so we don't end up with the same random numbers as a concurrently running test binary */ srand(seed()); diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 74c2a3cf1b1..5292c7b525e 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -40,16 +40,23 @@ extern "C" { #endif /* __cplusplus */ -#ifndef GRPC_TEST_SLOWDOWN_FACTOR -#define GRPC_TEST_SLOWDOWN_FACTOR 1.0 +#ifndef GRPC_TEST_SLOWDOWN_BUILD_FACTOR +#define GRPC_TEST_SLOWDOWN_BUILD_FACTOR 1.0 #endif +#ifndef GRPC_TEST_SLOWDOWN_MACHINE_FACTOR +#define GRPC_TEST_SLOWDOWN_MACHINE_FACTOR 1.0 +#endif + +#define GRPC_TEST_SLOWDOWN_FACTOR \ + (GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR) + #define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ gpr_time_add(gpr_now(), \ gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e6 * (x))) #define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ - gpr_time_add(gpr_now(), \ + gpr_time_add(gpr_now(), \ gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x))) void grpc_test_init(int argc, char **argv); diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py index b8178ffebf1..ad65da535b4 100755 --- a/tools/run_tests/jobset.py +++ b/tools/run_tests/jobset.py @@ -99,6 +99,7 @@ _CLEAR_LINE = '\x1b[2K' _TAG_COLOR = { 'FAILED': 'red', + 'TIMEOUT': 'red', 'PASSED': 'green', 'START': 'gray', 'WAITING': 'yellow', diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 22f12b019a6..4e0ff85c59d 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -171,6 +171,7 @@ argp.add_argument('-c', '--config', argp.add_argument('-n', '--runs_per_test', default=1, type=int) argp.add_argument('-r', '--regex', default='.*', type=str) argp.add_argument('-j', '--jobs', default=1000, type=int) +argp.add_argument('-s', '--slowdown', default=1.0, type=float) argp.add_argument('-f', '--forever', default=False, action='store_const', @@ -200,6 +201,7 @@ make_targets = [] languages = set(_LANGUAGES[l] for l in args.language) build_steps = [jobset.JobSpec(['make', '-j', '%d' % (multiprocessing.cpu_count() + 1), + 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' % args.slowdown, 'CONFIG=%s' % cfg] + list(set( itertools.chain.from_iterable( l.make_targets() for l in languages))))