#include <config.h>
#include "safeerrno.h"
#include "btreecheck.h"
#include "unixcmds.h"
#include "testsuite.h"
#include "testutils.h"
#include "utils.h"
#include <algorithm>
#include <fstream>
#include <string>
#include <sys/types.h>
#include "safesysstat.h"
Include dependency graph for btreetest.cc:
Go to the source code of this file.
Defines | |
#define | BTREE_CHECK(DIR, OPTS) BtreeCheck::check(DIR, OPTS, tout) |
Functions | |
static void | make_dir (const string &filename) |
static off_t | get_filesize (const string &filename) |
Get the size of the given file in bytes. | |
static int | process_lines (Btree &btree, ifstream &f) |
static int | do_update (const string &btree_dir, const string &datafile, bool full_compact=false) |
static void | do_create (const string &btree_dir, int block_size=2048) |
static void | unlink_table (const string &path) |
static void | check_table_values_hello (Btree &table, const string &world) |
static void | check_table_values_empty (Btree &table) |
Check the values returned by a table containing no key/tag pairs. | |
static bool | test_simple1 () |
Test playing with a btree. | |
static bool | test_insertdelete1 () |
Test inserting and deleting items from a Btree. | |
static bool | test_sequent1 () |
Test sequential addition in a Btree. | |
static bool | test_emptykey1 () |
static bool | test_table1 () |
Test making and playing with a Btree. | |
static bool | test_table2 () |
Test making and playing with a Btree. | |
static bool | test_table3 () |
Test making and playing with a Btree. | |
static bool | test_table4 () |
Test making and playing with a Btree. | |
static bool | test_table5 () |
Test making and playing with a Btree. | |
static bool | test_table6 () |
Test making and playing with a Btree. | |
static bool | test_cursor1 () |
Test Bcursors. | |
static bool | test_cursor2 () |
Regression test for cursors. | |
static bool | test_cursor3 () |
Check the values returned by a table containing key/tag "hello"/"world" Test making and playing with a Btree. | |
static bool | test_bitmap1 () |
Test large bitmap files. | |
static bool | test_overwrite1 () |
Test overwriting a table. | |
int | main (int argc, char **argv) |
Variables | |
static string | tmpdir |
static string | datadir |
test_desc | tests [] |
Definition at line 42 of file btreetest.cc.
Referenced by test_emptykey1(), test_insertdelete1(), and test_sequent1().
static void make_dir | ( | const string & | filename | ) | [static] |
static off_t get_filesize | ( | const string & | filename | ) | [static] |
Get the size of the given file in bytes.
Definition at line 56 of file btreetest.cc.
References stat().
Referenced by test_table2().
static int process_lines | ( | Btree & | btree, | |
ifstream & | f | |||
) | [static] |
Definition at line 64 of file btreetest.cc.
References Btree::add(), BTREE_MAX_KEY_LEN, and Btree::del().
Referenced by do_update().
static int do_update | ( | const string & | btree_dir, | |
const string & | datafile, | |||
bool | full_compact = false | |||
) | [static] |
Definition at line 85 of file btreetest.cc.
References Btree::commit(), Btree::get_open_revision_number(), Btree::open(), process_lines(), Btree::set_full_compaction(), TEST_AND_EXPLAIN, and tout.
Referenced by test_insertdelete1(), and test_sequent1().
static void do_create | ( | const string & | btree_dir, | |
int | block_size = 2048 | |||
) | [static] |
Definition at line 109 of file btreetest.cc.
References dummy, make_dir(), rm_rf(), and tout.
Referenced by test_emptykey1(), test_insertdelete1(), and test_sequent1().
static void unlink_table | ( | const string & | path | ) | [static] |
Definition at line 125 of file btreetest.cc.
References unlink().
Referenced by test_bitmap1(), test_cursor1(), test_cursor2(), test_cursor3(), test_overwrite1(), test_table1(), test_table2(), test_table3(), test_table4(), test_table5(), and test_table6().
static void check_table_values_hello | ( | Btree & | table, | |
const string & | world | |||
) | [static] |
Definition at line 132 of file btreetest.cc.
References Bcursor::current_key, Bcursor::current_tag, Btree::cursor_get(), Bcursor::find_entry(), Btree::get_exact_entry(), Bcursor::read_tag(), TEST, and TEST_EQUAL.
Referenced by test_table1().
static void check_table_values_empty | ( | Btree & | table | ) | [static] |
Check the values returned by a table containing no key/tag pairs.
Definition at line 174 of file btreetest.cc.
References Bcursor::current_key, Bcursor::current_tag, Btree::cursor_get(), Bcursor::find_entry(), Btree::get_exact_entry(), Bcursor::read_tag(), TEST, and TEST_EQUAL.
Referenced by test_table1().
static bool test_simple1 | ( | ) | [static] |
Test playing with a btree.
Definition at line 216 of file btreetest.cc.
References Btree::create(), Bcursor::find_entry(), Btree::open(), TEST, and tmpdir.
static bool test_insertdelete1 | ( | ) | [static] |
Test inserting and deleting items from a Btree.
Definition at line 239 of file btreetest.cc.
References BTREE_CHECK, datadir, do_create(), do_update(), file_exists(), Btree::get_entry_count(), Btree::open(), OPT_SHORT_TREE, OPT_SHOW_STATS, SKIP_TEST, TEST_EQUAL, and tmpdir.
static bool test_sequent1 | ( | ) | [static] |
Test sequential addition in a Btree.
Definition at line 269 of file btreetest.cc.
References BTREE_CHECK, datadir, do_create(), do_update(), file_exists(), Btree::get_entry_count(), Btree::open(), OPT_SHORT_TREE, OPT_SHOW_STATS, SKIP_TEST, TEST_EQUAL, and tmpdir.
static bool test_emptykey1 | ( | ) | [static] |
Definition at line 297 of file btreetest.cc.
References Btree::add(), BTREE_CHECK, Btree::commit(), Btree::del(), do_create(), Btree::get_entry_count(), Btree::get_open_revision_number(), Btree::open(), OPT_SHOW_STATS, TEST_EQUAL, tmpdir, and tout.
static bool test_table1 | ( | ) | [static] |
Test making and playing with a Btree.
Definition at line 355 of file btreetest.cc.
References Btree::add(), check_table_values_empty(), check_table_values_hello(), Btree::commit(), Btree::del(), Btree::get_entry_count(), Btree::get_latest_revision_number(), Btree::get_open_revision_number(), Btree::open(), TEST_EQUAL, TEST_EXCEPTION, TEST_NOT_EQUAL, tmpdir, and unlink_table().
static bool test_table2 | ( | ) | [static] |
Test making and playing with a Btree.
Definition at line 495 of file btreetest.cc.
References Btree::add(), Btree::commit(), Btree::create(), get_filesize(), Btree::get_latest_revision_number(), Btree::open(), TEST_EQUAL, tmpdir, and unlink_table().
static bool test_table3 | ( | ) | [static] |
Test making and playing with a Btree.
Definition at line 522 of file btreetest.cc.
References Btree::add(), Btree::commit(), Btree::create(), Bcursor::current_key, Bcursor::current_tag, Btree::cursor_get(), Bcursor::find_entry(), Btree::get_latest_revision_number(), Bcursor::next(), Btree::open(), Bcursor::read_tag(), TEST, TEST_EQUAL, tmpdir, and unlink_table().
static bool test_table4 | ( | ) | [static] |
Test making and playing with a Btree.
Definition at line 570 of file btreetest.cc.
References Btree::add(), Btree::commit(), Btree::create(), Btree::del(), Btree::get_entry_count(), Btree::get_latest_revision_number(), Btree::open(), TEST_EQUAL, tmpdir, and unlink_table().
static bool test_table5 | ( | ) | [static] |
Test making and playing with a Btree.
Definition at line 629 of file btreetest.cc.
References Btree::add(), Btree::commit(), Btree::create(), Btree::cursor_get(), Btree::get_entry_count(), Btree::get_latest_revision_number(), Btree::get_open_revision_number(), Btree::open(), TEST, TEST_EQUAL, tmpdir, and unlink_table().
static bool test_table6 | ( | ) | [static] |
Test making and playing with a Btree.
Definition at line 799 of file btreetest.cc.
References Btree::add(), Btree::cancel(), Btree::commit(), Btree::create(), Btree::cursor_get(), Btree::get_entry_count(), Btree::get_latest_revision_number(), Btree::get_open_revision_number(), Btree::open(), TEST, TEST_EQUAL, tmpdir, and unlink_table().
static bool test_cursor1 | ( | ) | [static] |
Test Bcursors.
Definition at line 862 of file btreetest.cc.
References Btree::add(), Bcursor::after_end(), Btree::commit(), Btree::create(), Bcursor::current_key, Bcursor::current_tag, Btree::cursor_get(), Btree::del(), Bcursor::find_entry(), Btree::get_latest_revision_number(), Bcursor::next(), Btree::open(), Bcursor::read_tag(), TEST, TEST_EQUAL, tmpdir, and unlink_table().
static bool test_cursor2 | ( | ) | [static] |
Regression test for cursors.
Definition at line 1066 of file btreetest.cc.
References Btree::add(), Btree::commit(), Btree::create(), Bcursor::current_key, Bcursor::current_tag, Btree::cursor_get(), Bcursor::find_entry(), Btree::get_latest_revision_number(), Btree::open(), Bcursor::read_tag(), TEST, TEST_EQUAL, tmpdir, and unlink_table().
static bool test_cursor3 | ( | ) | [static] |
Check the values returned by a table containing key/tag "hello"/"world" Test making and playing with a Btree.
Definition at line 1099 of file btreetest.cc.
References Btree::add(), Bcursor::after_end(), Btree::commit(), Btree::create(), Bcursor::current_key, Bcursor::current_tag, Btree::cursor_get(), Bcursor::find_entry(), Btree::get_entry_count(), Btree::get_latest_revision_number(), Btree::get_open_revision_number(), Bcursor::next(), Btree::open(), Bcursor::read_tag(), TEST, TEST_EQUAL, tmpdir, and unlink_table().
static bool test_bitmap1 | ( | ) | [static] |
Test large bitmap files.
Definition at line 1184 of file btreetest.cc.
References Btree::add(), Btree::commit(), Btree::create(), Btree::get_latest_revision_number(), om_tostring(), Btree::open(), tmpdir, and unlink_table().
static bool test_overwrite1 | ( | ) | [static] |
Test overwriting a table.
Definition at line 1210 of file btreetest.cc.
References Btree::add(), Btree::commit(), Btree::create(), Btree::get_exact_entry(), Btree::get_latest_revision_number(), om_tostring(), Btree::open(), TEST, TEST_EQUAL, TEST_EXCEPTION, tmpdir, and unlink_table().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 1275 of file btreetest.cc.
References datadir, test_driver::get_srcdir(), make_dir(), test_driver::parse_command_line(), rm_rf(), test_driver::run(), tests, and tmpdir.
string tmpdir [static] |
Definition at line 44 of file btreetest.cc.
Referenced by main(), test_adddoc1(), test_bitmap1(), test_create1(), test_cursor1(), test_cursor2(), test_cursor3(), test_emptykey1(), test_insertdelete1(), test_overwrite1(), test_sequent1(), test_simple1(), test_table1(), test_table2(), test_table3(), test_table4(), test_table5(), test_table6(), and test_writelock1().
string datadir [static] |
Definition at line 45 of file btreetest.cc.
Referenced by main(), test_insertdelete1(), and test_sequent1().
Initial value:
{ {"simple1", test_simple1}, {"insertdelete1", test_insertdelete1}, {"sequent1", test_sequent1}, {"emptykey1", test_emptykey1}, {"table1", test_table1}, {"table2", test_table2}, {"table3", test_table3}, {"table4", test_table4}, {"table5", test_table5}, {"table6", test_table6}, {"cursor1", test_cursor1}, {"cursor2", test_cursor2}, {"cursor3", test_cursor3}, {"bitmap1", test_bitmap1}, {"overwrite1", test_overwrite1}, {0, 0} }
Definition at line 1256 of file btreetest.cc.