sophia-ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.gitmodules +3 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +29 -0
  7. data/Rakefile +22 -0
  8. data/ext/extconf.rb +13 -0
  9. data/ext/sophia.c +220 -0
  10. data/lib/sophia-ruby.rb +1 -0
  11. data/lib/sophia/version.rb +3 -0
  12. data/sophia-ruby.gemspec +47 -0
  13. data/test/test_sophia.rb +33 -0
  14. data/vendor/sophia/.gitignore +18 -0
  15. data/vendor/sophia/COPYRIGHT +29 -0
  16. data/vendor/sophia/README +5 -0
  17. data/vendor/sophia/db/a.h +58 -0
  18. data/vendor/sophia/db/cat.c +195 -0
  19. data/vendor/sophia/db/cat.h +32 -0
  20. data/vendor/sophia/db/core.h +129 -0
  21. data/vendor/sophia/db/crc.c +343 -0
  22. data/vendor/sophia/db/crc.h +14 -0
  23. data/vendor/sophia/db/cursor.c +551 -0
  24. data/vendor/sophia/db/cursor.h +47 -0
  25. data/vendor/sophia/db/e.c +49 -0
  26. data/vendor/sophia/db/e.h +49 -0
  27. data/vendor/sophia/db/file.c +355 -0
  28. data/vendor/sophia/db/file.h +106 -0
  29. data/vendor/sophia/db/gc.c +71 -0
  30. data/vendor/sophia/db/gc.h +14 -0
  31. data/vendor/sophia/db/i.c +368 -0
  32. data/vendor/sophia/db/i.h +155 -0
  33. data/vendor/sophia/db/list.h +91 -0
  34. data/vendor/sophia/db/lock.h +77 -0
  35. data/vendor/sophia/db/macro.h +20 -0
  36. data/vendor/sophia/db/makefile +44 -0
  37. data/vendor/sophia/db/merge.c +662 -0
  38. data/vendor/sophia/db/merge.h +14 -0
  39. data/vendor/sophia/db/meta.h +87 -0
  40. data/vendor/sophia/db/recover.c +433 -0
  41. data/vendor/sophia/db/recover.h +14 -0
  42. data/vendor/sophia/db/ref.h +111 -0
  43. data/vendor/sophia/db/rep.c +128 -0
  44. data/vendor/sophia/db/rep.h +120 -0
  45. data/vendor/sophia/db/sophia.h +84 -0
  46. data/vendor/sophia/db/sp.c +626 -0
  47. data/vendor/sophia/db/sp.h +50 -0
  48. data/vendor/sophia/db/task.h +70 -0
  49. data/vendor/sophia/db/track.h +99 -0
  50. data/vendor/sophia/db/util.c +105 -0
  51. data/vendor/sophia/db/util.h +25 -0
  52. data/vendor/sophia/makefile +7 -0
  53. data/vendor/sophia/sophia.gyp +30 -0
  54. data/vendor/sophia/test/common.c +870 -0
  55. data/vendor/sophia/test/crash.c +492 -0
  56. data/vendor/sophia/test/i.c +403 -0
  57. data/vendor/sophia/test/limit.c +65 -0
  58. data/vendor/sophia/test/makefile +30 -0
  59. data/vendor/sophia/test/merge.c +890 -0
  60. data/vendor/sophia/test/recover.c +1550 -0
  61. data/vendor/sophia/test/test.h +66 -0
  62. metadata +134 -0
@@ -0,0 +1,30 @@
1
+
2
+ CC ?= gcc
3
+ RM ?= rm
4
+ CFLAGS ?= -I. -I../db -Wall -pthread -O0 -g
5
+ LDFLAGS ?= -pthread ../db/libsophia.a
6
+ all: clean i common recover merge crash limit
7
+ common: common.o
8
+ $(CC) common.o $(LDFLAGS) -o common
9
+ recover: recover.o
10
+ $(CC) recover.o $(LDFLAGS) -o recover
11
+ merge: merge.o
12
+ $(CC) merge.o $(LDFLAGS) -o merge
13
+ crash: crash.o
14
+ $(CC) crash.o $(LDFLAGS) -o crash
15
+ limit: limit.o
16
+ $(CC) limit.o $(LDFLAGS) -o limit
17
+ i: i.o
18
+ $(CC) i.o $(LDFLAGS) -o i
19
+ .c.o:
20
+ $(CC) $(CFLAGS) -c $<
21
+ clean:
22
+ $(RM) -f common.o common recover.o recover merge.o merge
23
+ $(RM) -f crash.o crash i.o i limit.o limit
24
+ test:
25
+ $(VALGRIND) ./i
26
+ $(VALGRIND) ./common
27
+ $(VALGRIND) ./recover
28
+ $(VALGRIND) ./merge
29
+ $(VALGRIND) ./crash
30
+ $(VALGRIND) ./limit
@@ -0,0 +1,890 @@
1
+
2
+ /*
3
+ * sophia database
4
+ * sphia.org
5
+ *
6
+ * Copyright (c) Dmitry Simonenko
7
+ * BSD License
8
+ */
9
+
10
+ #include <sophia.h>
11
+ #include "test.h"
12
+
13
+ static char *dbrep = "./rep";
14
+
15
+ static inline int
16
+ cmp(char *a, size_t asz, char *b, size_t bsz, void *arg) {
17
+ register uint32_t av = *(uint32_t*)a;
18
+ register uint32_t bv = *(uint32_t*)b;
19
+ if (av == bv)
20
+ return 0;
21
+ return (av > bv) ? 1 : -1;
22
+ }
23
+
24
+ static void
25
+ merge_liveonly(void) {
26
+ void *env = sp_env();
27
+ t( env != NULL );
28
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
29
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
30
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
31
+ void *db = sp_open(env);
32
+ t( exists(dbrep, 1, "log.incomplete") == 1 );
33
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
34
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
35
+ t( exists(dbrep, 1, "log") == 0 );
36
+ t( exists(dbrep, 1, "db") == 0 );
37
+ t( exists(dbrep, 1, "db.incomplete") == 0 );
38
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
39
+ t( exists(dbrep, 2, "log") == 0 );
40
+ t( sp_destroy(db) == 0 );
41
+ t( exists(dbrep, 1, "log") == 0 );
42
+ t( exists(dbrep, 2, "log") == 0 );
43
+ t( sp_destroy(env) == 0 );
44
+ t( rmrf(dbrep) == 0 );
45
+ }
46
+
47
+ static void
48
+ merge_phase0(void) {
49
+ void *env = sp_env();
50
+ t( env != NULL );
51
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
52
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
53
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
54
+ void *db = sp_open(env);
55
+ t( exists(dbrep, 1, "log.incomplete") == 1 );
56
+ uint32_t k = 1, v = 1;
57
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
58
+ k = 2;
59
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
60
+ k = 3;
61
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
62
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
63
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
64
+ t( exists(dbrep, 1, "log") == 0 );
65
+ t( exists(dbrep, 1, "db.incomplete") == 0 );
66
+ t( exists(dbrep, 1, "db") == 1 );
67
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
68
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
69
+ t( sp_destroy(db) == 0 );
70
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
71
+ t( exists(dbrep, 1, "log") == 0 );
72
+ t( exists(dbrep, 1, "db.incomplete") == 0 );
73
+ t( exists(dbrep, 1, "db") == 1 );
74
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
75
+ t( exists(dbrep, 2, "log") == 0 );
76
+ t( exists(dbrep, 2, "db") == 0 );
77
+ t( sp_destroy(env) == 0 );
78
+ t( rmrf(dbrep) == 0 );
79
+ }
80
+
81
+ static void
82
+ merge_phase1(void) {
83
+ void *env = sp_env();
84
+ t( env != NULL );
85
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
86
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
87
+ t( sp_ctl(env, SPGC, 0) == 0 );
88
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
89
+ void *db = sp_open(env);
90
+ t( exists(dbrep, 1, "log.incomplete") == 1 );
91
+ uint32_t k = 1, v = 1;
92
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
93
+ k = 2;
94
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
95
+ k = 3;
96
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
97
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
98
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
99
+ t( exists(dbrep, 1, "log") == 0 );
100
+ t( exists(dbrep, 1, "db.incomplete") == 0 );
101
+ t( exists(dbrep, 1, "db") == 1 );
102
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
103
+ t( exists(dbrep, 2, "log") == 0 );
104
+ k = 4;
105
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
106
+ k = 5;
107
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
108
+ k = 6;
109
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
110
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
111
+ t( exists(dbrep, 1, "db") == 1 );
112
+ t( exists(dbrep, 2, "db.incomplete") == 0 );
113
+ t( exists(dbrep, 2, "db") == 1 );
114
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
115
+ t( exists(dbrep, 2, "log") == 0 );
116
+ t( exists(dbrep, 3, "log.incomplete") == 1 );
117
+ t( exists(dbrep, 3, "log") == 0 );
118
+ t( sp_destroy(db) == 0 );
119
+ t( exists(dbrep, 1, "db") == 1 );
120
+ t( exists(dbrep, 2, "db.incomplete") == 0 );
121
+ t( exists(dbrep, 2, "db") == 1 );
122
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
123
+ t( exists(dbrep, 2, "log") == 0 );
124
+ t( exists(dbrep, 3, "log.incomplete") == 0 );
125
+ t( exists(dbrep, 3, "log") == 0 );
126
+ t( sp_destroy(env) == 0 );
127
+ t( rmrf(dbrep) == 0 );
128
+ }
129
+
130
+ static void
131
+ merge_phase1gc(void) {
132
+ void *env = sp_env();
133
+ t( env != NULL );
134
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
135
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
136
+ t( sp_ctl(env, SPGC, 1) == 0 );
137
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
138
+ void *db = sp_open(env);
139
+ t( exists(dbrep, 1, "log.incomplete") == 1 );
140
+ uint32_t k = 1, v = 1;
141
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
142
+ k = 2;
143
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
144
+ k = 3;
145
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
146
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
147
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
148
+ t( exists(dbrep, 1, "log") == 0 );
149
+ t( exists(dbrep, 1, "db.incomplete") == 0 );
150
+ t( exists(dbrep, 1, "db") == 1 );
151
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
152
+ t( exists(dbrep, 2, "log") == 0 );
153
+ k = 4;
154
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
155
+ k = 5;
156
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
157
+ k = 6;
158
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
159
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
160
+ t( exists(dbrep, 1, "db") == 0 );
161
+ t( exists(dbrep, 2, "db.incomplete") == 0 );
162
+ t( exists(dbrep, 2, "db") == 1 );
163
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
164
+ t( exists(dbrep, 2, "log") == 0 );
165
+ t( exists(dbrep, 3, "log.incomplete") == 1 );
166
+ t( exists(dbrep, 3, "log") == 0 );
167
+ t( sp_destroy(db) == 0 );
168
+ t( exists(dbrep, 1, "db") == 0 );
169
+ t( exists(dbrep, 2, "db.incomplete") == 0 );
170
+ t( exists(dbrep, 2, "db") == 1 );
171
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
172
+ t( exists(dbrep, 2, "log") == 0 );
173
+ t( exists(dbrep, 3, "log.incomplete") == 0 );
174
+ t( exists(dbrep, 3, "log") == 0 );
175
+ t( sp_destroy(env) == 0 );
176
+ t( rmrf(dbrep) == 0 );
177
+ }
178
+
179
+ static void
180
+ merge_phase1n(void) {
181
+ void *env = sp_env();
182
+ t( env != NULL );
183
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
184
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
185
+ t( sp_ctl(env, SPGC, 0) == 0 );
186
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
187
+ void *db = sp_open(env);
188
+ uint32_t k = 1, v = 1;
189
+ /* 1 */
190
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
191
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
192
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
193
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
194
+ /* 2 */
195
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
196
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
197
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
198
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
199
+ /* 3 */
200
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
201
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
202
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
203
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
204
+ /* 4 */
205
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
206
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
207
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
208
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
209
+ /* 5 */
210
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
211
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
212
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
213
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
214
+ /* merge */
215
+ t( exists(dbrep, 1, "db") == 1 );
216
+ t( exists(dbrep, 2, "db") == 1 );
217
+ t( exists(dbrep, 3, "db") == 1 );
218
+ t( exists(dbrep, 4, "db") == 1 );
219
+ t( exists(dbrep, 5, "db") == 1 );
220
+ t( sp_destroy(db) == 0 );
221
+ t( sp_destroy(env) == 0 );
222
+ t( rmrf(dbrep) == 0 );
223
+ }
224
+
225
+ static void
226
+ merge_phase1ngc(void) {
227
+ void *env = sp_env();
228
+ t( env != NULL );
229
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
230
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
231
+ t( sp_ctl(env, SPGC, 1) == 0 );
232
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
233
+ void *db = sp_open(env);
234
+ uint32_t k = 1, v = 1;
235
+ /* 1 */
236
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
237
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
238
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
239
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
240
+ /* 2 */
241
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
242
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
243
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
244
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
245
+ /* 3 */
246
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
247
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
248
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
249
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
250
+ /* 4 */
251
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
252
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
253
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
254
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
255
+ /* 5 */
256
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
257
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
258
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0 );
259
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
260
+ /* merge */
261
+ t( exists(dbrep, 1, "db") == 0 );
262
+ t( exists(dbrep, 2, "db") == 0 );
263
+ t( exists(dbrep, 3, "db") == 0 );
264
+ t( exists(dbrep, 4, "db") == 0 );
265
+ t( exists(dbrep, 5, "db") == 1 );
266
+ t( sp_destroy(db) == 0 );
267
+ t( sp_destroy(env) == 0 );
268
+ t( rmrf(dbrep) == 0 );
269
+ }
270
+
271
+ static void
272
+ merge_delete(void) {
273
+ void *env = sp_env();
274
+ t( env != NULL );
275
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
276
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
277
+ t( sp_ctl(env, SPGC, 0) == 0 );
278
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
279
+ void *db = sp_open(env);
280
+ t( db != NULL );
281
+ uint32_t k = 0, v = 1;
282
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
283
+ k = 1;
284
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
285
+ t( sp_destroy(db) == 0 );
286
+ t( exists(dbrep, 1, "log") == 1 );
287
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
288
+ db = sp_open(env);
289
+ t( db != NULL );
290
+ k = 0;
291
+ t( sp_delete(db, &k, sizeof(k)) == 0 );
292
+ k = 1;
293
+ t( sp_delete(db, &k, sizeof(k)) == 0 );
294
+ t( exists(dbrep, 1, "log") == 1 );
295
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
296
+ t( exists(dbrep, 2, "log") == 0 );
297
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
298
+ t( exists(dbrep, 1, "log") == 0 );
299
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
300
+ t( exists(dbrep, 2, "log") == 0 );
301
+ t( exists(dbrep, 3, "log.incomplete") == 1 );
302
+ t( exists(dbrep, 1, "db") == 0 );
303
+ t( exists(dbrep, 2, "db") == 0 );
304
+ t( sp_destroy(db) == 0 );
305
+ db = sp_open(env);
306
+ t( db != NULL );
307
+ k = 0;
308
+ size_t vsize = 0;
309
+ void *vp = NULL;
310
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
311
+ k = 1;
312
+ vsize = 0;
313
+ vp = NULL;
314
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
315
+ t( sp_destroy(db) == 0 );
316
+ t( sp_destroy(env) == 0 );
317
+ t( rmrf(dbrep) == 0 );
318
+ }
319
+
320
+ static void
321
+ merge_deletegc(void) {
322
+ void *env = sp_env();
323
+ t( env != NULL );
324
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
325
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
326
+ t( sp_ctl(env, SPGC, 1) == 0 );
327
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
328
+ void *db = sp_open(env);
329
+ t( db != NULL );
330
+ uint32_t k = 0, v = 1;
331
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
332
+ k = 1;
333
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
334
+ t( sp_destroy(db) == 0 );
335
+ t( exists(dbrep, 1, "log") == 1 );
336
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
337
+ db = sp_open(env);
338
+ t( db != NULL );
339
+ k = 0;
340
+ t( sp_delete(db, &k, sizeof(k)) == 0 );
341
+ k = 1;
342
+ t( sp_delete(db, &k, sizeof(k)) == 0 );
343
+ t( exists(dbrep, 1, "log") == 1 );
344
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
345
+ t( exists(dbrep, 2, "log") == 0 );
346
+ t( sp_ctl(db, SPMERGEFORCE) == 0 );
347
+ t( exists(dbrep, 1, "log") == 0 );
348
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
349
+ t( exists(dbrep, 2, "log") == 0 );
350
+ t( exists(dbrep, 1, "db") == 0 );
351
+ t( exists(dbrep, 2, "db") == 0 );
352
+ t( sp_destroy(db) == 0 );
353
+ db = sp_open(env);
354
+ t( db != NULL );
355
+ k = 0;
356
+ size_t vsize = 0;
357
+ void *vp = NULL;
358
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
359
+ k = 1;
360
+ vsize = 0;
361
+ vp = NULL;
362
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
363
+ t( sp_destroy(db) == 0 );
364
+ t( sp_destroy(env) == 0 );
365
+ t( rmrf(dbrep) == 0 );
366
+ }
367
+
368
+ static void
369
+ merge_delete_log_n(void) {
370
+ void *env = sp_env();
371
+ t( env != NULL );
372
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
373
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
374
+ t( sp_ctl(env, SPGC, 0) == 0 );
375
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
376
+ void *db = sp_open(env);
377
+ t( db != NULL );
378
+ uint32_t k = 0, v = 1;
379
+ while (k < 12) {
380
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
381
+ k++;
382
+ }
383
+ t( sp_destroy(db) == 0 );
384
+ t( exists(dbrep, 1, "log") == 1 );
385
+ db = sp_open(env);
386
+ t( db != NULL );
387
+ k = 0;
388
+ while (k < 12) {
389
+ t( sp_delete(db, &k, sizeof(k)) == 0);
390
+ k++;
391
+ }
392
+ t( exists(dbrep, 1, "log.incomplete") == 0 );
393
+ t( exists(dbrep, 1, "log") == 1 );
394
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
395
+ t( sp_destroy(db) == 0 );
396
+ db = sp_open(env);
397
+ t( db != NULL );
398
+ k = 0;
399
+ while (k < 12) {
400
+ size_t vsize = 0;
401
+ void *vp = NULL;
402
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
403
+ k++;
404
+ }
405
+ t( sp_destroy(db) == 0 );
406
+ t( exists(dbrep, 1, "log") == 1 );
407
+ t( exists(dbrep, 2, "log") == 1 );
408
+ t( exists(dbrep, 3, "log") == 0 );
409
+ t( sp_destroy(env) == 0 );
410
+ t( rmrf(dbrep) == 0 );
411
+ }
412
+
413
+ static void
414
+ merge_delete_page_n(void) {
415
+ void *env = sp_env();
416
+ t( env != NULL );
417
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
418
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
419
+ t( sp_ctl(env, SPGC, 0) == 0 );
420
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
421
+ void *db = sp_open(env);
422
+ t( db != NULL );
423
+ uint32_t k = 0, v = 1;
424
+ while (k < 12) {
425
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
426
+ k++;
427
+ }
428
+ t( sp_destroy(db) == 0 );
429
+ t( exists(dbrep, 1, "log") == 1 );
430
+ db = sp_open(env);
431
+ t( db != NULL );
432
+ k = 0;
433
+ while (k < 12) {
434
+ t( sp_delete(db, &k, sizeof(k)) == 0);
435
+ k++;
436
+ }
437
+ t( exists(dbrep, 1, "log") == 1 );
438
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
439
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
440
+ t( sp_destroy(db) == 0 );
441
+ db = sp_open(env);
442
+ t( db != NULL );
443
+ k = 0;
444
+ while (k < 12) {
445
+ size_t vsize = 0;
446
+ void *vp = NULL;
447
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
448
+ k++;
449
+ }
450
+ t( sp_destroy(db) == 0 );
451
+ t( exists(dbrep, 1, "log") == 0 );
452
+ t( exists(dbrep, 2, "log") == 0 );
453
+ t( exists(dbrep, 2, "db") == 0 );
454
+ t( sp_destroy(env) == 0 );
455
+ t( rmrf(dbrep) == 0 );
456
+ }
457
+
458
+ static void
459
+ merge_delete_page_log_n(void) {
460
+ void *env = sp_env();
461
+ t( env != NULL );
462
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
463
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
464
+ t( sp_ctl(env, SPGC, 0) == 0 );
465
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
466
+ void *db = sp_open(env);
467
+ t( db != NULL );
468
+ uint32_t k = 0, v = 1;
469
+ while (k < 12) {
470
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
471
+ k++;
472
+ }
473
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
474
+ t( exists(dbrep, 1, "db") == 1 );
475
+ t( sp_destroy(db) == 0 );
476
+ db = sp_open(env);
477
+ t( db != NULL );
478
+ k = 0;
479
+ while (k < 12) {
480
+ t( sp_delete(db, &k, sizeof(k)) == 0);
481
+ k++;
482
+ }
483
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
484
+ t( exists(dbrep, 2, "log.incomplete") == 0 );
485
+ t( exists(dbrep, 2, "db") == 1 );
486
+ t( exists(dbrep, 3, "log.incomplete") == 1 );
487
+ t( sp_destroy(db) == 0 );
488
+ db = sp_open(env);
489
+ t( db != NULL );
490
+ k = 0;
491
+ while (k < 12) {
492
+ size_t vsize = 0;
493
+ void *vp = NULL;
494
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
495
+ k++;
496
+ }
497
+ t( sp_destroy(db) == 0 );
498
+ t( exists(dbrep, 1, "db") == 1 );
499
+ t( exists(dbrep, 2, "db") == 1 );
500
+ t( exists(dbrep, 3, "log") == 0 );
501
+ t( sp_destroy(env) == 0 );
502
+ t( rmrf(dbrep) == 0 );
503
+ }
504
+
505
+ static void
506
+ merge_delete_page_log_n_even(void) {
507
+ void *env = sp_env();
508
+ t( env != NULL );
509
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
510
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
511
+ t( sp_ctl(env, SPGC, 0) == 0 );
512
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
513
+ void *db = sp_open(env);
514
+ t( db != NULL );
515
+ uint32_t k = 0, v = 1;
516
+ while (k < 12) {
517
+ v = k;
518
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
519
+ k++;
520
+ }
521
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
522
+ t( sp_destroy(db) == 0 );
523
+ t( exists(dbrep, 1, "db") == 1 );
524
+ db = sp_open(env);
525
+ t( db != NULL );
526
+ k = 0;
527
+ while (k < 12) {
528
+ if (k > 0 && (k % 2) == 0)
529
+ t( sp_delete(db, &k, sizeof(k)) == 0);
530
+ k++;
531
+ }
532
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
533
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
534
+ t( sp_destroy(db) == 0 );
535
+ db = sp_open(env);
536
+ t( db != NULL );
537
+ k = 0;
538
+ while (k < 12) {
539
+ size_t vsize = 0;
540
+ void *vp = NULL;
541
+ if (k == 0 || (k % 2) != 0) {
542
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 1 );
543
+ t( vsize == sizeof(v) );
544
+ t( *(uint32_t*)vp == k );
545
+ free(vp);
546
+ }
547
+ k++;
548
+ }
549
+ t( sp_destroy(db) == 0 );
550
+ t( sp_destroy(env) == 0 );
551
+ t( rmrf(dbrep) == 0 );
552
+ }
553
+
554
+ static void
555
+ merge_delete_page_log_n_extra(void) {
556
+ void *env = sp_env();
557
+ t( env != NULL );
558
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
559
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
560
+ t( sp_ctl(env, SPGC, 0) == 0 );
561
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
562
+ void *db = sp_open(env);
563
+ t( db != NULL );
564
+ uint32_t k = 0, v = 1;
565
+ while (k < 12) {
566
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
567
+ k++;
568
+ }
569
+ t( sp_destroy(db) == 0 );
570
+ t( exists(dbrep, 1, "log") == 1 );
571
+ db = sp_open(env);
572
+ t( db != NULL );
573
+ k = 0;
574
+ while (k < 12) {
575
+ t( sp_delete(db, &k, sizeof(k)) == 0);
576
+ k++;
577
+ }
578
+ k = 13;
579
+ v = k;
580
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
581
+ t( exists(dbrep, 2, "log.incomplete") == 1 );
582
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
583
+ t( exists(dbrep, 1, "db") == 0 );
584
+ t( exists(dbrep, 2, "db") == 1 );
585
+ t( sp_destroy(db) == 0 );
586
+ db = sp_open(env);
587
+ t( db != NULL );
588
+ k = 0;
589
+ while (k < 12) {
590
+ size_t vsize = 0;
591
+ void *vp = NULL;
592
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 0 );
593
+ k++;
594
+ }
595
+ k = 13;
596
+ size_t vsize = 0;
597
+ void *vp = NULL;
598
+ t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 1 );
599
+ t( vsize == sizeof(v) );
600
+ t( *(uint32_t*)vp == 13 );
601
+ free(vp);
602
+ t( sp_destroy(db) == 0 );
603
+ t( sp_destroy(env) == 0 );
604
+ t( rmrf(dbrep) == 0 );
605
+ }
606
+
607
+ static void
608
+ merge_delete_page_log_n_fetch_gte(void) {
609
+ void *env = sp_env();
610
+ t( env != NULL );
611
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
612
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
613
+ t( sp_ctl(env, SPGC, 0) == 0 );
614
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
615
+ void *db = sp_open(env);
616
+ t( db != NULL );
617
+ uint32_t k = 0, v = 1;
618
+ while (k < 12) {
619
+ v = k;
620
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
621
+ k++;
622
+ }
623
+ t( sp_destroy(db) == 0 );
624
+ db = sp_open(env);
625
+ t( db != NULL );
626
+ k = 0;
627
+ while (k < 12) {
628
+ if (k > 0 && (k % 2) == 0)
629
+ t( sp_delete(db, &k, sizeof(k)) == 0);
630
+ k++;
631
+ }
632
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
633
+ t( sp_destroy(db) == 0 );
634
+ db = sp_open(env);
635
+ t( db != NULL );
636
+ void *cur = sp_cursor(db, SPGTE, NULL, 0);
637
+ t( cur != NULL );
638
+ t( sp_fetch(cur) == 1 );
639
+ t( *(uint32_t*)sp_key(cur) == 0 );
640
+ t( sp_keysize(cur) == sizeof(k) );
641
+ t( *(uint32_t*)sp_value(cur) == 0 );
642
+ t( sp_valuesize(cur) == sizeof(v) );
643
+ t( sp_fetch(cur) == 1 );
644
+ t( *(uint32_t*)sp_key(cur) == 1 );
645
+ t( sp_keysize(cur) == sizeof(k) );
646
+ t( *(uint32_t*)sp_value(cur) == 1 );
647
+ t( sp_valuesize(cur) == sizeof(v) );
648
+ t( sp_fetch(cur) == 1 );
649
+ t( *(uint32_t*)sp_key(cur) == 3 );
650
+ t( sp_keysize(cur) == sizeof(k) );
651
+ t( *(uint32_t*)sp_value(cur) == 3 );
652
+ t( sp_valuesize(cur) == sizeof(v) );
653
+ t( sp_fetch(cur) == 1 );
654
+ t( *(uint32_t*)sp_key(cur) == 5 );
655
+ t( sp_keysize(cur) == sizeof(k) );
656
+ t( *(uint32_t*)sp_value(cur) == 5 );
657
+ t( sp_valuesize(cur) == sizeof(v) );
658
+ t( sp_fetch(cur) == 1 );
659
+ t( *(uint32_t*)sp_key(cur) == 7 );
660
+ t( sp_keysize(cur) == sizeof(k) );
661
+ t( *(uint32_t*)sp_value(cur) == 7 );
662
+ t( sp_valuesize(cur) == sizeof(v) );
663
+ t( sp_fetch(cur) == 1 );
664
+ t( *(uint32_t*)sp_key(cur) == 9 );
665
+ t( sp_keysize(cur) == sizeof(k) );
666
+ t( *(uint32_t*)sp_value(cur) == 9 );
667
+ t( sp_valuesize(cur) == sizeof(v) );
668
+ t( sp_fetch(cur) == 1 );
669
+ t( *(uint32_t*)sp_key(cur) == 11 );
670
+ t( sp_keysize(cur) == sizeof(k) );
671
+ t( *(uint32_t*)sp_value(cur) == 11 );
672
+ t( sp_valuesize(cur) == sizeof(v) );
673
+ t( sp_fetch(cur) == 0 );
674
+ t( sp_destroy(cur) == 0 );
675
+ t( sp_destroy(db) == 0 );
676
+ t( sp_destroy(env) == 0 );
677
+ t( rmrf(dbrep) == 0 );
678
+ }
679
+
680
+ static void
681
+ merge_delete_page_log_n_fetch_lte(void) {
682
+ void *env = sp_env();
683
+ t( env != NULL );
684
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
685
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
686
+ t( sp_ctl(env, SPGC, 0) == 0 );
687
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
688
+ void *db = sp_open(env);
689
+ t( db != NULL );
690
+ uint32_t k = 0, v = 1;
691
+ while (k < 12) {
692
+ v = k;
693
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
694
+ k++;
695
+ }
696
+ t( sp_destroy(db) == 0 );
697
+ db = sp_open(env);
698
+ t( db != NULL );
699
+ k = 0;
700
+ while (k < 12) {
701
+ if (k > 0 && (k % 2) == 0)
702
+ t( sp_delete(db, &k, sizeof(k)) == 0);
703
+ k++;
704
+ }
705
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
706
+ t( sp_destroy(db) == 0 );
707
+ db = sp_open(env);
708
+ t( db != NULL );
709
+ void *cur = sp_cursor(db, SPLTE, NULL, 0);
710
+ t( cur != NULL );
711
+ t( sp_fetch(cur) == 1 );
712
+ t( *(uint32_t*)sp_key(cur) == 11 );
713
+ t( sp_keysize(cur) == sizeof(k) );
714
+ t( *(uint32_t*)sp_value(cur) == 11 );
715
+ t( sp_valuesize(cur) == sizeof(v) );
716
+ t( sp_fetch(cur) == 1 );
717
+ t( *(uint32_t*)sp_key(cur) == 9 );
718
+ t( sp_keysize(cur) == sizeof(k) );
719
+ t( *(uint32_t*)sp_value(cur) == 9 );
720
+ t( sp_valuesize(cur) == sizeof(v) );
721
+ t( sp_fetch(cur) == 1 );
722
+ t( *(uint32_t*)sp_key(cur) == 7 );
723
+ t( sp_keysize(cur) == sizeof(k) );
724
+ t( *(uint32_t*)sp_value(cur) == 7 );
725
+ t( sp_valuesize(cur) == sizeof(v) );
726
+ t( sp_fetch(cur) == 1 );
727
+ t( *(uint32_t*)sp_key(cur) == 5 );
728
+ t( sp_keysize(cur) == sizeof(k) );
729
+ t( *(uint32_t*)sp_value(cur) == 5 );
730
+ t( sp_valuesize(cur) == sizeof(v) );
731
+ t( sp_fetch(cur) == 1 );
732
+ t( *(uint32_t*)sp_key(cur) == 3 );
733
+ t( sp_keysize(cur) == sizeof(k) );
734
+ t( *(uint32_t*)sp_value(cur) == 3 );
735
+ t( sp_valuesize(cur) == sizeof(v) );
736
+ t( sp_fetch(cur) == 1 );
737
+ t( *(uint32_t*)sp_key(cur) == 1 );
738
+ t( sp_keysize(cur) == sizeof(k) );
739
+ t( *(uint32_t*)sp_value(cur) == 1 );
740
+ t( sp_valuesize(cur) == sizeof(v) );
741
+ t( sp_fetch(cur) == 1 );
742
+ t( *(uint32_t*)sp_key(cur) == 0 );
743
+ t( sp_keysize(cur) == sizeof(k) );
744
+ t( *(uint32_t*)sp_value(cur) == 0 );
745
+ t( sp_valuesize(cur) == sizeof(v) );
746
+ t( sp_fetch(cur) == 0 );
747
+ t( sp_destroy(cur) == 0 );
748
+ t( sp_destroy(db) == 0 );
749
+ t( sp_destroy(env) == 0 );
750
+ t( rmrf(dbrep) == 0 );
751
+ }
752
+
753
+ static void
754
+ merge_delete_page_log_n_fetch_kgte(void) {
755
+ void *env = sp_env();
756
+ t( env != NULL );
757
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
758
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
759
+ t( sp_ctl(env, SPGC, 0) == 0 );
760
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
761
+ void *db = sp_open(env);
762
+ t( db != NULL );
763
+ uint32_t k = 0, v = 1;
764
+ while (k < 12) {
765
+ v = k;
766
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
767
+ k++;
768
+ }
769
+ t( sp_destroy(db) == 0 );
770
+ db = sp_open(env);
771
+ t( db != NULL );
772
+ k = 0;
773
+ while (k < 12) {
774
+ if (k > 0 && (k % 2) == 0)
775
+ t( sp_delete(db, &k, sizeof(k)) == 0);
776
+ k++;
777
+ }
778
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
779
+ t( sp_destroy(db) == 0 );
780
+ db = sp_open(env);
781
+ t( db != NULL );
782
+ k = 6;
783
+ void *cur = sp_cursor(db, SPGTE, &k, sizeof(k));
784
+ t( cur != NULL );
785
+ t( sp_fetch(cur) == 1 );
786
+ t( *(uint32_t*)sp_key(cur) == 7 );
787
+ t( sp_keysize(cur) == sizeof(k) );
788
+ t( *(uint32_t*)sp_value(cur) == 7 );
789
+ t( sp_valuesize(cur) == sizeof(v) );
790
+ t( sp_fetch(cur) == 1 );
791
+ t( *(uint32_t*)sp_key(cur) == 9 );
792
+ t( sp_keysize(cur) == sizeof(k) );
793
+ t( *(uint32_t*)sp_value(cur) == 9 );
794
+ t( sp_valuesize(cur) == sizeof(v) );
795
+ t( sp_fetch(cur) == 1 );
796
+ t( *(uint32_t*)sp_key(cur) == 11 );
797
+ t( sp_keysize(cur) == sizeof(k) );
798
+ t( *(uint32_t*)sp_value(cur) == 11 );
799
+ t( sp_valuesize(cur) == sizeof(v) );
800
+ t( sp_fetch(cur) == 0 );
801
+ t( sp_destroy(cur) == 0 );
802
+ t( sp_destroy(db) == 0 );
803
+ t( sp_destroy(env) == 0 );
804
+ t( rmrf(dbrep) == 0 );
805
+ }
806
+
807
+ static void
808
+ merge_delete_page_log_n_fetch_klte(void) {
809
+ void *env = sp_env();
810
+ t( env != NULL );
811
+ t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
812
+ t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
813
+ t( sp_ctl(env, SPGC, 0) == 0 );
814
+ t( sp_ctl(env, SPMERGE, 0) == 0 );
815
+ void *db = sp_open(env);
816
+ t( db != NULL );
817
+ uint32_t k = 0, v = 1;
818
+ while (k < 12) {
819
+ v = k;
820
+ t( sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0);
821
+ k++;
822
+ }
823
+ t( sp_destroy(db) == 0 );
824
+ db = sp_open(env);
825
+ t( db != NULL );
826
+ k = 0;
827
+ while (k < 12) {
828
+ if (k > 0 && (k % 2) == 0)
829
+ t( sp_delete(db, &k, sizeof(k)) == 0);
830
+ k++;
831
+ }
832
+ t( sp_ctl(db, SPMERGEFORCE) == 0);
833
+ t( sp_destroy(db) == 0 );
834
+ db = sp_open(env);
835
+ t( db != NULL );
836
+ k = 6;
837
+ void *cur = sp_cursor(db, SPLTE, &k, sizeof(k));
838
+ t( cur != NULL );
839
+ t( sp_fetch(cur) == 1 );
840
+ t( *(uint32_t*)sp_key(cur) == 5 );
841
+ t( sp_keysize(cur) == sizeof(k) );
842
+ t( *(uint32_t*)sp_value(cur) == 5 );
843
+ t( sp_valuesize(cur) == sizeof(v) );
844
+ t( sp_fetch(cur) == 1 );
845
+ t( *(uint32_t*)sp_key(cur) == 3 );
846
+ t( sp_keysize(cur) == sizeof(k) );
847
+ t( *(uint32_t*)sp_value(cur) == 3 );
848
+ t( sp_valuesize(cur) == sizeof(v) );
849
+ t( sp_fetch(cur) == 1 );
850
+ t( *(uint32_t*)sp_key(cur) == 1 );
851
+ t( sp_keysize(cur) == sizeof(k) );
852
+ t( *(uint32_t*)sp_value(cur) == 1 );
853
+ t( sp_valuesize(cur) == sizeof(v) );
854
+ t( sp_fetch(cur) == 1 );
855
+ t( *(uint32_t*)sp_key(cur) == 0 );
856
+ t( sp_keysize(cur) == sizeof(k) );
857
+ t( *(uint32_t*)sp_value(cur) == 0 );
858
+ t( sp_valuesize(cur) == sizeof(v) );
859
+ t( sp_fetch(cur) == 0 );
860
+ t( sp_destroy(cur) == 0 );
861
+ t( sp_destroy(db) == 0 );
862
+ t( sp_destroy(env) == 0 );
863
+ t( rmrf(dbrep) == 0 );
864
+ }
865
+
866
+ int
867
+ main(int argc, char *argv[])
868
+ {
869
+ rmrf(dbrep);
870
+
871
+ test(merge_liveonly);
872
+ test(merge_phase0);
873
+ test(merge_phase1);
874
+ test(merge_phase1gc);
875
+ test(merge_phase1n);
876
+ test(merge_phase1ngc);
877
+
878
+ test(merge_delete);
879
+ test(merge_deletegc);
880
+ test(merge_delete_log_n);
881
+ test(merge_delete_page_n);
882
+ test(merge_delete_page_log_n);
883
+ test(merge_delete_page_log_n_even);
884
+ test(merge_delete_page_log_n_extra);
885
+ test(merge_delete_page_log_n_fetch_gte);
886
+ test(merge_delete_page_log_n_fetch_lte);
887
+ test(merge_delete_page_log_n_fetch_kgte);
888
+ test(merge_delete_page_log_n_fetch_klte);
889
+ return 0;
890
+ }