more tdb
This commit is contained in:
parent
daa29bca42
commit
314e1e1af4
|
@ -18,5 +18,5 @@ target_link_libraries(
|
|||
)
|
||||
|
||||
if(${BUILD_TEST})
|
||||
# add_subdirectory(test)
|
||||
add_subdirectory(test)
|
||||
endif(${BUILD_TEST})
|
||||
|
|
|
@ -225,7 +225,7 @@ int tdbMPoolFileGetPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdbMPoolFilePutPage(TDB_MPOOL *mpf, pgno_t pgno, void *addr) {
|
||||
int tdbMPoolFilePutPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ struct TDB_MPFILE {
|
|||
// TDB_MPOOL
|
||||
int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize);
|
||||
int tdbMPoolClose(TDB_MPOOL *mp);
|
||||
int tdbMPoolSync(TDB_MPOOL *mp);
|
||||
|
||||
// TDB_MPFILE
|
||||
int tdbMPoolFileOpen(TDB_MPFILE **mpfp, const char *fname, TDB_MPOOL *mp);
|
||||
|
@ -83,7 +84,8 @@ int tdbMPoolFileClose(TDB_MPFILE *mpf);
|
|||
int tdbMPoolFileNewPage(TDB_MPFILE *mpf, pgno_t *pgno, void *addr);
|
||||
int tdbMPoolFileFreePage(TDB_MPOOL *mpf, pgno_t *pgno, void *addr);
|
||||
int tdbMPoolFileGetPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr);
|
||||
int tdbMPoolFilePutPage(TDB_MPOOL *mpf, pgno_t pgno, void *addr);
|
||||
int tdbMPoolFilePutPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr);
|
||||
int tdbMPoolFileSync(TDB_MPFILE *mpf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# tdbMPoolTest
|
||||
add_executable(tdbMPoolTest "tdbMPoolTest.cpp")
|
||||
target_link_libraries(tdbMPoolTest tdb gtest gtest_main)
|
||||
|
||||
# tdbTest
|
||||
add_executable(tdbTest "tdbTest.cpp")
|
||||
target_link_libraries(tdbTest tdb gtest gtest_main)
|
|
@ -0,0 +1,31 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "tdb_mpool.h"
|
||||
|
||||
TEST(tdb_mpool_test, test1) {
|
||||
TDB_MPOOL * mp;
|
||||
TDB_MPFILE *mpf;
|
||||
pgno_t pgno;
|
||||
void * pgdata;
|
||||
|
||||
// open mp
|
||||
tdbMPoolOpen(&mp, 16384, 4096);
|
||||
|
||||
// open mpf
|
||||
tdbMPoolFileOpen(&mpf, "test.db", mp);
|
||||
|
||||
#define TEST1_TOTAL_PAGES 100
|
||||
for (int i = 0; i < TEST1_TOTAL_PAGES; i++) {
|
||||
tdbMPoolFileNewPage(mpf, &pgno, pgdata);
|
||||
|
||||
*(pgno_t *)pgdata = i;
|
||||
}
|
||||
|
||||
// close mpf
|
||||
tdbMPoolFileClose(mpf);
|
||||
|
||||
// close mp
|
||||
tdbMPoolClose(mp);
|
||||
}
|
|
@ -3,8 +3,8 @@
|
|||
#include "tdb.h"
|
||||
|
||||
TEST(tdb_api_test, tdb_create_open_close_db_test) {
|
||||
int ret;
|
||||
TDB *dbp;
|
||||
// int ret;
|
||||
// TDB *dbp;
|
||||
|
||||
// tdbCreateDB(&dbp, TDB_BTREE_T);
|
||||
|
||||
|
|
Loading…
Reference in New Issue