summaryrefslogtreecommitdiff
path: root/tests/pack/indexer.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-12-11 15:02:20 -0800
committerRussell Belfer <rb@github.com>2013-12-11 15:02:20 -0800
commit7697e54176ccab22ed6d4597d7256e9a1e6ff202 (patch)
tree69c1bdd91bcf767b28bd6bc5ea9612084c1a765c /tests/pack/indexer.c
parent8b22d862fb4419b219210027f18c1e97dd36fa8b (diff)
downloadlibgit2-7697e54176ccab22ed6d4597d7256e9a1e6ff202.tar.gz
Test cancel from indexer progress callback
This adds tests that try canceling an indexer operation from within the progress callback. After writing the tests, I wanted to run this under valgrind and had a number of errors in that situation because mmap wasn't working. I added a CMake option to force emulation of mmap and consolidated the Amiga-specific code into that new place (so we don't actually need separate Amiga code now, just have to turn on -DNO_MMAP). Additionally, I made the indexer code propagate error codes more reliably than it used to.
Diffstat (limited to 'tests/pack/indexer.c')
-rw-r--r--tests/pack/indexer.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/pack/indexer.c b/tests/pack/indexer.c
index 07963a9e7..084f8e666 100644
--- a/tests/pack/indexer.c
+++ b/tests/pack/indexer.c
@@ -11,7 +11,7 @@
* This is a packfile with three objects. The second is a delta which
* depends on the third, which is also a delta.
*/
-unsigned char out_of_order_pack[] = {
+static const unsigned char out_of_order_pack[] = {
0x50, 0x41, 0x43, 0x4b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03,
0x32, 0x78, 0x9c, 0x63, 0x67, 0x00, 0x00, 0x00, 0x10, 0x00, 0x08, 0x76,
0xe6, 0x8f, 0xe8, 0x12, 0x9b, 0x54, 0x6b, 0x10, 0x1a, 0xee, 0x95, 0x10,
@@ -23,13 +23,13 @@ unsigned char out_of_order_pack[] = {
0x19, 0x87, 0x58, 0x80, 0x61, 0x09, 0x9a, 0x33, 0xca, 0x7a, 0x31, 0x92,
0x6f, 0xae, 0x66, 0x75
};
-unsigned int out_of_order_pack_len = 112;
+static const unsigned int out_of_order_pack_len = 112;
/*
* Packfile with two objects. The second is a delta against an object
* which is not in the packfile
*/
-unsigned char thin_pack[] = {
+static const unsigned char thin_pack[] = {
0x50, 0x41, 0x43, 0x4b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02,
0x32, 0x78, 0x9c, 0x63, 0x67, 0x00, 0x00, 0x00, 0x10, 0x00, 0x08, 0x76,
0xe6, 0x8f, 0xe8, 0x12, 0x9b, 0x54, 0x6b, 0x10, 0x1a, 0xee, 0x95, 0x10,
@@ -38,18 +38,19 @@ unsigned char thin_pack[] = {
0x3a, 0x6f, 0x39, 0xd1, 0xfe, 0x66, 0x68, 0x6b, 0xa5, 0xe5, 0xe2, 0x97,
0xac, 0x94, 0x6c, 0x76, 0x0b, 0x04
};
-unsigned int thin_pack_len = 78;
+static const unsigned int thin_pack_len = 78;
-unsigned char base_obj[] = { 07, 076 };
-unsigned int base_obj_len = 2;
+static const unsigned char base_obj[] = { 07, 076 };
+static const unsigned int base_obj_len = 2;
void test_pack_indexer__out_of_order(void)
{
- git_indexer *idx;
- git_transfer_progress stats;
+ git_indexer *idx = 0;
+ git_transfer_progress stats = { 0 };
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL, NULL));
- cl_git_pass(git_indexer_append(idx, out_of_order_pack, out_of_order_pack_len, &stats));
+ cl_git_pass(git_indexer_append(
+ idx, out_of_order_pack, out_of_order_pack_len, &stats));
cl_git_pass(git_indexer_commit(idx, &stats));
cl_assert_equal_i(stats.total_objects, 3);
@@ -61,8 +62,8 @@ void test_pack_indexer__out_of_order(void)
void test_pack_indexer__fix_thin(void)
{
- git_indexer *idx;
- git_transfer_progress stats;
+ git_indexer *idx = NULL;
+ git_transfer_progress stats = { 0 };
git_repository *repo;
git_odb *odb;
git_oid id, should_id;