aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2015-01-14 11:22:57 -0800
committerGravatar Yang Gao <yangg@google.com>2015-01-14 11:22:57 -0800
commit0e477384cbeb1e206f6358abda16dbc3aa01a8d3 (patch)
tree87d4abde06e5ca110454bfd3a1333486b0cae3d5
parent29512b56d0d16bec59f95999afbabb0d6f6e4aab (diff)
parent14e60e9f8b147d873b6320e24c100a8dbb087418 (diff)
Merge pull request #26 from ctiller/signals
Properly mask signals in unit tests
-rw-r--r--test/core/iomgr/tcp_posix_test.c3
-rw-r--r--test/core/transport/chttp2_transport_end2end_test.c3
-rw-r--r--test/core/util/test_config.c3
-rw-r--r--test/cpp/end2end/end2end_test.cc2
4 files changed, 5 insertions, 6 deletions
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 7fd2567cec..6af3ded98b 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -36,7 +36,6 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
-#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
@@ -491,8 +490,6 @@ static grpc_endpoint_test_config configs[] = {
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_iomgr_init();
- /* disable SIGPIPE */
- signal(SIGPIPE, SIG_IGN);
run_tests();
grpc_endpoint_tests(configs[0]);
grpc_iomgr_shutdown();
diff --git a/test/core/transport/chttp2_transport_end2end_test.c b/test/core/transport/chttp2_transport_end2end_test.c
index 30d2a17440..8b0f9aa25b 100644
--- a/test/core/transport/chttp2_transport_end2end_test.c
+++ b/test/core/transport/chttp2_transport_end2end_test.c
@@ -107,9 +107,6 @@ grpc_transport_test_config fixture_configs[] = {
int main(int argc, char **argv) {
size_t i;
- /* disable SIGPIPE */
- signal(SIGPIPE, SIG_IGN);
-
grpc_test_init(argc, argv);
grpc_iomgr_init();
diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c
index ab2c0d80a9..94245d85bc 100644
--- a/test/core/util/test_config.c
+++ b/test/core/util/test_config.c
@@ -35,6 +35,7 @@
#include <grpc/support/port_platform.h>
#include <stdlib.h>
+#include <signal.h>
#if GPR_GETPID_IN_UNISTD_H
#include <unistd.h>
@@ -51,6 +52,8 @@ static int seed(void) {
#endif
void grpc_test_init(int argc, char **argv) {
+ /* disable SIGPIPE */
+ signal(SIGPIPE, SIG_IGN);
/* 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/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index e01a6efe82..3a1da68e47 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -34,6 +34,7 @@
#include <chrono>
#include <thread>
+#include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.pb.h"
#include "test/cpp/util/echo.pb.h"
#include "src/cpp/util/time.h"
@@ -435,6 +436,7 @@ TEST_F(End2endTest, BadCredentials) {
} // namespace grpc
int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
grpc_init();
::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();