2
0

lib564.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <fcntl.h>
  26. #include "testutil.h"
  27. #include "warnless.h"
  28. #include "memdebug.h"
  29. #define TEST_HANG_TIMEOUT 60 * 1000
  30. CURLcode test(char *URL)
  31. {
  32. CURLcode res = CURLE_OK;
  33. CURL *curl = NULL;
  34. int running;
  35. CURLM *m = NULL;
  36. start_test_timing();
  37. global_init(CURL_GLOBAL_ALL);
  38. easy_init(curl);
  39. easy_setopt(curl, CURLOPT_URL, URL);
  40. easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  41. easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
  42. easy_setopt(curl, CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4);
  43. multi_init(m);
  44. multi_add_handle(m, curl);
  45. fprintf(stderr, "Start at URL 0\n");
  46. for(;;) {
  47. struct timeval interval;
  48. fd_set rd, wr, exc;
  49. int maxfd = -99;
  50. interval.tv_sec = 1;
  51. interval.tv_usec = 0;
  52. multi_perform(m, &running);
  53. abort_on_test_timeout();
  54. if(!running)
  55. break; /* done */
  56. FD_ZERO(&rd);
  57. FD_ZERO(&wr);
  58. FD_ZERO(&exc);
  59. multi_fdset(m, &rd, &wr, &exc, &maxfd);
  60. /* At this point, maxfd is guaranteed to be greater or equal than -1. */
  61. select_test(maxfd + 1, &rd, &wr, &exc, &interval);
  62. abort_on_test_timeout();
  63. }
  64. test_cleanup:
  65. /* undocumented cleanup sequence - type UB */
  66. curl_easy_cleanup(curl);
  67. curl_multi_cleanup(m);
  68. curl_global_cleanup();
  69. return res;
  70. }