/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: #ident "$Id$" /*====== This file is part of PerconaFT. Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. PerconaFT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. PerconaFT 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 PerconaFT. If not, see . ---------------------------------------- PerconaFT is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation. PerconaFT 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with PerconaFT. If not, see . ======= */ #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." #include "test.h" #include "cachetable-test.h" #include #include #include "cachetable/checkpoint.h" static const int item_size = 1; static int n_flush, n_write_me, n_keep_me, n_fetch; static void flush( CACHEFILE UU(cf), int UU(fd), CACHEKEY UU(key), void *UU(value), void** UU(dd), void *UU(extraargs), PAIR_ATTR size, PAIR_ATTR* UU(new_size), bool write_me, bool keep_me, bool UU(for_checkpoint), bool UU(is_clone) ) { //cf = cf; key = key; value = value; extraargs = extraargs; // assert(key == make_blocknum((long)value)); assert(size.size == item_size); n_flush++; if (write_me) n_write_me++; if (keep_me) n_keep_me++; } static int callback_was_called = 0; static int callback2_was_called = 0; static void checkpoint_callback(void * extra) { int * x = (int*) extra; (*x)++; if (verbose) printf("checkpoint_callback called %d (should be 1-16)\n", *x); } static void checkpoint_callback2(void * extra) { int * x = (int*) extra; (*x)++; if (verbose) printf("checkpoint_callback2 called %d (should be 1-16)\n", *x); } // put n items into the cachetable, maybe mark them dirty, do a checkpoint, and // verify that all of the items have been written and are clean. static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) { if (verbose) printf("%s:%d n=%d dirty=%d\n", __FUNCTION__, __LINE__, n, (int) dirty); const int test_limit = n; int r; CACHETABLE ct; toku_cachetable_create(&ct, test_limit, ZERO_LSN, nullptr); const char *fname1 = TOKU_TEST_FILENAME; unlink(fname1); CACHEFILE f1; r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); create_dummy_functions(f1); // insert items into the cachetable. all should be dirty int i; for (i=0; i