]> git.proxmox.com Git - libgit2.git/blame - tests/core/stream.c
DFSG changes
[libgit2.git] / tests / core / stream.c
CommitLineData
7fafde63
CMN
1#include "clar_libgit2.h"
2#include "git2/sys/stream.h"
3#include "tls_stream.h"
4#include "stream.h"
5
6static git_stream test_stream;
7static int ctor_called;
8
9static int test_ctor(git_stream **out, const char *host, const char *port)
10{
11 GIT_UNUSED(host);
12 GIT_UNUSED(port);
13
14 ctor_called = 1;
15 *out = &test_stream;
16
17 return 0;
18}
19
20void test_core_stream__register_tls(void)
21{
22 git_stream *stream;
23 int error;
24
25 ctor_called = 0;
26 cl_git_pass(git_stream_register_tls(test_ctor));
27 cl_git_pass(git_tls_stream_new(&stream, "localhost", "443"));
28 cl_assert_equal_i(1, ctor_called);
29 cl_assert_equal_p(&test_stream, stream);
30
31 ctor_called = 0;
32 stream = NULL;
33 cl_git_pass(git_stream_register_tls(NULL));
34 error = git_tls_stream_new(&stream, "localhost", "443");
35
ab062a39
AH
36 /* We don't have arbitrary TLS stream support on Windows
37 * or when openssl support is disabled (except on OSX
38 * with Security framework).
39 */
40#if defined(GIT_WIN32) || \
41 (!defined(GIT_SECURE_TRANSPORT) && !defined(GIT_OPENSSL))
7fafde63
CMN
42 cl_git_fail_with(-1, error);
43#else
44 cl_git_pass(error);
45#endif
46
47 cl_assert_equal_i(0, ctor_called);
48 cl_assert(&test_stream != stream);
49
50 git_stream_free(stream);
51}