Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

t.c

00001 #include <sys/types.h>
00002 
00003 #include <assert.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 
00007 #include "db.h"
00008 
00009 #define ENV {                                                           \
00010         if (dbenv != NULL)                                              \
00011                 assert(dbenv->close(dbenv, 0) == 0);                    \
00012         assert(db_env_create(&dbenv, 0) == 0);                          \
00013         dbenv->set_errfile(dbenv, stderr);                              \
00014 }
00015 
00016 int
00017 main()
00018 {
00019         const u_int8_t *lk_conflicts;
00020         DB_ENV *dbenv;
00021         db_timeout_t timeout;
00022         u_int32_t a, b, c, v;
00023         int nmodes, lk_modes;
00024         u_int8_t conflicts[40];
00025 
00026         dbenv = NULL;
00027 
00028         /* tx_max: NOT reset at run-time. */
00029         system("rm -rf TESTDIR; mkdir TESTDIR");
00030         ENV
00031         assert(dbenv->set_tx_max(dbenv, 37) == 0);
00032         assert(dbenv->open(dbenv,
00033             "TESTDIR", DB_CREATE | DB_INIT_TXN, 0666) == 0);
00034         assert(dbenv->get_tx_max(dbenv, &v) == 0);
00035         assert(v == 37);
00036         ENV
00037         assert(dbenv->set_tx_max(dbenv, 63) == 0);
00038         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00039         assert(dbenv->get_tx_max(dbenv, &v) == 0);
00040         assert(v == 37);
00041 
00042         /* lg_max: reset at run-time. */
00043         system("rm -rf TESTDIR; mkdir TESTDIR");
00044         ENV
00045         assert(dbenv->set_lg_max(dbenv, 37 * 1024 * 1024) == 0);
00046         assert(dbenv->open(dbenv,
00047             "TESTDIR", DB_CREATE | DB_INIT_LOG, 0666) == 0);
00048         assert(dbenv->get_lg_max(dbenv, &v) == 0);
00049         assert(v == 37 * 1024 * 1024);
00050         ENV
00051         assert(dbenv->set_lg_max(dbenv, 63 * 1024 * 1024) == 0);
00052         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00053         assert(dbenv->get_lg_max(dbenv, &v) == 0);
00054         assert(v == 63 * 1024 * 1024);
00055 
00056         /* lg_bsize: NOT reset at run-time. */
00057         system("rm -rf TESTDIR; mkdir TESTDIR");
00058         ENV
00059         assert(dbenv->set_lg_bsize(dbenv, 37 * 1024) == 0);
00060         assert(dbenv->open(dbenv,
00061             "TESTDIR", DB_CREATE | DB_INIT_LOG, 0666) == 0);
00062         assert(dbenv->get_lg_bsize(dbenv, &v) == 0);
00063         assert(v == 37 * 1024);
00064         ENV
00065         assert(dbenv->set_lg_bsize(dbenv, 63 * 1024) == 0);
00066         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00067         assert(dbenv->get_lg_bsize(dbenv, &v) == 0);
00068         assert(v == 37 * 1024);
00069 
00070         /* lg_regionmax: NOT reset at run-time. */
00071         system("rm -rf TESTDIR; mkdir TESTDIR");
00072         ENV
00073         assert(dbenv->set_lg_regionmax(dbenv, 137 * 1024) == 0);
00074         assert(dbenv->open(dbenv,
00075             "TESTDIR", DB_CREATE | DB_INIT_LOG, 0666) == 0);
00076         assert(dbenv->get_lg_regionmax(dbenv, &v) == 0);
00077         assert(v == 137 * 1024);
00078         ENV
00079         assert(dbenv->set_lg_regionmax(dbenv, 163 * 1024) == 0);
00080         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00081         assert(dbenv->get_lg_regionmax(dbenv, &v) == 0);
00082         assert(v == 137 * 1024);
00083 
00084         /* lk_get_lk_conflicts: NOT reset at run-time. */
00085         system("rm -rf TESTDIR; mkdir TESTDIR");
00086         ENV
00087         memset(conflicts, 'a', sizeof(conflicts));
00088         nmodes = 6;
00089         assert(dbenv->set_lk_conflicts(dbenv, conflicts, nmodes) == 0);
00090         assert(dbenv->open(dbenv,
00091             "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
00092         assert(dbenv->get_lk_conflicts(dbenv, &lk_conflicts, &lk_modes) == 0);
00093         assert(lk_conflicts[0] == 'a');
00094         assert(lk_modes == 6);
00095         ENV
00096         memset(conflicts, 'b', sizeof(conflicts));
00097         nmodes = 8;
00098         assert(dbenv->set_lk_conflicts(dbenv, conflicts, nmodes) == 0);
00099         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00100         assert(dbenv->get_lk_conflicts(dbenv, &lk_conflicts, &lk_modes) == 0);
00101         assert(lk_conflicts[0] == 'a');
00102         assert(lk_modes == 6);
00103 
00104         /* lk_detect: NOT reset at run-time. */
00105         system("rm -rf TESTDIR; mkdir TESTDIR");
00106         ENV
00107         assert(dbenv->set_lk_detect(dbenv, DB_LOCK_MAXLOCKS) == 0);
00108         assert(dbenv->open(dbenv,
00109             "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
00110         assert(dbenv->get_lk_detect(dbenv, &v) == 0);
00111         assert(v == DB_LOCK_MAXLOCKS);
00112         ENV
00113         assert(dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT) == 0);
00114         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00115         assert(dbenv->get_lk_detect(dbenv, &v) == 0);
00116         assert(v == DB_LOCK_MAXLOCKS);
00117 
00118         /* lk_max_locks: NOT reset at run-time. */
00119         system("rm -rf TESTDIR; mkdir TESTDIR");
00120         ENV
00121         assert(dbenv->set_lk_max_locks(dbenv, 37) == 0);
00122         assert(dbenv->open(dbenv,
00123             "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
00124         assert(dbenv->get_lk_max_locks(dbenv, &v) == 0);
00125         assert(v == 37);
00126         ENV
00127         assert(dbenv->set_lk_max_locks(dbenv, 63) == 0);
00128         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00129         assert(dbenv->get_lk_max_locks(dbenv, &v) == 0);
00130         assert(v == 37);
00131 
00132         /* lk_max_lockers: NOT reset at run-time. */
00133         system("rm -rf TESTDIR; mkdir TESTDIR");
00134         ENV
00135         assert(dbenv->set_lk_max_lockers(dbenv, 37) == 0);
00136         assert(dbenv->open(dbenv,
00137             "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
00138         assert(dbenv->get_lk_max_lockers(dbenv, &v) == 0);
00139         assert(v == 37);
00140         ENV
00141         assert(dbenv->set_lk_max_lockers(dbenv, 63) == 0);
00142         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00143         assert(dbenv->get_lk_max_lockers(dbenv, &v) == 0);
00144         assert(v == 37);
00145 
00146         /* lk_max_objects: NOT reset at run-time. */
00147         system("rm -rf TESTDIR; mkdir TESTDIR");
00148         ENV
00149         assert(dbenv->set_lk_max_objects(dbenv, 37) == 0);
00150         assert(dbenv->open(dbenv,
00151             "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
00152         assert(dbenv->get_lk_max_objects(dbenv, &v) == 0);
00153         assert(v == 37);
00154         ENV
00155         assert(dbenv->set_lk_max_objects(dbenv, 63) == 0);
00156         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00157         assert(dbenv->get_lk_max_objects(dbenv, &v) == 0);
00158         assert(v == 37);
00159 
00160         /* lock timeout: reset at run-time. */
00161         system("rm -rf TESTDIR; mkdir TESTDIR");
00162         ENV
00163         assert(dbenv->set_timeout(dbenv, 37, DB_SET_LOCK_TIMEOUT) == 0);
00164         assert(dbenv->open(dbenv,
00165             "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
00166         assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_LOCK_TIMEOUT) == 0);
00167         assert(timeout == 37);
00168         ENV
00169         assert(dbenv->set_timeout(dbenv, 63, DB_SET_LOCK_TIMEOUT) == 0);
00170         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00171         assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_LOCK_TIMEOUT) == 0);
00172         assert(timeout == 63);
00173 
00174         /* txn timeout: reset at run-time. */
00175         system("rm -rf TESTDIR; mkdir TESTDIR");
00176         ENV
00177         assert(dbenv->set_timeout(dbenv, 37, DB_SET_TXN_TIMEOUT) == 0);
00178         assert(dbenv->open(dbenv,
00179             "TESTDIR", DB_CREATE | DB_INIT_LOCK, 0666) == 0);
00180         assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
00181         assert(timeout == 37);
00182         ENV
00183         assert(dbenv->set_timeout(dbenv, 63, DB_SET_TXN_TIMEOUT) == 0);
00184         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00185         assert(dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
00186         assert(timeout == 63);
00187 
00188         /* cache size: NOT reset at run-time. */
00189         system("rm -rf TESTDIR; mkdir TESTDIR");
00190         ENV
00191         assert(dbenv->set_cachesize(dbenv, 1, 37, 3) == 0);
00192         assert(dbenv->open(dbenv,
00193             "TESTDIR", DB_CREATE | DB_INIT_MPOOL, 0666) == 0);
00194         assert(dbenv->get_cachesize(dbenv, &a, &b, &c) == 0);
00195         assert(a == 1 && b == 37 && c == 3);
00196         ENV
00197         assert(dbenv->set_cachesize(dbenv, 2, 63, 1) == 0);
00198         assert(dbenv->open(dbenv, "TESTDIR", DB_JOINENV, 0666) == 0);
00199         assert(dbenv->get_cachesize(dbenv, &a, &b, &c) == 0);
00200         assert(a == 1 && b == 37 && c == 3);
00201 
00202         return (0);
00203 }

Generated on Sun Dec 25 12:14:52 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2