lib583.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2020, 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. ***************************************************************************/
  22. /*
  23. * This test case is based on the sample code provided by Saqib Ali
  24. * https://curl.se/mail/lib-2011-03/0066.html
  25. */
  26. #include "test.h"
  27. #include <sys/stat.h>
  28. #include "memdebug.h"
  29. int test(char *URL)
  30. {
  31. int stillRunning;
  32. CURLM *multiHandle = NULL;
  33. CURL *curl = NULL;
  34. CURLcode res = CURLE_OK;
  35. CURLMcode mres;
  36. global_init(CURL_GLOBAL_ALL);
  37. multi_init(multiHandle);
  38. easy_init(curl);
  39. easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
  40. easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
  41. easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
  42. easy_setopt(curl, CURLOPT_UPLOAD, 1L);
  43. easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  44. easy_setopt(curl, CURLOPT_URL, URL);
  45. easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
  46. multi_add_handle(multiHandle, curl);
  47. /* this tests if removing an easy handle immediately after multi
  48. perform has been called succeeds or not. */
  49. fprintf(stderr, "curl_multi_perform()...\n");
  50. multi_perform(multiHandle, &stillRunning);
  51. fprintf(stderr, "curl_multi_perform() succeeded\n");
  52. fprintf(stderr, "curl_multi_remove_handle()...\n");
  53. mres = curl_multi_remove_handle(multiHandle, curl);
  54. if(mres) {
  55. fprintf(stderr, "curl_multi_remove_handle() failed, "
  56. "with code %d\n", (int)mres);
  57. res = TEST_ERR_MULTI;
  58. }
  59. else
  60. fprintf(stderr, "curl_multi_remove_handle() succeeded\n");
  61. test_cleanup:
  62. /* undocumented cleanup sequence - type UB */
  63. curl_easy_cleanup(curl);
  64. curl_multi_cleanup(multiHandle);
  65. curl_global_cleanup();
  66. return (int)res;
  67. }