Return to lib569.c CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / curl / tests / libtest |
1.1 ! misho 1: /*************************************************************************** ! 2: * _ _ ____ _ ! 3: * Project ___| | | | _ \| | ! 4: * / __| | | | |_) | | ! 5: * | (__| |_| | _ <| |___ ! 6: * \___|\___/|_| \_\_____| ! 7: * ! 8: * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. ! 9: * ! 10: * This software is licensed as described in the file COPYING, which ! 11: * you should have received as part of this distribution. The terms ! 12: * are also available at https://curl.haxx.se/docs/copyright.html. ! 13: * ! 14: * You may opt to use, copy, modify, merge, publish, distribute and/or sell ! 15: * copies of the Software, and permit persons to whom the Software is ! 16: * furnished to do so, under the terms of the COPYING file. ! 17: * ! 18: * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ! 19: * KIND, either express or implied. ! 20: * ! 21: ***************************************************************************/ ! 22: #include "test.h" ! 23: #include "memdebug.h" ! 24: ! 25: /* build request url */ ! 26: static char *suburl(const char *base, int i) ! 27: { ! 28: return curl_maprintf("%s%.4d", base, i); ! 29: } ! 30: ! 31: /* ! 32: * Test Session ID capture ! 33: */ ! 34: int test(char *URL) ! 35: { ! 36: int res; ! 37: CURL *curl; ! 38: char *stream_uri = NULL; ! 39: char *rtsp_session_id; ! 40: int request = 1; ! 41: int i; ! 42: ! 43: FILE *idfile = fopen(libtest_arg2, "wb"); ! 44: if(idfile == NULL) { ! 45: fprintf(stderr, "couldn't open the Session ID File\n"); ! 46: return TEST_ERR_MAJOR_BAD; ! 47: } ! 48: ! 49: if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { ! 50: fprintf(stderr, "curl_global_init() failed\n"); ! 51: fclose(idfile); ! 52: return TEST_ERR_MAJOR_BAD; ! 53: } ! 54: ! 55: curl = curl_easy_init(); ! 56: if(!curl) { ! 57: fprintf(stderr, "curl_easy_init() failed\n"); ! 58: curl_global_cleanup(); ! 59: fclose(idfile); ! 60: return TEST_ERR_MAJOR_BAD; ! 61: } ! 62: ! 63: test_setopt(curl, CURLOPT_HEADERDATA, stdout); ! 64: test_setopt(curl, CURLOPT_WRITEDATA, stdout); ! 65: test_setopt(curl, CURLOPT_VERBOSE, 1L); ! 66: ! 67: test_setopt(curl, CURLOPT_URL, URL); ! 68: ! 69: test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); ! 70: res = curl_easy_perform(curl); ! 71: if(res != (int)CURLE_BAD_FUNCTION_ARGUMENT) { ! 72: fprintf(stderr, "This should have failed. " ! 73: "Cannot setup without a Transport: header"); ! 74: res = TEST_ERR_MAJOR_BAD; ! 75: goto test_cleanup; ! 76: } ! 77: ! 78: /* Go through the various Session IDs */ ! 79: for(i = 0; i < 3; i++) { ! 80: stream_uri = suburl(URL, request++); ! 81: if(!stream_uri) { ! 82: res = TEST_ERR_MAJOR_BAD; ! 83: goto test_cleanup; ! 84: } ! 85: test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); ! 86: free(stream_uri); ! 87: stream_uri = NULL; ! 88: ! 89: test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); ! 90: test_setopt(curl, CURLOPT_RTSP_TRANSPORT, ! 91: "Fake/NotReal/JustATest;foo=baz"); ! 92: res = curl_easy_perform(curl); ! 93: if(res) ! 94: goto test_cleanup; ! 95: ! 96: curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id); ! 97: fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); ! 98: rtsp_session_id = NULL; ! 99: ! 100: stream_uri = suburl(URL, request++); ! 101: if(!stream_uri) { ! 102: res = TEST_ERR_MAJOR_BAD; ! 103: goto test_cleanup; ! 104: } ! 105: test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); ! 106: free(stream_uri); ! 107: stream_uri = NULL; ! 108: ! 109: test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); ! 110: res = curl_easy_perform(curl); ! 111: ! 112: /* Clear for the next go-round */ ! 113: test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL); ! 114: } ! 115: ! 116: test_cleanup: ! 117: ! 118: if(idfile) ! 119: fclose(idfile); ! 120: ! 121: free(stream_uri); ! 122: curl_easy_cleanup(curl); ! 123: curl_global_cleanup(); ! 124: ! 125: return res; ! 126: }