mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 23:04:20 +01:00
8d0368fd2f
git-svn-id: file:///svn/toku/tokudb@41591 c7de825b-a66e-492c-adef-691d508d4ae1
81 lines
1.9 KiB
C
81 lines
1.9 KiB
C
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
|
|
#ident "Id:"
|
|
|
|
// Test for #3748 (FIFO's do not shrink their size after a flush)
|
|
// This test makes sure that the code that stabilizes fifos works.
|
|
|
|
#include "includes.h"
|
|
#include "test.h"
|
|
int verbose;
|
|
|
|
static void test_3748 (void) {
|
|
FIFO f;
|
|
int r;
|
|
f = NULL;
|
|
r = toku_fifo_create(&f);
|
|
|
|
char *thekey = 0; int thekeylen;
|
|
char *theval = 0; int thevallen;
|
|
|
|
#define buildkey(len) { \
|
|
thekeylen = len; \
|
|
thekey = toku_realloc(thekey, thekeylen); \
|
|
memset(thekey, len, thekeylen); \
|
|
}
|
|
|
|
#define buildval(len) { \
|
|
thevallen = len+1; \
|
|
theval = toku_realloc(theval, thevallen); \
|
|
memset(theval, ~len, thevallen); \
|
|
}
|
|
|
|
MSN startmsn = ZERO_MSN;
|
|
|
|
int N=1000;
|
|
|
|
// enqueue some stuff
|
|
for (int i=0; i<N; i++) {
|
|
buildkey(i);
|
|
buildval(i);
|
|
|
|
XIDS xids = xids_get_root_xids();
|
|
MSN msn = next_dummymsn();
|
|
|
|
if (startmsn.msn == ZERO_MSN.msn)
|
|
startmsn = msn;
|
|
enum brt_msg_type type = (enum brt_msg_type) i;
|
|
r = toku_fifo_enq(f, thekey, thekeylen, theval, thevallen, type, msn, xids, true, NULL); assert(r == 0);
|
|
xids_destroy(&xids);
|
|
}
|
|
for (int i=N/10; i<N; i++) {
|
|
r = toku_fifo_deq(f);
|
|
}
|
|
unsigned int msize0 = toku_fifo_memory_size(f);
|
|
toku_fifo_size_is_stabilized(f);
|
|
unsigned int msize1 = toku_fifo_memory_size(f);
|
|
assert(msize1 < msize0);
|
|
|
|
while (toku_fifo_deq(f) == 0)
|
|
/*nothing*/;
|
|
|
|
toku_fifo_size_is_stabilized(f);
|
|
unsigned int msize2 = toku_fifo_memory_size(f);
|
|
assert(msize2 < msize1);
|
|
|
|
toku_fifo_free(&f);
|
|
assert(f == 0);
|
|
|
|
if (thekey) toku_free(thekey);
|
|
if (theval) toku_free(theval);
|
|
|
|
}
|
|
|
|
int
|
|
test_main(int argc, const char *argv[]) {
|
|
default_parse_args(argc, argv);
|
|
initialize_dummymsn();
|
|
test_3748();
|
|
|
|
return 0;
|
|
}
|