@@ -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)
@@ -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>