2013-04-17 00:00:59 -04:00
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
2013-04-16 23:59:42 -04:00
# ident "$Id$"
2013-04-17 00:00:59 -04:00
# ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
# ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11 / 760379 and to the patents and / or patent applications resulting from it."
2013-04-17 00:01:15 -04:00
2008-01-11 22:18:39 +00:00
2013-04-16 23:57:32 -04:00
# include "test.h"
2008-01-11 22:18:39 +00:00
2013-04-16 23:57:20 -04:00
static void
test_fifo_create ( void ) {
2008-01-11 22:18:39 +00:00
int r ;
FIFO f ;
f = 0 ;
r = toku_fifo_create ( & f ) ;
assert ( r = = 0 ) ; assert ( f ! = 0 ) ;
toku_fifo_free ( & f ) ;
assert ( f = = 0 ) ;
}
2013-04-16 23:57:20 -04:00
static void
test_fifo_enq ( int n ) {
2008-01-11 22:18:39 +00:00
int r ;
FIFO f ;
2013-04-16 23:59:40 -04:00
MSN startmsn = ZERO_MSN ;
2008-01-11 22:18:39 +00:00
f = 0 ;
r = toku_fifo_create ( & f ) ;
assert ( r = = 0 ) ; assert ( f ! = 0 ) ;
char * thekey = 0 ; int thekeylen ;
char * theval = 0 ; int thevallen ;
2013-04-16 23:57:19 -04:00
// this was a function but icc cant handle it
# define buildkey(len) { \
2013-04-17 00:00:47 -04:00
thekeylen = len + 1 ; \
2013-04-17 00:00:58 -04:00
XREALLOC_N ( thekeylen , thekey ) ; \
2013-04-16 23:57:19 -04:00
memset ( thekey , len , thekeylen ) ; \
2008-01-11 22:18:39 +00:00
}
2013-04-16 23:57:19 -04:00
# define buildval(len) { \
2013-04-17 00:00:47 -04:00
thevallen = len + 2 ; \
2013-04-17 00:00:58 -04:00
XREALLOC_N ( thevallen , theval ) ; \
2013-04-16 23:57:19 -04:00
memset ( theval , ~ len , thevallen ) ; \
2008-01-11 22:18:39 +00:00
}
2013-04-16 23:59:41 -04:00
for ( int i = 0 ; i < n ; i + + ) {
2008-01-11 22:18:39 +00:00
buildkey ( i ) ;
buildval ( i ) ;
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
XIDS xids ;
if ( i = = 0 )
xids = xids_get_root_xids ( ) ;
else {
r = xids_create_child ( xids_get_root_xids ( ) , & xids , ( TXNID ) i ) ;
assert ( r = = 0 ) ;
}
2013-04-17 00:00:07 -04:00
MSN msn = next_dummymsn ( ) ;
if ( startmsn . msn = = ZERO_MSN . msn )
startmsn = msn ;
2013-04-17 00:00:35 -04:00
enum ft_msg_type type = ( enum ft_msg_type ) i ;
2013-04-17 00:00:07 -04:00
r = toku_fifo_enq ( f , thekey , thekeylen , theval , thevallen , type , msn , xids , true , NULL ) ; assert ( r = = 0 ) ;
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
xids_destroy ( & xids ) ;
2008-01-11 22:18:39 +00:00
}
2013-04-16 23:59:41 -04:00
int i = 0 ;
2013-04-16 23:59:48 -04:00
FIFO_ITERATE ( f , key , keylen , val , vallen , type , msn , xids , UU ( is_fresh ) , {
2013-04-17 00:00:58 -04:00
if ( verbose ) printf ( " checkit %d %d % " PRIu64 " \n " , i , type , msn . msn ) ;
2013-04-16 23:59:40 -04:00
assert ( msn . msn = = startmsn . msn + i ) ;
2008-01-11 22:18:39 +00:00
buildkey ( i ) ;
buildval ( i ) ;
assert ( ( int ) keylen = = thekeylen ) ; assert ( memcmp ( key , thekey , keylen ) = = 0 ) ;
assert ( ( int ) vallen = = thevallen ) ; assert ( memcmp ( val , theval , vallen ) = = 0 ) ;
2013-04-16 23:59:40 -04:00
assert ( i % 256 = = ( int ) type ) ;
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
assert ( ( TXNID ) i = = xids_get_innermost_xid ( xids ) ) ;
2008-01-11 22:18:39 +00:00
i + = 1 ;
2013-04-16 23:57:21 -04:00
} ) ;
2008-01-11 22:18:39 +00:00
assert ( i = = n ) ;
2013-04-16 23:57:33 -04:00
if ( thekey ) toku_free ( thekey ) ;
if ( theval ) toku_free ( theval ) ;
2008-01-11 22:18:39 +00:00
toku_fifo_free ( & f ) ;
assert ( f = = 0 ) ;
}
2013-04-16 23:57:32 -04:00
int
test_main ( int argc , const char * argv [ ] ) {
default_parse_args ( argc , argv ) ;
2013-04-17 00:00:17 -04:00
initialize_dummymsn ( ) ;
2008-01-11 22:18:39 +00:00
test_fifo_create ( ) ;
2008-05-28 01:22:51 +00:00
test_fifo_enq ( 4 ) ;
2008-01-11 22:18:39 +00:00
test_fifo_enq ( 512 ) ;
2013-04-16 23:59:22 -04:00
2008-01-11 22:18:39 +00:00
return 0 ;
}