2
0

lib583.c 2.6 KB

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