]> tinc-vpn.org Git - tinc/commitdiff
More CI pipeline fixes
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 1 Apr 2026 22:05:59 +0000 (00:05 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 1 Apr 2026 22:05:59 +0000 (00:05 +0200)
- Use apt instead of apt-get
- Use libgcrypt20-dev on Debian
- Fix CFLAGS on macOS
- Skip ATTR_DEALLOCATOR when using Clang to avoid warnings
- Use tempfile.mkstemp() in test scripts
- Don't explicitly specify MPC_FAMILY
- Re-add forward-declarations of wrapped functions to avoid warnings

13 files changed:
.ci/deps.sh
.ci/package/deb/build.sh
.github/workflows/test.yml
src/have.h
test/integration/cmd_sign_verify.py
test/integration/device_fd.py
test/integration/systemd.py
test/integration/testlib/const.py
test/integration/testlib/notification.py
test/integration/testlib/template/script.py.tpl
test/integration/testlib/util.py
test/unit/test_fs.c
test/unit/test_net.c

index 9c35f07b984c58b21861ab41726e59db2af3ef3b..9cbd115f6ef9abf01e2b522e55e1e46f1f56eec4 100755 (executable)
@@ -18,7 +18,7 @@ deps_linux_alpine() {
 }
 
 deps_linux_debian_mingw() {
-  apt-get install -y \
+  apt install -y \
     mingw-w64 mingw-w64-tools \
     wine wine-binfmt \
     libgcrypt-mingw-w64-dev \
@@ -30,9 +30,9 @@ deps_linux_debian_linux() {
     dpkg --add-architecture "$HOST"
   fi
 
-  apt-get update
+  apt update
 
-  apt-get install -y \
+  apt install -y \
     binfmt-support binutils gcc make pkgconf \
     zlib1g-dev:"$HOST" \
     libssl-dev:"$HOST" \
@@ -40,7 +40,7 @@ deps_linux_debian_linux() {
     liblz4-dev:"$HOST" \
     libncurses-dev:"$HOST" \
     libreadline-dev:"$HOST" \
-    libgcrypt-dev:"$HOST" \
+    libgcrypt20-dev:"$HOST" \
     libminiupnpc-dev:"$HOST" \
     libvdeplug-dev:"$HOST" \
     libcmocka-dev:"$HOST" \
@@ -48,16 +48,16 @@ deps_linux_debian_linux() {
     "$@"
 
   if [ -n "$HOST" ]; then
-    apt-get install -y crossbuild-essential-"$HOST" qemu-user
+    apt install -y crossbuild-essential-"$HOST" qemu-user
   fi
 }
 
 deps_linux_debian() {
   export DEBIAN_FRONTEND=noninteractive
 
-  apt-get update
-  apt-get upgrade -y
-  apt-get install -y git pkgconf sudo texinfo meson
+  apt update
+  apt upgrade -y
+  apt install -y git pkgconf sudo texinfo meson
 
   HOST=${HOST:-}
   if [ "$HOST" = mingw ]; then
index 61396f1ef47fb299ee55db37e113ea130f8f7598..261375dce78629787beca4a4b58c08704fd3b61d 100755 (executable)
@@ -15,7 +15,7 @@ find_tag() {
 
 export DEBIAN_FRONTEND=noninteractive
 
-apt-get install -y devscripts git-buildpackage dh-make
+apt install -y devscripts git-buildpackage dh-make
 
 export USER=${USER:-$(whoami)}
 export EMAIL=ci@tinc-vpn.org
index c8741740a4157e7610c18450c1de9d7db00b67d3..0e69f2f2405c064b24e5f902dfbc271b8ab3bc71 100644 (file)
@@ -90,7 +90,7 @@ jobs:
 
       - name: Install tools
         run: |
-          sudo apt-get install -y astyle clang-tidy-$CLANG shellcheck shfmt black pylint mypy
+          sudo apt install -y astyle clang-tidy-$CLANG shellcheck shfmt black pylint mypy
           sudo update-alternatives --install /usr/bin/clang-tidy     clang-tidy     /usr/bin/clang-tidy-$CLANG     100
           sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-$CLANG 100
           python3 -m venv /tmp/venv
@@ -302,14 +302,14 @@ jobs:
         run: sh .ci/deps.sh
 
       - name: Run tests with default settings
-        run: CFLAGS=/opt/homebrew/include sh .ci/test/run.sh default
+        run: CFLAGS=-I/opt/homebrew/include sh .ci/test/run.sh default
 
       - name: Run tests without legacy protocol
-        run: CFLAGS=/opt/homebrew/include sh .ci/test/run.sh nolegacy
+        run: CFLAGS=-I/opt/homebrew/include sh .ci/test/run.sh nolegacy
         if: always()
 
       - name: Run tests with libgcrypt
-        run: CFLAGS=/opt/homebrew/include sh .ci/test/run.sh gcrypt
+        run: CFLAGS=-I/opt/homebrew/include sh .ci/test/run.sh gcrypt
         if: always()
 
       - name: Upload test results
index a155b04b41abe7a94f106bc8430b52fac6cb8914..186c5f7ada24dfe231cea875305dcde39ef214e8 100644 (file)
@@ -63,7 +63,7 @@
 #endif
 #endif
 
-#if defined(HAVE_ATTR_MALLOC_WITH_ARG)
+#if defined(HAVE_ATTR_MALLOC_WITH_ARG) && !defined(__clang__)
 #define ATTR_DEALLOCATOR(dealloc) __attribute__((__malloc__(dealloc)))
 #else
 #define ATTR_DEALLOCATOR(dealloc)
index 2e6959900e9dddc29f1c6dd7090bcf1073aa882a..e9677b78fb650ac967ff64b5dbef6ce3c3971457 100755 (executable)
@@ -28,9 +28,9 @@ fake testing data\n\
 hello there\n\
 """.encode("utf-8")
 
-RAW_DATA = tempfile.mktemp()
+raw_fd, raw_path = tempfile.mkstemp()
 
-with open(RAW_DATA, "wb") as raw_file:
+with os.fdopen(raw_fd, "wb") as raw_file:
     raw_file.write(util.random_string(64).encode("utf-8"))
 
 
@@ -53,19 +53,19 @@ def test_sign_errors(foo: Tinc) -> None:
     check.is_in("Could not open", err)
 
     os.truncate(foo.sub("ed25519_key.priv"), 0)
-    _, err = foo.cmd("sign", RAW_DATA, code=1)
+    _, err = foo.cmd("sign", raw_path, code=1)
     check.is_in("Could not read private key from", err)
 
     os.remove(foo.sub("ed25519_key.priv"))
-    _, err = foo.cmd("sign", RAW_DATA, code=1)
+    _, err = foo.cmd("sign", raw_path, code=1)
     check.is_in("Could not open", err)
 
 
 def test_verify(foo: Tinc) -> None:
     """Test `verify` of data known to work."""
 
-    signed_file = tempfile.mktemp()
-    with open(signed_file, "wb") as f:
+    fd, path = tempfile.mkstemp()
+    with os.fdopen(fd, "wb") as f:
         f.write(SIGNED_BYTES)
 
     foo.name = "foo"
@@ -75,13 +75,13 @@ def test_verify(foo: Tinc) -> None:
 
     for name in ".", foo.name:
         foo.cmd("verify", name, stdin=SIGNED_BYTES)
-        foo.cmd("verify", name, signed_file)
+        foo.cmd("verify", name, path)
 
     if os.name != "nt":
         foo.cmd("verify", "*", stdin=SIGNED_BYTES)
-        foo.cmd("verify", "*", signed_file)
+        foo.cmd("verify", "*", path)
 
-    os.remove(signed_file)
+    os.remove(path)
 
 
 def test_verify_errors(foo: Tinc) -> None:
@@ -129,30 +129,30 @@ def test_verify_errors(foo: Tinc) -> None:
 def test_sign_verify(foo: Tinc, bar: Tinc) -> None:
     """Test `sign` and pass its result to `verify`."""
 
-    signed, _ = foo.cmd("sign", RAW_DATA, stdin=b"")
+    signed, _ = foo.cmd("sign", raw_path, stdin=b"")
     assert isinstance(signed, bytes)
 
-    signed_file = tempfile.mktemp()
-    with open(signed_file, "wb") as f:
+    fd, path = tempfile.mkstemp()
+    with os.fdopen(fd, "wb") as f:
         f.write(signed)
 
     for name in ".", foo.name:
-        foo.cmd("verify", name, signed_file)
+        foo.cmd("verify", name, path)
         foo.cmd("verify", name, stdin=signed)
 
     if os.name != "nt":
-        foo.cmd("verify", "*", signed_file)
+        foo.cmd("verify", "*", path)
         foo.cmd("verify", "*", stdin=signed)
 
-    os.remove(signed_file)
+    os.remove(path)
 
     cmd.exchange(foo, bar)
 
     if os.name != "nt":
-        signed, _ = foo.cmd("sign", RAW_DATA)
+        signed, _ = foo.cmd("sign", raw_path)
         bar.cmd("verify", "*", stdin=signed)
 
-    signed, _ = bar.cmd("sign", RAW_DATA)
+    signed, _ = bar.cmd("sign", raw_path)
     foo.cmd("verify", bar.name, stdin=signed)
 
 
index 70b5072e2c65f2f95c8d9c209483ba61943ff4cf..1788b0d9f7de24e2aa98127c15941863ed1a5bf7 100755 (executable)
@@ -60,7 +60,7 @@ def test_device_fd(ctx: Test) -> None:
 
     log.info("create a UNIX socket to transfer FD")
     unix = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-    unix_path = tempfile.mktemp()
+    unix_path = tempfile.mkstemp()[1] + ".socket"
     unix.bind(unix_path)
     unix.listen(1)
 
index ccf2f23be292e2ef893b06f3ad73bb8edb08af41..9993a0da0248dcad8fddc9372f4dcc05d0fe1fbf 100755 (executable)
@@ -77,7 +77,7 @@ def recv_until(sock: socket.socket, want: bytes) -> None:
 def test_watchdog(foo: Tinc) -> None:
     """Test systemd watchdog."""
 
-    address = tempfile.mktemp()
+    address = tempfile.mkstemp()[1] + ".socket"
     foo_log = foo.sub("log")
 
     log.info("watchdog is disabled if no env vars are passed")
index 65a66a0a148945943a59458f3525336f40af2f11..b8d7697fc1a55155477680156a585027d261d7ad 100755 (executable)
@@ -5,9 +5,6 @@ import os
 # Exit code to skip current test
 EXIT_SKIP = 77
 
-# Family name for multiprocessing Listener/Connection
-MPC_FAMILY = "AF_PIPE" if os.name == "nt" else "AF_UNIX"
-
 # Do access checks on files. Disabled when not available or not applicable.
 RUN_ACCESS_CHECKS = os.name != "nt" and os.geteuid() != 0
 
index 7813bf01dc3da2ceb49d458944b921f49ae7d51e..5a421a3c64942395bcf379479d0b2564097be36d 100755 (executable)
@@ -9,7 +9,6 @@ import typing as T
 
 from .log import log
 from .event import Notification
-from .const import MPC_FAMILY
 
 
 def _get_key(name, script) -> str:
@@ -78,7 +77,7 @@ class NotificationServer:
             os.kill(0, signal.SIGTERM)
 
     def _listen(self) -> None:
-        with mp.Listener(family=MPC_FAMILY, authkey=self.authkey) as listener:
+        with mp.Listener(authkey=self.authkey) as listener:
             assert not isinstance(listener.address, tuple)
             self.address = listener.address
             self._ready.set()
index 59e229a40878f6428c39512e45e4f7a23e5ed04d..d542b5b17a3c6ed0309550c780138d80414f7152 100644 (file)
@@ -22,7 +22,6 @@ sys.path.append(r'$SRC_ROOT')
 from testlib.proc import Tinc
 from testlib.event import Notification
 from testlib.log import new_logger
-from testlib.const import MPC_FAMILY
 
 this = Tinc('$NODE_NAME')
 log = new_logger(this.name)
@@ -39,7 +38,7 @@ def notify_test(args: T.Dict[str, T.Any] = {}, error: T.Optional[Exception] = No
 
     for retry in range(1, 10):
         try:
-            with mpc.Client($NOTIFICATIONS_ADDR, family=MPC_FAMILY, authkey=$AUTH_KEY) as conn:
+            with mpc.Client($NOTIFICATIONS_ADDR, authkey=$AUTH_KEY) as conn:
                 conn.send(evt)
             log.debug(f'sent notification')
             break
index fdba760eb985350cde31e3af6423f1aa44a084cd..38aaffff63e1d200687a969875d989f23324fe22 100755 (executable)
@@ -35,10 +35,10 @@ def random_port() -> int:
 
 def temp_file(content: str) -> str:
     """Create a temporary file and write text content into it."""
-    file = tempfile.mktemp()
-    with open(file, "w", encoding="utf-8") as f:
+    fd, path = tempfile.mkstemp()
+    with os.fdopen(fd, "w", encoding="utf-8") as f:
         f.write(content)
-    return file
+    return path
 
 
 def remove_file(path: T.Union[str, Path]) -> bool:
index 37a4a7e6f48db6d1b68d7d11642ce5948eb17931..579efa3fd0b17a296eac08d850ff9e13f43b3a2e 100644 (file)
@@ -194,7 +194,6 @@ static void test_fopenmask_new(void **state) {
        struct stat st;
        strcpy(tmp, tmp_template);
 
-       // mktemp() nags about safety and using better alternatives
        int fd = mkstemp(tmp);
        assert_int_not_equal(-1, fd);
        close(fd);
index 9e56ee301a5f1b8e2662a3c09f699eaf457927be..0320a9e4ae1558cabf3f427637db5061c471ca81 100644 (file)
@@ -5,6 +5,10 @@
 static environment_t *device_env = NULL;
 
 // NOLINTBEGIN(misc-use-internal-linkage)
+void __wrap_environment_init(environment_t *env);
+void __wrap_environment_exit(environment_t *env);
+bool __wrap_execute_script(const char *name, environment_t *env);
+
 void __wrap_environment_init(environment_t *env) {
        assert_non_null(env);
        assert_null(device_env);