From patchwork Tue Apr 5 05:02:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 11627 Received: (qmail 38243 invoked by alias); 5 Apr 2016 05:02:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 36846 invoked by uid 89); 5 Apr 2016 05:02:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=68, 7, timing_t, *orig_src, 5312 X-HELO: mail-pf0-f171.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=hs17NfnFzTEL6cQivUqvDjwGqaR/XsPUxBpDB6HZJQA=; b=TWIoMo7hilulLOsY+NN9CuD85qmF6k9nsOlDvBXD6+aL/X8OkWzaQ3d4T/Y6PuEIyX kmRprErSqt2/3p15AN6t07TP3EdrYDWWujstMwWoe5kvLQZpXJ1JCzW7iU3GF6/PUMLy Xo5b0qfFu5cWHSyYsqhSVDHVrWKi0wAYrdVe7zHvIUVwfFqETLxWyJqp7DF/W56BBTrx iLaHQ83/Fk5XZhPpxneT0puS65axy1Ub84VYLjofa6N37wx3fE8wSoe45bwCFJHnKVLC b1OUWzydubESfW0S5YK8wkZSwMZoXTd3ROSdK0hHfjQwda4O/0PDBoLKtcgq+NcTiS4+ HKPg== X-Gm-Message-State: AD7BkJL2F0o5tIKhNt4pfcQ1/4tZCz7+o1xScc4Ej6WMPbL6HqtAyh+j4IkAMFQ66Zj/dQ== X-Received: by 10.98.13.132 with SMTP id 4mr26454898pfn.122.1459832539938; Mon, 04 Apr 2016 22:02:19 -0700 (PDT) Date: Mon, 4 Apr 2016 22:02:18 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] PR string/19907: Incorrect memcpy tests Message-ID: <20160405050218.GA5157@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Clear the destination buffer updated by the previous run in bench-memcpy.c and test-memcpy.c to catch the error when the following implementations do copy anything. Tested on x86-64. OK for master? H.J. --- PR string/19907 * enchtests/bench-memcpy.c (do_one_test): Clear the destination buffer updated by the previous run. * string/test-memcpy.c (do_one_test): Likewise. * benchtests/bench-memmove.c (do_one_test): Add a comment. * string/test-memmove.c (do_one_test): Likewise. --- benchtests/bench-memcpy.c | 4 ++++ benchtests/bench-memmove.c | 1 + string/test-memcpy.c | 6 ++++++ string/test-memmove.c | 1 + 4 files changed, 12 insertions(+) diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c index c5a7192..9d9e7b6 100644 --- a/benchtests/bench-memcpy.c +++ b/benchtests/bench-memcpy.c @@ -55,6 +55,10 @@ do_one_test (impl_t *impl, char *dst, const char *src, size_t i, iters = INNER_LOOP_ITERS; timing_t start, stop, cur; + /* Must clear the destination buffer set by the previous run. */ + for (i = 0; i < len; i++) + dst[i] = 0; + if (CALL (impl, dst, src, len) != MEMCPY_RESULT (dst, len)) { error (0, 0, "Wrong result in function %s %p %p", impl->name, diff --git a/benchtests/bench-memmove.c b/benchtests/bench-memmove.c index c38596b..3858f2a 100644 --- a/benchtests/bench-memmove.c +++ b/benchtests/bench-memmove.c @@ -70,6 +70,7 @@ do_one_test (impl_t *impl, char *dst, char *src, const char *orig_src, size_t i, iters = INNER_LOOP_ITERS; timing_t start, stop, cur; + /* This also clears the destination buffer set by the previous run. */ memcpy (src, orig_src, len); #ifdef TEST_BCOPY CALL (impl, src, dst, len); diff --git a/string/test-memcpy.c b/string/test-memcpy.c index 2a0994c..cb072f8 100644 --- a/string/test-memcpy.c +++ b/string/test-memcpy.c @@ -53,6 +53,12 @@ static void do_one_test (impl_t *impl, char *dst, const char *src, size_t len) { + size_t i; + + /* Must clear the destination buffer set by the previous run. */ + for (i = 0; i < len; i++) + dst[i] = 0; + if (CALL (impl, dst, src, len) != MEMCPY_RESULT (dst, len)) { error (0, 0, "Wrong result in function %s %p %p", impl->name, diff --git a/string/test-memmove.c b/string/test-memmove.c index d2ab3f3..4343329 100644 --- a/string/test-memmove.c +++ b/string/test-memmove.c @@ -68,6 +68,7 @@ static void do_one_test (impl_t *impl, char *dst, char *src, const char *orig_src, size_t len) { + /* This also clears the destination buffer set by the previous run. */ memcpy (src, orig_src, len); #ifdef TEST_BCOPY CALL (impl, src, dst, len);