MCPcopy Create free account
hub / github.com/ElementsProject/elements / main

Function main

src/leveldb/db/c_test.c:145–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145int main(int argc, char** argv) {
146 leveldb_t* db;
147 leveldb_comparator_t* cmp;
148 leveldb_cache_t* cache;
149 leveldb_env_t* env;
150 leveldb_options_t* options;
151 leveldb_readoptions_t* roptions;
152 leveldb_writeoptions_t* woptions;
153 char* dbname;
154 char* err = NULL;
155 int run = -1;
156
157 CheckCondition(leveldb_major_version() >= 1);
158 CheckCondition(leveldb_minor_version() >= 1);
159
160 StartPhase("create_objects");
161 cmp = leveldb_comparator_create(NULL, CmpDestroy, CmpCompare, CmpName);
162 env = leveldb_create_default_env();
163 cache = leveldb_cache_create_lru(100000);
164 dbname = leveldb_env_get_test_directory(env);
165 CheckCondition(dbname != NULL);
166
167 options = leveldb_options_create();
168 leveldb_options_set_comparator(options, cmp);
169 leveldb_options_set_error_if_exists(options, 1);
170 leveldb_options_set_cache(options, cache);
171 leveldb_options_set_env(options, env);
172 leveldb_options_set_info_log(options, NULL);
173 leveldb_options_set_write_buffer_size(options, 100000);
174 leveldb_options_set_paranoid_checks(options, 1);
175 leveldb_options_set_max_open_files(options, 10);
176 leveldb_options_set_block_size(options, 1024);
177 leveldb_options_set_block_restart_interval(options, 8);
178 leveldb_options_set_max_file_size(options, 3 << 20);
179 leveldb_options_set_compression(options, leveldb_no_compression);
180
181 roptions = leveldb_readoptions_create();
182 leveldb_readoptions_set_verify_checksums(roptions, 1);
183 leveldb_readoptions_set_fill_cache(roptions, 0);
184
185 woptions = leveldb_writeoptions_create();
186 leveldb_writeoptions_set_sync(woptions, 1);
187
188 StartPhase("destroy");
189 leveldb_destroy_db(options, dbname, &err);
190 Free(&err);
191
192 StartPhase("open_error");
193 db = leveldb_open(options, dbname, &err);
194 CheckCondition(err != NULL);
195 Free(&err);
196
197 StartPhase("leveldb_free");
198 db = leveldb_open(options, dbname, &err);
199 CheckCondition(err != NULL);
200 leveldb_free(err);
201 err = NULL;
202

Callers

nothing calls this directly

Calls 15

leveldb_major_versionFunction · 0.85
leveldb_minor_versionFunction · 0.85
StartPhaseFunction · 0.85
leveldb_cache_create_lruFunction · 0.85
leveldb_options_createFunction · 0.85
leveldb_options_set_envFunction · 0.85

Tested by

no test coverage detected