From patchwork Mon Aug 19 19:47:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 19336 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f198.google.com (mail-ye0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DFFE12469E for ; Mon, 19 Aug 2013 19:47:14 +0000 (UTC) Received: by mail-ye0-f198.google.com with SMTP id m1sf1419911yen.5 for ; Mon, 19 Aug 2013 12:47:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=e63Vb00oc7BKToPzECGwwqBpknOwdZd61FoIiz8SlFU=; b=YStMWEQj5E1Tym4Q4AdkeFf1Hq8n/csaKLU5LeRPKQomB8X9ZxUCos+bqtX7zI31tF lXrQI8+mI1SraIJegcBCXvE1H5iB5kZ3Koi7UXPv/3Etzfmi3VQevrwB+HESlyAZ5EYQ EjKWzpnnjDjmLBnMVmJNSkFFrv6AobUgZmTJ9SpDmqPefbsal/hOSzmNwLTRKHunyq5P VFlxNKuALTLbGroqXb4B37jMTYfMBljCSw8i+U01ekN/LZG5YVRXH4Hbi5EzgwgEBo9d HYWsf2KX4rRPJJtIxTChSsbJK+bz+r8JUOjXcBP5FYBYyXg1mCcuuOwWuR7bed5aO/+n //yw== X-Received: by 10.236.4.69 with SMTP id 45mr4658064yhi.20.1376941634701; Mon, 19 Aug 2013 12:47:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.74.102 with SMTP id s6ls1943783qev.17.gmail; Mon, 19 Aug 2013 12:47:14 -0700 (PDT) X-Received: by 10.221.64.17 with SMTP id xg17mr14914123vcb.5.1376941634585; Mon, 19 Aug 2013 12:47:14 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id j20si2737936vcm.3.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:14 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id pb11so3395691veb.11 for ; Mon, 19 Aug 2013 12:47:14 -0700 (PDT) X-Gm-Message-State: ALoCoQlfAf008uwaRChr8FFfrbxVhudbhEvhYBj7jbPs3ll72pRu1PTasPDg3MO4n6kU2d93orqd X-Received: by 10.52.115.102 with SMTP id jn6mr13001707vdb.18.1376941634498; Mon, 19 Aug 2013 12:47:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp114193vcz; Mon, 19 Aug 2013 12:47:14 -0700 (PDT) X-Received: by 10.15.22.69 with SMTP id e45mr6077179eeu.59.1376941633591; Mon, 19 Aug 2013 12:47:13 -0700 (PDT) Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by mx.google.com with ESMTPS id 41si11079593eee.17.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:13 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.48 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=74.125.83.48; Received: by mail-ee0-f48.google.com with SMTP id l10so2309171eei.7 for ; Mon, 19 Aug 2013 12:47:13 -0700 (PDT) X-Received: by 10.14.183.130 with SMTP id q2mr25461666eem.5.1376941632824; Mon, 19 Aug 2013 12:47:12 -0700 (PDT) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginmedia.com. [82.1.113.198]) by mx.google.com with ESMTPSA id k7sm19517278eeg.13.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:11 -0700 (PDT) Message-ID: <5212763E.2040702@linaro.org> Date: Mon, 19 Aug 2013 20:47:10 +0100 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: libc-alpha@sourceware.org CC: patches@linaro.org Subject: [PATCH 5/7] malloc/tst-valloc.c: Improve test coverage and use test-skeleton.c. X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , ChangeLog: 2013-08-12 Will Newton * malloc/tst-valloc.c: Rewrite to use test-skeleton.c and improve test coverage. --- malloc/tst-valloc.c | 85 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/malloc/tst-valloc.c b/malloc/tst-valloc.c index 643a0dd..5d2c65aa 100644 --- a/malloc/tst-valloc.c +++ b/malloc/tst-valloc.c @@ -1,23 +1,76 @@ -/* Test case by Stephen Tweedie . */ -#include -#include +/* Copyright (C) 2013 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 + +static int errors = 0; + +static void +merror (const char *msg) +{ + ++errors; + printf ("Error: %s\n", msg); +} -int -main (void) +static int +do_test (void) { - char *p; - int pagesize = getpagesize (); - int i; + void *p; + unsigned long pagesize = getpagesize(); + unsigned long ptrval; - p = valloc (pagesize); - i = (long int) p; + p = valloc (-1); - if ((i & (pagesize-1)) != 0) - { - fprintf (stderr, "Alignment problem: valloc returns %p\n", p); - exit (1); - } + if (p != NULL) + merror ("valloc (-1) succeeded."); - return 0; + p = valloc (-pagesize); + + if (p != NULL) + merror ("valloc (-pagesize) succeeded."); + + p = valloc (0); + + if (p == NULL) + merror ("valloc (0) failed."); + + free (p); + + p = valloc (32); + + if (p == NULL) + merror ("valloc (32) failed."); + + ptrval = (unsigned long)p; + + if (p == NULL) + merror ("valloc (32) failed."); + + if ((ptrval & (pagesize - 1)) != 0) + merror ("returned pointer is not page aligned."); + + free (p); + + return errors != 0; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"