lib502.c for multi interface tests on a single URL without select()

This commit is contained in:
Daniel Stenberg 2002-12-13 13:40:25 +00:00
parent 978541adc2
commit d346ba5c3c
2 changed files with 38 additions and 1 deletions

View File

@ -9,7 +9,7 @@ INCLUDES = -I$(top_srcdir)/include
LIBDIR = ../../lib
# here are all tools used for running libcurl tests
bin_PROGRAMS = lib500 lib501
bin_PROGRAMS = lib500 lib501 lib502
lib500_SOURCES = lib500.c first.c test.h
lib500_LDADD = $(LIBDIR)/libcurl.la
@ -18,3 +18,7 @@ lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la
lib501_SOURCES = lib501.c first.c test.h
lib501_LDADD = $(LIBDIR)/libcurl.la
lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la
lib502_SOURCES = lib502.c first.c test.h
lib502_LDADD = $(LIBDIR)/libcurl.la
lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la

33
tests/libtest/lib502.c Normal file
View File

@ -0,0 +1,33 @@
#include "test.h"
/*
* Get a single URL without select().
*/
CURLcode test(char *URL)
{
CURL *c;
CURLM *m;
CURLMcode res;
int running=1;
curl_global_init(CURL_GLOBAL_ALL);
c = curl_easy_init();
curl_easy_setopt(c, CURLOPT_URL, URL);
m = curl_multi_init();
res = curl_multi_add_handle(m, c);
while (running) {
res = curl_multi_perform(m, &running);
if (running <= 0) {
fprintf(stderr, "nothing left running.\n");
break;
}
}
curl_multi_remove_handle(m, c);
curl_easy_cleanup(c);
curl_multi_cleanup(m);
return 0;
}