]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson: tests/pytests - compile tls proxy
authorTomas Krizek <tomas.krizek@nic.cz>
Mon, 4 Feb 2019 11:02:59 +0000 (12:02 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 12 Mar 2019 09:41:54 +0000 (10:41 +0100)
tests/meson.build
tests/pytests/meson.build [new file with mode: 0644]
tests/pytests/proxy/array.h [deleted symlink]
tests/pytests/proxy/tls-proxy.c

index 08ccb01adf684d2d4ee08f33c07d92eeeb729eca..03068d0244f6de7c9c77a5c22536fe161447efbb 100644 (file)
@@ -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 (file)
index 0000000..05359d2
--- /dev/null
@@ -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 (symlink)
index 33f18f4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../lib/generic/array.h
\ No newline at end of file
index ac925461432e9dde39d21da708a2cbd9d35a1122..d782d2613f0e494a790fc26381828c6cbe97b314 100644 (file)
@@ -6,7 +6,7 @@
 #include <stdbool.h>
 #include <gnutls/gnutls.h>
 #include <uv.h>
-#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;