]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
libxml2: backport -timeout flag for testlimits
authorTrevor Gamblin <tgamblin@baylibre.com>
Tue, 13 Jan 2026 18:45:32 +0000 (13:45 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 14 Jan 2026 17:34:55 +0000 (17:34 +0000)
[YOCTO #15912]

A commit was recently merged upstream to make the testlimits test's
timeout configurable. This test fails intermittently on the AB under
heavy load (particularly on qemuriscv64), so backport the change and
adjust the timeout from two seconds to five.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/libxml/libxml2/0001-testlimits-optionally-accept-timeout-input.patch [new file with mode: 0644]
meta/recipes-core/libxml/libxml2/run-ptest
meta/recipes-core/libxml/libxml2_2.15.1.bb

diff --git a/meta/recipes-core/libxml/libxml2/0001-testlimits-optionally-accept-timeout-input.patch b/meta/recipes-core/libxml/libxml2/0001-testlimits-optionally-accept-timeout-input.patch
new file mode 100644 (file)
index 0000000..2f0899a
--- /dev/null
@@ -0,0 +1,92 @@
+From b45e38edab72e4f09b24a5c9672df818f8df020c Mon Sep 17 00:00:00 2001
+From: Trevor Gamblin <tgamblin@baylibre.com>
+Date: Thu, 8 Jan 2026 15:30:47 -0500
+Subject: [PATCH] testlimits: optionally accept '-timeout' input
+
+Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/-/commit/b45e38edab72e4f09b24a5c9672df818f8df020c]
+Fixes: #1032
+
+The testlimits tests can use a lot of system resources, and thus they
+may fail when run on systems under heavy load, given that the default
+parsing timeout is set to two seconds. Retain this default value, but
+make the timeout length configurable with a new '-timeout' flag.
+
+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
+---
+ testlimits.c | 33 ++++++++++++++++++++++++++-------
+ 1 file changed, 26 insertions(+), 7 deletions(-)
+
+diff --git a/testlimits.c b/testlimits.c
+index 695cbf48..87fcd1a1 100644
+--- a/testlimits.c
++++ b/testlimits.c
+@@ -35,9 +35,10 @@ static int tests_quiet = 0;
+  *                                                                    *
+  ************************************************************************/
+-/* maximum time for one parsing before declaring a timeout */
+-#define MAX_TIME 2 /* seconds */
++/* default maximum time for one parsing before declaring a timeout */
++#define DEFAULT_MAX_TIME 2 /* seconds */
++static int max_time = DEFAULT_MAX_TIME;
+ static clock_t t0;
+ static int timeout = 0;
+@@ -48,7 +49,7 @@ static void reset_timout(void) {
+ static int check_time(void) {
+     clock_t tnow = clock();
+-    if (((tnow - t0) / CLOCKS_PER_SEC) > MAX_TIME) {
++    if (((tnow - t0) / CLOCKS_PER_SEC) > max_time) {
+         timeout = 1;
+         return(0);
+     }
+@@ -1228,22 +1229,40 @@ runcrazy(void) {
+     return(ret);
+ }
+-
+ int
+ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
+     int i, a, ret = 0;
+     int subset = 0;
++    char *endptr;
++    long val;
+     fillFilling();
+     initializeLibxml2();
+     for (a = 1; a < argc;a++) {
+         if (!strcmp(argv[a], "-v"))
+-          verbose = 1;
++            verbose = 1;
+         else if (!strcmp(argv[a], "-quiet"))
+-          tests_quiet = 1;
++            tests_quiet = 1;
+         else if (!strcmp(argv[a], "-crazy"))
+-          subset = 1;
++            subset = 1;
++        else if (!strcmp(argv[a], "-timeout")) {
++            if (a + 1 >= argc) {
++                fprintf(stderr, "Error: -timeout requires a value in seconds\n");
++                return 1;
++            }
++            val = strtol(argv[a + 1], &endptr, 10);
++            if (endptr == argv[a + 1] || *endptr != '\0') {
++                fprintf(stderr, "Error: -timeout value '%s' is not a valid number\n", argv[a + 1]);
++                return 1;
++            }
++            if (val <= 0 || val > INT_MAX) {
++                fprintf(stderr, "Error: -timeout must be a positive integer (got %s)\n", argv[a + 1]);
++                return 1;
++            }
++            max_time = (int)val;
++            a++;
++        }
+     }
+     if (subset == 0) {
+       for (i = 0; testDescriptions[i].func != NULL; i++) {
+-- 
+2.52.0
+
index 868649240b9f2c224e3950c5066132910280b579..becf61398e14e6156c1b7d6d5c2b7d0013b82f15 100755 (executable)
@@ -5,9 +5,12 @@ set -e
 export LC_ALL=en_US.UTF-8
 
 # testModule isn't that useful and hard-codes buildtree, so we don't run that
-TESTS="runtest runsuite testrecurse testchar testdict runxmlconf testapi testlimits testparser"
+TESTS="runtest runsuite testrecurse testchar testdict runxmlconf testapi testparser"
 
 for T in $TESTS; do
     echo Running $T
     ./$T && echo PASS: $T || echo FAIL: $T
 done
+
+echo Running testlimits with -timeout 5
+./testlimits -timeout 5 && echo PASS: testlimits || echo FAIL: testlimits
index 905688e834bc656fa2a31893ee7b999cae473a36..736aaea00e33d1012fe30c73b2d8ceb1591c1267 100644 (file)
@@ -18,6 +18,7 @@ SRC_URI += "http://www.w3.org/XML/Test/xmlts20130923.tar;subdir=${BP};name=testt
            file://run-ptest \
            file://install-tests.patch \
            file://0001-Revert-cmake-Fix-installation-directories-in-libxml2.patch \
+           file://0001-testlimits-optionally-accept-timeout-input.patch \
            "
 
 SRC_URI[archive.sha256sum] = "c008bac08fd5c7b4a87f7b8a71f283fa581d80d80ff8d2efd3b26224c39bc54c"