From 5b3aec2b904a2eb7478240dac2f56d8928fc2362 Mon Sep 17 00:00:00 2001 From: "magnus@neptunus.(none)" <> Date: Wed, 14 Apr 2004 10:53:21 +0200 Subject: Initial revision of NDB Cluster files --- .../kernel/vm/testDataBuffer/testDataBuffer.cpp | 186 +++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp (limited to 'ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp') diff --git a/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp b/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp new file mode 100644 index 00000000000..def8387e343 --- /dev/null +++ b/ndb/src/kernel/vm/testDataBuffer/testDataBuffer.cpp @@ -0,0 +1,186 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include +#include +#include + +struct Buffer { + Buffer(Uint32 size){ m_sz = size; buffer = new Uint32[m_sz]; m_len = 0;} + ~Buffer(){ delete [] buffer;} + + Uint32 m_sz; + Uint32 m_len; + Uint32 * buffer; +}; + +inline +void +require(bool b){ + if(!b) + abort(); +} + +template +void +compare(DataBuffer & db, Buffer & buf){ + typename DataBuffer::DataBufferIterator it; + db.first(it); + for(Uint32 i = 0; i +void +test(Uint32 loops, Uint32 iter){ + + ndbout_c("DataBuffer<%d> loops=%d iter=%d", sz, loops, iter); + + while(loops-- > 0){ + Uint32 size = sz*((10 + (rand() % (10 * sz)) + sz - 1)/sz); + + typename DataBuffer::DataBufferPool thePool; + typename DataBuffer::DataBufferIterator it; + DataBuffer db(thePool); + + thePool.setSize((size + sz - 1) / sz); + Buffer buf(size); + + bool testOverRun = true; + + for(Uint32 i = 0; i= 1 && c <= 3) + c += 3; + } + + if(free <= 1) + alloc = 1; + else + alloc = 1 + (rand() % (free - 1)); + + //ndbout_c("iter=%d case=%d free=%d alloc=%d", i, c, free, alloc); + switch(c){ + case 0: // Release + db.first(it); + for(; !it.curr.isNull(); db.next(it)) + * it.data = 0; + + db.release(); + buf.m_len = 0; + break; + case 1:{ // Append (success) + for(Uint32 i = 0; i(1000, 1000); + test<11>(1000, 1000); + test<15>(1000, 1000); + test<16>(1000, 1000); + test<17>(1000, 1000); +#if 0 +#endif + return 0; +} + +void +ErrorReporter::handleAssert(const char * msg, const char * file, int line) +{ + ndbout << "ErrorReporter::handleAssert activated - " + << " line= " << line << endl; + abort(); +} -- cgit v1.2.1