aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib571.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-02-05 18:07:19 +0000
committerYang Tse <yangsita@gmail.com>2010-02-05 18:07:19 +0000
commitcad9c3f55fad5da988144dc83ad76a8544a071a2 (patch)
tree9231f49bc11dfdb69b4cac9af3b1dd473d1507ad /tests/libtest/lib571.c
parent12d01bc5f72c4c0f9aabfa45628d9c4702491fb0 (diff)
Addes OOM handling for curl_easy_setopt() calls in test
Diffstat (limited to 'tests/libtest/lib571.c')
-rw-r--r--tests/libtest/lib571.c67
1 files changed, 47 insertions, 20 deletions
diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c
index a1cd032ab..a264eddbd 100644
--- a/tests/libtest/lib571.c
+++ b/tests/libtest/lib571.c
@@ -91,7 +91,7 @@ int test(char *URL)
{
CURLcode res;
CURL *curl;
- char *stream_uri;
+ char *stream_uri = NULL;
int request=1;
FILE *protofile;
@@ -113,54 +113,81 @@ int test(char *URL)
fclose(protofile);
return TEST_ERR_MAJOR_BAD;
}
- curl_easy_setopt(curl, CURLOPT_URL, URL);
+ test_setopt(curl, CURLOPT_URL, URL);
- stream_uri = suburl(URL, request++);
- curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
+ if((stream_uri = suburl(URL, request++)) == NULL) {
+ res = TEST_ERR_MAJOR_BAD;
+ goto test_cleanup;
+ }
+ test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
+ stream_uri = NULL;
- curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3);
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, protofile);
+ test_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
+ test_setopt(curl, CURLOPT_TIMEOUT, 3);
+ test_setopt(curl, CURLOPT_VERBOSE, 1L);
+ test_setopt(curl, CURLOPT_WRITEDATA, protofile);
+
+ test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1");
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
- curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1");
- curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(curl);
+ if(res)
+ goto test_cleanup;
/* This PLAY starts the interleave */
- stream_uri = suburl(URL, request++);
- curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
+ if((stream_uri = suburl(URL, request++)) == NULL) {
+ res = TEST_ERR_MAJOR_BAD;
+ goto test_cleanup;
+ }
+ test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
- curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
+ stream_uri = NULL;
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
+
res = curl_easy_perform(curl);
+ if(res)
+ goto test_cleanup;
/* The DESCRIBE request will try to consume data after the Content */
- stream_uri = suburl(URL, request++);
- curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
+ if((stream_uri = suburl(URL, request++)) == NULL) {
+ res = TEST_ERR_MAJOR_BAD;
+ goto test_cleanup;
+ }
+ test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
- curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
+ stream_uri = NULL;
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
res = curl_easy_perform(curl);
+ if(res)
+ goto test_cleanup;
stream_uri = suburl(URL, request++);
- curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
+ test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
- curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
+ stream_uri = NULL;
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
+
res = curl_easy_perform(curl);
+ if(res)
+ goto test_cleanup;
fprintf(stderr, "PLAY COMPLETE\n");
/* Use Receive to get the rest of the data */
while(!res && rtp_packet_count < 13) {
fprintf(stderr, "LOOPY LOOP!\n");
- curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE);
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE);
res = curl_easy_perform(curl);
}
+test_cleanup:
+
+ fclose(protofile);
+
curl_easy_cleanup(curl);
curl_global_cleanup();
- fclose(protofile);
return (int)res;
}