From: Tomas Krizek Date: Mon, 4 Feb 2019 11:02:59 +0000 (+0100) Subject: meson: tests/pytests - compile tls proxy X-Git-Tag: v4.0.0~24^2~195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3bbbf72cde760cd0bf250d57328f44811bf31feb;p=thirdparty%2Fknot-resolver.git meson: tests/pytests - compile tls proxy --- diff --git a/tests/meson.build b/tests/meson.build index 08ccb01ad..03068d024 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,2 +1,3 @@ subdir('config') subdir('unit') +subdir('pytests') diff --git a/tests/pytests/meson.build b/tests/pytests/meson.build new file mode 100644 index 000000000..05359d256 --- /dev/null +++ b/tests/pytests/meson.build @@ -0,0 +1,38 @@ +tlsproxy_src = [ + 'proxy/tlsproxy.c', + 'proxy/tls-proxy.c', +] + +tlsproxy = executable( + 'tlsproxy', + tlsproxy_src, + dependencies: [ + libkres_dep, + libuv, + gnutls, + ], + build_by_default: false, +) + + +pytest = find_program('pytest', required: false) +test( + 'pytests.basic', + pytest, + is_parallel: false + args: [ + '--html', 'pytests.basic.html', + '--self-contained-html', + '-d', + '-n', '24', + meson.current_source_dir(), + ], + env: [ + 'KRESD_EXEC=@0@'.format(kresd_install_path), + 'TLSPROXY_EXEC=@0@'.format(join_paths(meson.current_build_dir(), 'tlsproxy')), + ], + suite: [ + 'postinstall', + 'pytests', + ], +) diff --git a/tests/pytests/proxy/array.h b/tests/pytests/proxy/array.h deleted file mode 120000 index 33f18f447..000000000 --- a/tests/pytests/proxy/array.h +++ /dev/null @@ -1 +0,0 @@ -../../../lib/generic/array.h \ No newline at end of file diff --git a/tests/pytests/proxy/tls-proxy.c b/tests/pytests/proxy/tls-proxy.c index ac9254614..d782d2613 100644 --- a/tests/pytests/proxy/tls-proxy.c +++ b/tests/pytests/proxy/tls-proxy.c @@ -6,7 +6,7 @@ #include #include #include -#include "array.h" +#include "lib/generic/array.h" #include "tls-proxy.h" #define TLS_MAX_SEND_RETRIES 100 @@ -382,7 +382,7 @@ static void accept_connection_from_client(uv_stream_t *server) return; } memcpy(&upstream->addr, &proxy->upstream_addr, sizeof(struct sockaddr_storage)); - + struct tls_ctx *tls = calloc(1, sizeof(struct tls_ctx)); tls->handshake_state = TLS_HS_NOT_STARTED; @@ -922,7 +922,7 @@ struct tls_proxy_ctx *tls_proxy_allocate() } int tls_proxy_init(struct tls_proxy_ctx *proxy, const struct args *a) -{ +{ const char *server_addr = a->local_addr; int server_port = a->local_port; const char *upstream_addr = a->upstream; @@ -952,7 +952,7 @@ int tls_proxy_init(struct tls_proxy_ctx *proxy, const struct args *a) proxy->conn_sequence = 0; proxy->loop->data = proxy; - + int err = 0; if (gnutls_references == 0) { err = gnutls_global_init(); @@ -963,7 +963,7 @@ int tls_proxy_init(struct tls_proxy_ctx *proxy, const struct args *a) } } gnutls_references += 1; - + err = gnutls_certificate_allocate_credentials(&proxy->tls_credentials); if (err != GNUTLS_E_SUCCESS) { fprintf(stdout, "[proxy] gnutls_certificate_allocate_credentials() failed: (%d) %s\n", @@ -1016,7 +1016,7 @@ void tls_proxy_free(struct tls_proxy_ctx *proxy) gnutls_certificate_free_credentials(proxy->tls_credentials); gnutls_priority_deinit(proxy->tls_priority_cache); free(proxy); - + gnutls_references -= 1; if (gnutls_references == 0) { gnutls_global_deinit(); @@ -1024,7 +1024,7 @@ void tls_proxy_free(struct tls_proxy_ctx *proxy) } int tls_proxy_start_listen(struct tls_proxy_ctx *proxy) -{ +{ uv_tcp_bind(&proxy->server.handle, (const struct sockaddr*)&proxy->server.addr, 0); int ret = uv_listen((uv_stream_t*)&proxy->server.handle, 128, on_client_connection); return ret;