diff options
author | Tharanga Gamaethige <tgamaethige@netflix.com> | 2020-05-13 15:46:57 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-07-01 13:55:36 -0700 |
commit | 7e64232119cd182f43617e628e660dc75b7bb411 (patch) | |
tree | 58fa9f07a6fe3b999459d7286a6e85e21961daf4 | |
parent | 7c2df4a70d3aa50dd507ee92a0af4e0279433988 (diff) | |
download | memcached-7e64232119cd182f43617e628e660dc75b7bb411.tar.gz |
fixing the basic tls test so it exits correctly when fails
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | testapp.c | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am index d62facf..a0d5900 100644 --- a/Makefile.am +++ b/Makefile.am @@ -114,8 +114,8 @@ test_tls: test_basic_tls: @if test $(SSL_TEST)1 != 1; then \ echo "Running basic tests with TLS"; \ - $(builddir)/testapp; \ - prove $(srcdir)/t/binary.t $(srcdir)/t/getset.t $(srcdir)/t/ssl*; \ + $(builddir)/testapp && \ + prove $(srcdir)/t/binary.t $(srcdir)/t/getset.t $(srcdir)/t/ssl* && \ echo "Finished running basic TLS tests"; \ else \ echo "Set SSL_TEST=1 to enable TLS tests"; \ @@ -519,7 +519,6 @@ static pid_t start_server(in_port_t *port_out, bool daemon, int timeout) { pid_t pid = fork(); assert(pid != -1); - if (pid == 0) { /* Child */ char *argv[24]; @@ -574,8 +573,16 @@ static pid_t start_server(in_port_t *port_out, bool daemon, int timeout) { } /* Yeah just let us "busy-wait" for the file to be created ;-) */ - while (access(filename, F_OK) == -1) { - usleep(10); + useconds_t wait_timeout = 1000000 * 10; + useconds_t wait = 1000; + while (access(filename, F_OK) == -1 && wait_timeout > 0) { + usleep(wait); + wait_timeout -= (wait > wait_timeout ? wait_timeout : wait); + } + + if (access(filename, F_OK) == -1) { + fprintf(stderr, "Failed to start the memcached server.\n"); + assert(false); } FILE *fp = fopen(filename, "r"); |