Merge pull request #26 from ctiller/signals

Properly mask signals in unit tests
pull/28/head
Yang Gao 10 years ago
commit 0e477384cb
  1. 3
      test/core/iomgr/tcp_posix_test.c
  2. 3
      test/core/transport/chttp2_transport_end2end_test.c
  3. 3
      test/core/util/test_config.c
  4. 2
      test/cpp/end2end/end2end_test.cc

@ -36,7 +36,6 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <signal.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
@ -491,8 +490,6 @@ static grpc_endpoint_test_config configs[] = {
int main(int argc, char **argv) { int main(int argc, char **argv) {
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_iomgr_init(); grpc_iomgr_init();
/* disable SIGPIPE */
signal(SIGPIPE, SIG_IGN);
run_tests(); run_tests();
grpc_endpoint_tests(configs[0]); grpc_endpoint_tests(configs[0]);
grpc_iomgr_shutdown(); grpc_iomgr_shutdown();

@ -107,9 +107,6 @@ grpc_transport_test_config fixture_configs[] = {
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i; size_t i;
/* disable SIGPIPE */
signal(SIGPIPE, SIG_IGN);
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_iomgr_init(); grpc_iomgr_init();

@ -35,6 +35,7 @@
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h>
#if GPR_GETPID_IN_UNISTD_H #if GPR_GETPID_IN_UNISTD_H
#include <unistd.h> #include <unistd.h>
@ -51,6 +52,8 @@ static int seed(void) {
#endif #endif
void grpc_test_init(int argc, char **argv) { 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 /* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */ concurrently running test binary */
srand(seed()); srand(seed());

@ -34,6 +34,7 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.pb.h" #include "test/cpp/util/echo_duplicate.pb.h"
#include "test/cpp/util/echo.pb.h" #include "test/cpp/util/echo.pb.h"
#include "src/cpp/util/time.h" #include "src/cpp/util/time.h"
@ -435,6 +436,7 @@ TEST_F(End2endTest, BadCredentials) {
} // namespace grpc } // namespace grpc
int main(int argc, char** argv) { int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init(); grpc_init();
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS(); int result = RUN_ALL_TESTS();

Loading…
Cancel
Save