diff options
| author | Chris Conroy <cconroy@gmail.com> | 2010-03-24 01:35:03 -0400 | 
|---|---|---|
| committer | Daniel Stenberg <daniel@haxx.se> | 2010-03-24 13:21:14 +0100 | 
| commit | 1ac168e576d8e78b58640e1e997249717529b482 (patch) | |
| tree | 28e15363ef86b15292b5025ec05b8f66cb53cb9f /tests/libtest | |
| parent | 50b51161c9ae3833489d2bf42b43fced46ab5587 (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/libtest')
| -rw-r--r-- | tests/libtest/Makefile.inc | 4 | ||||
| -rw-r--r-- | tests/libtest/lib572.c | 177 | 
2 files changed, 180 insertions, 1 deletions
| 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; +} + | 
