bd911976d51f102751848568ccf56592fd5f6d77Tinderbox User * Copyright (C) 1999-2001, 2004, 2007, 2009, 2013, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews/* $Id: t_mem.c,v 1.15 2009/01/22 23:47:54 tbox Exp $ */
1e107b3d7b54de5022c3328423164e533afcc15eMark Andrews * Adapted from the original mempool_test.c program.
c1807114ce574896694e3f449c73b098fe91730fMark Andrews unsigned int i, j;
c1807114ce574896694e3f449c73b098fe91730fMark Andrews t_info("setting freemax to %d\n", MP1_FREEMAX);
c1807114ce574896694e3f449c73b098fe91730fMark Andrews t_info("setting fillcount to %d\n", MP1_FILLCNT);
c1807114ce574896694e3f449c73b098fe91730fMark Andrews t_info("setting maxalloc to %d\n", MP1_MAXALLOC);
c1807114ce574896694e3f449c73b098fe91730fMark Andrews * Allocate MP1_MAXALLOC items from the pool. This is our max.
ec3f1d35170225c74d11c27bb184e250d150b209Tatuya JINMEI 神明達哉 for (i = 0; i < MP1_MAXALLOC; i++) {
54570ba7ffb85ad8449d86bd0e14fb6fb2e271c4James Brister t_info("isc_mempool_get unexpectedly failed\n");
54570ba7ffb85ad8449d86bd0e14fb6fb2e271c4James Brister * Try to allocate one more. This should fail.
33911b409bea2e0576cb1a58e0f3408f63187976Andreas Gustafsson t_info("isc_mempool_get unexpectedly succeeded\n");
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * Free the first 11 items. Verify that there are 10 free items on
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * the free list (which is our max).
4ed0c326e6c344589db02738358f98d96c6299d2Andreas Gustafsson for (i = 0; i < 11; i++) {
ff89d6add5f529ffd2119708ef6d70aca69f45b1Mark Andrews t_info("isc_mempool_getfreecount returned %d, expected %d\n",
35af0018ddee51e2a9551d7aec343933498d0a79Andreas Gustafsson t_info("isc_mempool_getallocated returned %d, expected %d\n",
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews * Now, beat up on mp2 for a while. Allocate 50 items, then free
15683369e0113bd08863a705a8a1785c093455d3Mark Andrews * them, then allocate 50 more, etc.
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews t_info("setting freemax to %d\n", MP2_FREEMAX);
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews t_info("setting fillcount to %d\n", MP2_FILLCNT);
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews for (j = 0; j < 500000; j++) {
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews for (i = 0; i < 50; i++) {
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews t_info("items2[%d] is unexpectedly null\n", i);
ff89d6add5f529ffd2119708ef6d70aca69f45b1Mark Andrews for (i = 0; i < 50; i++) {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence if (j % 50000 == 0)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Free all the other items and blow away this pool.
0b8c40c8d841de7e539f03fbc8e8815f06d49425Mark Andrews "the memory module supports the creation of memory contexts "
0b8c40c8d841de7e539f03fbc8e8815f06d49425Mark Andrews "and the management of memory pools.";