aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Conroy <cconroy@gmail.com>2010-03-24 01:35:03 -0400
committerDaniel Stenberg <daniel@haxx.se>2010-03-24 13:21:14 +0100
commit1ac168e576d8e78b58640e1e997249717529b482 (patch)
tree28e15363ef86b15292b5025ec05b8f66cb53cb9f /tests
parent50b51161c9ae3833489d2bf42b43fced46ab5587 (diff)
Fix RTSP GET_PARAMETER empty and non-empty operation.
Test coverage included. Thanks to Massimo Callegari for the bug report
Diffstat (limited to 'tests')
-rw-r--r--tests/data/Makefile.am2
-rw-r--r--tests/data/test572121
-rw-r--r--tests/libtest/Makefile.inc4
-rw-r--r--tests/libtest/lib572.c177
4 files changed, 302 insertions, 2 deletions
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 1878e013c..6f2c09079 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -65,7 +65,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test564 test1101 test1102 test1103 test1104 test299 test310 test311 \
test312 test1105 test565 test800 test1106 test801 test566 test802 test803 \
test1107 test1108 test1109 test1110 test1111 test1112 test129 test567 \
- test568 test569 test570 test571 test804
+ test568 test569 test570 test571 test804 test572
filecheck:
@mkdir test-place; \
diff --git a/tests/data/test572 b/tests/data/test572
new file mode 100644
index 000000000..c06e531fc
--- /dev/null
+++ b/tests/data/test572
@@ -0,0 +1,121 @@
+<testcase>
+
+#Informational
+<info>
+<keywords>
+RTSP
+GET_PARAMETER
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data1>
+RTSP/1.0 200 OK
+Server: RTSPD/libcurl-test
+Session: getparams-test
+CSeq: 1
+
+</data1>
+
+<data2>
+RTSP/1.0 200 OK
+Server: RTSPD/libcurl-test
+Session: getparams-test
+Content-Type: text/parameters
+Content-Length: 32
+Cseq: 2
+
+scale=enormous
+speed=ludicrous
+</data2>
+
+<data3>
+RTSP/1.0 200 OK
+Server: RTSPD/libcurl-test
+Session: getparams-test
+Cseq: 3
+
+</data3>
+
+<data4>
+RTSP/1.0 200 Okie Dokie
+Server: RTSPD/libcurl-test
+Session: getparams-test
+Cseq: 4
+Content-Length: 37
+
+packets_received: 1000
+jitter: 0.314
+</data4>
+<data5>
+RTSP/1.0 200 OK
+Server: RTSPD/libcurl-test
+Session: getparams-test
+CSeq: 5
+Curl-private: swsclose
+Informational: Empty Options Response
+
+</data5>
+</reply>
+
+# Client-Side
+<client>
+<server>
+rtsp
+</server>
+<tool>
+lib572
+</tool>
+
+<name>
+RTSP GET_PARAMETER (Put/Heartbeat/Post)
+</name>
+<command>
+rtsp://%HOSTIP:%RTSPPORT/572
+</command>
+# file written before test command runs
+<file name="log/file572.txt">
+scale
+speed
+</file>
+</client>
+
+<verify>
+<strip>
+^If-Modified-Since:.*
+</strip>
+<protocol>
+SETUP rtsp://%HOSTIP:%RTSPPORT/5720001 RTSP/1.0
+CSeq: 1
+Transport: Planes/Trains/Automobiles
+
+GET_PARAMETER rtsp://%HOSTIP:%RTSPPORT/5720002 RTSP/1.0
+CSeq: 2
+Session: getparams-test
+Content-Length: 12
+Content-Type: text/parameters
+
+scale
+speed
+GET_PARAMETER rtsp://%HOSTIP:%RTSPPORT/5720003 RTSP/1.0
+CSeq: 3
+Session: getparams-test
+
+GET_PARAMETER rtsp://%HOSTIP:%RTSPPORT/5720004 RTSP/1.0
+CSeq: 4
+Session: getparams-test
+Content-Length: 24
+Content-Type: text/parameters
+
+packets_received
+jitter
+OPTIONS rtsp://%HOSTIP:%RTSPPORT/5720005 RTSP/1.0
+CSeq: 5
+Session: getparams-test
+
+</protocol>
+</verify>
+
+</testcase>
+
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 5a5a0ea8e..4dc8615a7 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -11,7 +11,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
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 lib567 \
- lib568 lib569 lib570 lib571
+ lib568 lib569 lib570 lib571 lib572
lib500_SOURCES = lib500.c $(SUPPORTFILES)
@@ -143,3 +143,5 @@ lib570_SOURCES = lib570.c $(SUPPORTFILES)
lib571_SOURCES = lib571.c $(SUPPORTFILES)
+lib572_SOURCES = lib572.c $(SUPPORTFILES)
+
diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c
new file mode 100644
index 000000000..8286487ea
--- /dev/null
+++ b/tests/libtest/lib572.c
@@ -0,0 +1,177 @@
+
+/*****************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * $Id$
+ */
+
+#include "test.h"
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#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 GET_PARAMETER: PUT, HEARTBEAT, and POST
+ */
+int test(char *URL)
+{
+ int res;
+ CURL *curl;
+ int params;
+ FILE *paramsf = NULL;
+ struct_stat file_info;
+ char *stream_uri = NULL;
+ 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;
+ }
+
+
+ test_setopt(curl, CURLOPT_HEADERDATA, stdout);
+ test_setopt(curl, CURLOPT_WRITEDATA, stdout);
+ test_setopt(curl, CURLOPT_VERBOSE, 1L);
+
+ test_setopt(curl, CURLOPT_URL, URL);
+
+ /* SETUP */
+ 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;
+
+ test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles");
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
+ fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__);
+ res = curl_easy_perform(curl);
+ fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__);
+ if(res)
+ goto test_cleanup;
+
+ 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;
+ fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__);
+
+ /* PUT style GET_PARAMETERS */
+ params = open("log/file572.txt", O_RDONLY);
+ fstat(params, &file_info);
+ close(params);
+
+ paramsf = fopen("log/file572.txt", "rb");
+ if(paramsf == NULL) {
+ fprintf(stderr, "can't open log/file572.txt\n");
+ res = TEST_ERR_MAJOR_BAD;
+ goto test_cleanup;
+ }
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
+
+ test_setopt(curl, CURLOPT_READDATA, paramsf);
+ test_setopt(curl, CURLOPT_UPLOAD, 1L);
+ test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
+
+ fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__);
+ res = curl_easy_perform(curl);
+ if(res)
+ goto test_cleanup;
+
+ test_setopt(curl, CURLOPT_UPLOAD, 0L);
+ fclose(paramsf);
+ paramsf = NULL;
+ fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__);
+
+ /* Heartbeat GET_PARAMETERS */
+ 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;
+
+ fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__);
+ res = curl_easy_perform(curl);
+ if(res)
+ goto test_cleanup;
+
+ /* POST GET_PARAMETERS */
+
+ 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;
+
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
+ test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n");
+
+ res = curl_easy_perform(curl);
+ if(res)
+ goto test_cleanup;
+
+ test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
+
+ /* Make sure we can do a normal request now */
+ 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;
+
+ test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
+ res = curl_easy_perform(curl);
+
+test_cleanup:
+
+ if(paramsf)
+ fclose(paramsf);
+
+ if(stream_uri)
+ free(stream_uri);
+
+ if(custom_headers)
+ curl_slist_free_all(custom_headers);
+
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+
+ return res;
+}
+