From patchwork Mon Apr 10 15:59:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1767203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=MFDFaGv8; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PwDFX40XVz1yZP for ; Tue, 11 Apr 2023 02:00:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F6003857714 for ; Mon, 10 Apr 2023 15:59:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F6003857714 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681142398; bh=jgilcCbCl+XdzV5Ey4xrRVJ3KgN0O+5U6u0PYjsdDdM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MFDFaGv8/qH8PIpvEBMYCt/zNwTkstkttqTae7Ls+gPb0zhGQZ+3P7iz20hzjvu6B RriNQtUb9SKN8+V6IZeOQ6eeYiD1H+imIQolIaMRpwPK1llVUgZ1ezXNmnobbNTDBL s8EnmUNrdUlOf6dUMBJi+WfpVi6A2gwWE7MCkUg8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id EA9473858C62 for ; Mon, 10 Apr 2023 15:59:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA9473858C62 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-dXX1elrePcmE5CJhqkZzGw-1; Mon, 10 Apr 2023 11:59:42 -0400 X-MC-Unique: dXX1elrePcmE5CJhqkZzGw-1 Received: by mail-qt1-f199.google.com with SMTP id t30-20020a05622a181e00b003e37dd114e3so4489117qtc.10 for ; Mon, 10 Apr 2023 08:59:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681142382; x=1683734382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jgilcCbCl+XdzV5Ey4xrRVJ3KgN0O+5U6u0PYjsdDdM=; b=6+qV/mcZG0YF10r5r+tqG4CEd6+xJyW4MYvbbImlJ4OrHdfGDWNNYyI1fG3Dpo2GwU NxyBbuqGcdH0eEEWi8hySdakNM1oJdqgnYdI4mJ7SgbD1kkNDqaTAoJVzueWOxZqe/jx nLuxHas3/6Bia+KUDpIZG+Xv2S2zQHhl+3DLeFFxJ4QgFixfqSB7/84QUPRN7V7rZJdB YROegZe2fn+qS0B1V29uD5yQuHs8Ypd9RGCfEG7GmcEeebLKZDNS5qiGS4jiJ5fQRxGD b4nRGOmeh7H865WZFX6FchMQV850EVuI4r3blKiXM7sjR3joXgQjxNGZ7jVRwLzN2iMF oUbQ== X-Gm-Message-State: AAQBX9dm/R6vig87xqDcnQMe60ypaxJVz8SXdkx0URypbUsJX/qtLh6n FByLht7m0aAX5FgABHDCXNJ6Wy11hUuv4bmrHc+jC/NQbak/UvhAdg0ntnGuSxOrlUOBRMnJkLv OxjFIUVaOf8PLpn2UjMmmbFMn22Btvxdc83/ws//S9rvJkVZRc4ujk1F6fLaJngfYEMWXPyY03b reA7+L X-Received: by 2002:ad4:594e:0:b0:5e0:6931:3b8 with SMTP id eo14-20020ad4594e000000b005e0693103b8mr20160655qvb.2.1681142381845; Mon, 10 Apr 2023 08:59:41 -0700 (PDT) X-Google-Smtp-Source: AKy350bapGxJFkyaOohnseuNLJmld2O4jjAzUy0VOgTrZKe5fxVMBzixPiUY9OrX29XgoWvM9HfW8g== X-Received: by 2002:ad4:594e:0:b0:5e0:6931:3b8 with SMTP id eo14-20020ad4594e000000b005e0693103b8mr20160627qvb.2.1681142381455; Mon, 10 Apr 2023 08:59:41 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id h2-20020ad45442000000b005dd8b9345e0sm3470413qvt.120.2023.04.10.08.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 08:59:41 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott , Adhemerval Zanella Subject: [PATCH v4 1/4] string: Allow use of test-string.h for non-ifunc implementations. Date: Mon, 10 Apr 2023 11:59:31 -0400 Message-Id: <20230410155934.3503627-2-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230410155934.3503627-1-josimmon@redhat.com> References: <20230329150500.2886135-1-josimmon@redhat.com> <20230410155934.3503627-1-josimmon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Mark two variables as unused to silence warning when using test-string.h for non-ifunc implementations. Reviewed-by: Adhemerval Zanella --- string/test-string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/string/test-string.h b/string/test-string.h index 41de973479..8bcb8afd0a 100644 --- a/string/test-string.h +++ b/string/test-string.h @@ -130,8 +130,8 @@ cmdline_process_function (int c) /* Increase size of FUNC_LIST if assert is triggered at run-time. */ static struct libc_ifunc_impl func_list[32]; static int func_count; -static int impl_count = -1; -static impl_t *impl_array; +static int impl_count __attribute__ ((unused)) = -1; +static impl_t *impl_array __attribute__ ((unused)); # define FOR_EACH_IMPL(impl, notall) \ impl_t *impl; \ From patchwork Mon Apr 10 15:59:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1767205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=RlP2XiJu; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PwDGQ3nfbz1yZK for ; Tue, 11 Apr 2023 02:00:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F1BA3857014 for ; Mon, 10 Apr 2023 16:00:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F1BA3857014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681142444; bh=Gch4CSrrjoguVoFNvj2wLNXVUbQ9WquqD5Q/ZYN/tVg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=RlP2XiJu/tLPOf6XqZagpmjJSzgqDZUeOoYJufxtYhfWGJSfOXG0q15DcwkCsHOwO mK9+DcQuIpv/lI1DSlPV4P3gWBCuWjXHmisNzdwJZWqK71PvkSlXFyHIvjrMoUDFLs 8NXah1Ld6gCxYQSDXK4HgK/VgYdFg5I300byiJFE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 83F503858401 for ; Mon, 10 Apr 2023 15:59:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83F503858401 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-14GGPNliOHKixrs1y4Sr2A-1; Mon, 10 Apr 2023 11:59:45 -0400 X-MC-Unique: 14GGPNliOHKixrs1y4Sr2A-1 Received: by mail-qt1-f199.google.com with SMTP id a19-20020a05622a02d300b003e4ecb5f613so28738677qtx.21 for ; Mon, 10 Apr 2023 08:59:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681142384; x=1683734384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gch4CSrrjoguVoFNvj2wLNXVUbQ9WquqD5Q/ZYN/tVg=; b=vC+9Pa/y0KfQFcNq8geOkwBEFGySY6KKO8VasEGl4N60ML4sDy5I02KZVhQGhMo9ZM DKlUY8KDaYk6h9DO3EDgMEHnZcz/hqIAcPWd5c+i5z2/A89cGB4YN0fwkIBFrIV0jPPh OF7BNEdsUm55V9YXDpYDbAxyzWNqrTVvnZTrRzQONlryYfiAK3LlbQoQBR7T+DKzV7J8 RJHzdQIsSPPz5HH4j4bTrvy/e+PtUn1ebb6E7nFWvR3elHeUXi5hLzJJ7JG5U7u0OJRd T/fyJgF4LN+xFvEpGJWd+e3xIxwd200cQ1CpYDLuIdzFJpfAmtp/5gDS3QSWkk2YkVcI Yf+A== X-Gm-Message-State: AAQBX9fCm1BsJ4IELGxz31f7NTj0xx9PDFncFhmdLS92Q5MVwRs+q1iS MG5uYRa6ps/jUChfjCSmfYSqBideeCnMpNDAswIBT4J7lc9IdNfmiqTEmfg0eCfDICoc0Uhr2dp FJQf21LVv6WXbvEhclSKAQuJKsixrdhKatxasAwDKre8NDTHs25XATHFQieDVewPDWduBWp1iEw t23joW X-Received: by 2002:a05:6214:1c8a:b0:5c7:cc77:d203 with SMTP id ib10-20020a0562141c8a00b005c7cc77d203mr16702815qvb.3.1681142384050; Mon, 10 Apr 2023 08:59:44 -0700 (PDT) X-Google-Smtp-Source: AKy350YErseA4fitVkDU1QBEkkJjqi7+dFQp0oFLtULpwNL902+kZ55RGujjAgaGC1FGPJ6YrT2XIA== X-Received: by 2002:a05:6214:1c8a:b0:5c7:cc77:d203 with SMTP id ib10-20020a0562141c8a00b005c7cc77d203mr16702793qvb.3.1681142383695; Mon, 10 Apr 2023 08:59:43 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id h2-20020ad45442000000b005dd8b9345e0sm3470413qvt.120.2023.04.10.08.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 08:59:42 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v4 2/4] string: Add tests for strdup (BZ #30266) Date: Mon, 10 Apr 2023 11:59:32 -0400 Message-Id: <20230410155934.3503627-3-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230410155934.3503627-1-josimmon@redhat.com> References: <20230329150500.2886135-1-josimmon@redhat.com> <20230410155934.3503627-1-josimmon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Copy strcpy tests for strdup. Covers some basic testcases with random strings. Add a zero-length string testcase. Reviewed-by: Adhemerval Zanella --- string/Makefile | 1 + string/test-strdup.c | 203 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 string/test-strdup.c diff --git a/string/Makefile b/string/Makefile index c84b49aaa5..472e318aea 100644 --- a/string/Makefile +++ b/string/Makefile @@ -157,6 +157,7 @@ tests := \ test-strcmp \ test-strcpy \ test-strcspn \ + test-strdup \ test-strlen \ test-strncasecmp \ test-strncat \ diff --git a/string/test-strdup.c b/string/test-strdup.c new file mode 100644 index 0000000000..8a1a267782 --- /dev/null +++ b/string/test-strdup.c @@ -0,0 +1,203 @@ +/* Test and measure strdup functions. + Copyright (C) 2023 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 + +#ifdef WIDE +# include +# define CHAR wchar_t +# define UCHAR wchar_t +# define sfmt "ls" +# define BIG_CHAR WCHAR_MAX +# define SMALL_CHAR 1273 +# define STRCMP wcscmp +# define MEMCMP wmemcmp +# define MEMSET wmemset +# define TCS TEST_COMPARE_STRING_WIDE +#else +# define CHAR char +# define UCHAR unsigned char +# define sfmt "s" +# define BIG_CHAR CHAR_MAX +# define SMALL_CHAR 127 +# define STRCMP strcmp +# define MEMCMP memcmp +# define MEMSET memset +# define TCS TEST_COMPARE_STRING +#endif + +#ifndef STRDUP_RESULT +# define STRDUP_RESULT(dst, len) dst +# define TEST_MAIN +# ifndef WIDE +# define TEST_NAME "strdup" +# else +# define TEST_NAME "wcsdup" +# endif +# include "test-string.h" +# ifndef WIDE +# define STRDUP strdup +# else +# define STRDUP wcsdup +# endif +#endif + +typedef CHAR *(*proto_t) (const CHAR *); + +static void +do_zero_len_test (void) +{ + CHAR src[1] = { '\0' }; + CHAR *dst = STRDUP (src); + + TCS (dst, src); + free (dst); +} + +static void +do_one_test (const CHAR *src, + size_t len __attribute__((unused))) +{ + CHAR *dst = STRDUP (src); + + if (STRCMP (dst, src) != 0) + { + error (0, 0, + "Wrong result in function %s dst \"%" sfmt "\" src \"%" sfmt "\"", + TEST_NAME, dst, src); + ret = 1; + free (dst); + return; + } + free (dst); +} + +static void +do_test (size_t align1, size_t align2, size_t len, int max_char) +{ + size_t i; + CHAR *s1; +/* For wcsdup: align1 and align2 here mean alignment not in bytes, + but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t)) + len for wcschr here isn't in bytes but it's number of wchar_t symbols. */ + align1 &= 7; + if ((align1 + len) * sizeof (CHAR) >= page_size) + return; + + align2 &= 7; + if ((align2 + len) * sizeof (CHAR) >= page_size) + return; + + s1 = (CHAR *) (buf1) + align1; + + for (i = 0; i < len; i++) + s1[i] = 32 + 23 * i % (max_char - 32); + s1[len] = 0; + + do_one_test (s1, len); +} + +static void +do_random_tests (void) +{ + size_t i, j, n, align1, align2, len; + UCHAR *p1 = (UCHAR *) (buf1 + page_size) - 512; + UCHAR *res; + + for (n = 0; n < ITERATIONS; n++) + { + /* align1 and align2 are expressed as wchar_t and not in bytes for wide + char test, and thus it will be equal to align times wchar_t size. + + For non wide version we need to check all alignments from 0 to 63 + since some assembly implementations have separate prolog for alignments + more 48. */ + + align1 = random () & (63 / sizeof (CHAR)); + if (random () & 1) + align2 = random () & (63 / sizeof (CHAR)); + else + align2 = align1 + (random () & 24); + len = random () & 511; + j = align1; + if (align2 > j) + j = align2; + if (len + j >= 511) + len = 510 - j - (random () & 7); + j = len + align1 + 64; + if (j > 512) + j = 512; + for (i = 0; i < j; i++) + { + if (i == len + align1) + p1[i] = 0; + else + { + p1[i] = random () & BIG_CHAR; + if (i >= align1 && i < len + align1 && !p1[i]) + p1[i] = (random () & SMALL_CHAR) + 3; + } + } + + res = (UCHAR *) STRDUP((CHAR *) p1 + align1); + TCS ((CHAR *) res, (CHAR *) (p1 + align1)); + free (res); + } +} + + +int +test_main (void) +{ + size_t i; + + test_init (); + + printf ("%23s", ""); + printf ("\t%s", TEST_NAME); + putchar ('\n'); + + for (i = 0; i < 16; ++i) + { + do_test (0, 0, i, SMALL_CHAR); + do_test (0, 0, i, BIG_CHAR); + do_test (0, i, i, SMALL_CHAR); + do_test (i, 0, i, BIG_CHAR); + } + + for (i = 1; i < 8; ++i) + { + do_test (0, 0, 8 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 8 << i, SMALL_CHAR); + } + + for (i = 1; i < 8; ++i) + { + do_test (i, 2 * i, 8 << i, SMALL_CHAR); + do_test (2 * i, i, 8 << i, BIG_CHAR); + do_test (i, i, 8 << i, SMALL_CHAR); + do_test (i, i, 8 << i, BIG_CHAR); + } + + do_zero_len_test (); + do_random_tests (); + + return ret; +} + +#include From patchwork Mon Apr 10 15:59:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1767204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=HI434/VF; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PwDGK16qqz1yZK for ; Tue, 11 Apr 2023 02:00:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A9383857344 for ; Mon, 10 Apr 2023 16:00:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A9383857344 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681142439; bh=0cSEvvK962p/u7tD0+Yh+NFQOo+CJxm0ScDWNggWcwU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=HI434/VF9dWKqAIflPVRx/jP6mIbTavRUicHHSgCVnrtVb7lV65p4liyrncTLsYSq InlefWB66UotOfbAiFz04AuNduwu3InXaGMzeL3ITuNdMl51H+O9AK/ShF3Q78E011 ktvDVsSZzI9eve2amiuOrCHWwBiCx4NNnuWZanFE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1A48C3858425 for ; Mon, 10 Apr 2023 15:59:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A48C3858425 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-CUpLEPoeNuGK8tg06ByNYg-1; Mon, 10 Apr 2023 11:59:46 -0400 X-MC-Unique: CUpLEPoeNuGK8tg06ByNYg-1 Received: by mail-qv1-f69.google.com with SMTP id f17-20020a0cbed1000000b005d70160fbb0so2783129qvj.21 for ; Mon, 10 Apr 2023 08:59:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681142386; x=1683734386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0cSEvvK962p/u7tD0+Yh+NFQOo+CJxm0ScDWNggWcwU=; b=CDAGiqELsP93Z51kYfLZ5pMgcHMorJ6ekAAKDoLoCifL7CnNCFwprAQwnEnmH9Foo3 xe14ALyUIajy4rFgclFFo++x4ohmhl6WjolKgcVNMfFENOr8vbRhU57ZLnxcnJnIgUDl 6OfBZhEtRfLLD8hElp5ms7H+olCc27dPhaWQyCUej5VKeWHjQ1IIbmF/yvH/TIoZ1YQG JxoLcfYdNT3kOf1YyPyXuyZjGMHJUa0Qwz4uhzeb6dh1OZ2VLypC2HFYmHIuIjv+xANl +upVpbECOixFD8pJoS2HgFVB1vxwOKK8UlbwqdBXXDFb7BZDf4cpIwyDNbHGRLq9/iyg fYbA== X-Gm-Message-State: AAQBX9crNVYZpmmukseEJNwye/Xdm5C6FHGF5ER972cTQWVhFOe9xNfa /ZPLomOWuOollgExZg2cCI20Oia6ya/2v8xdG89eMqv85aw1qbbbCelYVj8ryR1uXTHMWUA7TrY gPKtnfGZD2rF8NGIq+YpC1YC8cft9l1oNl2r/mrtWI90pga5HtEJHRDhHcEZo3F8D64FZIwQNrV jqt0n1 X-Received: by 2002:ad4:4eaf:0:b0:5df:88d0:cf9d with SMTP id ed15-20020ad44eaf000000b005df88d0cf9dmr18869118qvb.39.1681142385776; Mon, 10 Apr 2023 08:59:45 -0700 (PDT) X-Google-Smtp-Source: AKy350aZtfs8jOaRtfQjq0k3wqatFgFPR/c8JyS1vCmt3uhNGNhXv5MU3Qicdj43bRFkJbp6fOBbmg== X-Received: by 2002:ad4:4eaf:0:b0:5df:88d0:cf9d with SMTP id ed15-20020ad44eaf000000b005df88d0cf9dmr18869085qvb.39.1681142385347; Mon, 10 Apr 2023 08:59:45 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id h2-20020ad45442000000b005dd8b9345e0sm3470413qvt.120.2023.04.10.08.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 08:59:44 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v4 3/4] string: Add tests for strndup (BZ #30266) Date: Mon, 10 Apr 2023 11:59:33 -0400 Message-Id: <20230410155934.3503627-4-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230410155934.3503627-1-josimmon@redhat.com> References: <20230329150500.2886135-1-josimmon@redhat.com> <20230410155934.3503627-1-josimmon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Copy strncpy tests for strndup. Covers some basic testcases with random strings. Remove tests that set the destination's bytes and checked the resulting buffer's bytes. Remove wide character test support since wcsndup() doesn't exist. --- string/Makefile | 1 + string/test-strndup.c | 222 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100644 string/test-strndup.c diff --git a/string/Makefile b/string/Makefile index 472e318aea..2eef6f1dfc 100644 --- a/string/Makefile +++ b/string/Makefile @@ -163,6 +163,7 @@ tests := \ test-strncat \ test-strncmp \ test-strncpy \ + test-strndup \ test-strnlen \ test-strpbrk \ test-strrchr \ diff --git a/string/test-strndup.c b/string/test-strndup.c new file mode 100644 index 0000000000..b5665a3eec --- /dev/null +++ b/string/test-strndup.c @@ -0,0 +1,222 @@ +/* Test strndup functions. + Copyright (C) 2023 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 + +#define CHAR char +#define UCHAR unsigned char +#define BIG_CHAR CHAR_MAX +#define SMALL_CHAR 127 +#define MEMSET memset + + +#ifndef STRNDUP_RESULT +# define STRNDUP_RESULT(dst, len, n) dst +# define TEST_MAIN +# define TEST_NAME "strndup" +# include "test-string.h" + +#endif /* !STRNDUP_RESULT */ + +static void +do_one_test (const CHAR *src, size_t len, size_t n) +{ + CHAR *dst = strndup(src, n); + size_t s = (len > n ? n: len) * sizeof (CHAR); + + TEST_COMPARE_BLOB(dst, s, src, s); +} + +static void +do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char) +{ + size_t i; + CHAR *s1; + +/* For wcsndup: align1 and align2 here mean alignment not in bytes, + but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t)). */ + align1 &= 7; + if ((align1 + len) * sizeof (CHAR) >= page_size) + return; + + align2 &= 7; + if ((align2 + len) * sizeof (CHAR) >= page_size) + return; + + s1 = (CHAR *) (buf1) + align1; + + for (i = 0; i < len; ++i) + s1[i] = 32 + 23 * i % (max_char - 32); + s1[len] = 0; + for (i = len + 1; (i + align1) * sizeof (CHAR) < page_size && i < len + 64; + ++i) + s1[i] = 32 + 32 * i % (max_char - 32); + + do_one_test (s1, len, n); +} + +static void +do_page_tests (void) +{ + CHAR *s1; + const size_t maxoffset = 64; + + /* Put s1 at the maxoffset from the edge of buf1's last page. */ + s1 = (CHAR *) buf1 + BUF1PAGES * page_size / sizeof(CHAR) - maxoffset; + /* s2 needs room to put a string with size of maxoffset + 1 at s2 + + (maxoffset - 1). */ + + MEMSET (s1, 'a', maxoffset - 1); + s1[maxoffset - 1] = '\0'; + + /* Both strings are bounded to a page with read/write access and the next + page is protected with PROT_NONE (meaning that any access outside of the + page regions will trigger an invalid memory access). + + The loop copies the string s1 for all possible offsets up to maxoffset + for both inputs with a size larger than s1 (so memory access outside the + expected memory regions might trigger invalid access). */ + + for (size_t off1 = 0; off1 < maxoffset; off1++) + { + for (size_t off2 = 0; off2 < maxoffset; off2++) + { + do_one_test (s1 + off1, maxoffset - off1 - 1, + maxoffset + (maxoffset - off2)); + } + } +} + +static void +do_random_tests (void) +{ + size_t i, j, n, align1, align2, len, size, mode; + UCHAR *p1 = (UCHAR *) (buf1 + page_size) - 512; + UCHAR *res; + + for (n = 0; n < ITERATIONS; n++) + { + /* For wcsndup: align1 and align2 here mean align not in bytes, + but in wchar_ts, in bytes it will equal to align * (sizeof + (wchar_t)). */ + + mode = random (); + if (mode & 1) + { + size = random () & 255; + align1 = 512 - size - (random () & 15); + if (mode & 2) + align2 = align1 - (random () & 24); + else + align2 = align1 - (random () & 31); + if (mode & 4) + { + j = align1; + align1 = align2; + align2 = j; + } + if (mode & 8) + len = size - (random () & 31); + else + len = 512; + if (len >= 512) + len = random () & 511; + } + else + { + align1 = random () & 31; + if (mode & 2) + align2 = random () & 31; + else + align2 = align1 + (random () & 24); + len = random () & 511; + j = align1; + if (align2 > j) + j = align2; + if (mode & 4) + { + size = random () & 511; + if (size + j > 512) + size = 512 - j - (random () & 31); + } + else + size = 512 - j; + if ((mode & 8) && len + j >= 512) + len = 512 - j - (random () & 7); + } + j = len + align1 + 64; + if (j > 512) + j = 512; + for (i = 0; i < j; i++) + { + if (i == len + align1) + p1[i] = 0; + else + { + p1[i] = random () & BIG_CHAR; + if (i >= align1 && i < len + align1 && !p1[i]) + p1[i] = (random () & SMALL_CHAR) + 3; + } + } + + res = (UCHAR *) strndup ((CHAR *) (p1 + align1), size); + j = len + 1; + if (size < j) + j = size; + TEST_COMPARE_BLOB (res, j, (CHAR *) (p1 + align1), j); + free (res); + } +} + +int +test_main (void) +{ + size_t i; + + test_init (); + + printf ("%28s", ""); + printf ("\t%s", TEST_NAME); + putchar ('\n'); + + for (i = 1; i < 8; ++i) + { + do_test (i, i, 16, 16, SMALL_CHAR); + do_test (i, i, 16, 16, BIG_CHAR); + do_test (i, 2 * i, 16, 16, SMALL_CHAR); + do_test (2 * i, i, 16, 16, BIG_CHAR); + do_test (8 - i, 2 * i, 1 << i, 2 << i, SMALL_CHAR); + do_test (2 * i, 8 - i, 2 << i, 1 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 1 << i, 2 << i, BIG_CHAR); + do_test (2 * i, 8 - i, 2 << i, 1 << i, BIG_CHAR); + } + + for (i = 1; i < 8; ++i) + { + do_test (0, 0, 4 << i, 8 << i, SMALL_CHAR); + do_test (0, 0, 16 << i, 8 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 4 << i, 8 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 16 << i, 8 << i, SMALL_CHAR); + } + + do_random_tests (); + do_page_tests (); + return ret; +} + +#include From patchwork Mon Apr 10 15:59:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1767206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=gBYwG61P; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PwDHD3Lyrz1yZK for ; Tue, 11 Apr 2023 02:01:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 691F5385773A for ; Mon, 10 Apr 2023 16:01:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 691F5385773A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681142486; bh=GiIrGl1N0Yg7taVJ26+nguSa8dLNPi66jPUDlY1Zac4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=gBYwG61POqGimjArseI+FI8g3uAFhBdeFbjMbH4zta7cNs4GV7fQe3vSxNnabjovc fckmF3e/2rzh8Ns+GasCVuRzFqqHBSV+KRJcaCl1Qqykm3FTyf1dok81taIz3PaNO1 eJ8LM7fHaRstSz4rD82fys6pzusoff084oqB/lJk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1BED03857709 for ; Mon, 10 Apr 2023 15:59:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BED03857709 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-335-GKHD8UzBPs-C0ZPUqoz2Yw-1; Mon, 10 Apr 2023 11:59:48 -0400 X-MC-Unique: GKHD8UzBPs-C0ZPUqoz2Yw-1 Received: by mail-qv1-f72.google.com with SMTP id pe26-20020a056214495a00b005df3eac4c0bso19695057qvb.1 for ; Mon, 10 Apr 2023 08:59:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681142387; x=1683734387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GiIrGl1N0Yg7taVJ26+nguSa8dLNPi66jPUDlY1Zac4=; b=z2Hje8e/GWVHj7/L/cY559eHmXdhuh04MC9GHcx0oDQFbe/eOa8huvnbWFIy3pXH1M 4YhDzMcGkbiWu8Gy5Ulelfi06PLfcSGW8H/h/jNCG0x3r3zJuyOH3RiMPNBP2GXdY4nl ab/dTh8TM3o+f1nFSnXXvB/TlVl5pdXWWaJQ0sRipq8aDomzJXnxAd4aUzlKoi/DnjJs L1pu7xqKSlQ/UHYIfaaRPIfW8iRt+nWruw8m1nLyt6j3ZHh4wnEwrbSTAcdNaUOmAxcV Wkls9Z4uLmfAY2zoyZrqQHRRtrcN6e2jvujopffEtn1JMNDSX34xGRXp8KKopf85lWrW kosw== X-Gm-Message-State: AAQBX9cdvk2N5qsr5ZOKm8HNXB466vmnrOVWRYxVE2SvqQHWbS4mLwgw Mig+jH/uAf2TU/rzKN8hz94O17TDI4A9P2bc9g35+NkkS3cf/YFvAiseOQkt8eYT02mIlH4BhEM p52d0ZnzZRuHpax3AmRSkBslJGmsRu52TMccNgJrF7QFfx3dV57rxjQpckODIwbUPypAiHDgC1M iU/B3r X-Received: by 2002:a05:6214:2a8b:b0:5c9:422e:c7b9 with SMTP id jr11-20020a0562142a8b00b005c9422ec7b9mr19624943qvb.19.1681142387755; Mon, 10 Apr 2023 08:59:47 -0700 (PDT) X-Google-Smtp-Source: AKy350aPfaSlgTEmR13Y8LC+/pKQAxoLLu2q/+nj6hrNTbmKyajOhsoX802NB1Q7iy+K9/0mZ3XJtg== X-Received: by 2002:a05:6214:2a8b:b0:5c9:422e:c7b9 with SMTP id jr11-20020a0562142a8b00b005c9422ec7b9mr19624922qvb.19.1681142387492; Mon, 10 Apr 2023 08:59:47 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id h2-20020ad45442000000b005dd8b9345e0sm3470413qvt.120.2023.04.10.08.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 08:59:47 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v4 4/4] wcsmbs: Add wcsdup() tests. (BZ #30266) Date: Mon, 10 Apr 2023 11:59:34 -0400 Message-Id: <20230410155934.3503627-5-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230410155934.3503627-1-josimmon@redhat.com> References: <20230329150500.2886135-1-josimmon@redhat.com> <20230410155934.3503627-1-josimmon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Enable wide character testcases for wcsdup(). Reviewed-by: Adhemerval Zanella --- wcsmbs/Makefile | 2 +- wcsmbs/test-wcsdup.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 wcsmbs/test-wcsdup.c diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index b12a3b0750..bd39335b0e 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -49,7 +49,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \ strop-tests := wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \ wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn wcspbrk \ - wcscspn wmemchr wmemset + wcscspn wmemchr wmemset wcsdup tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \ tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \ tst-c16c32-1 wcsatcliff tst-wcstol-locale tst-wcstod-nan-locale \ diff --git a/wcsmbs/test-wcsdup.c b/wcsmbs/test-wcsdup.c new file mode 100644 index 0000000000..e39e063d0b --- /dev/null +++ b/wcsmbs/test-wcsdup.c @@ -0,0 +1,2 @@ +#define WIDE 1 +#include "../string/test-strdup.c"