From patchwork Thu Jul 9 17:48:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 138837 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A01074BA23F5 for ; Thu, 9 Jul 2026 17:50:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A01074BA23F5 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hPoTO7Q3 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 2480A4BA2E2F for ; Thu, 9 Jul 2026 17:50:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2480A4BA2E2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2480A4BA2E2F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619404; cv=none; b=wPW094yriYJTgDDaY2PUWbp5XHbWE5bv9JR2xH9cFLFes9rHyKLiTk86nK7poBVB81L+DCoVFBm3TlfwuxuixqAkv/+X40EzuEax0lXmzIR70RrgpNxm3kWGQIWfiS3MFCHeVCV9POUOZJj0rF9y/izgYQPY0mcKBxYbWUwlqGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619404; c=relaxed/simple; bh=dQKPrTFMsAXT7/hFujGYCpmfC/6821IcwSJnDyD/am4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MfYgcQoMr8zOd8AyT70YMi4cz9JXBZ2O1FKDo88p8BYpFZif0BrLlrXALvF2evuwH2gnj2bviiikMs4mZhgQZqbucxNOFL5xqjsg0b+bFJSjjJ/r6lGIdwLNzrI7LkD9wKzQQdB51KYE959nfsAZMcdOFCVjGNjv2fT+TM77/qs= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hPoTO7Q3 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2480A4BA2E2F Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-c998fd549a8so74020a12.2 for ; Thu, 09 Jul 2026 10:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783619403; x=1784224203; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=aZpBpyXUVoEaG7xVQUsa1D/0GZ3pslzZLA9g+GBVII4=; b=hPoTO7Q3ZGhOQUjufcsdsy23anzd54covONxjWtm2MDWpn2O3VxhGkdvJM2F1tCS6N WK9+S5utvlsXu9USW758YBCrvsQwrZEHjg8fBKFJQMuwm6eXOxhJK/exbqkw3ftWdrb8 CZzU3MFKdBWcF45OAwJzZSb8nhnGDFwl/sJs7af+aDp5bbEbdZmR9sYMD7V2vI2pGpXl wbP95MYsQpHo/ZYmK0xf5+lAU0VWABFcNtSMKBVbA+rNQsZETkS/NeDkXHC6ZVQiCBGg lvX3w+kygJqub6VlxUj4eXXv9UV5b4SvBUeafXE3R9gkwSsoJc9tSdo5H9Paa3ldYLDT FyzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783619403; x=1784224203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=aZpBpyXUVoEaG7xVQUsa1D/0GZ3pslzZLA9g+GBVII4=; b=jExQ3qq2kU2YwCtyd9XnBBQaA+8ShfxuwreAuXeyv7ppaSbzDK+PRxEoMg7GjeF48p HY32E8+qoqec1s4ze6f+3H9Ugs3SjPf3qPuKK6BFYPds+qYMIJddy2EmEy2H9bB0PGVO dzpCV1dR8pki6hYY9Z/jRlyUoxP48cUj2fhClgQollLJcxaWRa/7457S7cz/liXFHz/R jJeiD2lF9OBU80mTh1OknduY5hcLgOgMHEKgIJrHbzrO2jYz5lcM0pcca5iMw+32Mpk6 W+NmQJCcVyUvhr4JZkfeDqpXzbiP+7rdwj1f57nDJkLVdGaFY3YhWr5X45cW2V+38Jo2 GD8A== X-Gm-Message-State: AOJu0YzgFq/UBFoA00SgP8TmEW/bqYMlQsVMa/B41fsZl3hUYjZbczxb LmBe/uWkPQRL57p5KpKPCgqCzTw52X+PGE2eTLxYB34/43fuYVjql0rEFEYDFKo6FcemhV0Rm3M ZnMYF X-Gm-Gg: AfdE7cn2etC3kGZ42WsoQezrnqzBs6VSon8ddK70yGNZPDG3wtFsdjYFGPwIaqxiX/K 1uHKsVZuhesKide72Im7jyPSSKhELGyNqcrqWpk4+VHkaHhWs1+WOMcj+syfdr+lSe01AFHwJ5q m0vfGO+m5Ob/wC2f+xcnrpZ6BlgQ3odXVNrTIKjZlkx53dvFeB5z3CgvwRJQyQBcELH3HCA8Vdd MDL2nlSnkrhq1xViNvXTypO4adsDSgKAdwB5bY8GY9rHyp8oXuJP3ufi3tBkjKjklT8v8CifMh5 ELiLvsg2FwaaNge8azcFMZ+lKIx/cjThFEk/faFyGh0l37Ai+nNA6EYEYlYgtjG0zBTtfQ+IL8q rZ6c/0nweNulTlbqkxaruHDSSb7dBpFGP1aAJX9tfiUYAAgjX3N77xBt7rvuTKk+DF33ae8mxa1 GDVNP6E4eSBp7oT0BkbP27rVCE X-Received: by 2002:a05:6a20:430b:b0:3bf:bfe6:ab6e with SMTP id adf61e73a8af0-3c0bcf49b4emr10483031637.6.1783619402920; Thu, 09 Jul 2026 10:50:02 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:2485:88d2:edd6:52d6:462d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311950eb930sm17377902eec.8.2026.07.09.10.50.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:50:02 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/6] nss: Use test resolver for tst-getaddrinfo4 Date: Thu, 9 Jul 2026 14:48:14 -0300 Message-ID: <20260709174957.670741-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709174957.670741-1-adhemerval.zanella@linaro.org> References: <20260709174957.670741-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Rewrite the BZ#15339 test to use the resolv_test framework instead of querying the network, so it can run as a regular test. Reviewed-by: Florian Weimer --- nss/Makefile | 5 ++- nss/tst-getaddrinfo4.c | 73 ++++++++++++++++++++++++++++-------------- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/nss/Makefile b/nss/Makefile index b1f25f0d719..5a4d5794b36 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -322,6 +322,7 @@ tests := \ tst-getaddrinfo \ tst-getaddrinfo2 \ tst-getaddrinfo3 \ + tst-getaddrinfo4 \ tst-gethnm \ tst-getpw \ tst-gshadow \ @@ -343,7 +344,6 @@ tests := \ xtests := \ bug-erange \ - tst-getaddrinfo4 \ tst-getaddrinfo5 \ # xtests @@ -513,6 +513,9 @@ endif $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)libnss_files.so $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)libnss_files.so +$(objpfx)tst-getaddrinfo4: \ + $(common-objpfx)resolv/libresolv.so $(shared-thread-library) + $(objpfx)tst-default-domain: $(objpfx)nisdomain.os tst-nss-gai-hv2-canonname-ENV = \ diff --git a/nss/tst-getaddrinfo4.c b/nss/tst-getaddrinfo4.c index c04e12c4b5e..67d1acd6f5d 100644 --- a/nss/tst-getaddrinfo4.c +++ b/nss/tst-getaddrinfo4.c @@ -16,52 +16,77 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include #include +#include +#include +#include -static int +static void +response (const struct resolv_response_context *ctx, + struct resolv_response_builder *b, + const char *qname, uint16_t qclass, uint16_t qtype) +{ + resolv_response_init (b, (struct resolv_response_flags) { }); + resolv_response_add_question (b, qname, qclass, qtype); + resolv_response_section (b, ns_s_an); + resolv_response_open_record (b, qname, qclass, qtype, 0); + switch (qtype) + { + case T_A: + resolv_response_add_data (b, "\xc0\x00\x02\x01", 4); + break; + case T_AAAA: + resolv_response_add_data + (b, "\x20\x01\x0d\xb8\0\0\0\0\0\0\0\0\0\0\0\x01", 16); + break; + } + resolv_response_close_record (b); +} + +static void try (const char *service, int family, int flags) { - struct addrinfo hints, *h, *ai; - int res; + struct addrinfo hints, *ai; memset (&hints, 0, sizeof hints); hints.ai_family = family; hints.ai_flags = flags; - errno = 0; - h = (family || flags) ? &hints : NULL; - res = getaddrinfo ("example.net", service, h, &ai); + int res = getaddrinfo ("example.net", service, + (family || flags) ? &hints : NULL, &ai); switch (res) { case 0: + freeaddrinfo (ai); + /* Fall through. */ case EAI_AGAIN: case EAI_NONAME: printf ("SUCCESS getaddrinfo(service=%s, family=%d, flags=%d): %s: %m\n", service ?: "NULL", family, flags, gai_strerror (res)); - return 0; + return; } - printf ("FAIL getaddrinfo(service=%s, family=%d, flags=%d): %s: %m\n", - service ?: "NULL", family, flags, gai_strerror (res)); - return 1; + FAIL ("getaddrinfo(service=%s, family=%d, flags=%d): %s", + service ?: "NULL", family, flags, gai_strerror (res)); } static int do_test (void) { - int err = 0; - err |= try (NULL, 0, 0); - err |= try (NULL, AF_UNSPEC, AI_ADDRCONFIG); - err |= try (NULL, AF_INET, 0); - err |= try (NULL, AF_INET6, 0); - err |= try ("http", 0, 0); - err |= try ("http", AF_UNSPEC, AI_ADDRCONFIG); - err |= try ("http", AF_INET, 0); - err |= try ("http", AF_INET6, 0); - return err; + struct resolv_test *obj = resolv_test_start + ((struct resolv_redirect_config) { .response_callback = response }); + + try (NULL, 0, 0); + try (NULL, AF_UNSPEC, AI_ADDRCONFIG); + try (NULL, AF_INET, 0); + try (NULL, AF_INET6, 0); + try ("http", 0, 0); + try ("http", AF_UNSPEC, AI_ADDRCONFIG); + try ("http", AF_INET, 0); + try ("http", AF_INET6, 0); + + resolv_test_end (obj); + return 0; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include From patchwork Thu Jul 9 17:48:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 138842 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41E634BA23DC for ; Thu, 9 Jul 2026 17:52:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41E634BA23DC Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=DCA+wkni X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id D10BF4BA2E3E for ; Thu, 9 Jul 2026 17:50:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D10BF4BA2E3E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D10BF4BA2E3E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619406; cv=none; b=sGja9iEq+P3b2tVObFdg2CS1US7qol0dJs50LzUnn2VivIIdJh/nUZvsgXIzD7se5TDDCMephvuizEu/7J1lpr20+Tp9+SaOvGTpRqWZp3nC68HgN8SjlkGirrn8r39dLxnVtdTUWKAr1cYjUU49UmWAOZ835OwoFA5j2wcakDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619406; c=relaxed/simple; bh=mLCPgeP+6898e/dnbSuQcL+VE4k29hRTaWQ96dOmkEg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t7iTpp/MqK3H/PuHFZozzysZ4h5tD5bC0iFrZHvZvLkC+8odwQkQ0AYWk43rjMqhKy6VwUVqzIBU6zAdHanFh5tw4lY+QQXe2W4yL5Gbr9h857DBkn3+OSATeIDpd29733MY23R31WBT82Yp7W1FWXY9/vRLoMb6LQsHQiwVIHc= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=DCA+wkni DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D10BF4BA2E3E Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-c9e0b89e228so68530a12.1 for ; Thu, 09 Jul 2026 10:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783619405; x=1784224205; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=fi4Gq6fIZcZ+W67Iarc0vdh66LtBZwI38kDnd0phnbE=; b=DCA+wkniDgFIqbA05+KwZcS5xFcS4/LbyeFy8aMQsu7QhX2sggBaHldSLJg/EcZcmb y2o+I9/xMkcaaY747YIHbhfjYLKpLnFGeqCbKuvRCMclSXXT9qNY3OOZ7zqc5V2vPdEL /wo0/S365RdLAfTaTHOzlbML4to0sEEALKWHnAtfwH8GkWUrbaBI7k0P6D48dxnoidYk nB9kxPI496j9mCx63F50D/FK9dZu2vEWk/b40fms3hfqyCrASDKja6kBhC+v8wYGLwCY gleKfc1blBHRbbIYMVRS9MIPNusT13E8x9Mi8N8ObREDSdjrwW/ENpOmid/D+M8TK+Rx G+TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783619405; x=1784224205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=fi4Gq6fIZcZ+W67Iarc0vdh66LtBZwI38kDnd0phnbE=; b=eZ/M6NoqKW0DtvIohHh8TyFES3dg58kg0r7OpEaQQZ7NOA6cr14NrHyCMoOKOz8F3V aLSjzuG6KVXLQcnFoF+Rk3Ew0+7ma9fiZU8fjMLiedkhnA7ABOYn/qlupBYmIvPO/S5K irTgTHFFgCAp4wnJ/A4oDrM+9oxfMZXEGhAk5BNPn8Xq2DuuHm6DbqbEtdvUUQkddZFa WGmjWFXenYvo93XU+SQmaMUk9qSRCWUD/KRFmJ5bgskJvkr+OCY8iAQODxyG9RLLLrMP d8BcH6kxid3iG0w/7fFQVu+RuPsjFuFY+pQCB9c9Ao8CAr2TV1/Wf4nY2CC8nw2ts2HT psXg== X-Gm-Message-State: AOJu0Ywighht243BALUjFSyVde/xLtm7q9D3EUzCtrnAPK1o2RPnRGcH kAsxgRn93DM3nn0rGsW8rSCTkmWCUpTHm8VPgeVg/mfEVWgyN8OTNJl7BYl0bAkpY90UuyNyR6/ +QkCA X-Gm-Gg: AfdE7clUl8DUHLTnpB577fOkkD+jtso4WvkxytKcc3zvI7TaBbkkAz/Z5GDYT0gT2QR khoV6w5+WRYzjSJuGKjovUnepxyzs0B00sc8MsQ2+Mqdyj8z4cedWg1vGCwxpUp+FEX5Yhya9xI d+CxieBU40QjtNoI5RjHV/4+YG03QjgVaiBrZ1yT1wAUJ5xh8kBunal/LlQ2rnXSl/FGzVUENkO 9K4VptIQuqgSkTFEjtPTjGDzZnFJktqmgXhUwxjShZuGqjgn9Aq2CxcnpS87qd9PPtnyzI3Mtoi 9jSx11tFLQjsiPQWpO++bImRnPA0n04kQbdM5bUghey8IHE6w6K94zsBLN1fpwE7/55Y8+AlCKE NZ+Bi4ZYEwCY7Hic0kVct1et0htXeqJgWlYDDk8MMsOzDkbbmIicwy7SfyldB/wanMgomDIS6hZ Yum6Frf7WnlBRz3EgkKjMSbj7/ X-Received: by 2002:a05:6300:6ccb:10b0:3c0:c9ee:3746 with SMTP id adf61e73a8af0-3c0c9ee3780mr3897588637.34.1783619404568; Thu, 09 Jul 2026 10:50:04 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:2485:88d2:edd6:52d6:462d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311950eb930sm17377902eec.8.2026.07.09.10.50.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:50:03 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/6] nss: Use test resolver for tst-getaddrinfo5 Date: Thu, 9 Jul 2026 14:48:15 -0300 Message-ID: <20260709174957.670741-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709174957.670741-1-adhemerval.zanella@linaro.org> References: <20260709174957.670741-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Rewrite the BZ#6469 test to use the resolv_test framework instead of querying the network, so it can run as a regular test. --- nss/Makefile | 4 +- nss/tst-getaddrinfo5.c | 83 +++++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/nss/Makefile b/nss/Makefile index 5a4d5794b36..bbcb7201699 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -323,6 +323,7 @@ tests := \ tst-getaddrinfo2 \ tst-getaddrinfo3 \ tst-getaddrinfo4 \ + tst-getaddrinfo5 \ tst-gethnm \ tst-getpw \ tst-gshadow \ @@ -344,7 +345,6 @@ tests := \ xtests := \ bug-erange \ - tst-getaddrinfo5 \ # xtests tests-container := \ @@ -515,6 +515,8 @@ $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)libnss_files.so $(objpfx)tst-getaddrinfo4: \ $(common-objpfx)resolv/libresolv.so $(shared-thread-library) +$(objpfx)tst-getaddrinfo5: \ + $(common-objpfx)resolv/libresolv.so $(shared-thread-library) $(objpfx)tst-default-domain: $(objpfx)nisdomain.os diff --git a/nss/tst-getaddrinfo5.c b/nss/tst-getaddrinfo5.c index f00b27372e2..a8297ede3c8 100644 --- a/nss/tst-getaddrinfo5.c +++ b/nss/tst-getaddrinfo5.c @@ -16,54 +16,47 @@ License along with the GNU C Library; if not, see . */ -#include -#include #include #include -#include +#include +#include -static int -test (void) +static void +response (const struct resolv_response_context *ctx, + struct resolv_response_builder *b, + const char *qname, uint16_t qclass, uint16_t qtype) { - static char host1[] = "localhost.."; - static char host2[] = "www.gnu.org.."; - static char *hosts[] = { host1, host2 }; - int i; - int pass = 0; - - for (i = 0; i < sizeof (hosts) / sizeof (*hosts); i++) - { - char *host = hosts[i]; - size_t len = strlen (host); - struct addrinfo *ai; - - /* If the name doesn't resolve with a single dot at the - end, skip it. */ - host[len-1] = 0; - if (getaddrinfo (host, NULL, NULL, &ai) != 0) - { - printf ("resolving \"%s\" failed, skipping this hostname\n", host); - continue; - } - printf ("resolving \"%s\" worked, proceeding to test\n", host); - freeaddrinfo (ai); - - /* If it resolved with a single dot, check that it doesn't with - a second trailing dot. */ - host[len-1] = '.'; - if (getaddrinfo (host, NULL, NULL, &ai) == 0) - { - printf ("resolving \"%s\" worked, test failed\n", host); - return 1; - } - printf ("resolving \"%s\" failed, test passed\n", host); - pass = 1; - } - - /* We want at least one successful name resolution for the test to - succeed. */ - return pass ? 0 : 2; + resolv_response_init (b, (struct resolv_response_flags) { }); + resolv_response_add_question (b, qname, qclass, qtype); + resolv_response_section (b, ns_s_an); + resolv_response_open_record (b, qname, qclass, qtype, 0); + if (qtype == T_A) + resolv_response_add_data (b, "\xc0\x00\x02\x01", 4); + else + resolv_response_add_data + (b, "\x20\x01\x0d\xb8\0\0\0\0\0\0\0\0\0\0\0\x01", 16); + resolv_response_close_record (b); } -#define TEST_FUNCTION test () -#include "../test-skeleton.c" +static int +do_test (void) +{ + struct resolv_test *obj = resolv_test_start + ((struct resolv_redirect_config) { .response_callback = response }); + + struct addrinfo *ai; + + /* A single trailing dot resolves. */ + printf ("resolving \"example.net.\", expecting success\n"); + TEST_COMPARE (getaddrinfo ("example.net.", NULL, NULL, &ai), 0); + freeaddrinfo (ai); + + /* A second trailing dot must not. */ + printf ("resolving \"example.net..\", expecting failure\n"); + TEST_COMPARE (getaddrinfo ("example.net..", NULL, NULL, &ai), EAI_NONAME); + + resolv_test_end (obj); + return 0; +} + +#include From patchwork Thu Jul 9 17:48:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 138841 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 362A34BA23C9 for ; Thu, 9 Jul 2026 17:52:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 362A34BA23C9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=sFSfxLP7 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 43D3D4BA23D0 for ; Thu, 9 Jul 2026 17:50:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43D3D4BA23D0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43D3D4BA23D0 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619407; cv=none; b=UIextw7TvhE+eV9W+Vilc2X6iwQEiNCJ/+EWSdEmNoUgNUibjL7LZrDyvgE3g1vqqs9Vp5cut7+a/jnDm30rhJcxCsw+iOCITVMoL7OqO+8WOCIFDCWF5wGLpofqhXCeA1hUXZ9c4Ojw7TojwoZ+498Ww2yqlzFd+04nyL/koMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619407; c=relaxed/simple; bh=Twnz1CQEvO80yIwOpo37WrADtCieBelNEHGQoXTEaVg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RBnI50stg0l7X3xmTQU+hPX1nwiII3v0lZlsvLcfIj/c9uk86Qz4ebayEnOqitQT01G95eptRKSOfHRqFOGV+rbZRsH9l8IgFyMssaRj1o+drFhWEmHsgbk7/oGDH2K7AXDCFzTldtvCSQMjLQiaYgD7Az4GPEUTnc2f5GE2H+g= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=sFSfxLP7 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43D3D4BA23D0 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-ca957432c7fso89041a12.1 for ; Thu, 09 Jul 2026 10:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783619406; x=1784224206; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=eoOOA7v5G3jCmld9Kk+AA/PtPDkckC8hHPMnGF/BhIw=; b=sFSfxLP7UyUGP3IyNn9ED5uK57frMwl4aVE/wYAoaCLiIPPZP0+VUMczjTm8gIuN/V EhprO23epLKhtckDHBneWwBjZZ2NqTIv1MGJvHwiLU16wVvg/EaSBfq2VCZ2QlDz6y5O Xcw13iKPr3VwT5BBNiguQfzcDXu9zY6UooBZbmDjb0tEwpO5tK9VDw4Y6QFw3PlDSgf4 vZ8oT7uxwXqUtnXUJrIkV+qYyjJCPd+ht/y4QBopsi38QMQVmPq4bmfFdHWylyqb9uV3 iyhTDf3nBAdoqlx2ZbSLvr0nywyhHWwvOLMBGSS1x946SmhPuWXjhQ3Y7N29zUdg7QpF 2wyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783619406; x=1784224206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=eoOOA7v5G3jCmld9Kk+AA/PtPDkckC8hHPMnGF/BhIw=; b=axva/mAFqsGterbQ9o2Mvw0ic5odtdtfbHtWp1s3r1gXVnGnTr7TjCzR5SaEeeyrwE hEe9GwaDsU4V1RrJTsC9nyofl8EDIvnfQeplt7MPNHiqyCi3a7QcB9TAy7gOLSXMdBlu BVEU+yDyexd6SjU+JBMqVvTqCh63cGgl/AA3pRg9svldn0/xXraZukDDHK8++J/kfXLe uhP4KjwEZVCCYuquHFqtLjgNLL7ftvDyfGd/fp62/B9LsP8Dzf8kfP51aJ0czCE+YyXF T3oDJNGG+bpRT72wXuZdCHDsM3hWmMlmok/F3pF+m567t6+BlgDaM66DUqvz/F45wzfX Zb9Q== X-Gm-Message-State: AOJu0YzS/fU3n7n+kkjwdjm8xw+dbS13gUtEVyozXedStW6FzT0ZpuU7 8vrl/LohY558ABXkJhe5SNnsODmk0THO6P4UQCGFqXaHnUtggeAQ0PBn83Hyi4wAGJOcZjtRI7L +qwYC X-Gm-Gg: AfdE7cl14VjJlf4Bo3xS3ZWwgksOpsC/maLDXpaZ0ooi7YewNDGc+S7bN1qm1/RFa6A 4WVJ1n0T+dmodnAApw1s98lHhzFx9w4XC+A0jSjOV7Qxn3f1Ic5F88ogvez4ZshDDL7qivNAYFG izaHdQThLNX5kHE1T9Pg/J2lduUu4DpTF0GxxD219PVF2uWaYvIimNVIZXgO+FKnqyz4ORG/6Pp T0uU3LWuLQthHjdW5l8ug3vUneRNJH3O0yW43WmqrJHG0mMdOOM10dpTfiYwki4ZcWWEa0KvUSC GCvfWzIPxD3vwHyI4jSTX0rote3qaVIX1KNN+5ExIAUUN5xnrtGj/H6i72pJzbXEtY32Z0jrsuY clTuvGngVGUOFSejxISlgEiQC5/U1iXvRfZGkAWSlMfG+tZqkZrnL2pn53JPvhDN8qESnwkWqOW C1ib26IWYonzV7YsGTlFPSESZx X-Received: by 2002:a05:6a20:3d0c:b0:3a2:d838:bfc6 with SMTP id adf61e73a8af0-3c0bccbbc8amr9261334637.29.1783619406094; Thu, 09 Jul 2026 10:50:06 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:2485:88d2:edd6:52d6:462d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311950eb930sm17377902eec.8.2026.07.09.10.50.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:50:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/6] nss: Use test resolver for bug-erange Date: Thu, 9 Jul 2026 14:48:16 -0300 Message-ID: <20260709174957.670741-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709174957.670741-1-adhemerval.zanella@linaro.org> References: <20260709174957.670741-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Rewrite the gethostbyname_r ERANGE test to use the resolv_test framework instead of querying the network, so it can run as a regular test. --- nss/Makefile | 7 ++-- nss/bug-erange.c | 90 +++++++++++++++++++++++++++++------------------- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/nss/Makefile b/nss/Makefile index bbcb7201699..4cab4f74c42 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -312,6 +312,7 @@ tests-internal := \ # tests-internal tests := \ + bug-erange \ bug17079 \ test-digits-dots \ test-netdb \ @@ -343,10 +344,6 @@ tests := \ tst-shadow \ # tests -xtests := \ - bug-erange \ - # xtests - tests-container := \ tst-initgroups1 \ tst-initgroups2 \ @@ -517,6 +514,8 @@ $(objpfx)tst-getaddrinfo4: \ $(common-objpfx)resolv/libresolv.so $(shared-thread-library) $(objpfx)tst-getaddrinfo5: \ $(common-objpfx)resolv/libresolv.so $(shared-thread-library) +$(objpfx)bug-erange: \ + $(common-objpfx)resolv/libresolv.so $(shared-thread-library) $(objpfx)tst-default-domain: $(objpfx)nisdomain.os diff --git a/nss/bug-erange.c b/nss/bug-erange.c index b709418b5cf..04b0a40c9ab 100644 --- a/nss/bug-erange.c +++ b/nss/bug-erange.c @@ -1,52 +1,70 @@ -/* Test case for gethostbyname_r bug when buffer expansion required. */ +/* Test case for gethostbyname_r bug when buffer expansion required. + Copyright (C) 2004-2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ -#include -#include #include -#include -#include +#include #include -#include +#include +#include +#include +#include -int -main (void) +static void +response (const struct resolv_response_context *ctx, + struct resolv_response_builder *b, + const char *qname, uint16_t qclass, uint16_t qtype) { - const char *host = "www.gnu.org"; + resolv_response_init (b, (struct resolv_response_flags) { }); + resolv_response_add_question (b, qname, qclass, qtype); + resolv_response_section (b, ns_s_an); + resolv_response_open_record (b, qname, qclass, qtype, 0); + resolv_response_add_data (b, "\xc0\x00\x02\x01", 4); + resolv_response_close_record (b); +} - /* This code approximates the example code in the library manual. */ +static int +do_test (void) +{ + struct resolv_test *obj = resolv_test_start + ((struct resolv_redirect_config) { .response_callback = response }); struct hostent hostbuf, *hp; - size_t hstbuflen; - char *tmphstbuf; - int res; - int herr; + char *buf; + size_t buflen = 1; /* Make it way small to ensure ERANGE. */ + int res, herr; - hstbuflen = 16; /* Make it way small to ensure ERANGE. */ - /* Allocate buffer, remember to free it to avoid memory leakage. */ - tmphstbuf = malloc (hstbuflen); - - while ((res = gethostbyname_r (host, &hostbuf, tmphstbuf, hstbuflen, + buf = xmalloc (buflen); + while ((res = gethostbyname_r ("example.net", &hostbuf, buf, buflen, &hp, &herr)) == ERANGE) { - /* Enlarge the buffer. */ - hstbuflen *= 2; - tmphstbuf = realloc (tmphstbuf, hstbuflen); + buflen *= 2; + buf = xrealloc (buf, buflen); } - if (res != 0 || hp == NULL) - { - printf ("gethostbyname_r failed: %s (errno: %m)\n", strerror (res)); + TEST_COMPARE (res, 0); + TEST_VERIFY_EXIT (hp != NULL); + TEST_COMPARE (hp->h_addrtype, AF_INET); + TEST_COMPARE (hp->h_length, 4); + TEST_COMPARE_BLOB (hp->h_addr_list[0], 4, "\xc0\x00\x02\x01", 4); - if (access ("/etc/resolv.conf", R_OK)) - { - puts ("DNS probably not set up"); - return 0; - } - - return 1; - } - - printf ("Got: %s %s\n", hp->h_name, - inet_ntoa (*(struct in_addr *) hp->h_addr)); + free (buf); + resolv_test_end (obj); return 0; } + +#include From patchwork Thu Jul 9 17:48:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 138840 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC8194BA23E2 for ; Thu, 9 Jul 2026 17:51:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC8194BA23E2 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hDhO694G X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id 936FA4BA2E3E for ; Thu, 9 Jul 2026 17:50:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 936FA4BA2E3E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 936FA4BA2E3E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1032 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619408; cv=none; b=vwu+4NuAhu5UL/QKHBKWslax6h7u9p7vv+4Gw5TPakbkwIoeLNyDEc/Yx82kAGJGt24jg0zHs2DRoCs2IbLiUi1pL2w+qW0EBjfI+mU1IkKX8wZ6GTwyvv78XQSoTcotkDtvkAyKQCCJRnRhqc7D3yB8u1PU5X/TuDP/IGsPfek= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619408; c=relaxed/simple; bh=JpcaskvidEobd9RKwEe4YjI+Y/j7N9lPxmilLChrA+Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cWKwhxn/BEF0x3ykjPhAibftalJIHjtnY0O/IEIcK0HQyJghkiVdFe8nmF7c9HBjmNP6jhECVwcqDVC3rvjMqHBBVsCsEZXzVKFcQlhhqTW/e5qSDpqXMccq0qSuSIsB5ZRm35At80nhqSZyO0ehgSvREgcpPJR1mjYv0qU/vlg= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hDhO694G DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 936FA4BA2E3E Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-38a0c7e841fso268834a91.2 for ; Thu, 09 Jul 2026 10:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783619407; x=1784224207; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=KY6ezs+SriVd5K0I1OH22NfH/iA+kDVi122aPQSrRCg=; b=hDhO694GItVTrL5JBPawSjojBq5NG2oJFApIYn5zFQyEl3D/6P7q5960vlneAhX4XP B8CrSLYdjQkkx7lTBQx2BD/Zk6SqgRRzhmAOyYSbnhDmtUH1bb/nzPo0N0YW+rFyIOj4 2HzpAUIkK1Qn/EclEa8DPBiSstXUYqgy6icIXl9qvwgNvDumOQ51kOG0ye22Nk7rMTP4 lea/EP0OCPU0KxcxMxT0sEz2JasiWEsmhIji9ZjIGJuMd9jatSWUkqBxbQL0WYrZ/ntk lB7fctil5//ZaaZxD8aH0V4sQdXZo8PGf1aWq1yYp4ONW+G3pQfZj08LxnPuXq3YmGq/ cf5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783619407; x=1784224207; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=KY6ezs+SriVd5K0I1OH22NfH/iA+kDVi122aPQSrRCg=; b=pirLmw6+wAe15HhRooPXwHupAau0GsEjifHMkqTTvKLjLNJt4E/taq4ml7Z5FuwZ+2 olAp4P9IHp+xfiaKVMctDEqpGC4MbPsGVZgFmaEkZcJmrumtpCZNWPznMrR+qCgMBaQW DLZuqLk2Hn+QcHzKeRHX7oeRHZYvZ6ip1LGeDQ6O+oEPhWJQ5pmrBsMR4MRVwYTjmmbX 0t6vfzoLc36xXG/H0LWBTAX2ATnTbwzVIQEPfsQC4qp1Lo82oCUv7bS4KPtEGE2jmx3e eiu3SoA1XtVEyB+HyZT5E7MVsS1KDbvFzkreVzoVY5YhxqI08R+de4F8//nPKUoogXc1 iIPw== X-Gm-Message-State: AOJu0YydqwJGmNBUJNMN78e4HEi2IBIybzGj+SmxrmW0v1HAh4ECKfrz W5HSa4/duqXTUBTCyArDswWxdr93/Dr+/MqB85B3JSbVp4hWp1vUTqDMXI/UwoxWR5MoNw2VccF g4aSR X-Gm-Gg: AfdE7cmWhKdenWTG/oPNb6KdnbvS3ry+iMhch2KowfDJ/klq2N7ZjzHpmhJ9LQ3Jw15 YdhuF19RY1X836QiX1urfqO1ruo8CILB57KQVnxAzNyQaaubl5W9LvqJY3UOdpKB2LkgIIHS96p mmgc5o1j6sBEEPc7ozngSFRnoZYYcdI2sdCiXZGlCx3LHspnz6YGDFO8XuMvW/bSmXQHMf5vNBR EKtLTf1I1/i3lYlGbHGCSJzrngJxcnlfwA1A4B5GVPXnD5QOeXK9UtB4czQj6+whpouHsVWWusJ edVuWWI0VYU70sia0cMLGitJsv3cxgBfrTJQDoBV8Xm009fJOO9yIsY0MrdA8HIyb/NCZNFaLSd qjOT2DPADBrsmDjiySVzY02omuWR3ikYppaCbLElUqsudfKxC510ixCOZUWuEQLTb0oJKjlD8Mw 14FvyASx4//wvFOJdT4gSlT5XB X-Received: by 2002:a17:90b:184d:b0:37f:a94e:10b0 with SMTP id 98e67ed59e1d1-38941cc599emr8432172a91.24.1783619407581; Thu, 09 Jul 2026 10:50:07 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:2485:88d2:edd6:52d6:462d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311950eb930sm17377902eec.8.2026.07.09.10.50.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:50:06 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 4/6] sunrpc: Remove obsolete tst-getmyaddr and thrsvc xtests Date: Thu, 9 Jul 2026 14:48:17 -0300 Message-ID: <20260709174957.670741-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709174957.670741-1-adhemerval.zanella@linaro.org> References: <20260709174957.670741-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org These exercise the deprecated Sun RPC interfaces and require network access. Remove them along with their xtests entries. --- sunrpc/Makefile | 6 --- sunrpc/thrsvc.c | 109 ----------------------------------------- sunrpc/tst-getmyaddr.c | 24 --------- 3 files changed, 139 deletions(-) delete mode 100644 sunrpc/thrsvc.c delete mode 100644 sunrpc/tst-getmyaddr.c diff --git a/sunrpc/Makefile b/sunrpc/Makefile index 63c90874581..36babe303d9 100644 --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -74,10 +74,7 @@ tests = \ tst-xdrmem2 # tests -xtests := tst-getmyaddr - ifeq ($(have-thread-library),yes) -xtests += thrsvc tests += tst-udp-garbage tst-svc_register endif @@ -104,15 +101,12 @@ CFLAGS-pmap_rmt.c += -fexceptions CFLAGS-clnt_perr.c += -fexceptions CFLAGS-openchild.c += -fexceptions -$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so $(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so $(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so $(objpfx)tst-udp-error: $(common-objpfx)linkobj/libc.so $(objpfx)tst-svc_register: \ $(common-objpfx)linkobj/libc.so $(shared-thread-library) -$(objpfx)thrsvc: $(common-objpfx)linkobj/libc.so $(shared-thread-library) - $(objpfx)tst-udp-timeout: $(common-objpfx)linkobj/libc.so $(objpfx)tst-udp-nonblocking: $(common-objpfx)linkobj/libc.so $(objpfx)tst-udp-garbage: \ diff --git a/sunrpc/thrsvc.c b/sunrpc/thrsvc.c deleted file mode 100644 index 63cfbf9810d..00000000000 --- a/sunrpc/thrsvc.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#define PROGNUM 1234 -#define VERSNUM 1 -#define PROCNUM 1 -#define PROCQUIT 2 - -static int exitcode; - -struct rpc_arg -{ - CLIENT *client; - u_long proc; -}; - -static void -dispatch(struct svc_req *request, SVCXPRT *xprt) -{ - svc_sendreply(xprt, (xdrproc_t)xdr_void, 0); - if (request->rq_proc == PROCQUIT) - exit (0); -} - -static void -test_one_call (struct rpc_arg *a) -{ - struct timeval tout = { 60, 0 }; - enum clnt_stat result; - - printf ("test_one_call: "); - result = clnt_call (a->client, a->proc, - (xdrproc_t) xdr_void, 0, - (xdrproc_t) xdr_void, 0, tout); - if (result == RPC_SUCCESS) - puts ("success"); - else - { - clnt_perrno (result); - putchar ('\n'); - exitcode = 1; - } -} - -static void * -thread_wrapper (void *arg) -{ - struct rpc_arg a; - - a.client = (CLIENT *)arg; - a.proc = PROCNUM; - test_one_call (&a); - a.client = (CLIENT *)arg; - a.proc = PROCQUIT; - test_one_call (&a); - return 0; -} - -int -main (void) -{ - pthread_t tid; - pid_t pid; - int err; - SVCXPRT *svx; - CLIENT *clnt; - struct sockaddr_in sin; - struct timeval wait = { 5, 0 }; - int sock = RPC_ANYSOCK; - struct rpc_arg a; - - svx = svcudp_create (RPC_ANYSOCK); - svc_register (svx, PROGNUM, VERSNUM, dispatch, 0); - - pid = fork (); - if (pid == -1) - { - perror ("fork"); - return 1; - } - if (pid == 0) - svc_run (); - - inet_aton ("127.0.0.1", &sin.sin_addr); - sin.sin_port = htons (svx->xp_port); - sin.sin_family = AF_INET; - - clnt = clntudp_create (&sin, PROGNUM, VERSNUM, wait, &sock); - - a.client = clnt; - a.proc = PROCNUM; - - /* Test in this thread */ - test_one_call (&a); - - /* Test in a child thread */ - err = pthread_create (&tid, 0, thread_wrapper, (void *) clnt); - if (err) - fprintf (stderr, "pthread_create: %s\n", strerror (err)); - err = pthread_join (tid, 0); - if (err) - fprintf (stderr, "pthread_join: %s\n", strerror (err)); - - return exitcode; -} diff --git a/sunrpc/tst-getmyaddr.c b/sunrpc/tst-getmyaddr.c deleted file mode 100644 index 1eaf9b22caf..00000000000 --- a/sunrpc/tst-getmyaddr.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#include -#include - - -static int -do_test (void) -{ - struct sockaddr_in ad; - struct sockaddr_in ad2; - memset (&ad, '\0', sizeof (ad)); - memset (&ad2, '\0', sizeof (ad2)); - - get_myaddress (&ad); - - printf ("addr = %s:%d\n", inet_ntoa (ad.sin_addr), ad.sin_port); - - return memcmp (&ad, &ad2, sizeof (ad)) == 0; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" From patchwork Thu Jul 9 17:48:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 138838 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31BAF4BA2E07 for ; Thu, 9 Jul 2026 17:50:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31BAF4BA2E07 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LR4Uk7Ad X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 158204BA23D0 for ; Thu, 9 Jul 2026 17:50:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 158204BA23D0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 158204BA23D0 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1036 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619410; cv=none; b=xVG8KZsbbDg9bCjnp5vRD0Kd/U55PSHMBxzf/KO3bWkE7lBcKvglYHFh+vtqImfjqIwEnKd6OUtKb7sIl758L/XUgCJkpittJHrihY5iZQXo2i0ZbcbUUd4nZQNd8d40xRhv4EyxzQ37Ri26czm3cDvDwlT5hoBxp5bk4vnMhds= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619410; c=relaxed/simple; bh=/uxyqHY/jCEotZRz6zXSHPaYvl5KMofK0FRCEWs+RtI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MelCc+YJEAkT0nVCgm7Z7jZe/ns7mgf22WfuE0u0fY2infB5bvjckbF28uTBKY8n8z/pyDyV+gYzXM+AEgDSitumwdcG/N13NLz8/hHqTYQDqHQetUAMZRXbCLqMIen9Zus/3gDiyBLc2gsTmNhrzYyXEmP7GRkX/30N3lWC2WQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LR4Uk7Ad DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 158204BA23D0 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-38759bcd877so145427a91.2 for ; Thu, 09 Jul 2026 10:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783619409; x=1784224209; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=nd+3JD+B0WBVcr/jDndKxkDvg20E16cPB7s8AAFXOpg=; b=LR4Uk7Ad7LO0eNUUeEyoYvmCyo6ZIU7lpSpPg8obTb6jrpmTC4HsBj3ClSTh9rVhAe 42icGbl8R6Ajz/Zi567LucyydRKtP4Wc+ilYUY77Eo0Dc7tBLwPRyKwKhU3n6q4wqFKs WXTxfnKi0VDxruRALECy3dg2TlPUosH07dRyFbgIyLeBHFsOP7MItbSn1zdv8K5m0IWL gjJLfmVBtzj0H1WNj8NOuu8n8XF+brSqXjzD18zt4YCBwGBlptK8EOuDlJBIjsSQCKpl kY8BBqeNMPwuXWnDfwrNC5uD7S+eGCGuikgjlE2QmWtD2gSamtthL0eBuF7khLiYy+Zm VnUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783619409; x=1784224209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=nd+3JD+B0WBVcr/jDndKxkDvg20E16cPB7s8AAFXOpg=; b=pwc+t089h8eYNl+8SKARhaC6MxMHNOIAqq6HoO1IhA7oq19GAfjrL5SXT2mlTIvoHX I0wfMrnR25kTzo2ImxjS8l6Zv2WCOXshxsb2biRcUVFs3kBDn11IPaGOvy4OzuTO5Yrs hBZ46XCf/cfqhRwHXezcP3aiWOzt9eiDhTVdwACz4oLVOK/bV0Cy+esDdxHwI71cUsmf XhArb5Q53my/WwhXGHpCmnFSIezkryrGnFG5xvNKSwQ8DyBKZdhvUlZhhkfekAZgtW3n PIQmMB4OUnBieP9wqr/S7UmUeSs4JV84h545gUuceF4kHd1WGFPjbBRrDiXja81POz8c 6iYg== X-Gm-Message-State: AOJu0YxwLiLWzsf9g831uFhIYdaNQDkRCoUqeba5OBY1kVqPg/Rnc78X V+tIOd+NYq70N7QBk2FAH1bhC+6b7TAGDgzypnXWac1Yz1vplfIo0THwd5wKnJCuceL/md3oCWH 3T4Cw X-Gm-Gg: AfdE7ck2dZ6WUqWpbpZkzG9qtbOGRJdnnVV3s1T7Fbi+wmDWWAFDREY36EaNejjuF2j wg1+rfBUeM8ScLe/hjy9bUt09Us7ZAPZlMAwWJHCkEsPqieZuJyQ6CGzH35I56tnJKT1+lhKEsn jywp4CgstwjwbFyIRp1tCpxaRZyRkBFI3W4+O8B4NmG0hQI/Ie6oPuXRv0ibBUkJA07kd2+Eo6S GHvKzfMHOPD6mzXUh2gT5ZCUZHiftuUn7MQzLSLqIuF6LgNwCODEgqffNxbeUHbRpBqGZH6PeK4 VK/1baWQ3KQ2+ZX0HCtCBVJEYeDv3ElRkT7K/WeFBb6hk1Kd15RnPqZrZiqAZGmonTjgKms0uM1 f2sx8/6Wqz7/oAEhn5ZgTSqaueyvTbg1+4qxuMxGQO4EryjllXNIvVZCgeOS6znUU/POoRYtVM8 qj6osM/Y6DVWLsylWOZiOlrRa5xGJ/kf6ILRc= X-Received: by 2002:a17:90b:2f88:b0:36a:c4b:76cf with SMTP id 98e67ed59e1d1-38941acc562mr9085521a91.23.1783619408908; Thu, 09 Jul 2026 10:50:08 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:2485:88d2:edd6:52d6:462d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311950eb930sm17377902eec.8.2026.07.09.10.50.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:50:08 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/6] resolv: Make tst-resolv-qtypes a regular test Date: Thu, 9 Jul 2026 14:48:18 -0300 Message-ID: <20260709174957.670741-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709174957.670741-1-adhemerval.zanella@linaro.org> References: <20260709174957.670741-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org 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(-) 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 . */ +#include #include #include #include @@ -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 From patchwork Thu Jul 9 17:48:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 138839 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0B814BA2E35 for ; Thu, 9 Jul 2026 17:51:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0B814BA2E35 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=qjqp0139 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id AEF1A4BA23D4 for ; Thu, 9 Jul 2026 17:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEF1A4BA23D4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AEF1A4BA23D4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619411; cv=none; b=tKF2tm14wQnR+NME9WHHPFqZOTrOpI8A+Tw4p/35KE9jVDNZeJjXmzXE0td9P3L73qtxgiRQRMnL1oiUflAUwZowCLoC0afafTXQbHqYq5JbzSdPluRN8QO4bkZzyqg4GTHo0e22USL5Fequ0F/4GWhej1aU0+ctL7JvaAI6F6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783619411; c=relaxed/simple; bh=Bk+oHNbJyYOOZpDZ1MlkfV7cFjTHZPA+39DiDCkRYTI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hHoEVpNGNZEVW2d0nHSksMn4FOixuAgRQ9HE7l5CkCecYILQpkz0qSW+gRFFFxDNi8K3t+n3GkKpuLCVIu6r18R2PBFqRFtk47PMKLMEOlj/kWeO5DLmTJ4QDfnU8zZEOENUozaIiX5vcI4hZLCdmMb9qMANROnX6mT1epe9ghI= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=qjqp0139 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEF1A4BA23D4 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2cc7ef7ec27so291995ad.1 for ; Thu, 09 Jul 2026 10:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783619411; x=1784224211; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=JCL7lZiwMXMkvsFDRYYuJSUV7cswHlfKeQVVO5TJNxg=; b=qjqp0139TFvObW1xQ8EV8eBUHuPfry6MS06dC6sbBorAuGklt3HLqZywJ8IydePUn/ K3jyRolV/JL8kJO5U9cG2E7qwlN+bWI+FtJopTMZMXo1hAygtqAmI/X/rDkWxZb2nFY7 wgBlmHO7mmfsk5N748n1g9vesUvZQBDDjQuQ/dYvuEpvQrTSE+MWYTAZj4ebb4+FHk8r x98/YBIwp6PU5fGYhPa7AKW2vtjBsvzvCo/4G2SZbN6Z1DF0PNhBeZQGLN/Hnirg9Xox tvrBHvPsKqJEBAwfDM4KnnSKd3KGDr16JmDuoBJYR2QJIN4NjqNAVHd4tmzxMnE81g2P 8I3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783619411; x=1784224211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=JCL7lZiwMXMkvsFDRYYuJSUV7cswHlfKeQVVO5TJNxg=; b=OB+eBT5Tj0iCfAU9INlrFslbUmOWtzV4cG3KpoNWIfmagRI3/Lapj1KKuQT3ccZvQp XIqjkYNWewo7RLqvgKaCq3IDTKg4i5wwfyJR2sTi2ibyPUk4jDRNOV0xOJ1iaVP6N8Og PpRKI8dHE6STPKdc7uLBsdBdcyXh4JwRo2/eLz/A/h7FJJ1dLCrn3M2m33OnH/8hTM8D CuKBM2azNBAE9Cec+4vZyyi7l/dBLyXN0LLViGYz1MZk6LRRucVdTNxD1Bm1vCsIC5bp jFx8NXnhU7SCVZtwX86pSgIPI/6cQGnK7N66eiDMA09fLr4qa1sEJjKYwGP/fUkKIlyr qrfw== X-Gm-Message-State: AOJu0Yw8bwB25pa696Y+7VU+bobWoLHPz/57tTaMbgTBHh/94BMZQqN1 mt2py/omrzcB9C6lWcwyZT1pbPDm0fSv8PENIqcx2yf6uGlhD/pImb996pnq3vCunwDxkqZypGA /5Rbl X-Gm-Gg: AfdE7cm1xj7Hdgq7tUPASZkRQe4ztNGM4CDrf/GEPCXdaDJ4yFOlK6C33YAXbmSr+jJ xXh3pwHWQJlFitL+eMziwj4tUpeJAr8ShfAHHu6dRsY/8wDvr4e/kkaEKGDzFF9TYcuIs1WZcBb s7sbTdBfUAzkEuKsPrF3wvx64HIlo8Z7yAN6rmHGSMfMGaJs53HTqx1CZ3tzwyTF6nXUX6T7l0M I7MXhQfgIebpQzVS34fdqcH/zemDrPQvLJAfnYPoj8xJ5kbxnBcMqY+3SqzaW5JNgqdqQ7T1oQ5 W6EpFiSZ3ECOTZ8G4M4ZALyktV+ffdfSdLEGQA+mGCQcuAYg6H48r7Yb/6Df4TEtDlkKiaRGeWz pOr8noY1YYn/m/c7xX9UyHq/BqJwNXBRNttwE7E43dANy6NCUp+xeDty3XxqcWQGb8JDVJs+iFq WOuwVAVGw4dO4wsRXiLYW4/Irs X-Received: by 2002:a05:6a20:12d1:b0:3c0:9c19:65b9 with SMTP id adf61e73a8af0-3c0bccafaf5mr10363594637.65.1783619410359; Thu, 09 Jul 2026 10:50:10 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:2485:88d2:edd6:52d6:462d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311950eb930sm17377902eec.8.2026.07.09.10.50.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:50:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 6/6] iconv: Replace test-iconvconfig xtest with a container test Date: Thu, 9 Jul 2026 14:48:19 -0300 Message-ID: <20260709174957.670741-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260709174957.670741-1-adhemerval.zanella@linaro.org> References: <20260709174957.670741-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The old xtests-special target compared a generated cache against $(inst_gconvdir)/gconv-modules.cache, so it required a prior make install and only ran under make xcheck. It also access the system gconv configuration, which might not be in the expected place depending of how the system configures glibc. Run iconvconfig over the installed gconv modules inside a test-container instead and check that cache generation succeeds and is deterministic. --- iconv/Makefile | 13 +- iconv/tst-iconvconfig-cache.c | 192 ++++++++++++++++++ .../tst-iconvconfig-cache.root/postclean.req | 0 iconv/tst-iconvconfig-cache.root/preclean.req | 0 4 files changed, 194 insertions(+), 11 deletions(-) create mode 100644 iconv/tst-iconvconfig-cache.c create mode 100644 iconv/tst-iconvconfig-cache.root/postclean.req create mode 100644 iconv/tst-iconvconfig-cache.root/preclean.req diff --git a/iconv/Makefile b/iconv/Makefile index 69555cbe579..02980457b38 100644 --- a/iconv/Makefile +++ b/iconv/Makefile @@ -78,8 +78,9 @@ cpp-srcs-left := $(iconv_prog-modules) $(iconvconfig-modules) lib := iconvprogs include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left)) +tests-container += tst-iconvconfig-cache + ifeq ($(run-built-tests),yes) -xtests-special += $(objpfx)test-iconvconfig.out tests-special += \ $(objpfx)tst-iconv_prog-buffer-large.out \ $(objpfx)tst-iconv_prog-buffer-tiny.out \ @@ -129,16 +130,6 @@ $(inst_bindir)/iconv: $(objpfx)iconv_prog $(+force) $(objpfx)iconv_prog: $(iconv_prog-modules:%=$(objpfx)%.o) $(objpfx)iconvconfig: $(iconvconfig-modules:%=$(objpfx)%.o) -$(objpfx)test-iconvconfig.out: $(objpfx)iconvconfig - (set -e; \ - tmp=$(objpfx)gconv-modules.cache.$$$$; \ - rm -f $$tmp; \ - $(run-program-prefix) $(objpfx)iconvconfig \ - --output=$$tmp --nostdlib $(inst_gconvdir); \ - cmp $$tmp $(inst_gconvdir)/gconv-modules.cache; \ - rm -f $$tmp) > $@; \ - $(evaluate-test) - $(objpfx)tst-iconv_prog.out: tst-iconv_prog.sh $(objpfx)iconv_prog \ $(gen-locales) $(BASH) $< $(common-objdir) '$(test-wrapper-env)' \ diff --git a/iconv/tst-iconvconfig-cache.c b/iconv/tst-iconvconfig-cache.c new file mode 100644 index 00000000000..e0d87e6654e --- /dev/null +++ b/iconv/tst-iconvconfig-cache.c @@ -0,0 +1,192 @@ +/* Test that iconvconfig produces a valid, reproducible module cache. + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define GCONV_CACHE_MAGIC 0x20010324 + +static char *iconvconfig; +static char *gconvdir; + +static void +run_iconvconfig (const char *out) +{ + char *arg_output = xasprintf ("--output=%s", out); + char *const argv[] = + { + iconvconfig, arg_output, (char *) "--nostdlib", gconvdir, NULL + }; + struct support_capture_subprocess proc + = support_capture_subprogram (iconvconfig, argv, NULL); + support_capture_subprocess_check (&proc, "iconvconfig", 0, sc_allow_none); + support_capture_subprocess_free (&proc); + free (arg_output); +} + +struct cache_file_t +{ + char *data; + size_t length; +}; + +static struct cache_file_t +read_cache_file (const char *path) +{ + struct stat64 st; + xstat64 (path, &st); + char *buffer = xmalloc (st.st_size); + int fd = xopen (path, O_RDONLY, 0); + xread (fd, buffer, st.st_size); + xclose (fd); + return (struct cache_file_t) { buffer, st.st_size }; +} + +static void +free_cache_file (struct cache_file_t *cache_file) +{ + free (cache_file->data); +} + +static void +write_cache_file (const char *path, const char *data, size_t length) +{ + int fd = xopen (path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + xwrite (fd, data, length); + xclose (fd); +} + +static void +move_cache_file (const char *from, const char *to) +{ + if (access (from, F_OK) != 0) + FAIL_EXIT1 ("access(%s): %m", from); + if (rename (from, to) != 0) + FAIL_EXIT1 ("rename(%s, %s): %m", from, to); +} + +static void +check_valid_cache (const struct cache_file_t *cache_file) +{ + TEST_VERIFY_EXIT (cache_file->length >= sizeof (uint32_t)); + uint32_t magic; + memcpy (&magic, cache_file->data, sizeof (magic)); + TEST_COMPARE (magic, GCONV_CACHE_MAGIC); +} + +/* Install the generated cache CAHCE_FILE at the canonical gconv cache path + and confirm that the runtime loads it and resolves a module-backed + conversion. The gconv-modules text configuration is moved aside, so the + conversion can only succeed if it is satisfied from the cache. A corrupt + cache would make the loader fall back to the missing text configuration + and the conversion would fail. */ +static void +check_loadable_cache (const struct cache_file_t *cache_file) +{ + char *cache = xasprintf ("%s/gconv-modules.cache", gconvdir); + char *conf = xasprintf ("%s/gconv-modules", gconvdir); + char *confd = xasprintf ("%s/gconv-modules.d", gconvdir); + char *conf_bak = xasprintf ("%s.disabled", conf); + char *confd_bak = xasprintf ("%s.disabled", confd); + + write_cache_file (cache, cache_file->data, cache_file->length); + + /* The runtime bypasses the cache when GCONV_PATH is set. */ + unsetenv ("GCONV_PATH"); + + move_cache_file (conf, conf_bak); + move_cache_file (confd, confd_bak); + + /* Force a module resolution, which here can only come from the cache. */ + iconv_t cd = iconv_open ("EUC-JP", "UTF-8"); + TEST_VERIFY (cd != (iconv_t) -1); + + { + /* ASCII is a subset of EUC-JP, so 'A' converts to itself. */ + char in[] = "A"; + char out[8]; + char *inp = in; + char *outp = out; + size_t inleft = 1; + size_t outleft = sizeof (out); + TEST_VERIFY (iconv (cd, &inp, &inleft, &outp, &outleft) != (size_t) -1); + TEST_COMPARE (outp - out, 1); + TEST_COMPARE (out[0], 'A'); + TEST_COMPARE (iconv_close (cd), 0); + } + + /* Restore the configuration for any later use of the container. */ + TEST_COMPARE (rename (conf_bak, conf), 0); + TEST_COMPARE (rename (confd_bak, confd), 0); + + free (cache); + free (conf); + free (confd); + free (conf_bak); + free (confd_bak); +} + +static int +do_test (void) +{ + iconvconfig = xasprintf ("%s/iconvconfig", support_sbindir_prefix); + gconvdir = xasprintf ("%s/gconv", support_libdir_prefix); + + char *cache1; + xclose (create_temp_file ("iconvconfig-cache1-", &cache1)); + char *cache2; + xclose (create_temp_file ("iconvconfig-cache2-", &cache2)); + + run_iconvconfig (cache1); + run_iconvconfig (cache2); + + struct cache_file_t cache_file1 = read_cache_file (cache1); + struct cache_file_t cache_file2 = read_cache_file (cache2); + + /* Check if the cache generation is deterministic. */ + TEST_VERIFY (cache_file1.length > 0); + TEST_COMPARE (cache_file1.length, cache_file2.length); + TEST_COMPARE_BLOB (cache_file1.data, cache_file1.length, + cache_file1.data, cache_file1.length); + + /* And well-formed. */ + check_valid_cache (&cache_file1); + + /* And the runtime must be able to load it and convert through it. */ + check_loadable_cache (&cache_file2); + + free_cache_file (&cache_file1); + free_cache_file (&cache_file2); + free (iconvconfig); + free (gconvdir); + + return 0; +} + +#include diff --git a/iconv/tst-iconvconfig-cache.root/postclean.req b/iconv/tst-iconvconfig-cache.root/postclean.req new file mode 100644 index 00000000000..e69de29bb2d diff --git a/iconv/tst-iconvconfig-cache.root/preclean.req b/iconv/tst-iconvconfig-cache.root/preclean.req new file mode 100644 index 00000000000..e69de29bb2d