ccnbtreetest.c File Reference

Unit tests for btree functions. More...

Go to the source code of this file.

Defines

#define FAILIF(cond)   do {} while ((cond) && fatal(__func__, __LINE__))
#define CHKSYS(res)   FAILIF((res) == -1)
#define CHKPTR(p)   FAILIF((p) == NULL)

Functions

static int fatal (const char *fn, int lineno)
static int test_directory_creation (void)
 Use standard mkdtemp() to create a subdirectory of the current working directory, and set the TEST_DIRECTORY environment variable with its name.
static int test_btree_io (void)
 Basic tests of ccn_btree_io_from_directory() and its methods.
static void check_structure_size (const char *what, int sz)
 Helper for test_structure_sizes().
int test_structure_sizes (void)
 Helper for test_structure_sizes().
int test_btree_lockfile (void)
 Test that the lockfile works.
int test_btree_chknode (void)
int test_btree_key_fetch (void)
int test_btree_compare (void)
int test_btree_searchnode (void)
int test_btree_init (void)
struct ccn_btreeexample_btree_small (void)
int test_btree_lookup (void)
int test_basic_btree_insert_entry (void)
int test_basic_btree_delete_entry (void)
int test_btree_inserts_from_stdin (void)
int test_flatname (void)
static int testhelp_count_matches (struct ccn_btree *btree, unsigned char *msg, size_t size)
 Given an Interest (or a Name), find the matching objects.
int test_insert_content (void)
 Make an index from a file filled ccnb-encoded content objects.
int ccnbtreetest_main (int argc, char **argv)

Variables

struct node_example ex1
struct node_example ex2
struct root_example rootex1

Detailed Description

Unit tests for btree functions.

Definition in file ccnbtreetest.c.


Define Documentation

#define CHKPTR (  )     FAILIF((p) == NULL)
#define CHKSYS ( res   )     FAILIF((res) == -1)
#define FAILIF ( cond   )     do {} while ((cond) && fatal(__func__, __LINE__))

Function Documentation

int ccnbtreetest_main ( int  argc,
char **  argv 
)

Definition at line 994 of file ccnbtreetest.c.

static void check_structure_size ( const char *  what,
int  sz 
) [static]

Helper for test_structure_sizes().

Prints out the size of the struct

Definition at line 146 of file ccnbtreetest.c.

Referenced by test_structure_sizes().

struct ccn_btree* example_btree_small ( void   )  [read]
static int fatal ( const char *  fn,
int  lineno 
) [static]

Definition at line 45 of file ccnbtreetest.c.

int test_basic_btree_delete_entry ( void   ) 

Definition at line 555 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_basic_btree_insert_entry ( void   ) 

Definition at line 492 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_chknode ( void   ) 

Definition at line 242 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_compare ( void   ) 

Definition at line 318 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_init ( void   ) 

Definition at line 394 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_inserts_from_stdin ( void   ) 

Definition at line 593 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

static int test_btree_io ( void   )  [static]

Basic tests of ccn_btree_io_from_directory() and its methods.

Assumes TEST_DIRECTORY has been set.

Definition at line 88 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_key_fetch ( void   ) 

Definition at line 268 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_lockfile ( void   ) 

Test that the lockfile works.

Definition at line 175 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_lookup ( void   ) 

Definition at line 450 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_btree_searchnode ( void   ) 

Definition at line 348 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

static int test_directory_creation ( void   )  [static]

Use standard mkdtemp() to create a subdirectory of the current working directory, and set the TEST_DIRECTORY environment variable with its name.

Definition at line 60 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_flatname ( void   ) 

Definition at line 720 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_insert_content ( void   ) 

Make an index from a file filled ccnb-encoded content objects.

Interspersed interests will be regarded as querys, and matches will be found.

The file is named by the environment variable TEST_CONTENT.

Definition at line 875 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

int test_structure_sizes ( void   ) 

Helper for test_structure_sizes().

Prints the size of important structures, and make sure that they are mutiples of CCN_BT_SIZE_UNITS.

Definition at line 160 of file ccnbtreetest.c.

Referenced by ccnbtreetest_main().

static int testhelp_count_matches ( struct ccn_btree btree,
unsigned char *  msg,
size_t  size 
) [static]

Given an Interest (or a Name), find the matching objects.

Returns:
count of matches, or -1 for an error.

Definition at line 805 of file ccnbtreetest.c.

Referenced by test_insert_content().


Variable Documentation

struct node_example ex1
struct node_example ex2
Initial value:
 {
    {{0x05, 0x3a, 0xde, 0x78}, {1}},
    "struthiomimus",
    {
        {.t={.koff1={0,0,0,2+8}, .ksiz1={0,3}, .entdx={0,0}, .entsz={3}}}, 
        {.t={.koff0={0,0,0,0+8}, .ksiz0={0,5}, .entdx={0,1}, .entsz={3}}}, 
        {.t={.koff0={0,0,0,1+8}, .ksiz0={0,5}, .entdx={0,2}, .entsz={3}}}, 
    }
}

Definition at line 215 of file ccnbtreetest.c.

struct root_example rootex1

Referenced by example_btree_small().

Generated on Tue Aug 21 14:54:52 2012 for Content-Centric Networking in C by  doxygen 1.6.3