diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/Makefile.am | 3 | ||||
-rw-r--r-- | tests/data/test567 | 50 | ||||
-rw-r--r-- | tests/data/test568 | 117 | ||||
-rw-r--r-- | tests/data/test569 | 110 | ||||
-rw-r--r-- | tests/data/test570 | 77 | ||||
-rw-r--r-- | tests/data/test571 | 108 | ||||
-rw-r--r-- | tests/libtest/Makefile.inc | 14 | ||||
-rw-r--r-- | tests/libtest/lib567.c | 54 | ||||
-rw-r--r-- | tests/libtest/lib568.c | 135 | ||||
-rw-r--r-- | tests/libtest/lib569.c | 107 | ||||
-rw-r--r-- | tests/libtest/lib570.c | 87 | ||||
-rw-r--r-- | tests/libtest/lib571.c | 139 |
12 files changed, 999 insertions, 2 deletions
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 993c40ca4..0a9ac547c 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -64,7 +64,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test1097 test560 test561 test1098 test1099 test562 test563 test1100 \ test564 test1101 test1102 test1103 test1104 test299 test310 test311 \ test312 test1105 test565 test800 test1106 test801 test566 test802 test803 \ - test1107 test1108 test1109 test1110 test1111 test1112 test129 + test1107 test1108 test1109 test1110 test1111 test1112 test129 test567 \ + test568 test569 test570 test571 filecheck: @mkdir test-place; \ diff --git a/tests/data/test567 b/tests/data/test567 new file mode 100644 index 000000000..fe32d0f19 --- /dev/null +++ b/tests/data/test567 @@ -0,0 +1,50 @@ +<testcase> + +#Informational +<info> +<keywords> +RTSP +OPTIONS +</keywords> +</info> + +# Server-side +<reply> +<data> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +CSeq: 1 +Public: DESCRIBE, OPTIONS, SETUP, TEARDOWN, PLAY, PAUSE +Curl-Private: swsclose +</data> +</reply> + +# Client-Side +<client> +<server> +rtsp +</server> +<tool> +lib567 +</tool> + +<name> +simple RTSP OPTIONS command +</name> +<command> +rtsp://%HOSTIP:%RTSPPORT/567 +</command> +</client> + +<verify> +<protocol> +OPTIONS rtsp://%HOSTIP:%RTSPPORT/567 RTSP/1.0
+CSeq: 1
+User-Agent: test567
+Test-Number: 567
+
+</protocol> +</verify> + +</testcase> + diff --git a/tests/data/test568 b/tests/data/test568 new file mode 100644 index 000000000..a7e2cc4a8 --- /dev/null +++ b/tests/data/test568 @@ -0,0 +1,117 @@ +<testcase> + +#Informational +<info> +<keywords> +RTSP +ANNOUNCE +</keywords> +</info> + +# Server-side +<reply> +<data1> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Cseq: 1 + +</data1> + +<data2> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Cseq: 2 +Content-Length: 70 +Content-Type: application/sdp + +v=0 +s=sws SDP +i=A fake SDP reply +u=http://www.curl.haxx.se/fakesdp.ps +</data2> +<data3> +RTSP/1.0 200 Okie Dokie +Server: SWS/libcurl-test +Cseq: 3 + +</data3> +<data4> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +CSeq: 4 +Curl-private: swsclose +Informational: Empty Options Response + +</data4> +</reply> + +# Client-Side +<client> +<server> +rtsp +</server> +<tool> +lib568 +</tool> + +<name> +RTSP Announce (PUT and POST style) test +</name> +<command> +rtsp://%HOSTIP:%RTSPPORT/568 +</command> +# file written before test command runs +<file name="log/file568.txt"> +v=0
+o=mhandley 2890844526 2890845468 IN IP4 126.16.64.4
+s=SDP Seminar
+i=A Seminar on the session description protocol
+u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps
+e=mjh@isi.edu (Mark Handley)
+c=IN IP4 224.2.17.12/127
+t=2873397496 2873404696
+a=recvonly
+m=audio 3456 RTP/AVP 0
+m=video 2232 RTP/AVP 31
+</file> +</client> + +<verify> +<strip> +^If-Modified-Since:.* +</strip> +<protocol> +ANNOUNCE rtsp://%HOSTIP:%RTSPPORT/5680001 RTSP/1.0
+CSeq: 1
+Content-Length: 317
+Content-Type: application/sdp
+
+v=0
+o=mhandley 2890844526 2890845468 IN IP4 126.16.64.4
+s=SDP Seminar
+i=A Seminar on the session description protocol
+u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps
+e=mjh@isi.edu (Mark Handley)
+c=IN IP4 224.2.17.12/127
+t=2873397496 2873404696
+a=recvonly
+m=audio 3456 RTP/AVP 0
+m=video 2232 RTP/AVP 31
+DESCRIBE rtsp://%HOSTIP:%RTSPPORT/5680002 RTSP/1.0
+CSeq: 2
+Accept: application/sdp
+
+ANNOUNCE rtsp://%HOSTIP:%RTSPPORT/5680003 RTSP/1.0
+CSeq: 3
+Content-Type: posty goodness
+Content-Length: 35
+
+postyfield=postystuff&project=curl
+OPTIONS rtsp://%HOSTIP:%RTSPPORT/5680004 RTSP/1.0
+CSeq: 4
+
+</protocol> +</verify> + +</testcase> + diff --git a/tests/data/test569 b/tests/data/test569 new file mode 100644 index 000000000..77c258407 --- /dev/null +++ b/tests/data/test569 @@ -0,0 +1,110 @@ +<testcase> + +#Informational +<info> +<keywords> +RTSP +SESSION_ID +</keywords> +</info> + +# Server-side +<reply> +<data1> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +CSeq: 1 +Session: 00.+1-am-aSe55ion_id\$yes-i-am\$;timeout=60 + +</data1> +<data2> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +CSeq: 2 + +</data2> +<data3> +RTSP/1.0 200 OK +Session: \$extraspaces ignore-this-part-------;foo=bar +CSeq: 3 +Server: SWS/libcurl-test + +</data3> +<data4> +RTSP/1.0 200 OK +CSeq: 4 +Server: SWS/libcurl-test + +</data4> +<data5> +RTSP/1.0 200 OK +Session: A +Server: SWS/libcurl-test +CSeq: 5 +Informational: Single Character + +</data5> +<data6> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Curl-Private: swsclose +CSeq: 6 + +</data6> + +# Client-Side +<client> +<server> +rtsp +</server> +<tool> +lib569 +</tool> + +<name> +RTSP Session ID parsing +</name> +<command> +rtsp://%HOSTIP:%RTSPPORT/569 log/idfile.txt +</command> +</client> + +<verify> +<strip> +^If-Modified-Since:.* +</strip> +<protocol> +SETUP rtsp://%HOSTIP:%RTSPPORT/5690001 RTSP/1.0
+CSeq: 1
+Transport: Fake/NotReal/JustATest;foo=baz
+
+TEARDOWN rtsp://%HOSTIP:%RTSPPORT/5690002 RTSP/1.0
+CSeq: 2
+Session: 00.+1-am-aSe55ion_id\$yes-i-am\$
+
+SETUP rtsp://%HOSTIP:%RTSPPORT/5690003 RTSP/1.0
+CSeq: 3
+Transport: Fake/NotReal/JustATest;foo=baz
+
+TEARDOWN rtsp://%HOSTIP:%RTSPPORT/5690004 RTSP/1.0
+CSeq: 4
+Session: \$extraspaces
+
+SETUP rtsp://%HOSTIP:%RTSPPORT/5690005 RTSP/1.0
+CSeq: 5
+Transport: Fake/NotReal/JustATest;foo=baz
+
+TEARDOWN rtsp://%HOSTIP:%RTSPPORT/5690006 RTSP/1.0
+CSeq: 6
+Session: A
+
+</protocol> +<file name="log/idfile.txt"> +Got Session ID: [00.+1-am-aSe55ion_id\$yes-i-am\$] +Got Session ID: [\$extraspaces] +Got Session ID: [A] +</file> +</verify> + +</testcase> + diff --git a/tests/data/test570 b/tests/data/test570 new file mode 100644 index 000000000..9bc9e0c8e --- /dev/null +++ b/tests/data/test570 @@ -0,0 +1,77 @@ +<testcase> + +#Informational +<info> +<keywords> +RTSP +Mismatch checking +</keywords> +</info> + +# Server-side +<reply> +<data1> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +CSeq: 2 +Public: DESCRIBE, OPTIONS, SETUP, TEARDOWN, PLAY, PAUSE +Informational: CSeq Mismatch + +</data1> +<data2> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Session: asdf +CSeq: 999 + +</data2> +<data3> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Session: asdfWRONG +Informational: Session ID mismatch +Curl-Private: swsclose +CSeq: 1000 + +</data3> + +</reply> + +# Client-Side +<client> +<server> +rtsp +</server> +<tool> +lib570 +</tool> + +<name> +RTSP CSeq and Session Mismatch checks +</name> +<command> +rtsp://%HOSTIP:%RTSPPORT/570 +</command> +</client> + +<verify> +<strip> +^If-Modified-Since:.* +</strip> +<protocol> +OPTIONS rtsp://%HOSTIP:%RTSPPORT/5700001 RTSP/1.0
+CSeq: 1
+
+SETUP rtsp://%HOSTIP:%RTSPPORT/5700002 RTSP/1.0
+CSeq: 999
+Transport: RAW/RAW/UDP;unicast;client_port=3056-3057
+
+PLAY rtsp://%HOSTIP:%RTSPPORT/5700003 RTSP/1.0
+CSeq: 1000
+Session: asdf
+
+</protocol> +</verify> + +</testcase> + diff --git a/tests/data/test571 b/tests/data/test571 new file mode 100644 index 000000000..a03d86af8 --- /dev/null +++ b/tests/data/test571 @@ -0,0 +1,108 @@ +<testcase> + +# Informational +# Bang on RTP by +# 1) giving an evil payload (with $) +# 2) Giving evil content (SDP starting with $) +# 3) packing rtp after headers, after content, and at the start +<info> +<keywords> +RTSP +RTP +</keywords> +</info> + +# Server-side +<reply> +<data1> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Session: asdf +CSeq: 1 + +</data1> + +<data2> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +CSeq: 2 +Session: asdf + +</data2> + +<data3> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Cseq: 3 +Content-Length: 4 +Content-Type: fake/evil + +$99 +</data3> + +<data4> +RTSP/1.0 200 OK +Server: SWS/libcurl-test +Session: asdf +CSeq: 4 + +</data4> + +<servercmd> +rtp: part 2 channel 1 size 10 +rtp: part 2 channel 0 size 500 +rtp: part 2 channel 0 size 196 +rtp: part 2 channel 0 size 124 +rtp: part 2 channel 0 size 824 +rtp: part 3 channel 1 size 10 +rtp: part 3 channel 0 size 50 +rtp: part 4 channel 0 size 798 +rtp: part 4 channel 0 size 42 +rtp: part 4 channel 1 size 30 +rtp: part 4 channel 0 size 2048 +rtp: part 4 channel 0 size 85 +rtp: part 4 channel 1 size 24 +</servercmd> +</reply> + +# Client-Side +<client> +<server> +rtsp +</server> +<tool> +lib571 +</tool> + +<name> +RTSP RTP Interleaving Test +</name> +<command> +rtsp://%HOSTIP:%RTSPPORT/571 log/protofile.txt +</command> +</client> + +<verify> +<stdout> +RTP: message size 10, channel 1 +RTP: message size 500, channel 0 +RTP: message size 196, channel 0 +RTP: message size 124, channel 0 +RTP: message size 824, channel 0 +RTP: message size 10, channel 1 +RTP: message size 50, channel 0 +RTP: message size 798, channel 0 +RTP: message size 42, channel 0 +RTP: message size 30, channel 1 +RTP: message size 2048, channel 0 +RTP: message size 85, channel 0 +RTP: message size 24, channel 1 +</stdout> + +<file name="log/protofile.txt"> +$99 +</file> +</verify> + +</testcase> + diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 087758d73..5a5a0ea8e 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -10,7 +10,8 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 + lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ + lib568 lib569 lib570 lib571 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -131,3 +132,14 @@ lib565_SOURCES = lib510.c $(SUPPORTFILES) lib565_CFLAGS = -DLIB565 lib566_SOURCES = lib566.c $(SUPPORTFILES) + +lib567_SOURCES = lib567.c $(SUPPORTFILES) + +lib568_SOURCES = lib568.c $(SUPPORTFILES) + +lib569_SOURCES = lib569.c $(SUPPORTFILES) + +lib570_SOURCES = lib570.c $(SUPPORTFILES) + +lib571_SOURCES = lib571.c $(SUPPORTFILES) + diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c new file mode 100644 index 000000000..e04873b11 --- /dev/null +++ b/tests/libtest/lib567.c @@ -0,0 +1,54 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" +#include "memdebug.h" + +/* + * Test a simple OPTIONS request with a custom header + */ +int test(char *URL) +{ + CURLcode res; + CURL *curl; + struct curl_slist *custom_headers=NULL; + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + /* Dump data to stdout for protocol verification */ + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + curl_easy_setopt(curl, CURLOPT_USERAGENT, "test567"); + + custom_headers = curl_slist_append(custom_headers, "Test-Number: 567"); + curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); + + res = curl_easy_perform(curl); + + curl_slist_free_all(custom_headers); + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c new file mode 100644 index 000000000..5e59a9cae --- /dev/null +++ b/tests/libtest/lib568.c @@ -0,0 +1,135 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include <unistd.h> +#include <fcntl.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include <curl/mprintf.h> + +#include "memdebug.h" + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +/* + * Test the Client->Server ANNOUNCE functionality (PUT style) + */ +int test(char *URL) +{ + CURLcode res; + CURL *curl; + int sdp; + FILE *sdpf; + struct stat file_info; + char *stream_uri; + int request=1; + struct curl_slist *custom_headers=NULL; + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + sdp = open("log/file568.txt", O_RDONLY); + fstat(sdp, &file_info); + sdpf = fdopen(sdp, "rb"); + if(sdpf == NULL) { + close(sdp); + fprintf(stderr, "can't open log/file568.txt\n"); + return TEST_ERR_MAJOR_BAD; + } + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); + + curl_easy_setopt(curl, CURLOPT_READDATA, sdpf); + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); + + /* Do the ANNOUNCE */ + res = curl_easy_perform(curl); + if(res) { + fclose(sdpf); + close(sdp); + return res; + } + + curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L); + fclose(sdpf); + close(sdp); + + /* Make sure we can do a normal request now */ + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); + res = curl_easy_perform(curl); + if(res) + return res; + + /* Now do a POST style one */ + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + custom_headers = curl_slist_append(custom_headers, + "Content-Type: posty goodness"); + + curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, + "postyfield=postystuff&project=curl\n"); + + res = curl_easy_perform(curl); + if(res) + return res; + + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); + curl_easy_setopt(curl, CURLOPT_RTSPHEADER, NULL); + curl_slist_free_all(custom_headers); + + /* Make sure we can do a normal request now */ + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + res = curl_easy_perform(curl); + if(res) + return res; + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} + diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c new file mode 100644 index 000000000..6f276d350 --- /dev/null +++ b/tests/libtest/lib569.c @@ -0,0 +1,107 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include <curl/mprintf.h> + +#include "memdebug.h" + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +/* + * Test Session ID capture + */ +int test(char *URL) +{ + CURLcode res; + CURL *curl; + char *stream_uri; + char *rtsp_session_id; + int request=1; + int i; + FILE *idfile; + + idfile = fopen(libtest_arg2, "w"); + if(idfile == NULL) { + fprintf(stderr, "couldn't open the Session ID File\n"); + return TEST_ERR_MAJOR_BAD; + } + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(idfile); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + fclose(idfile); + return TEST_ERR_MAJOR_BAD; + } + + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + res = curl_easy_perform(curl); + if(res != CURLE_BAD_FUNCTION_ARGUMENT) { + fprintf(stderr, "This should have failed. " + "Cannot setup without a Transport: header"); + fclose(idfile); + return TEST_ERR_MAJOR_BAD; + } + + /* Go through the various Session IDs */ + for(i = 0; i < 3; i++) { + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "Fake/NotReal/JustATest;foo=baz"); + res = curl_easy_perform(curl); + if(res) { + fclose(idfile); + return res; + } + + curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id); + fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); + rtsp_session_id = NULL; + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); + curl_easy_perform(curl); + + /* Clear for the next go-round */ + curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL); + } + + fclose(idfile); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c new file mode 100644 index 000000000..69a0168e0 --- /dev/null +++ b/tests/libtest/lib570.c @@ -0,0 +1,87 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include <curl/mprintf.h> + +#include "memdebug.h" + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + int request=1; + char *stream_uri; + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + res = curl_easy_perform(curl); + if(res != CURLE_RTSP_CSEQ_ERROR) { + fprintf(stderr, "Failed to detect CSeq mismatch"); + return res; + } + + curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999); + curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "RAW/RAW/UDP;unicast;client_port=3056-3057"); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + res = curl_easy_perform(curl); + if(res) + return res; + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + res = curl_easy_perform(curl); + if(res != CURLE_RTSP_SESSION_ERROR) { + fprintf(stderr, "Failed to detect a Session ID mismatch"); + } + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c new file mode 100644 index 000000000..f530deadc --- /dev/null +++ b/tests/libtest/lib571.c @@ -0,0 +1,139 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include <unistd.h> +#include <fcntl.h> +#include <stdlib.h> +#include <sys/stat.h> + +#include <curl/mprintf.h> + +#include "memdebug.h" + +#define RTP_DATA_SIZE 12 +static const char *RTP_DATA = "$_1234\n\0asdf"; + +static int rtp_packet_count = 0; + +static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) { + char *data = (char *)ptr; + int channel = (int)data[0]; + int message_size = (int)(size * nmemb - 3); + int i; + (void)stream; + + printf("RTP: message size %d, channel %d\n", message_size, channel); + + data += 3; + for(i = 0; i < message_size; i+= RTP_DATA_SIZE) { + if(message_size - i > RTP_DATA_SIZE) { + if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) { + printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i); + } + } else { + if (memcmp(RTP_DATA, data + i, message_size - i) != 0) { + printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n", + message_size - i, data + i); + } + } + } + + rtp_packet_count++; + fprintf(stderr, "packet count is %d\n", rtp_packet_count); + + return size * nmemb; +} + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + char *stream_uri; + int request=1; + FILE *protofile; + + protofile = fopen(libtest_arg2, "w"); + if(protofile == NULL) { + fprintf(stderr, "Couldn't open the protocol dump file\n"); + return TEST_ERR_MAJOR_BAD; + } + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(protofile); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + fclose(protofile); + return TEST_ERR_MAJOR_BAD; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + 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); + + 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); + + /* This PLAY starts the interleave */ + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + res = curl_easy_perform(curl); + + /* 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); + free(stream_uri); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); + + res = curl_easy_perform(curl); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + res = curl_easy_perform(curl); + + 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); + res = curl_easy_perform(curl); + } + + curl_easy_cleanup(curl); + curl_global_cleanup(); + fclose(protofile); + + return (int)res; +} + |