2
0

lib574.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "test.h"
  25. #include "memdebug.h"
  26. #define TEST_HANG_TIMEOUT (60 * 1000)
  27. static int new_fnmatch(void *ptr,
  28. const char *pattern, const char *string)
  29. {
  30. (void)ptr;
  31. fprintf(stderr, "lib574: match string '%s' against pattern '%s'\n",
  32. string, pattern);
  33. return CURL_FNMATCHFUNC_MATCH;
  34. }
  35. CURLcode test(char *URL)
  36. {
  37. CURLcode res;
  38. CURL *curl;
  39. if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
  40. fprintf(stderr, "curl_global_init() failed\n");
  41. return TEST_ERR_MAJOR_BAD;
  42. }
  43. curl = curl_easy_init();
  44. if(!curl) {
  45. fprintf(stderr, "curl_easy_init() failed\n");
  46. curl_global_cleanup();
  47. return TEST_ERR_MAJOR_BAD;
  48. }
  49. test_setopt(curl, CURLOPT_URL, URL);
  50. test_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
  51. test_setopt(curl, CURLOPT_FNMATCH_FUNCTION, new_fnmatch);
  52. test_setopt(curl, CURLOPT_TIMEOUT_MS, (long) TEST_HANG_TIMEOUT);
  53. res = curl_easy_perform(curl);
  54. if(res) {
  55. fprintf(stderr, "curl_easy_perform() failed %d\n", res);
  56. goto test_cleanup;
  57. }
  58. res = curl_easy_perform(curl);
  59. if(res) {
  60. fprintf(stderr, "curl_easy_perform() failed %d\n", res);
  61. goto test_cleanup;
  62. }
  63. test_cleanup:
  64. curl_easy_cleanup(curl);
  65. curl_global_cleanup();
  66. return res;
  67. }