From 5cd8f23953330d565a6f38dc46d48c7f3a81ae6a Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tomas.krizek@nic.cz>
Date: Mon, 21 Jun 2021 14:06:47 +0200
Subject: [PATCH 1/4] ci: test on armhf and arm64

---
 .gitlab-ci.yml | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a743f2bcc..decff4550 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -92,6 +92,28 @@ build:
     - ninja -C build_ci install >/dev/null
     - ${MESON_TEST} --suite unit --suite config --suite dnstap --no-suite snowflake
 
+build:armhf:
+  <<: *build
+  tags:
+    - armhf
+    - shell
+  script:
+    - meson build_ci_armhf --default-library=static --prefix=$PREFIX -Dwerror=true -Dextra_tests=enabled
+    - ninja -C build_ci_armhf
+    - ninja -C build_ci_armhf install >/dev/null
+    - ${MESON_TEST} --suite unit --suite config --no-suite snowflake --no-suite y2k38
+
+build:arm64:
+  <<: *build
+  tags:
+    - arm64
+    - shell
+  script:
+    - meson build_ci_arm64 --default-library=static --prefix=$PREFIX -Dwerror=true -Dextra_tests=enabled
+    - ninja -C build_ci_arm64
+    - ninja -C build_ci_arm64 install >/dev/null
+    - ${MESON_TEST} --suite unit --suite config --no-suite snowflake
+
 build-asan:
   <<: *build
   script:
-- 
GitLab


From d186a90173a03bda92ca04ed3af25e028b0aef85 Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tomas.krizek@nic.cz>
Date: Mon, 21 Jun 2021 14:51:28 +0200
Subject: [PATCH 2/4] printf: use platform independent length modifiers

Make sure we use the correct lemgth modifiers to support both 32b and
64b architectures.
---
 daemon/http.c                   | 2 +-
 tests/pytests/proxy/tls-proxy.h | 2 ++
 tests/pytests/proxy/tlsproxy.c  | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/daemon/http.c b/daemon/http.c
index 3055f3d0c..e21b0db14 100644
--- a/daemon/http.c
+++ b/daemon/http.c
@@ -331,7 +331,7 @@ static int header_callback(nghttp2_session *h2, const nghttp2_frame *frame,
 			/* Limit maximum value size to reduce attack surface. */
 			if (valuelen > HTTP_MAX_HEADER_IN_SIZE) {
 				kr_log_verbose(
-					"[http] stream %d: header too large (%ld B), refused\n",
+					"[http] stream %d: header too large (%zu B), refused\n",
 					stream_id, valuelen);
 				refuse_stream(h2, stream_id);
 				return 0;
diff --git a/tests/pytests/proxy/tls-proxy.h b/tests/pytests/proxy/tls-proxy.h
index c6f468d49..2dbd9fd81 100644
--- a/tests/pytests/proxy/tls-proxy.h
+++ b/tests/pytests/proxy/tls-proxy.h
@@ -1,6 +1,8 @@
 #pragma once
 /* SPDX-License-Identifier: GPL-3.0-or-later */
 
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <netinet/in.h>
diff --git a/tests/pytests/proxy/tlsproxy.c b/tests/pytests/proxy/tlsproxy.c
index f1b4acc2f..bcdffb03d 100644
--- a/tests/pytests/proxy/tlsproxy.c
+++ b/tests/pytests/proxy/tlsproxy.c
@@ -25,7 +25,7 @@ void help(char *argv[], struct args *a)
 	       " -t, --cert=[path]      Path to certificate file (default: %s).\n"
 	       " -k, --key=[path]       Path to key file (default: %s).\n"
 	       " -c, --close=[N]        Close connection to client after\n"
-	       "                        every N ms (default: %li).\n"
+	       "                        every N ms (default: %" PRIu64 ").\n"
 	       " -f, --fail=[N]         Delay every Nth incoming connection by 10 sec,\n"
 	       "                        0 disables delaying (default: 0).\n"
 	       " -r, --rehandshake      Do TLS rehandshake after every 8 bytes\n"
-- 
GitLab


From f1450e3475492d8b3438449aea54191890fdf447 Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tomas.krizek@nic.cz>
Date: Mon, 21 Jun 2021 16:23:41 +0200
Subject: [PATCH 3/4] ci: disable ta_bootstrap on 32bit ARM

The test attempts to use the timestamp 2050-12-31T23:59:59, which can't
be represented with 32bit time_t due to Year 2038 problem.
---
 daemon/lua/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemon/lua/meson.build b/daemon/lua/meson.build
index 08539b0cb..fabf0414b 100644
--- a/daemon/lua/meson.build
+++ b/daemon/lua/meson.build
@@ -5,7 +5,7 @@ config_tests += [
   ['controlsock', files('controlsock.test.lua')],
   ['krprint', files('krprint.test.lua')],
   ['ta', files('trust_anchors.test/ta.test.lua')],
-  ['ta_bootstrap', files('trust_anchors.test/bootstrap.test.lua')],
+  ['ta_bootstrap', files('trust_anchors.test/bootstrap.test.lua'), ['y2k38']],
 ]
 
 integr_tests += [
-- 
GitLab


From 34c6e29fe2842201225cd4b97fef2cbd3e776bae Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tomas.krizek@nic.cz>
Date: Mon, 21 Jun 2021 16:45:09 +0200
Subject: [PATCH 4/4] ci: attempt to make CI more robust by reducing paralelism

Some tests (typically those using network) ocassionally fail due to
timeouts, which is probably due to increased CI load - perhaps reducing
it could make the tests more stable.
---
 .gitlab-ci.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index decff4550..f04f66b44 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -101,7 +101,7 @@ build:armhf:
     - meson build_ci_armhf --default-library=static --prefix=$PREFIX -Dwerror=true -Dextra_tests=enabled
     - ninja -C build_ci_armhf
     - ninja -C build_ci_armhf install >/dev/null
-    - ${MESON_TEST} --suite unit --suite config --no-suite snowflake --no-suite y2k38
+    - MESON_TESTTHREADS=1 ${MESON_TEST} --suite unit --suite config --no-suite snowflake --no-suite y2k38
 
 build:arm64:
   <<: *build
@@ -112,7 +112,7 @@ build:arm64:
     - meson build_ci_arm64 --default-library=static --prefix=$PREFIX -Dwerror=true -Dextra_tests=enabled
     - ninja -C build_ci_arm64
     - ninja -C build_ci_arm64 install >/dev/null
-    - ${MESON_TEST} --suite unit --suite config --no-suite snowflake
+    - MESON_TESTTHREADS=1 ${MESON_TEST} --suite unit --suite config --no-suite snowflake
 
 build-asan:
   <<: *build
@@ -123,7 +123,7 @@ build-asan:
     - ninja -C build_ci_asan install >/dev/null
       # TODO _leaks: not sure what exactly is wrong in leak detection on config tests
       # TODO skip_asan: all three of these disappear locally when using gcc 9.1 (except some leaks)
-    - ASAN_OPTIONS=detect_leaks=0 ${MESON_TEST} --suite unit --suite config --suite dnstap --no-suite skip_asan --no-suite snowflake
+    - MESON_TESTTHREADS=1 ASAN_OPTIONS=detect_leaks=0 ${MESON_TEST} --suite unit --suite config --suite dnstap --no-suite skip_asan --no-suite snowflake
 
 build:macOS:
   <<: *nodep
-- 
GitLab