[5/6] resolv: Make tst-resolv-qtypes a regular test

Message ID 20260709174957.670741-6-adhemerval.zanella@linaro.org (mailing list archive)
State New
Headers
Series Move some xtests to make check |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Adhemerval Zanella Netto July 9, 2026, 5:48 p.m. UTC
  The record type is an opaque 16-bit value on the query path, so sweeping
all 1..65535 values sent millions of packets with no added coverage over
a representative sample.

Test a curated set instead and move it out of xtests.
---
 resolv/Makefile            |  4 +---
 resolv/tst-resolv-qtypes.c | 17 +++++++++++++++--
 2 files changed, 16 insertions(+), 5 deletions(-)
  

Patch

diff --git a/resolv/Makefile b/resolv/Makefile
index 28f6ba6c3b5..73983eb13c3 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -123,6 +123,7 @@  tests += \
   tst-resolv-noaaaa \
   tst-resolv-noaaaa-vc \
   tst-resolv-nondecimal \
+  tst-resolv-qtypes \
   tst-resolv-res_init-failure \
   tst-resolv-res_init-multi \
   tst-resolv-search \
@@ -184,9 +185,6 @@  ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes)
 tests += tst-p_secstodate
 endif
 
-# This test sends millions of packets and is rather slow.
-xtests += tst-resolv-qtypes
-
 # This test has dropped packet tests and runs for a long time.
 xtests += tst-resolv-rotate
 endif # $(have-thread-library)
diff --git a/resolv/tst-resolv-qtypes.c b/resolv/tst-resolv-qtypes.c
index f2f97a334ee..69588748afe 100644
--- a/resolv/tst-resolv-qtypes.c
+++ b/resolv/tst-resolv-qtypes.c
@@ -16,6 +16,7 @@ 
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <array_length.h>
 #include <resolv.h>
 #include <string.h>
 #include <support/check.h>
@@ -29,6 +30,18 @@ 
    over TCP instead of UDP.  */
 static volatile bool force_tcp;
 
+/* The record type is an opaque 16-bit value on the query path, so this
+   representative sample (low values, well-known and meta record types,
+   and values around the 8-bit and 16-bit boundaries) exercises the same
+   code as the full 1..65535 range at a fraction of the cost.  */
+static const int qtypes[] =
+  {
+    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+    28, 33, 35, 39, 41, 43, 46, 47, 48, 52, 99, 108, 249, 250, 251,
+    252, 253, 254, 255, 256, 257, 511, 512, 1000, 4096, 32767, 32768,
+    32769, 65534, 65535,
+  };
+
 /* Send back a fake resource record matching the QTYPE.  */
 static void
 response (const struct resolv_response_context *ctx,
@@ -133,8 +146,9 @@  test_function (const char *fname,
   for (int tcp = 0; tcp < 2; ++tcp)
     {
       force_tcp = tcp;
-      for (unsigned int type = 1; type <= 65535; ++type)
+      for (size_t i = 0; i < array_length (qtypes); ++i)
         {
+          unsigned int type = qtypes[i];
           if (test_verbose)
             printf ("info: sending QTYPE %d with %s (tcp=%d)\n",
                     type, fname, tcp);
@@ -181,5 +195,4 @@  do_test (void)
   return 0;
 }
 
-#define TIMEOUT 300
 #include <support/test-driver.c>