From patchwork Mon Aug 19 19:47:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 19337 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 75F192469E for ; Mon, 19 Aug 2013 19:47:19 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id k8sf2686771qcq.3 for ; Mon, 19 Aug 2013 12:47:19 -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=3mxSqSZV2rGPIk2awKaC2dvZEUhTgm2z+Jn89x9Mdik=; b=ZykfXm3DvUSD6gz1c6XGtrLV8Yodypnqi7zaAUO2e2THmcw2Bjiofo8SMFPNZ1foYd pvHhD7DDdepa69fUd5MAoRD7EwD5qDFY8eMq+moVQZpQqgQJxqLeweuECl8qpH6i12U1 5DuRvg0L7b8eb3e1iJFYIdFSAEex7cK2c46WDbYAjO3aaVzq6GAVrBY+84g1wfDxdXPH ggXeWF0REmZT2fG62c9rwcPGvFvxkrLfm3InphVKBGhB5lnx5TxO2XryWElpKnsNv/Ot tiBp/tsE92JZkpayVi1vPp9y191t2aHqP5Pp/3MvgKvVTusCYYwvEpUcD1hzkbqGs+Pw LpJQ== X-Received: by 10.236.222.228 with SMTP id t94mr4734679yhp.18.1376941639295; Mon, 19 Aug 2013 12:47:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.3.102 with SMTP id b6ls1244098qeb.1.gmail; Mon, 19 Aug 2013 12:47:19 -0700 (PDT) X-Received: by 10.52.110.66 with SMTP id hy2mr12720723vdb.16.1376941639021; Mon, 19 Aug 2013 12:47:19 -0700 (PDT) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id rx10si2726313vdc.86.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id f12so3403131vbg.39 for ; Mon, 19 Aug 2013 12:47:18 -0700 (PDT) X-Gm-Message-State: ALoCoQlnEbJW93AqceJIa9XQCWS/cVJKYSGlpnVZ/AOtRWfgvnZbj+aYsstqLUm/QqEV2xMedpfb X-Received: by 10.52.35.171 with SMTP id i11mr12633113vdj.4.1376941638893; Mon, 19 Aug 2013 12:47:18 -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 u4csp114194vcz; Mon, 19 Aug 2013 12:47:18 -0700 (PDT) X-Received: by 10.15.48.67 with SMTP id g43mr16483984eew.17.1376941637994; Mon, 19 Aug 2013 12:47:17 -0700 (PDT) Received: from mail-ea0-f176.google.com (mail-ea0-f176.google.com [209.85.215.176]) by mx.google.com with ESMTPS id l4si11049580eew.191.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:17 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.176 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=209.85.215.176; Received: by mail-ea0-f176.google.com with SMTP id q16so2504288ead.35 for ; Mon, 19 Aug 2013 12:47:17 -0700 (PDT) X-Received: by 10.15.45.8 with SMTP id a8mr25345124eew.1.1376941637355; Mon, 19 Aug 2013 12:47:17 -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 k7sm19522538eeg.13.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:16 -0700 (PDT) Message-ID: <52127642.6060404@linaro.org> Date: Mon, 19 Aug 2013 20:47:14 +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 6/7] malloc: Add pvalloc test. 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.212.52 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-16 Will Newton * malloc/Makefile: Add tst-pvalloc. * malloc/tst-pvalloc.c: New file. --- malloc/Makefile | 3 ++- malloc/tst-pvalloc.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 malloc/tst-pvalloc.c diff --git a/malloc/Makefile b/malloc/Makefile index 4903c13..17d146b 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -26,7 +26,8 @@ dist-headers := malloc.h headers := $(dist-headers) obstack.h mcheck.h tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \ tst-mallocstate tst-mcheck tst-mallocfork tst-trim1 \ - tst-malloc-usable tst-realloc tst-posix_memalign + tst-malloc-usable tst-realloc tst-posix_memalign \ + tst-pvalloc test-srcs = tst-mtrace routines = malloc morecore mcheck mtrace obstack diff --git a/malloc/tst-pvalloc.c b/malloc/tst-pvalloc.c new file mode 100644 index 0000000..5dcf8d4 --- /dev/null +++ b/malloc/tst-pvalloc.c @@ -0,0 +1,76 @@ +/* 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); +} + +static int +do_test (void) +{ + void *p; + unsigned long pagesize = getpagesize(); + unsigned long ptrval; + + p = pvalloc (-1); + + if (p != NULL) + merror ("pvalloc (-1) succeeded."); + + p = pvalloc (-pagesize); + + if (p != NULL) + merror ("pvalloc (-pagesize) succeeded."); + + p = pvalloc (0); + + if (p == NULL) + merror ("pvalloc (0) failed."); + + free (p); + + p = pvalloc (32); + + if (p == NULL) + merror ("pvalloc (32) failed."); + + ptrval = (unsigned long)p; + + if (p == NULL) + merror ("pvalloc (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"