summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/libgit2/odb/foreach.c10
-rw-r--r--tests/libgit2/odb/loose.c12
-rw-r--r--tests/libgit2/odb/pack_data_one_sha256.h10
-rw-r--r--tests/libgit2/odb/packed_one.c8
-rw-r--r--tests/libgit2/odb/packed_one_sha256.c75
-rw-r--r--tests/libgit2/odb/sorting.c6
-rw-r--r--tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.idxbin0 -> 1376 bytes
-rw-r--r--tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.packbin0 -> 1406 bytes
8 files changed, 106 insertions, 15 deletions
diff --git a/tests/libgit2/odb/foreach.c b/tests/libgit2/odb/foreach.c
index 98b5d80b7..5e4dae41b 100644
--- a/tests/libgit2/odb/foreach.c
+++ b/tests/libgit2/odb/foreach.c
@@ -52,7 +52,15 @@ void test_odb_foreach__one_pack(void)
int nobj = 0;
cl_git_pass(git_odb_new(&_odb, NULL));
- cl_git_pass(git_odb_backend_one_pack(&backend, cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")));
+ cl_git_pass(git_odb_backend_one_pack(
+ &backend,
+ cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")
+
+#ifdef GIT_EXPERIMENTAL_SHA256
+, NULL
+#endif
+
+ ));
cl_git_pass(git_odb_add_backend(_odb, backend, 1));
_repo = NULL;
diff --git a/tests/libgit2/odb/loose.c b/tests/libgit2/odb/loose.c
index 93895deb5..9651ebab6 100644
--- a/tests/libgit2/odb/loose.c
+++ b/tests/libgit2/odb/loose.c
@@ -188,18 +188,6 @@ void test_odb_loose__exists_sha256(void)
#endif
}
-void test_odb_loose__zzz(void)
-{
- write_object_files(&one_sha256);
- write_object_files(&commit_sha256);
- write_object_files(&tree_sha256);
- write_object_files(&tag_sha256);
- write_object_files(&zero_sha256);
- write_object_files(&two_sha256);
- write_object_files(&some_sha256);
- abort();
-}
-
void test_odb_loose__simple_reads_sha1(void)
{
test_read_object(&commit);
diff --git a/tests/libgit2/odb/pack_data_one_sha256.h b/tests/libgit2/odb/pack_data_one_sha256.h
new file mode 100644
index 000000000..4b9282a40
--- /dev/null
+++ b/tests/libgit2/odb/pack_data_one_sha256.h
@@ -0,0 +1,10 @@
+/* Just a few to make sure it's working, the rest is tested already */
+static const char *packed_objects_one_sha256[] = {
+ "083c2b8b445640d171e7aa667b0b32007006f786711032ebb82931cca69cc15b",
+ "34a4854b5426f92460b4ae35e6d79746be66c38bffd6ef3bc4f053ed78a36ba4",
+ "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
+ "4c0d52d180c61d01ce1a91dec5ee58f0cbe65fd59433aea803ab927965493fd7",
+ "a2a430fb63b294f868af4ef6ccc9c3e8256e370859ce578a23837ac85337f562",
+ "f535d7595d5d0e5e530b5deb34542c96491fea300a1318036b605306548cb225",
+ "f8625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b"
+};
diff --git a/tests/libgit2/odb/packed_one.c b/tests/libgit2/odb/packed_one.c
index 777b54b98..8822585c6 100644
--- a/tests/libgit2/odb/packed_one.c
+++ b/tests/libgit2/odb/packed_one.c
@@ -11,7 +11,13 @@ void test_odb_packed_one__initialize(void)
git_odb_backend *backend = NULL;
cl_git_pass(git_odb_new(&_odb, NULL));
- cl_git_pass(git_odb_backend_one_pack(&backend, cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")));
+ cl_git_pass(git_odb_backend_one_pack(
+ &backend,
+ cl_fixture("testrepo.git/objects/pack/pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")
+#ifdef GIT_EXPERIMENTAL_SHA256
+ , NULL
+#endif
+ ));
cl_git_pass(git_odb_add_backend(_odb, backend, 1));
}
diff --git a/tests/libgit2/odb/packed_one_sha256.c b/tests/libgit2/odb/packed_one_sha256.c
new file mode 100644
index 000000000..6cebc321b
--- /dev/null
+++ b/tests/libgit2/odb/packed_one_sha256.c
@@ -0,0 +1,75 @@
+#include "clar_libgit2.h"
+#include "git2/odb_backend.h"
+
+#include "pack_data_one_sha256.h"
+#include "pack.h"
+
+#ifdef GIT_EXPERIMENTAL_SHA256
+static git_odb *_odb;
+#endif
+
+void test_odb_packed_one_sha256__initialize(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ git_odb_backend *backend = NULL;
+ git_odb_options odb_opts = GIT_ODB_OPTIONS_INIT;
+ git_odb_backend_pack_options backend_opts = GIT_ODB_BACKEND_PACK_OPTIONS_INIT;
+
+ odb_opts.oid_type = GIT_OID_SHA256;
+ backend_opts.oid_type = GIT_OID_SHA256;
+
+ cl_git_pass(git_odb_new(&_odb, &odb_opts));
+ cl_git_pass(git_odb_backend_one_pack(&backend, cl_fixture("packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.idx"), &backend_opts));
+ cl_git_pass(git_odb_add_backend(_odb, backend, 1));
+#endif
+}
+
+void test_odb_packed_one_sha256__cleanup(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ git_odb_free(_odb);
+ _odb = NULL;
+#endif
+}
+
+void test_odb_packed_one_sha256__mass_read(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(packed_objects_one_sha256); ++i) {
+ git_oid id;
+ git_odb_object *obj;
+
+ cl_git_pass(git_oid_fromstr(&id, packed_objects_one_sha256[i], GIT_OID_SHA256));
+ cl_assert(git_odb_exists(_odb, &id) == 1);
+ cl_git_pass(git_odb_read(&obj, _odb, &id));
+
+ git_odb_object_free(obj);
+ }
+#endif
+}
+
+void test_odb_packed_one_sha256__read_header_0(void)
+{
+#ifdef GIT_EXPERIMENTAL_SHA256
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(packed_objects_one_sha256); ++i) {
+ git_oid id;
+ git_odb_object *obj;
+ size_t len;
+ git_object_t type;
+
+ cl_git_pass(git_oid_fromstr(&id, packed_objects_one_sha256[i], GIT_OID_SHA256));
+
+ cl_git_pass(git_odb_read(&obj, _odb, &id));
+ cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
+
+ cl_assert(obj->cached.size == len);
+ cl_assert(obj->cached.type == type);
+
+ git_odb_object_free(obj);
+ }
+#endif
+}
diff --git a/tests/libgit2/odb/sorting.c b/tests/libgit2/odb/sorting.c
index 33ce289b5..dc4d615c7 100644
--- a/tests/libgit2/odb/sorting.c
+++ b/tests/libgit2/odb/sorting.c
@@ -82,7 +82,11 @@ void test_odb_sorting__override_default_backend_priority(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, 5));
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, 3));
- git_odb_backend_pack(&packed, "./testrepo.git/objects");
+ git_odb_backend_pack(&packed, "./testrepo.git/objects"
+#ifdef GIT_EXPERIMENTAL_SHA256
+ , NULL
+#endif
+ );
git_odb_backend_loose(&loose, "./testrepo.git/objects", NULL);
cl_git_pass(git_odb_open(&new_odb, cl_fixture("testrepo.git/objects"), NULL));
diff --git a/tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.idx b/tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.idx
new file mode 100644
index 000000000..7aa472cea
--- /dev/null
+++ b/tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.idx
Binary files differ
diff --git a/tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.pack b/tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.pack
new file mode 100644
index 000000000..adbe70ad3
--- /dev/null
+++ b/tests/resources/packfile-sha256/pack-b4a043c0ec5e079e8ac67d823776d752efc71661592db317474a0cf292915f31.pack
Binary files differ