Commit 0cf02ff92d5c08516ff2253f59daad1c4c582d8f

Vicent Marti 2010-05-26T21:23:01

Added t0501-walk (simple test for all revision pool walking modes) Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>

diff --git a/tests/t0501-objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 b/tests/t0501-objects/13/85f264afb75a56a5bec74243be9b367ba4ca08
new file mode 100644
index 0000000..cedb2a2
Binary files /dev/null and b/tests/t0501-objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 differ
diff --git a/tests/t0501-objects/18/1037049a54a1eb5fab404658a3a250b44335d7 b/tests/t0501-objects/18/1037049a54a1eb5fab404658a3a250b44335d7
new file mode 100644
index 0000000..93a16f1
Binary files /dev/null and b/tests/t0501-objects/18/1037049a54a1eb5fab404658a3a250b44335d7 differ
diff --git a/tests/t0501-objects/18/10dff58d8a660512d4832e740f692884338ccd b/tests/t0501-objects/18/10dff58d8a660512d4832e740f692884338ccd
new file mode 100644
index 0000000..ba0bfb3
Binary files /dev/null and b/tests/t0501-objects/18/10dff58d8a660512d4832e740f692884338ccd differ
diff --git a/tests/t0501-objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 b/tests/t0501-objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057
new file mode 100644
index 0000000..7ca4cee
Binary files /dev/null and b/tests/t0501-objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 differ
diff --git a/tests/t0501-objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 b/tests/t0501-objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045
new file mode 100644
index 0000000..8953b6c
--- /dev/null
+++ b/tests/t0501-objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045
@@ -0,0 +1,2 @@
+xQ
+0D)6ͦ "xO-FbEo0Ǥ,ske[Pn8R,EpD?g}^3<GhYK8ЖDA);gݧjp4-r;sGA4ۺ=(in7IKFE
\ No newline at end of file
diff --git a/tests/t0501-objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 b/tests/t0501-objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644
new file mode 100644
index 0000000..c1f22c5
--- /dev/null
+++ b/tests/t0501-objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644
@@ -0,0 +1,2 @@
+x	1ENi@k2 "X$YW0YcÅszMD08!sXgd::@X0Pw"F/RUzmZZV}|/o5I!1z:vUim}/>
+F-
\ No newline at end of file
diff --git a/tests/t0501-objects/75/057dd4114e74cca1d750d0aee1647c903cb60a b/tests/t0501-objects/75/057dd4114e74cca1d750d0aee1647c903cb60a
new file mode 100644
index 0000000..2ef4faa
Binary files /dev/null and b/tests/t0501-objects/75/057dd4114e74cca1d750d0aee1647c903cb60a differ
diff --git a/tests/t0501-objects/81/4889a078c031f61ed08ab5fa863aea9314344d b/tests/t0501-objects/81/4889a078c031f61ed08ab5fa863aea9314344d
new file mode 100644
index 0000000..2f9b6b6
Binary files /dev/null and b/tests/t0501-objects/81/4889a078c031f61ed08ab5fa863aea9314344d differ
diff --git a/tests/t0501-objects/84/96071c1b46c854b31185ea97743be6a8774479 b/tests/t0501-objects/84/96071c1b46c854b31185ea97743be6a8774479
new file mode 100644
index 0000000..5df58dd
Binary files /dev/null and b/tests/t0501-objects/84/96071c1b46c854b31185ea97743be6a8774479 differ
diff --git a/tests/t0501-objects/9f/d738e8f7967c078dceed8190330fc8648ee56a b/tests/t0501-objects/9f/d738e8f7967c078dceed8190330fc8648ee56a
new file mode 100644
index 0000000..a796124
--- /dev/null
+++ b/tests/t0501-objects/9f/d738e8f7967c078dceed8190330fc8648ee56a
@@ -0,0 +1,3 @@
+x[
+0E*fդ "W0-Ft݁pS[Yx^
+Db	CLhut}8X*4ZsYUA
X3RM) s6輢Mរ&Jm;}<\@ޏpĀv?jۺL?H
\ No newline at end of file
diff --git a/tests/t0501-objects/a4/a7dce85cf63874e984719f4fdd239f5145052f b/tests/t0501-objects/a4/a7dce85cf63874e984719f4fdd239f5145052f
new file mode 100644
index 0000000..f858869
--- /dev/null
+++ b/tests/t0501-objects/a4/a7dce85cf63874e984719f4fdd239f5145052f
@@ -0,0 +1,2 @@
+x;j1Dmdǎ|M3`V{>QvL0I?!4Z=!צ8F!rsQy9]$D&l6A>jFWҵIKNiZ%S
+	U~̽>'	w
[DGڡQ-M>dO}\8g_ШoYr
\ No newline at end of file
diff --git a/tests/t0501-objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd b/tests/t0501-objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd
new file mode 100644
index 0000000..d0d7e73
Binary files /dev/null and b/tests/t0501-objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd differ
diff --git a/tests/t0501-objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 b/tests/t0501-objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6
new file mode 100644
index 0000000..18a7f61
Binary files /dev/null and b/tests/t0501-objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 differ
diff --git a/tests/t0501-objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644 b/tests/t0501-objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644
new file mode 100644
index 0000000..0817229
--- /dev/null
+++ b/tests/t0501-objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644
@@ -0,0 +1,3 @@
+xKj1D)zUB-0uV9<#+W<J&8/seȕKJS
+Rv{QrYQN$H\E=6X5K Fr)(dCΆjs}9c-w8o\rI:
+l}FW$DsǣٚOWe]V8-Ý"U
\ No newline at end of file
diff --git a/tests/t0501-objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd b/tests/t0501-objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd
new file mode 100644
index 0000000..75f541f
--- /dev/null
+++ b/tests/t0501-objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd
@@ -0,0 +1,3 @@
+xQ
+0D)ʦI<'lR+FjEo0<xha ]șXUlPF)z4y,\r	'S-mI4
+Xh&F}n+\Y-p|鷜oUz;-alt{?I,:oRcHK
\ No newline at end of file
diff --git a/tests/t0501-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/tests/t0501-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
new file mode 100644
index 0000000..7112238
Binary files /dev/null and b/tests/t0501-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 differ
diff --git a/tests/t0501-objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 b/tests/t0501-objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1
new file mode 100644
index 0000000..0377096
Binary files /dev/null and b/tests/t0501-objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 differ
diff --git a/tests/t0501-objects/fa/49b077972391ad58037050f2a75f74e3671e92 b/tests/t0501-objects/fa/49b077972391ad58037050f2a75f74e3671e92
new file mode 100644
index 0000000..112998d
Binary files /dev/null and b/tests/t0501-objects/fa/49b077972391ad58037050f2a75f74e3671e92 differ
diff --git a/tests/t0501-objects/fd/093bff70906175335656e6ce6ae05783708765 b/tests/t0501-objects/fd/093bff70906175335656e6ce6ae05783708765
new file mode 100644
index 0000000..12bf5f3
Binary files /dev/null and b/tests/t0501-objects/fd/093bff70906175335656e6ce6ae05783708765 differ
diff --git a/tests/t0501-objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx b/tests/t0501-objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx
new file mode 100644
index 0000000..94c3c71
Binary files /dev/null and b/tests/t0501-objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx differ
diff --git a/tests/t0501-objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack b/tests/t0501-objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack
new file mode 100644
index 0000000..74c7fe4
Binary files /dev/null and b/tests/t0501-objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack differ
diff --git a/tests/t0501-walk.c b/tests/t0501-walk.c
new file mode 100644
index 0000000..755a4f7
--- /dev/null
+++ b/tests/t0501-walk.c
@@ -0,0 +1,77 @@
+#include "test_lib.h"
+#include "test_helpers.h"
+#include "commit.h"
+
+#include <git/odb.h>
+#include <git/commit.h>
+#include <git/revwalk.h>
+
+static const char *odb_dir = "../t0501-objects";
+/*
+    $ git log --oneline --graph --decorate
+    *   a4a7dce (HEAD, br2) Merge branch 'master' into br2
+    |\
+    | * 9fd738e (master) a fourth commit
+    | * 4a202b3 a third commit
+    * | c47800c branch commit one
+    |/
+    * 5b5b025 another commit
+    * 8496071 testing
+*/
+static const char *commit_head = "a4a7dce85cf63874e984719f4fdd239f5145052f";
+
+static const char *commit_ids[] = {
+    "a4a7dce85cf63874e984719f4fdd239f5145052f", // 0
+    "9fd738e8f7967c078dceed8190330fc8648ee56a", // 1
+    "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", // 2
+    "c47800c7266a2be04c571c04d5a6614691ea99bd", // 3
+    "8496071c1b46c854b31185ea97743be6a8774479", // 4
+    "5b5b025afb0b4c913b4c338a42934a3863bf3644", // 5
+};
+
+static const int commit_sorting_topo[] = {0, 1, 2, 3, 5, 4};
+static const int commit_sorting_time[] = {0, 3, 1, 2, 5, 4};
+static const int commit_sorting_topo_reverse[] = {4, 5, 3, 2, 1, 0};
+static const int commit_sorting_time_reverse[] = {4, 5, 2, 1, 3, 0};
+static const int commit_sorting_topo_time[] = {0};
+
+BEGIN_TEST(simple_walk_test)
+    git_odb *db;
+    git_oid id;
+    git_revpool *pool;
+    git_commit *head = NULL;
+
+    must_pass(git_odb_open(&db, odb_dir));
+
+    pool = gitrp_alloc(db);
+    must_be_true(pool != NULL);
+
+    git_oid_mkstr(&id, commit_head);
+
+    head = git_commit_parse(pool, &id);
+    must_be_true(head != NULL);
+
+    gitrp_push(pool, head);
+
+#define TEST_WALK(sort_flags, result_array) {\
+    char oid[40]; int i = 0;\
+    git_commit *commit = NULL;\
+    gitrp_sorting(pool, sort_flags);\
+    while ((commit = gitrp_next(pool)) != NULL) {\
+        git_oid_fmt(oid, &commit->object.id);\
+        must_be_true(memcmp(oid, commit_ids[result_array[i++]], 40) == 0);\
+    }\
+    must_be_true(i == sizeof(result_array)/sizeof(int));\
+    gitrp_reset(pool);\
+}
+
+    TEST_WALK(GIT_RPSORT_TIME, commit_sorting_time);
+    TEST_WALK(GIT_RPSORT_TOPOLOGICAL, commit_sorting_topo);
+    TEST_WALK(GIT_RPSORT_TIME | GIT_RPSORT_REVERSE, commit_sorting_time_reverse);
+    TEST_WALK(GIT_RPSORT_TOPOLOGICAL | GIT_RPSORT_REVERSE, commit_sorting_topo_reverse);
+
+#undef TEST_WALK
+
+    gitrp_free(pool);
+    git_odb_close(db);
+END_TEST