]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: build non-debug unit tests with autotools, run them
authorViktor Szakats <commit@vsz.me>
Wed, 19 Mar 2025 23:55:55 +0000 (00:55 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 24 Mar 2025 09:15:05 +0000 (10:15 +0100)
Before this patch, autotools disabled building unit tests for
non-debug-enabled (`DEBUGBUILD`) builds. runtests skipped running this
combination, though they were built in cmake builds. There seems to be
no technical reason anymore for these restrictions. This patch removes
them, allowing to build and run unit tests for non-debug-enabled builds.

To improve unit test build and run coverage.

- autotools: do not disable building unit tests for non-debug-enabled
  build. Bringing behavior closer to cmake builds. (There are still
  exceptions in autotools, something for another PR)

- runtests: run unit tests for non-debug-enabled builds.
  It extends coverage by 50 tests.

- `lib/altsvc.c`: fix to include `CURL_TIME` support in libcurlu, for
  unit tests. It fixes test 1654, and syncs `CURL_TIME` behavior with
  test 1660 and `lib/hsts.c`.

Ref: 10a7d05be3921b9c9762477a18d41aff232d94d8
Ref: fc8e0dee3045658f293452121f5290d81ba3aa1e #13694
Ref: 99f78cbf6ed376391f519de18d289a6924228591 #16770

Closes #16771

configure.ac
lib/altsvc.c
tests/runtests.pl

index aff1b7ca72c26d5566121536efb36618207857b5..f54f5f8270b5b6d8472ebab8368f7db605526ec4 100644 (file)
@@ -572,6 +572,8 @@ case $host_os in
     ;;
 esac
 
+AM_CONDITIONAL(BUILD_UNITTESTS, test x$supports_unittests = xyes)
+
 # In order to detect support of sendmmsg(), we need to escape the POSIX
 # jail by defining _GNU_SOURCE or <sys/socket.h> will not expose it.
 case $host_os in
@@ -580,15 +582,6 @@ case $host_os in
     ;;
 esac
 
-dnl Build unit tests when option --enable-debug is given.
-if test "x$want_debug" = "xyes" &&
-   test "x$supports_unittests" = "xyes"; then
-  want_unittests=yes
-else
-  want_unittests=no
-fi
-AM_CONDITIONAL(BUILD_UNITTESTS, test x$want_unittests = xyes)
-
 dnl Apply curl debug options to test servers
 OPT_SERVER_DEBUG="default"
 AC_ARG_ENABLE(server-debug,
index c4dca59f3d013539a9603d49e9ffed85fa8770e0..77bbbdb88ed90021257bb94961cf2bc7fa2e4011 100644 (file)
@@ -438,7 +438,7 @@ static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid,
   }
 }
 
-#ifdef DEBUGBUILD
+#if defined(DEBUGBUILD) || defined(UNITTESTS)
 /* to play well with debug builds, we can *set* a fixed time this will
    return */
 static time_t altsvc_debugtime(void *unused)
index ae2e5fef817a9ca6c8836495503c35ee5de78096..947e5b4790fb671a153dfc4595ff171425c4eb99 100755 (executable)
@@ -804,7 +804,7 @@ sub checksystemfeatures {
     }
     close($manh);
 
-    $feature{"unittest"} = $feature{"Debug"};
+    $feature{"unittest"} = 1;
     $feature{"nghttpx"} = !!$ENV{'NGHTTPX'};
     $feature{"nghttpx-h3"} = !!$nghttpx_h3;