Commit 491442f97ec18dfdfa88912d20c2304d6ded378f

Julio Espinoza-Sokal 2009-03-12T22:10:22

Factor out test helper methods for creating/deleting loose objects Signed-off-by: Julio Espinoza-Sokal <julioes@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
diff --git a/Makefile b/Makefile
index 56933ff..ca88eb6 100644
--- a/Makefile
+++ b/Makefile
@@ -114,8 +114,8 @@ $(GIT_LIB): $(OBJS)
 	$(AR) cr $(GIT_LIB) $(OBJS)
 	$(RANLIB) $(GIT_LIB)
 
-T_HDR         = tests/test_lib.h
-T_LIB         = tests/test_lib.o
+T_HDR         = tests/test_lib.h tests/test_helpers.h
+T_LIB         = tests/test_lib.o tests/test_helpers.o
 T_MAIN_C      = tests/test_main.c
 
 $(T_LIB):    $(T_HDR) $(HDRS)
diff --git a/tests/t0201-readloose.c b/tests/t0201-readloose.c
index 37e46f4..78abdb6 100644
--- a/tests/t0201-readloose.c
+++ b/tests/t0201-readloose.c
@@ -1,5 +1,6 @@
 
 #include "test_lib.h"
+#include "test_helpers.h"
 #include <git/odb.h>
 #include "fileops.h"
 
@@ -12,17 +13,6 @@
 
 static char *odb_dir = "test-objects";
 
-typedef struct object_data {
-    unsigned char *bytes;  /* (compressed) bytes stored in object store */
-    size_t        blen;    /* length of data in object store            */
-    char          *id;     /* object id (sha1)                          */
-    char          *type;   /* object type                               */
-    char          *dir;    /* object store (fan-out) directory name     */
-    char          *file;   /* object store filename                     */
-    unsigned char *data;   /* (uncompressed) object data                */
-    size_t        dlen;    /* length of (uncompressed) object data      */
-} object_data;
-
 /* commit == 3d7f8a6af076c8c3f20071a8935cdbe8228594d1 */
 static unsigned char commit_bytes[] = {
     0x78, 0x01, 0x85, 0x50, 0xc1, 0x6a, 0xc3, 0x30,
@@ -534,78 +524,12 @@ static object_data some = {
     sizeof(some_data),
 };
 
-static int write_object_data(char *file, void *data, size_t len)
-{
-    git_file fd;
-    int ret;
-
-    if ((fd = gitfo_creat(file, 0664)) < 0)
-        return -1;
-    ret = gitfo_write(fd, data, len);
-    gitfo_close(fd);
-
-    return ret;
-}
-
-static int write_object_files(object_data *d)
-{
-    if (gitfo_mkdir(odb_dir, 0755) < 0) {
-        if (errno == EEXIST) {
-            fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir);
-            return -1;
-        }
-        fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir);
-        return -1;
-    }
-
-    if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
-        fprintf(stderr, "can't make object directory \"%s\"\n", d->dir);
-        return -1;
-    }
-    if (write_object_data(d->file, d->bytes, d->blen) < 0) {
-        fprintf(stderr, "can't write object file \"%s\"\n", d->file);
-        return -1;
-    }
-
-    return 0;
-}
-
-static int remove_object_files(object_data *d)
-{
-    if (gitfo_unlink(d->file) < 0) {
-        fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
-        return -1;
-    }
-    if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
-        fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
-        return -1;
-    }
-
-    if (gitfo_rmdir(odb_dir) < 0) {
-        fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir);
-        return -1;
-    }
-
-    return 0;
-}
-
-static int cmp_objects(git_obj *o, object_data *d)
-{
-    if (o->type != git_obj_string_to_type(d->type))
-        return -1;
-    if (o->len != d->dlen)
-        return -1;
-    if ((o->len > 0) && (memcmp(o->data, d->data, o->len) != 0))
-        return -1;
-    return 0;
-}
-
 BEGIN_TEST(read_loose_commit)
     git_odb *db;
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&commit));
+    must_pass(write_object_files(odb_dir, &commit));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, commit.id));
 
@@ -614,7 +538,7 @@ BEGIN_TEST(read_loose_commit)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&commit));
+    must_pass(remove_object_files(odb_dir, &commit));
 END_TEST
 
 BEGIN_TEST(read_loose_tree)
@@ -622,7 +546,7 @@ BEGIN_TEST(read_loose_tree)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&tree));
+    must_pass(write_object_files(odb_dir, &tree));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, tree.id));
 
@@ -631,7 +555,7 @@ BEGIN_TEST(read_loose_tree)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&tree));
+    must_pass(remove_object_files(odb_dir, &tree));
 END_TEST
 
 BEGIN_TEST(read_loose_tag)
@@ -639,7 +563,7 @@ BEGIN_TEST(read_loose_tag)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&tag));
+    must_pass(write_object_files(odb_dir, &tag));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, tag.id));
 
@@ -648,7 +572,7 @@ BEGIN_TEST(read_loose_tag)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&tag));
+    must_pass(remove_object_files(odb_dir, &tag));
 END_TEST
 
 BEGIN_TEST(read_loose_zero)
@@ -656,7 +580,7 @@ BEGIN_TEST(read_loose_zero)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&zero));
+    must_pass(write_object_files(odb_dir, &zero));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, zero.id));
 
@@ -665,7 +589,7 @@ BEGIN_TEST(read_loose_zero)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&zero));
+    must_pass(remove_object_files(odb_dir, &zero));
 END_TEST
 
 BEGIN_TEST(read_loose_one)
@@ -673,7 +597,7 @@ BEGIN_TEST(read_loose_one)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&one));
+    must_pass(write_object_files(odb_dir, &one));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, one.id));
 
@@ -682,7 +606,7 @@ BEGIN_TEST(read_loose_one)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&one));
+    must_pass(remove_object_files(odb_dir, &one));
 END_TEST
 
 BEGIN_TEST(read_loose_two)
@@ -690,7 +614,7 @@ BEGIN_TEST(read_loose_two)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&two));
+    must_pass(write_object_files(odb_dir, &two));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, two.id));
 
@@ -699,7 +623,7 @@ BEGIN_TEST(read_loose_two)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&two));
+    must_pass(remove_object_files(odb_dir, &two));
 END_TEST
 
 BEGIN_TEST(read_loose_some)
@@ -707,7 +631,7 @@ BEGIN_TEST(read_loose_some)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&some));
+    must_pass(write_object_files(odb_dir, &some));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, some.id));
 
@@ -716,6 +640,6 @@ BEGIN_TEST(read_loose_some)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&some));
+    must_pass(remove_object_files(odb_dir, &some));
 END_TEST
 
diff --git a/tests/t0202-readloose.c b/tests/t0202-readloose.c
index 744e1c7..8708808 100644
--- a/tests/t0202-readloose.c
+++ b/tests/t0202-readloose.c
@@ -1,5 +1,6 @@
 
 #include "test_lib.h"
+#include "test_helpers.h"
 #include <git/odb.h>
 #include "fileops.h"
 
@@ -18,17 +19,6 @@
 
 static char *odb_dir = "test-objects";
 
-typedef struct object_data {
-    unsigned char *bytes;  /* (compressed) bytes stored in object store */
-    size_t        blen;    /* length of data in object store            */
-    char          *id;     /* object id (sha1)                          */
-    char          *type;   /* object type                               */
-    char          *dir;    /* object store (fan-out) directory name     */
-    char          *file;   /* object store filename                     */
-    unsigned char *data;   /* (uncompressed) object data                */
-    size_t        dlen;    /* length of (uncompressed) object data      */
-} object_data;
-
 /* commit == 3d7f8a6af076c8c3f20071a8935cdbe8228594d1 */
 static unsigned char commit_bytes[] = {
     0x92, 0x16, 0x78, 0x9c, 0x85, 0x90, 0x3d, 0x6e,
@@ -535,78 +525,12 @@ static object_data some = {
     sizeof(some_data),
 };
 
-static int write_object_data(char *file, void *data, size_t len)
-{
-    git_file fd;
-    int ret;
-
-    if ((fd = gitfo_creat(file, 0664)) < 0)
-        return -1;
-    ret = gitfo_write(fd, data, len);
-    gitfo_close(fd);
-
-    return ret;
-}
-
-static int write_object_files(object_data *d)
-{
-    if (gitfo_mkdir(odb_dir, 0755) < 0) {
-        if (errno == EEXIST) {
-            fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir);
-            return -1;
-        }
-        fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir);
-        return -1;
-    }
-
-    if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
-        fprintf(stderr, "can't make object directory \"%s\"\n", d->dir);
-        return -1;
-    }
-    if (write_object_data(d->file, d->bytes, d->blen) < 0) {
-        fprintf(stderr, "can't write object file \"%s\"\n", d->file);
-        return -1;
-    }
-
-    return 0;
-}
-
-static int remove_object_files(object_data *d)
-{
-    if (gitfo_unlink(d->file) < 0) {
-        fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
-        return -1;
-    }
-    if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
-        fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
-        return -1;
-    }
-
-    if (gitfo_rmdir(odb_dir) < 0) {
-        fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir);
-        return -1;
-    }
-
-    return 0;
-}
-
-static int cmp_objects(git_obj *o, object_data *d)
-{
-    if (o->type != git_obj_string_to_type(d->type))
-        return -1;
-    if (o->len != d->dlen)
-        return -1;
-    if ((o->len > 0) && (memcmp(o->data, d->data, o->len) != 0))
-        return -1;
-    return 0;
-}
-
 BEGIN_TEST(read_loose_commit)
     git_odb *db;
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&commit));
+    must_pass(write_object_files(odb_dir, &commit));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, commit.id));
 
@@ -615,7 +539,7 @@ BEGIN_TEST(read_loose_commit)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&commit));
+    must_pass(remove_object_files(odb_dir, &commit));
 END_TEST
 
 BEGIN_TEST(read_loose_tree)
@@ -623,7 +547,7 @@ BEGIN_TEST(read_loose_tree)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&tree));
+    must_pass(write_object_files(odb_dir, &tree));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, tree.id));
 
@@ -632,7 +556,7 @@ BEGIN_TEST(read_loose_tree)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&tree));
+    must_pass(remove_object_files(odb_dir, &tree));
 END_TEST
 
 BEGIN_TEST(read_loose_tag)
@@ -640,7 +564,7 @@ BEGIN_TEST(read_loose_tag)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&tag));
+    must_pass(write_object_files(odb_dir, &tag));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, tag.id));
 
@@ -649,7 +573,7 @@ BEGIN_TEST(read_loose_tag)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&tag));
+    must_pass(remove_object_files(odb_dir, &tag));
 END_TEST
 
 BEGIN_TEST(read_loose_zero)
@@ -657,7 +581,7 @@ BEGIN_TEST(read_loose_zero)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&zero));
+    must_pass(write_object_files(odb_dir, &zero));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, zero.id));
 
@@ -666,7 +590,7 @@ BEGIN_TEST(read_loose_zero)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&zero));
+    must_pass(remove_object_files(odb_dir, &zero));
 END_TEST
 
 BEGIN_TEST(read_loose_one)
@@ -674,7 +598,7 @@ BEGIN_TEST(read_loose_one)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&one));
+    must_pass(write_object_files(odb_dir, &one));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, one.id));
 
@@ -683,7 +607,7 @@ BEGIN_TEST(read_loose_one)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&one));
+    must_pass(remove_object_files(odb_dir, &one));
 END_TEST
 
 BEGIN_TEST(read_loose_two)
@@ -691,7 +615,7 @@ BEGIN_TEST(read_loose_two)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&two));
+    must_pass(write_object_files(odb_dir, &two));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, two.id));
 
@@ -700,7 +624,7 @@ BEGIN_TEST(read_loose_two)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&two));
+    must_pass(remove_object_files(odb_dir, &two));
 END_TEST
 
 BEGIN_TEST(read_loose_some)
@@ -708,7 +632,7 @@ BEGIN_TEST(read_loose_some)
     git_oid id;
     git_obj obj;
 
-    must_pass(write_object_files(&some));
+    must_pass(write_object_files(odb_dir, &some));
     must_pass(git_odb_open(&db, odb_dir));
     must_pass(git_oid_mkstr(&id, some.id));
 
@@ -717,6 +641,6 @@ BEGIN_TEST(read_loose_some)
 
     git_obj_close(&obj);
     git_odb_close(db);
-    must_pass(remove_object_files(&some));
+    must_pass(remove_object_files(odb_dir, &some));
 END_TEST
 
diff --git a/tests/test_helpers.c b/tests/test_helpers.c
new file mode 100644
index 0000000..edc21d0
--- /dev/null
+++ b/tests/test_helpers.c
@@ -0,0 +1,93 @@
+/*
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2,
+ * as published by the Free Software Foundation.
+ *
+ * In addition to the permissions in the GNU General Public License,
+ * the authors give you unlimited permission to link the compiled
+ * version of this file into combinations with other programs,
+ * and to distribute those combinations without any restriction
+ * coming from the use of this file.  (The General Public License
+ * restrictions do apply in other respects; for example, they cover
+ * modification of the file, and distribution when not linked into
+ * a combined executable.)
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "test_helpers.h"
+#include "fileops.h"
+
+int write_object_data(char *file, void *data, size_t len)
+{
+    git_file fd;
+    int ret;
+
+    if ((fd = gitfo_creat(file, S_IREAD | S_IWRITE)) < 0)
+        return -1;
+    ret = gitfo_write(fd, data, len);
+    gitfo_close(fd);
+
+    return ret;
+}
+
+int write_object_files(const char *odb_dir, object_data *d)
+{
+    if (gitfo_mkdir(odb_dir, 0755) < 0) {
+        if (errno == EEXIST) {
+            fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir);
+            return -1;
+        }
+        fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir);
+        return -1;
+    }
+
+    if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
+        fprintf(stderr, "can't make object directory \"%s\"\n", d->dir);
+        return -1;
+    }
+    if (write_object_data(d->file, d->bytes, d->blen) < 0) {
+        fprintf(stderr, "can't write object file \"%s\"\n", d->file);
+        return -1;
+    }
+
+    return 0;
+}
+
+int remove_object_files(const char *odb_dir, object_data *d)
+{
+    if (gitfo_unlink(d->file) < 0) {
+        fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
+        return -1;
+    }
+    if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
+        fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
+        return -1;
+    }
+
+    if (gitfo_rmdir(odb_dir) < 0) {
+        fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir);
+        return -1;
+    }
+
+    return 0;
+}
+
+int cmp_objects(git_obj *o, object_data *d)
+{
+    if (o->type != git_obj_string_to_type(d->type))
+        return -1;
+    if (o->len != d->dlen)
+        return -1;
+    if ((o->len > 0) && (memcmp(o->data, d->data, o->len) != 0))
+        return -1;
+    return 0;
+}
diff --git a/tests/test_helpers.h b/tests/test_helpers.h
new file mode 100644
index 0000000..2c09181
--- /dev/null
+++ b/tests/test_helpers.h
@@ -0,0 +1,53 @@
+/*
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2,
+ * as published by the Free Software Foundation.
+ *
+ * In addition to the permissions in the GNU General Public License,
+ * the authors give you unlimited permission to link the compiled
+ * version of this file into combinations with other programs,
+ * and to distribute those combinations without any restriction
+ * coming from the use of this file.  (The General Public License
+ * restrictions do apply in other respects; for example, they cover
+ * modification of the file, and distribution when not linked into
+ * a combined executable.)
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDE_test_helpers_h__
+#define INCLUDE_test_helpers_h__
+
+#include "test_lib.h"
+#include <git/odb.h>
+
+
+typedef struct object_data {
+    unsigned char *bytes;  /* (compressed) bytes stored in object store */
+    size_t        blen;    /* length of data in object store            */
+    char          *id;     /* object id (sha1)                          */
+    char          *type;   /* object type                               */
+    char          *dir;    /* object store (fan-out) directory name     */
+    char          *file;   /* object store filename                     */
+    unsigned char *data;   /* (uncompressed) object data                */
+    size_t        dlen;    /* length of (uncompressed) object data      */
+} object_data;
+
+extern int write_object_data(char *file, void *data, size_t len);
+
+extern int write_object_files(const char *odb_dir, object_data *d);
+
+extern int remove_object_files(const char *odb_dir, object_data *d);
+
+extern int cmp_objects(git_obj *o, object_data *d);
+
+#endif
+/* INCLUDE_test_helpers_h__ */