From patchwork Tue Apr 8 10:34:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 27933 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8365420447 for ; Tue, 8 Apr 2014 10:34:47 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id c41sf2198060yho.5 for ; Tue, 08 Apr 2014 03:34:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=5jMXvfZh7qUAnAWm9irwVYgulJ2EyzciWVzmjcewUHM=; b=nASKV5RTcXZPMGpfLL5ByY6eSqBxly8y8th3FM9TOIt9MEuj5CJzLQYk9hRIpclJDc 1Ykl2QQDliEUQNgiSkPOb75coi6Eb+NPzsyK9qPzINNDV9GvVxSTQO5RRxLJntSyoRt+ h5rlQkR1xxAFfQ7OW5Y7g4FA6BokvNyV7/C0DkEXKC00/ztOfwEW/j5OP+F+tH79Vpj7 i5/L4dv1yCISDlZYK69l+GlE6oaGfWQjl3SRepPm2og3NQFsUG5Xeegek9W/7Bwr81Ac /EtaK2pCmXcg2yyjwi8HBiLCznjUWWU7rmbWNihBj4UUNQskYSkdLTw3XtyfSk4ShBz/ JNHA== X-Gm-Message-State: ALoCoQmIR/sz86HG1KcRrDxoE81X3xSNbd+f75jRENyschhR3KR/D4f1rl3IcMhMw95g3wMamch5 X-Received: by 10.58.94.232 with SMTP id df8mr1072765veb.23.1396953287121; Tue, 08 Apr 2014 03:34:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.115 with SMTP id 106ls159816qgg.75.gmail; Tue, 08 Apr 2014 03:34:47 -0700 (PDT) X-Received: by 10.58.49.10 with SMTP id q10mr2471139ven.5.1396953286997; Tue, 08 Apr 2014 03:34:46 -0700 (PDT) Received: from mail-ve0-x232.google.com (mail-ve0-x232.google.com [2607:f8b0:400c:c01::232]) by mx.google.com with ESMTPS id sh5si310282vdc.176.2014.04.08.03.34.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Apr 2014 03:34:46 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::232; Received: by mail-ve0-f178.google.com with SMTP id jw12so591813veb.9 for ; Tue, 08 Apr 2014 03:34:46 -0700 (PDT) X-Received: by 10.52.34.137 with SMTP id z9mr2113526vdi.12.1396953286925; Tue, 08 Apr 2014 03:34:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp234026vcv; Tue, 8 Apr 2014 03:34:46 -0700 (PDT) X-Received: by 10.68.240.99 with SMTP id vz3mr3492849pbc.93.1396953286143; Tue, 08 Apr 2014 03:34:46 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id tk5si854434pbc.338.2014.04.08.03.34.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Apr 2014 03:34:46 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-48895-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 1231 invoked by alias); 8 Apr 2014 10:34:36 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 1214 invoked by uid 89); 8 Apr 2014 10:34:34 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f176.google.com X-Received: by 10.180.99.161 with SMTP id er1mr8621413wib.3.1396953270116; Tue, 08 Apr 2014 03:34:30 -0700 (PDT) From: Will Newton To: libc-alpha@sourceware.org Subject: [PATCH] malloc: Add mallopt test. Date: Tue, 8 Apr 2014 11:34:24 +0100 Message-Id: <1396953264-6020-1-git-send-email-will.newton@linaro.org> X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::232 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; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 ChangeLog: 2014-04-08 Will Newton * malloc/Makefile (tests): Add tst-mallopt. * malloc/tst-mallopt.c: New file. --- malloc/Makefile | 2 +- malloc/tst-mallopt.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 malloc/tst-mallopt.c diff --git a/malloc/Makefile b/malloc/Makefile index 2871726..d962331 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -27,7 +27,7 @@ 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-pvalloc tst-memalign + tst-pvalloc tst-memalign tst-mallopt test-srcs = tst-mtrace routines = malloc morecore mcheck mtrace obstack diff --git a/malloc/tst-mallopt.c b/malloc/tst-mallopt.c new file mode 100644 index 0000000..9569b7d --- /dev/null +++ b/malloc/tst-mallopt.c @@ -0,0 +1,75 @@ +/* Copyright (C) 2014 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 + +static int errors = 0; + +static void +merror (const char *msg) +{ + ++errors; + printf ("Error: %s\n", msg); +} + +static int +do_test (void) +{ + int ret; + + ret = mallopt(M_CHECK_ACTION, 1); + + if (ret != 1) + merror ("mallopt (M_CHECK_ACTION, 1) failed."); + + ret = mallopt(M_MMAP_MAX, 64*1024); + + if (ret != 1) + merror ("mallopt (M_MMAP_MAX, 64*1024) failed."); + + ret = mallopt(M_MMAP_THRESHOLD, 64*1024); + + if (ret != 1) + merror ("mallopt (M_MMAP_THRESHOLD, 64*1024) failed."); + + ret = mallopt(M_MXFAST, 0); + + if (ret != 1) + merror ("mallopt (M_MXFAST, 0) failed."); + + ret = mallopt(M_PERTURB, 0xa5); + + if (ret != 1) + merror ("mallopt (M_PERTURB, 0xa5) failed."); + + ret = mallopt(M_TOP_PAD, 64*1024); + + if (ret != 1) + merror ("mallopt (M_TOP_PAD, 64*1024) failed."); + + ret = mallopt(M_TRIM_THRESHOLD, -1); + + if (ret != 1) + merror ("mallopt (M_TRIM_THRESHOLD, -1) failed."); + + return errors != 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"