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: 337615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 73DC91400AA for ; Tue, 8 Apr 2014 20:34:42 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=axcP1fOFUke2KrmPjYbiigL1yTzfMspsBEXNvFlr/6+1IMKp01ZKk 9KtNrYLsBWzVmo+8mdyvKK5v3T1d6zdjXvEJleb+775305bQHfKJrVgKQu8/a2xr 0CrfX9jQIEjjcTgIAlQOMuBkdNXIlunoCg92COFR1DKHSoPlF1WGFw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=pEDa1vxqA10Ovd0cngqJbD4kqDU=; b=LF3ERaZrItpu7H+rf+os7DD9uPbv Fu59OzXPPU3ruzsAn26XjV7vyRj/DYgWWPwutqJ7I0FZKGW4F2uHtmqb3INhy1se mR/VxRd+FRH0e80M4aZFbxY/A6D7I1pvpMWujNzdFp86azt0rs1Zduy2imcLXpG3 pfRC3IJInlO37Jk= Received: (qmail 1231 invoked by alias); 8 Apr 2014 10:34:36 -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 1214 invoked by uid 89); 8 Apr 2014 10:34:34 -0000 Authentication-Results: sourceware.org; auth=none 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=5jMXvfZh7qUAnAWm9irwVYgulJ2EyzciWVzmjcewUHM=; b=IhRXzEIsrNPg4kadIwvxe9CZWtPghvLKOJViLttSIYdDZExrug/jlpj3N78kWi4pVr zaUo9STAAOcOcepp8LiPS/ZibbR2il6WjWcp8jtjxF2F+Y7TTORUS9g5YXmOakjQhPT6 oJfdHrhdduJH07cROO5J+VtxfAbtv6Q38z6lJN5ffnkniC2PmLRSZ78N/fWx+YNPfmpf XFDWqO0z1j+2sq8I3ulX3oLWRcfIR9La6k1dwYGfuBcVYLkAC6iTkiitzWVKA4MwNc8m pGHVP82QD2txssp6vhi/nJTBOzLLBZPeoXVs2wYRdvdIguxD0CD2TKdfmXSfx963pepN n5zQ== X-Gm-Message-State: ALoCoQlX/9Plf0bVrintwcVHpZDJtEC5PuxTFYjsDZufToPS5wPBlQGnqZ42YJrs4Uz9rhmfQm+O 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> 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"