Commit fd29cd13 by Ben Straub

Moved testing resources to clar, and removed old tests directory.

Removed the BUILD_CLAR CMake flag, and updated the readme.
parent 270303ca
......@@ -51,8 +51,7 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
# Build options
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF)
OPTION (BUILD_TESTS "Build Tests" ON)
OPTION (BUILD_CLAR "Build Tests using the Clar suite" OFF)
OPTION (BUILD_CLAR "Build Tests using the Clar suite" ON)
OPTION (TAGS "Generate tags" OFF)
# Platform specific compilation flags
......@@ -128,29 +127,10 @@ INSTALL(DIRECTORY include/git2 DESTINATION ${INSTALL_INC} )
INSTALL(FILES include/git2.h DESTINATION ${INSTALL_INC} )
# Tests
IF (BUILD_TESTS)
SET(TEST_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/tests/resources" CACHE PATH "Path to test resources.")
ADD_DEFINITIONS(-DTEST_RESOURCES=\"${TEST_RESOURCES}\")
INCLUDE_DIRECTORIES(tests)
FILE(GLOB SRC_TEST tests/t??-*.c)
ADD_EXECUTABLE(libgit2_test tests/test_main.c tests/test_lib.c tests/test_helpers.c ${SRC} ${SRC_TEST} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX})
TARGET_LINK_LIBRARIES(libgit2_test ${CMAKE_THREAD_LIBS_INIT})
IF (WIN32)
TARGET_LINK_LIBRARIES(libgit2_test ws2_32)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
TARGET_LINK_LIBRARIES(libgit2_test socket nsl)
ENDIF ()
ENABLE_TESTING()
ADD_TEST(libgit2_test libgit2_test)
ENDIF ()
IF (BUILD_CLAR)
FIND_PACKAGE(PythonInterp REQUIRED)
SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/tests/resources/")
SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/tests-clar/resources/")
SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tests-clar")
ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
......
......@@ -68,8 +68,7 @@ The following CMake variables are declared:
- `INSTALL_LIB`: Where to install libraries to.
- `INSTALL_INC`: Where to install headers to.
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
- `BUILD_TESTS`: Build the libgit2 test suite (defaults to ON)
- `BUILD_CLAR`: Build [Clar](https://github.com/tanoku/clar)-based test suite (defaults to OFF)
- `BUILD_CLAR`: Build [Clar](https://github.com/tanoku/clar)-based test suite (defaults to ON)
- `THREADSAFE`: Build libgit2 with threading support (defaults to OFF)
Language Bindings
......
a4a7dce85cf63874e984719f4fdd239f5145052f
a65fedf39aefe402d3bb6e24df4d4f5fe4547750
4a202b346bb0fb0db7eff3cffeb3c70babbd2045
763d71aadf09a7951596c9746c024e7eece7c7af
e90810b8df3e80c413d903f631643c716887138d
7b4384978d2493e851f9cca7858815fac9b10980
1385f264afb75a56a5bec74243be9b367ba4ca08
b25fa35b38051e4ae45d4222e795f9df2e43f1d1
[core]
repositoryformatversion = 0
filemode = true
bare = true
logallrefupdates = true
[remote "test"]
url = git://github.com/libgit2/libgit2
fetch = +refs/heads/*:refs/remotes/test/*
# pack-refs with: peeled
41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9 refs/heads/packed
5b5b025afb0b4c913b4c338a42934a3863bf3644 refs/heads/packed-test
a4a7dce85cf63874e984719f4fdd239f5145052f
a65fedf39aefe402d3bb6e24df4d4f5fe4547750
763d71aadf09a7951596c9746c024e7eece7c7af
e90810b8df3e80c413d903f631643c716887138d
7b4384978d2493e851f9cca7858815fac9b10980
b25fa35b38051e4ae45d4222e795f9df2e43f1d1
Test sources should be named:
t????-function.c
where ???? is a four digit code. The first two digits classify
the test into a major category; the final two digits indicate the
sequence of the test within that category. The function part of
the test name should give a rough indication of what it does.
Categories
----------
00__: Core library routines based only on the standard library,
and that are essential for everything else to run. E.g.
errno and malloc.
01__: Basic hashing functions, needed to handle the content
addressable store.
02__: Basic object read access.
03__: Basic object writing.
04__: Parsing and loading commit data
05__: Revision walking
06__: Index reading, writing and searching
07__: Tests for the internal hashtable code
08__: Tag reading and writing
09__: Reading tree objects
10__: Symbolic, loose and packed references reading and writing.
11__: SQLite backend
12__: Repository init and opening
13__: Threads, empty as of now
14__: Redis backend
15__: Configuration parsing
16__: Remotes
17__: Buffers
18__: File Status
a4a7dce85cf63874e984719f4fdd239f5145052f
a65fedf39aefe402d3bb6e24df4d4f5fe4547750
763d71aadf09a7951596c9746c024e7eece7c7af
e90810b8df3e80c413d903f631643c716887138d
7b4384978d2493e851f9cca7858815fac9b10980
b25fa35b38051e4ae45d4222e795f9df2e43f1d1
[core]
repositoryformatversion = 0
filemode = true
bare = true
logallrefupdates = true
[remote "test"]
url = git://github.com/libgit2/libgit2
fetch = +refs/heads/*:refs/remotes/test/*
# pack-refs with: peeled
41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9 refs/heads/packed
5b5b025afb0b4c913b4c338a42934a3863bf3644 refs/heads/packed-test
a4a7dce85cf63874e984719f4fdd239f5145052f
a65fedf39aefe402d3bb6e24df4d4f5fe4547750
e90810b8df3e80c413d903f631643c716887138d
7b4384978d2493e851f9cca7858815fac9b10980
b25fa35b38051e4ae45d4222e795f9df2e43f1d1
/*
* 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 "common.h"
#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 = p_creat(file, S_IREAD | S_IWRITE)) < 0)
return -1;
ret = p_write(fd, data, len);
p_close(fd);
return ret;
}
int write_object_files(const char *odb_dir, object_data *d)
{
if (p_mkdir(odb_dir, GIT_OBJECT_DIR_MODE) < 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 ((p_mkdir(d->dir, GIT_OBJECT_DIR_MODE) < 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 (p_unlink(d->file) < 0) {
fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
return -1;
}
if ((p_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
return -1;
}
if (p_rmdir(odb_dir) < 0) {
fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
return -1;
}
return 0;
}
void locate_loose_object(const char *repository_folder, git_object *object, char **out, char **out_folder)
{
static const char *objects_folder = "objects/";
char *ptr, *full_path, *top_folder;
int path_length, objects_length;
assert(repository_folder && object);
objects_length = strlen(objects_folder);
path_length = strlen(repository_folder);
ptr = full_path = git__malloc(path_length + objects_length + GIT_OID_HEXSZ + 3);
strcpy(ptr, repository_folder);
strcpy(ptr + path_length, objects_folder);
ptr = top_folder = ptr + path_length + objects_length;
*ptr++ = '/';
git_oid_pathfmt(ptr, git_object_id(object));
ptr += GIT_OID_HEXSZ + 1;
*ptr = 0;
*out = full_path;
if (out_folder)
*out_folder = top_folder;
}
int loose_object_mode(const char *repository_folder, git_object *object)
{
char *object_path;
struct stat st;
locate_loose_object(repository_folder, object, &object_path, NULL);
if (p_stat(object_path, &st) < 0)
return 0;
free(object_path);
return st.st_mode;
}
int loose_object_dir_mode(const char *repository_folder, git_object *object)
{
char *object_path;
size_t pos;
struct stat st;
locate_loose_object(repository_folder, object, &object_path, NULL);
pos = strlen(object_path);
while (pos--) {
if (object_path[pos] == '/') {
object_path[pos] = 0;
break;
}
}
if (p_stat(object_path, &st) < 0)
return 0;
free(object_path);
return st.st_mode;
}
int remove_loose_object(const char *repository_folder, git_object *object)
{
char *full_path, *top_folder;
locate_loose_object(repository_folder, object, &full_path, &top_folder);
if (p_unlink(full_path) < 0) {
fprintf(stderr, "can't delete object file \"%s\"\n", full_path);
return -1;
}
*top_folder = 0;
if ((p_rmdir(full_path) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", full_path);
return -1;
}
git__free(full_path);
return GIT_SUCCESS;
}
int cmp_objects(git_rawobj *o, object_data *d)
{
if (o->type != git_object_string2type(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;
}
int copy_file(const char *src, const char *dst)
{
git_buf source_buf = GIT_BUF_INIT;
git_file dst_fd;
int error = GIT_ERROR;
if (git_futils_readbuffer(&source_buf, src) < GIT_SUCCESS)
return GIT_ENOTFOUND;
dst_fd = git_futils_creat_withpath(dst, 0777, 0666);
if (dst_fd < 0)
goto cleanup;
error = p_write(dst_fd, source_buf.ptr, source_buf.size);
cleanup:
git_buf_free(&source_buf);
p_close(dst_fd);
return error;
}
int cmp_files(const char *a, const char *b)
{
git_buf buf_a = GIT_BUF_INIT;
git_buf buf_b = GIT_BUF_INIT;
int error = GIT_ERROR;
if (git_futils_readbuffer(&buf_a, a) < GIT_SUCCESS)
return GIT_ERROR;
if (git_futils_readbuffer(&buf_b, b) < GIT_SUCCESS) {
git_buf_free(&buf_a);
return GIT_ERROR;
}
if (buf_a.size == buf_b.size && !memcmp(buf_a.ptr, buf_b.ptr, buf_a.size))
error = GIT_SUCCESS;
git_buf_free(&buf_a);
git_buf_free(&buf_b);
return error;
}
typedef struct {
git_buf src;
size_t src_baselen;
git_buf dst;
size_t dst_baselen;
} copydir_data;
static int copy_filesystem_element_recurs(void *_data, git_buf *source)
{
copydir_data *data = (copydir_data *)_data;
git_buf_truncate(&data->dst, data->dst_baselen);
git_buf_puts(&data->dst, source->ptr + data->src_baselen);
if (git_path_isdir(source->ptr) == GIT_SUCCESS)
return git_path_direach(source, copy_filesystem_element_recurs, _data);
else
return copy_file(source->ptr, data->dst.ptr);
}
int copydir_recurs(
const char *source_directory_path,
const char *destination_directory_path)
{
int error;
copydir_data data = { GIT_BUF_INIT, 0, GIT_BUF_INIT, 0 };
/* Source has to exist, Destination hast to _not_ exist */
if (git_path_isdir(source_directory_path) != GIT_SUCCESS ||
git_path_isdir(destination_directory_path) == GIT_SUCCESS)
return GIT_EINVALIDPATH;
git_buf_joinpath(&data.src, source_directory_path, "");
data.src_baselen = data.src.size;
git_buf_joinpath(&data.dst, destination_directory_path, "");
data.dst_baselen = data.dst.size;
error = copy_filesystem_element_recurs(&data, &data.src);
git_buf_free(&data.src);
git_buf_free(&data.dst);
return error;
}
int open_temp_repo(git_repository **repo, const char *path)
{
int error;
if ((error = copydir_recurs(path, TEMP_REPO_FOLDER)) < GIT_SUCCESS)
return error;
return git_repository_open(repo, TEMP_REPO_FOLDER);
}
void close_temp_repo(git_repository *repo)
{
git_repository_free(repo);
if (git_futils_rmdir_r(TEMP_REPO_FOLDER, 1) < GIT_SUCCESS) {
printf("\nFailed to remove temporary folder. Aborting test suite.\n");
exit(-1);
}
}
typedef struct {
const char *filename;
size_t filename_len;
} remove_data;
static int remove_placeholders_recurs(void *_data, git_buf *path)
{
remove_data *data = (remove_data *)_data;
size_t pathlen;
if (!git_path_isdir(path->ptr))
return git_path_direach(path, remove_placeholders_recurs, data);
pathlen = path->size;
if (pathlen < data->filename_len)
return GIT_SUCCESS;
/* if path ends in '/'+filename (or equals filename) */
if (!strcmp(data->filename, path->ptr + pathlen - data->filename_len) &&
(pathlen == data->filename_len ||
path->ptr[pathlen - data->filename_len - 1] == '/'))
return p_unlink(path->ptr);
return GIT_SUCCESS;
}
int remove_placeholders(const char *directory_path, const char *filename)
{
int error;
remove_data data;
git_buf buffer = GIT_BUF_INIT;
if (git_path_isdir(directory_path))
return GIT_EINVALIDPATH;
if ((error = git_buf_sets(&buffer, directory_path)) < GIT_SUCCESS)
return error;
data.filename = filename;
data.filename_len = strlen(filename);
error = remove_placeholders_recurs(&data, &buffer);
git_buf_free(&buffer);
return error;
}
/*
* 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 <git2.h>
#include "odb.h"
#define TEST_REPOSITORY_NAME "testrepo.git"
#define REPOSITORY_FOLDER TEST_RESOURCES "/" TEST_REPOSITORY_NAME "/"
#define ODB_FOLDER (REPOSITORY_FOLDER "objects/")
#define TEST_INDEX_PATH (REPOSITORY_FOLDER "index")
#define TEST_INDEX2_PATH (TEST_RESOURCES "/gitgit.index")
#define TEST_INDEXBIG_PATH (TEST_RESOURCES "/big.index")
#define EMPTY_REPOSITORY_FOLDER TEST_RESOURCES "/empty_standard_repo/.gitted/"
#define TEMP_FOLDER ""
#define TEMP_REPO_FOLDER TEMP_FOLDER TEST_REPOSITORY_NAME "/"
#define TEMP_REPO_FOLDER_NS TEMP_FOLDER TEST_REPOSITORY_NAME
#define TEST_STD_REPO_FOLDER TEMP_REPO_FOLDER ".git/"
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_rawobj *o, object_data *d);
extern void locate_loose_object(const char *odb_dir, git_object *object, char **out, char **out_folder);
extern int loose_object_mode(const char *odb_dir, git_object *object);
extern int loose_object_dir_mode(const char *odb_dir, git_object *object);
extern int remove_loose_object(const char *odb_dir, git_object *object);
extern int cmp_files(const char *a, const char *b);
extern int copy_file(const char *source, const char *dest);
extern int rmdir_recurs(const char *directory_path);
extern int copydir_recurs(const char *source_directory_path, const char *destination_directory_path);
extern int remove_placeholders(const char *directory_path, const char *filename);
extern int open_temp_repo(git_repository **repo, const char *path);
extern void close_temp_repo(git_repository *repo);
#endif
/* INCLUDE_test_helpers_h__ */
#include <assert.h>
#include <setjmp.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "test_lib.h"
#define DO_ALLOC(TYPE) ((TYPE*) malloc(sizeof(TYPE)))
#define GIT_MAX_TEST_CASES 64
struct git_test {
char *name;
char *message;
char *failed_pos;
char *description;
char *error_message;
git_testfunc function;
unsigned failed:1, ran:1;
jmp_buf *jump;
};
struct git_testsuite {
char *name;
int count, fail_count;
git_test *list[GIT_MAX_TEST_CASES];
};
static void test_free(git_test *t)
{
if (t) {
free(t->name);
free(t->description);
free(t->failed_pos);
free(t->message);
free(t->error_message);
free(t);
}
}
static void test_run(git_test *tc)
{
jmp_buf buf;
tc->jump = &buf;
if (setjmp(buf) == 0) {
tc->ran = 1;
(tc->function)(tc);
}
tc->jump = 0;
}
static git_test *create_test(git_testfunc function)
{
git_test *t = DO_ALLOC(git_test);
memset(t, 0x0, sizeof(git_test));
t->function = function;
return t;
}
void git_test__init(git_test *t, const char *name, const char *description)
{
t->name = strdup(name);
t->description = strdup(description);
}
/*-------------------------------------------------------------------------*
* Public assert methods
*-------------------------------------------------------------------------*/
static void fail_test(git_test *tc, const char *file, int line, const char *message)
{
char buf[1024];
const char *last_error = git_lasterror();
snprintf(buf, 1024, "%s:%d", file, line);
tc->failed = 1;
tc->message = strdup(message);
tc->failed_pos = strdup(buf);
if (last_error)
tc->error_message = strdup(last_error);
if (tc->jump != 0)
longjmp(*(tc->jump), 0);
}
void git_test__fail(git_test *tc, const char *file, int line, const char *message)
{
fail_test(tc, file, line, message);
}
void git_test__assert(git_test *tc, const char *file, int line, const char *message, int condition)
{
if (condition == 0)
fail_test(tc, file, line, message);
}
void git_test__assert_pass(git_test *tc, const char *file, int line, const char *message, int ret_value)
{
if (ret_value < 0)
fail_test(tc, file, line, message);
}
/*-------------------------------------------------------------------------*
* Test Suite
*-------------------------------------------------------------------------*/
static void testsuite_init(git_testsuite *ts)
{
ts->count = 0;
ts->fail_count = 0;
memset(ts->list, 0, sizeof(ts->list));
}
git_testsuite *git_testsuite_new(const char *name)
{
git_testsuite *ts = DO_ALLOC(git_testsuite);
testsuite_init(ts);
ts->name = strdup(name);
return ts;
}
static void free_suite(git_testsuite *ts)
{
unsigned int n;
for (n = 0; n < GIT_MAX_TEST_CASES; n++)
if (ts->list[n])
test_free(ts->list[n]);
free(ts->name);
free(ts);
}
void git_testsuite_add(git_testsuite *ts, git_testfunc test)
{
assert(ts->count < GIT_MAX_TEST_CASES);
ts->list[ts->count++] = create_test(test);
}
static void print_details(git_testsuite *ts)
{
int i;
int failCount = 0;
if (ts->fail_count == 0) {
const char *testWord = ts->count == 1 ? "test" : "tests";
printf("OK (%d %s)\n", ts->count, testWord);
} else {
printf("Failed (%d failures):\n", ts->fail_count);
for (i = 0 ; i < ts->count ; ++i) {
git_test *tc = ts->list[i];
if (tc->failed) {
failCount++;
printf(" %d) \"%s\" [test %s @ %s]\n\t%s\n",
failCount, tc->description, tc->name, tc->failed_pos, tc->message);
if (tc->error_message)
printf("\tError: %s\n", tc->error_message);
}
}
}
}
int git_testsuite_run(git_testsuite *ts)
{
int i, fail_count;
printf("Suite \"%s\": ", ts->name);
for (i = 0 ; i < ts->count ; ++i) {
git_test *tc = ts->list[i];
test_run(tc);
if (tc->failed) {
ts->fail_count++;
putchar('F');
} else
putchar('.');
fflush(stdout);
}
printf("\n ");
print_details(ts);
fail_count = ts->fail_count;
free_suite(ts);
return fail_count;
}
#ifndef __LIBGIT2_TEST_H__
#define __LIBGIT2_TEST_H__
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include <git2.h>
#define DECLARE_SUITE(SNAME) extern git_testsuite *libgit2_suite_##SNAME(void)
#define SUITE_NAME(SNAME) libgit2_suite_##SNAME
#define BEGIN_SUITE(SNAME) \
git_testsuite *libgit2_suite_##SNAME(void);\
git_testsuite *libgit2_suite_##SNAME(void) {\
git_testsuite *_gitsuite = git_testsuite_new(#SNAME);
#define ADD_TEST(TNAME) \
git_testsuite_add(_gitsuite, _gittest__##TNAME);
#define END_SUITE \
return _gitsuite;\
}
#define BEGIN_TEST(TNAME, DESC) \
static void _gittest__##TNAME(git_test *_gittest) { \
git_test__init(_gittest, #TNAME, DESC); \
git_clearerror();\
{\
#define END_TEST }}
typedef struct git_test git_test;
typedef struct git_testsuite git_testsuite;
typedef void (*git_testfunc)(git_test *);
typedef git_testsuite *(*libgit2_suite)(void);
void git_test__init(git_test *t, const char *name, const char *description);
void git_test__fail(git_test *tc, const char *file, int line, const char *message);
void git_test__assert(git_test *tc, const char *file, int line, const char *message, int condition);
void git_test__assert_pass(git_test *tc, const char *file, int line, const char *message, int ret_value);
#define must_pass(expr) git_test__assert_pass(_gittest, __FILE__, __LINE__, "Method failed: " #expr, (expr))
#define must_fail(expr) git_test__assert(_gittest, __FILE__, __LINE__, "Expected method to fail: " #expr, (expr) < 0)
#define must_be_true(expr) git_test__assert(_gittest, __FILE__, __LINE__, "Expression is not true: " #expr, !!(expr))
git_testsuite *git_testsuite_new(const char *name);
void git_testsuite_add(git_testsuite *ts, git_testfunc test);
int git_testsuite_run(git_testsuite *ts);
#endif
/*
* 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 <string.h>
#include <git2.h>
#include "posix.h"
#include "test_lib.h"
#include "test_helpers.h"
DECLARE_SUITE(core);
DECLARE_SUITE(rawobjects);
DECLARE_SUITE(objwrite);
DECLARE_SUITE(commit);
DECLARE_SUITE(revwalk);
DECLARE_SUITE(index);
DECLARE_SUITE(hashtable);
DECLARE_SUITE(tag);
DECLARE_SUITE(tree);
DECLARE_SUITE(refs);
DECLARE_SUITE(repository);
DECLARE_SUITE(threads);
DECLARE_SUITE(buffers);
DECLARE_SUITE(status);
static libgit2_suite suite_methods[]= {
SUITE_NAME(core),
SUITE_NAME(rawobjects),
SUITE_NAME(objwrite),
SUITE_NAME(commit),
SUITE_NAME(revwalk),
SUITE_NAME(index),
SUITE_NAME(hashtable),
SUITE_NAME(tag),
SUITE_NAME(tree),
SUITE_NAME(refs),
SUITE_NAME(repository),
SUITE_NAME(threads),
SUITE_NAME(buffers),
SUITE_NAME(status),
};
#define GIT_SUITE_COUNT (ARRAY_SIZE(suite_methods))
#ifdef GIT_WIN32
int __cdecl
#else
int
#endif
main(int argc, char *argv[])
{
unsigned int i, failures;
GIT_UNUSED(argc);
GIT_UNUSED(argv);
git_threads_init();
p_umask(0);
failures = 0;
for (i = 0; i < GIT_SUITE_COUNT; ++i)
failures += git_testsuite_run(suite_methods[i]());
git_threads_shutdown();
return failures ? -1 : 0;
}
{
ignore-zlib-cond
Memcheck:Cond
obj:*libz.so*
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment