From a4b1828d6dbad9126122ea1e04c54bbbb83bc311 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 13 Mar 2017 23:52:15 +0300 Subject: [PATCH] test: windows doesn't have WNOWAIT Fixes: 66a4eb0c3ae3b1f22b084b2d3aeb5c872f37efbd ("Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)") --- test/regress.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/test/regress.c b/test/regress.c index 94fcbec9..dcfb598c 100644 --- a/test/regress.c +++ b/test/regress.c @@ -848,11 +848,34 @@ simple_child_read_cb(evutil_socket_t fd, short event, void *arg) called++; } + +#define TEST_FORK_EXIT_SUCCESS 76 +static void fork_wait_check(int pid) +{ + int status; + + TT_BLATHER(("Before waitpid")); + +#ifdef WNOWAIT + if ((waitpid(pid, &status, WNOWAIT) == -1 && errno == EINVAL) && +#else + if ( +#endif + waitpid(pid, &status, 0) == -1) { + perror("waitpid"); + exit(1); + } + TT_BLATHER(("After waitpid")); + + if (WEXITSTATUS(status) != TEST_FORK_EXIT_SUCCESS) { + fprintf(stdout, "FAILED (exit): %d\n", WEXITSTATUS(status)); + exit(1); + } +} static void test_fork(void) { char c; - int status; struct event ev, sig_ev, usr_ev, existing_ev; pid_t pid; @@ -917,7 +940,7 @@ test_fork(void) /* we do not send an EOF; simple_read_cb requires an EOF * to set test_ok. we just verify that the callback was * called. */ - exit(test_ok != 0 || called != 2 ? -2 : 76); + exit(test_ok != 0 || called != 2 ? -2 : TEST_FORK_EXIT_SUCCESS); } /** wait until client read first message */ @@ -928,18 +951,7 @@ test_fork(void) tt_fail_perror("write"); } - TT_BLATHER(("Before waitpid")); - if ((waitpid(pid, &status, WNOWAIT) == -1 && errno == EINVAL) && - waitpid(pid, &status, 0) == -1) { - perror("waitpid"); - exit(1); - } - TT_BLATHER(("After waitpid")); - - if (WEXITSTATUS(status) != 76) { - fprintf(stdout, "FAILED (exit): %d\n", WEXITSTATUS(status)); - exit(1); - } + fork_wait_check(pid); /* test that the current event loop still works */ if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) { -- 2.40.0