realloc-pool unit-test
This commit is contained in:
parent
6cf5e989c0
commit
3c87629c7e
|
@ -67,6 +67,10 @@ public:
|
||||||
void printstats ();
|
void printstats ();
|
||||||
void dumpsegments ();
|
void dumpsegments ();
|
||||||
|
|
||||||
|
#ifdef RAP_WITH_CALL_STATS
|
||||||
|
size_t mem_used () const { return _cur_used; }
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _name;
|
std::string _name;
|
||||||
size_t _poolsize;
|
size_t _poolsize;
|
||||||
|
|
40
libs/pbd/test/reallocpool_test.cc
Normal file
40
libs/pbd/test/reallocpool_test.cc
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include "reallocpool_test.h"
|
||||||
|
#include "pbd/reallocpool.h"
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION (ReallocPoolTest);
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
ReallocPoolTest::ReallocPoolTest ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ReallocPoolTest::testBasic ()
|
||||||
|
{
|
||||||
|
srand (0);
|
||||||
|
PBD::ReallocPool *m = new PBD::ReallocPool("TestPool", 256 * 1024);
|
||||||
|
|
||||||
|
for (int l = 0; l < 2 * 1024 * 1024; ++l) {
|
||||||
|
void *x[32];
|
||||||
|
size_t s[32];
|
||||||
|
int cnt = rand() % 32;
|
||||||
|
for (int i = 0; i < cnt; ++i) {
|
||||||
|
s[i] = rand() % 1024;
|
||||||
|
x[i] = m->malloc (s[i]);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < cnt; ++i) {
|
||||||
|
if (x[i]) {
|
||||||
|
memset (x[i], 0xa5, s[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < cnt; ++i) {
|
||||||
|
m->free (x[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef RAP_WITH_CALL_STATS
|
||||||
|
CPPUNIT_ASSERT (m->mem_used() == 0);
|
||||||
|
#endif
|
||||||
|
delete (m);
|
||||||
|
}
|
16
libs/pbd/test/reallocpool_test.h
Normal file
16
libs/pbd/test/reallocpool_test.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
#include "glibmm/threads.h"
|
||||||
|
|
||||||
|
class ReallocPoolTest : public CppUnit::TestFixture
|
||||||
|
{
|
||||||
|
CPPUNIT_TEST_SUITE (ReallocPoolTest);
|
||||||
|
CPPUNIT_TEST (testBasic);
|
||||||
|
CPPUNIT_TEST_SUITE_END ();
|
||||||
|
|
||||||
|
public:
|
||||||
|
ReallocPoolTest ();
|
||||||
|
void testBasic ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
|
@ -164,6 +164,7 @@ def build(bld):
|
||||||
test/signals_test.cc
|
test/signals_test.cc
|
||||||
test/convert_test.cc
|
test/convert_test.cc
|
||||||
test/filesystem_test.cc
|
test/filesystem_test.cc
|
||||||
|
test/reallocpool_test.cc
|
||||||
test/xml_test.cc
|
test/xml_test.cc
|
||||||
test/test_common.cc
|
test/test_common.cc
|
||||||
'''.split()
|
'''.split()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user