diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/t0020-dirent.c | 36 | ||||
| -rw-r--r-- | tests/t0101-oid.c | 2 | ||||
| -rw-r--r-- | tests/t0102-objtype.c | 26 | ||||
| -rw-r--r-- | tests/t0201-existsloose.c | 4 | ||||
| -rw-r--r-- | tests/t0301-write.c | 73 | ||||
| -rw-r--r-- | tests/test_helpers.c | 88 | ||||
| -rw-r--r-- | tests/test_lib.c | 9 | ||||
| -rw-r--r-- | tests/test_lib.h | 2 |
8 files changed, 119 insertions, 121 deletions
diff --git a/tests/t0020-dirent.c b/tests/t0020-dirent.c index 399b7d5ee..2e6776cae 100644 --- a/tests/t0020-dirent.c +++ b/tests/t0020-dirent.c @@ -123,9 +123,9 @@ BEGIN_TEST(dot) must_pass(setup(&dot)); must_pass(gitfo_dirent(path_buffer, - sizeof(path_buffer), - one_entry, - &dot)); + sizeof(path_buffer), + one_entry, + &dot)); must_pass(check_counts(&dot)); @@ -148,9 +148,9 @@ BEGIN_TEST(sub) must_pass(setup(&sub)); must_pass(gitfo_dirent(path_buffer, - sizeof(path_buffer), - one_entry, - &sub)); + sizeof(path_buffer), + one_entry, + &sub)); must_pass(check_counts(&sub)); @@ -167,9 +167,9 @@ BEGIN_TEST(sub_slash) must_pass(setup(&sub_slash)); must_pass(gitfo_dirent(path_buffer, - sizeof(path_buffer), - one_entry, - &sub_slash)); + sizeof(path_buffer), + one_entry, + &sub_slash)); must_pass(check_counts(&sub_slash)); @@ -196,17 +196,17 @@ BEGIN_TEST(empty) must_pass(setup(&empty)); must_pass(gitfo_dirent(path_buffer, - sizeof(path_buffer), - one_entry, - &empty)); + sizeof(path_buffer), + one_entry, + &empty)); must_pass(check_counts(&empty)); /* make sure callback not called */ must_pass(gitfo_dirent(path_buffer, - sizeof(path_buffer), - dont_call_me, - &empty)); + sizeof(path_buffer), + dont_call_me, + &empty)); must_pass(knockdown(&empty)); END_TEST @@ -229,9 +229,9 @@ BEGIN_TEST(odd) must_pass(setup(&odd)); must_pass(gitfo_dirent(path_buffer, - sizeof(path_buffer), - one_entry, - &odd)); + sizeof(path_buffer), + one_entry, + &odd)); must_pass(check_counts(&odd)); diff --git a/tests/t0101-oid.c b/tests/t0101-oid.c index 16ba02bda..c867e4ff4 100644 --- a/tests/t0101-oid.c +++ b/tests/t0101-oid.c @@ -50,7 +50,7 @@ BEGIN_TEST(invalid_string_all_chars) test_die("line %d: must accept '%s'", __LINE__, in); if (memcmp(out.id, exp, sizeof(out.id))) test_die("line %d: bad parse of '%s', %x != %x", - __LINE__, in, exp[19], out.id[19]); + __LINE__, in, exp[19], out.id[19]); } else if (!git_oid_mkstr(&out, in)) test_die("line %d: must not accept '%s'", __LINE__, in); } diff --git a/tests/t0102-objtype.c b/tests/t0102-objtype.c index 425b3cd58..b42f3f731 100644 --- a/tests/t0102-objtype.c +++ b/tests/t0102-objtype.c @@ -3,19 +3,19 @@ #include <git/odb.h> BEGIN_TEST(type_to_string) - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BAD),"")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT1),"")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_COMMIT),"commit")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TREE),"tree")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BLOB),"blob")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TAG),"tag")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT2),"")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_OFS_DELTA),"OFS_DELTA")); - must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_REF_DELTA),"REF_DELTA")); - - must_be_true(!strcmp(git_obj_type_to_string(-2),"")); - must_be_true(!strcmp(git_obj_type_to_string(8),"")); - must_be_true(!strcmp(git_obj_type_to_string(1234),"")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BAD), "")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT1), "")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_COMMIT), "commit")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TREE), "tree")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BLOB), "blob")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TAG), "tag")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT2), "")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_OFS_DELTA), "OFS_DELTA")); + must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_REF_DELTA), "REF_DELTA")); + + must_be_true(!strcmp(git_obj_type_to_string(-2), "")); + must_be_true(!strcmp(git_obj_type_to_string(8), "")); + must_be_true(!strcmp(git_obj_type_to_string(1234), "")); END_TEST BEGIN_TEST(string_to_type) diff --git a/tests/t0201-existsloose.c b/tests/t0201-existsloose.c index 76f293894..0c7fda8e4 100644 --- a/tests/t0201-existsloose.c +++ b/tests/t0201-existsloose.c @@ -37,8 +37,8 @@ BEGIN_TEST(exists_loose_one) must_be_true(git_odb_exists(db, &id)); /* Test for a non-existant object */ - must_pass(git_oid_mkstr(&id2,"8b137891791fe96927ad78e64b0aad7bded08baa")); - must_be_true(0 == git_odb_exists(db, &id2)); + must_pass(git_oid_mkstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa")); + must_be_true(0 == git_odb_exists(db, &id2)); git_odb_close(db); must_pass(remove_object_files(odb_dir, &one)); diff --git a/tests/t0301-write.c b/tests/t0301-write.c index f161ce12c..b4440c0be 100644 --- a/tests/t0301-write.c +++ b/tests/t0301-write.c @@ -351,55 +351,54 @@ static git_obj some_obj = { static int make_odb_dir(void) { - 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; - } - - return 0; + if (gitfo_mkdir(odb_dir, 0755) < 0) { + int err = errno; + fprintf(stderr, "can't make directory \"%s\"", odb_dir); + if (err == EEXIST) + fprintf(stderr, " (already exists)"); + fprintf(stderr, "\n"); + 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; + 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 directory \"%s\"\n", d->dir); + return -1; + } + + if (gitfo_rmdir(odb_dir) < 0) { + fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir); + return -1; + } + + return 0; } static int check_object_files(object_data *d) { - if (gitfo_exists(d->dir) < 0) - return -1; - if (gitfo_exists(d->file) < 0) - return -1; - return 0; + if (gitfo_exists(d->dir) < 0) + return -1; + if (gitfo_exists(d->file) < 0) + return -1; + return 0; } static int cmp_objects(git_obj *o1, git_obj *o2) { - if (o1->type != o2->type) - return -1; - if (o1->len != o2->len) - return -1; - if ((o1->len > 0) && (memcmp(o1->data, o2->data, o1->len) != 0)) - return -1; - return 0; + if (o1->type != o2->type) + return -1; + if (o1->len != o2->len) + return -1; + if ((o1->len > 0) && (memcmp(o1->data, o2->data, o1->len) != 0)) + return -1; + return 0; } BEGIN_TEST(write_commit) diff --git a/tests/test_helpers.c b/tests/test_helpers.c index 6829e2c49..46a29b40d 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -29,66 +29,66 @@ int write_object_data(char *file, void *data, size_t len) { - git_file fd; - int ret; + 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); + if ((fd = gitfo_creat(file, S_IREAD | S_IWRITE)) < 0) + return -1; + ret = gitfo_write(fd, data, len); + gitfo_close(fd); - return ret; + 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(odb_dir, 0755) < 0) { + int err = errno; + fprintf(stderr, "can't make directory \"%s\"", odb_dir); + if (err == EEXIST) + fprintf(stderr, " (already exists)"); + fprintf(stderr, "\n"); + 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; - } + 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; + 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_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; - } + if (gitfo_rmdir(odb_dir) < 0) { + fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir); + return -1; + } - return 0; + 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; + 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_lib.c b/tests/test_lib.c index 9475785cf..1ce3f92bf 100644 --- a/tests/test_lib.c +++ b/tests/test_lib.c @@ -26,8 +26,7 @@ #define GIT__NO_HIDE_MALLOC #include "test_lib.h" -struct test_info -{ +struct test_info { struct test_info *next; const char *test_name; const char *file_name; @@ -40,9 +39,9 @@ static struct test_info *current_test; static void show_test_result(const char *status) { fprintf(stderr, "* %-6s %5d: %s\n", - status, - current_test->line_no, - current_test->test_name); + status, + current_test->line_no, + current_test->test_name); } void test_die(const char *fmt, ...) diff --git a/tests/test_lib.h b/tests/test_lib.h index f863bba4d..78f992332 100644 --- a/tests/test_lib.h +++ b/tests/test_lib.h @@ -45,7 +45,7 @@ * @param name C symbol to assign to this test's function. */ #define BEGIN_TEST(name) \ - void testfunc__##name (void) \ + void testfunc__##name(void) \ { \ test_begin(#name, __FILE__, __LINE__); \ { |
