Git init
[external/curl.git] / tests / libtest / lib570.c
1 /*****************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  */
9
10 #include "test.h"
11
12 #include <curl/mprintf.h>
13
14 #include "memdebug.h"
15
16 /* build request url */
17 static char *suburl(const char *base, int i)
18 {
19   return curl_maprintf("%s%.4d", base, i);
20 }
21
22 int test(char *URL)
23 {
24   int res;
25   CURL *curl;
26   int request=1;
27   char *stream_uri = NULL;
28
29   if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
30     fprintf(stderr, "curl_global_init() failed\n");
31     return TEST_ERR_MAJOR_BAD;
32   }
33
34   if ((curl = curl_easy_init()) == NULL) {
35     fprintf(stderr, "curl_easy_init() failed\n");
36     curl_global_cleanup();
37     return TEST_ERR_MAJOR_BAD;
38   }
39
40   test_setopt(curl, CURLOPT_HEADERDATA, stdout);
41   test_setopt(curl, CURLOPT_WRITEDATA, stdout);
42   test_setopt(curl, CURLOPT_VERBOSE, 1L);
43
44   test_setopt(curl, CURLOPT_URL, URL);
45
46   test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
47
48   if((stream_uri = suburl(URL, request++)) == NULL) {
49     res = TEST_ERR_MAJOR_BAD;
50     goto test_cleanup;
51   }
52   test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
53   free(stream_uri);
54   stream_uri = NULL;
55
56   res = curl_easy_perform(curl);
57   if(res != (int)CURLE_RTSP_CSEQ_ERROR) {
58     fprintf(stderr, "Failed to detect CSeq mismatch");
59     res = TEST_ERR_MAJOR_BAD;
60     goto test_cleanup;
61   }
62
63   test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999);
64   test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
65                     "RAW/RAW/UDP;unicast;client_port=3056-3057");
66   test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
67
68   if((stream_uri = suburl(URL, request++)) == NULL) {
69     res = TEST_ERR_MAJOR_BAD;
70     goto test_cleanup;
71   }
72   test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
73   free(stream_uri);
74   stream_uri = NULL;
75
76   res = curl_easy_perform(curl);
77   if(res)
78     goto test_cleanup;
79
80   test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
81
82   if((stream_uri = suburl(URL, request++)) == NULL) {
83     res = TEST_ERR_MAJOR_BAD;
84     goto test_cleanup;
85   }
86   test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
87   free(stream_uri);
88   stream_uri = NULL;
89
90   res = curl_easy_perform(curl);
91   if(res != CURLE_RTSP_SESSION_ERROR) {
92     fprintf(stderr, "Failed to detect a Session ID mismatch");
93   }
94
95 test_cleanup:
96
97   if(stream_uri)
98     free(stream_uri);
99
100   curl_easy_cleanup(curl);
101   curl_global_cleanup();
102
103   return res;
104 }
105