PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/resolv/tst-resolv-ai_idn.c

https://github.com/hjl-tools/glibc
C | 54 lines | 29 code | 8 blank | 17 comment | 6 complexity | e2270ef86c83a9a3e34fe03a9636ed9b MD5 | raw file
  1. /* Test getaddrinfo and getnameinfo with AI_IDN, NI_IDN (UTF-8).
  2. Copyright (C) 2018-2020 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #define TEST_USE_UTF8 1
  16. #include "tst-resolv-ai_idn-common.c"
  17. #include <locale.h>
  18. #include <support/xdlfcn.h>
  19. static int
  20. do_test (void)
  21. {
  22. void *handle = dlopen (LIBIDN2_SONAME, RTLD_LAZY);
  23. if (handle == NULL)
  24. FAIL_UNSUPPORTED ("libidn2 not installed");
  25. void *check_ver_sym = xdlsym (handle, "idn2_check_version");
  26. const char *check_res
  27. = ((const char *(*) (const char *)) check_ver_sym) ("2.0.5");
  28. if (check_res == NULL)
  29. FAIL_UNSUPPORTED ("libidn2 too old");
  30. if (setlocale (LC_CTYPE, "en_US.UTF-8") == NULL)
  31. FAIL_EXIT1 ("setlocale: %m");
  32. struct resolv_test *aux = resolv_test_start
  33. ((struct resolv_redirect_config)
  34. {
  35. .response_callback = response,
  36. });
  37. gai_tests_with_libidn2 ();
  38. gni_tests_with_libidn2 ();
  39. resolv_test_end (aux);
  40. xdlclose (handle);
  41. return 0;
  42. }
  43. #include <support/test-driver.c>