[Tarantool-patches] [tarantool-patches] [PATCH v2 2/2] say: take getaddrinfo() errors into account
Alexander Turenko
alexander.turenko at tarantool.org
Fri Dec 27 00:05:24 MSK 2019
> > I run tests and got EAI_AGAIN. Let's add it too to the list. See
> > https://lists.tarantool.org/pipermail/tarantool-patches/2019-December/013260.html
> + /*
> + * gh-4138: Check getaddrinfo() retval and diagnostics
> + * area.
> + */
> + rc = coio_getaddrinfo("non_exists_hostname", port, NULL, &i,
> + 15768000000);
> + isnt(rc, 0, "getaddrinfo retval");
> + const char *errmsg = diag_get()->last->errmsg;
> + const char *exp_errmsg_1 = "getaddrinfo: nodename nor servname provided"
> + ", or not known";
> + const char *exp_errmsg_2 = "getaddrinfo: Servname not supported for "
> + "ai_socktype";
> + const char *exp_errmsg_3 = "getaddrinfo: Name or service not known";
> + const char *exp_errmsg_4 = "getaddrinfo: hostname nor servname provided"
> + ", or not known";
> + const char *exp_errmsg_5 = "getaddrinfo: temporary failure in name "
> + "resolution";
Linux:
$ gcc -Wall -Wextra -x c <(echo -e '#include <sys/types.h>\n#include <sys/socket.h>\n#include <netdb.h>\n#include <stdio.h>\nint main() { printf("%s\\n", gai_strerror(EAI_AGAIN)); return 0; }') && ./a.out; rm a.out
Temporary failure in name resolution
Mac OS:
$ clang -Wall -Wextra -x c <(echo -e '#include <sys/types.h>\n#include <sys/socket.h>\n#include <netdb.h>\n#include <stdio.h>\nint main() { printf("%s\\n", gai_strerror(EAI_AGAIN)); return 0; }') && ./a.out; rm a.out
Temporary failure in name resolution
FreeBSD:
% printf '#include <sys/types.h>\n#include <sys/socket.h>\n#include <netdb.h>\n#include <stdio.h>\nint main() { printf("%%s\\n", gai_strerror(EAI_AGAIN)); return 0; }' > tmp.c && gcc -Wall -Wextra -x c tmp.c && ./a.out ; rm a.out tmp.c
Name could not be resolved at this time
"temporary failure in name resolution" does not match any.
> + bool is_match_with_exp = strcmp(errmsg, exp_errmsg_1) == 0 ||
> + strcmp(errmsg, exp_errmsg_2) == 0 ||
> + strcmp(errmsg, exp_errmsg_3) == 0 ||
> + strcmp(errmsg, exp_errmsg_4) == 0 ||
> + strcmp(errmsg, exp_errmsg_5) == 0;
> + is(is_match_with_exp, true, "getaddrinfo error message");
More information about the Tarantool-patches
mailing list