Commit fb799dfe by Andreas Ericsson

Merge remote branch 'ramsay/dev'

* ramsay/dev:
  Add a pack index 'virtual function' to fetch an index entry
  Add a pack index 'virtual function' to search by file offset
  Change the interface of the pack index search function
  Add an 64-bit offset table index bounds check for v2 pack index
  Add a minimum size check when opening an v2 pack index file
  win32: Add separate MinGW and MSVC compatability header files
  Makefile: Add support for custom build options in config.mak file
  Fix some coding style issues
parents 10074651 2cdc4544
/apidocs /apidocs
/trash-*.exe /trash-*.exe
/libgit2.pc /libgit2.pc
/config.mak
*.o *.o
*.a *.a
*.exe *.exe
......
...@@ -52,6 +52,8 @@ ifneq (,$(findstring MINGW,$(uname_S))) ...@@ -52,6 +52,8 @@ ifneq (,$(findstring MINGW,$(uname_S)))
SPARSE_FLAGS=-Wno-one-bit-signed-bitfield SPARSE_FLAGS=-Wno-one-bit-signed-bitfield
endif endif
-include config.mak
SRC_C = $(wildcard src/*.c) SRC_C = $(wildcard src/*.c)
OS_SRC = $(wildcard src/$(OS)/*.c) OS_SRC = $(wildcard src/$(OS)/*.c)
SRC_C += $(OS_SRC) SRC_C += $(OS_SRC)
......
...@@ -9,7 +9,7 @@ struct git_commit { ...@@ -9,7 +9,7 @@ struct git_commit {
git_oid id; git_oid id;
time_t commit_time; time_t commit_time;
unsigned parsed:1, unsigned parsed:1,
flags:26; flags:26;
}; };
#endif #endif
...@@ -32,43 +32,13 @@ ...@@ -32,43 +32,13 @@
# include <io.h> # include <io.h>
# include <direct.h> # include <direct.h>
# include <windows.h> # include <windows.h>
# include "msvc-compat.h"
# include "mingw-compat.h"
# define snprintf _snprintf # define snprintf _snprintf
# if defined(__DMC__)
# if defined(_M_AMD64)
# define SSIZE_T long long
# else
# define SSIZE_T int
# endif
# endif
typedef SSIZE_T ssize_t; typedef SSIZE_T ssize_t;
# if defined(_MSC_VER)
/* access() mode parameter #defines */
# define F_OK 0 /* existence check */
# define W_OK 2 /* write mode check */
# define R_OK 4 /* read mode check */
# endif
#if defined(__MINGW32__)
# define off_t off64_t
# define lseek _lseeki64
# define stat _stati64
# define fstat _fstati64
#elif defined(_MSC_VER)
typedef __int64 off64_t;
# define off_t off64_t
# define lseek _lseeki64
# define stat _stat64
# define fstat _fstat64
#endif
#else #else
# include <unistd.h> # include <unistd.h>
...@@ -84,13 +54,4 @@ typedef __int64 off64_t; ...@@ -84,13 +54,4 @@ typedef __int64 off64_t;
#define GIT_PATH_MAX 4096 #define GIT_PATH_MAX 4096
#ifndef GIT_HAVE_INTTYPES_H
/* add some missing <stdint.h> typedef's */
typedef long int32_t;
typedef unsigned long uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
#endif /* INCLUDE_common_h__ */ #endif /* INCLUDE_common_h__ */
...@@ -34,7 +34,7 @@ extern int git__fsync(int fd); ...@@ -34,7 +34,7 @@ extern int git__fsync(int fd);
# ifndef GIT__WIN32_NO_HIDE_FILEOPS # ifndef GIT__WIN32_NO_HIDE_FILEOPS
# define unlink(p) git__unlink(p) # define unlink(p) git__unlink(p)
# define mkstemp(t) git__mkstemp(t) # define mkstemp(t) git__mkstemp(t)
# define mkdir(p,m) git__mkdir(p,m) # define mkdir(p,m) git__mkdir(p, m)
# define fsync(fd) git__fsync(fd) # define fsync(fd) git__fsync(fd)
# endif # endif
#endif /* GIT_WIN32 */ #endif /* GIT_WIN32 */
......
...@@ -25,14 +25,14 @@ typedef struct git_commit git_commit; ...@@ -25,14 +25,14 @@ typedef struct git_commit git_commit;
* pool's git_odb, or if the commit is present but is * pool's git_odb, or if the commit is present but is
* too malformed to be parsed successfully. * too malformed to be parsed successfully.
*/ */
GIT_EXTERN(git_commit*) git_commit_parse(git_revpool *pool, const git_oid *id); GIT_EXTERN(git_commit *) git_commit_parse(git_revpool *pool, const git_oid *id);
/** /**
* Get the id of a commit. * Get the id of a commit.
* @param commit a previously parsed commit. * @param commit a previously parsed commit.
* @return object identity for the commit. * @return object identity for the commit.
*/ */
GIT_EXTERN(const git_oid*) git_commit_id(git_commit *commit); GIT_EXTERN(const git_oid *) git_commit_id(git_commit *commit);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
/** Declare a public function exported for application use. */ /** Declare a public function exported for application use. */
#ifdef __GNUC__ #ifdef __GNUC__
# define GIT_EXTERN(type) extern \ # define GIT_EXTERN(type) extern \
__attribute__((visibility("default"))) \ __attribute__((visibility("default"))) \
type type
#else #else
# define GIT_EXTERN(type) extern type # define GIT_EXTERN(type) extern type
#endif #endif
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
/** Declare a public TLS symbol exported for application use. */ /** Declare a public TLS symbol exported for application use. */
#ifdef __GNUC__ #ifdef __GNUC__
# define GIT_EXTERN_TLS(type) extern \ # define GIT_EXTERN_TLS(type) extern \
__attribute__((visibility("default"))) \ __attribute__((visibility("default"))) \
GIT_TLS \ GIT_TLS \
type type
#else #else
# define GIT_EXTERN_TLS(type) extern GIT_TLS type # define GIT_EXTERN_TLS(type) extern GIT_TLS type
#endif #endif
......
...@@ -20,8 +20,7 @@ GIT_BEGIN_DECL ...@@ -20,8 +20,7 @@ GIT_BEGIN_DECL
#define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2) #define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2)
/** Unique identity of any object (commit, tree, blob, tag). */ /** Unique identity of any object (commit, tree, blob, tag). */
typedef struct typedef struct {
{
/** raw binary formatted id */ /** raw binary formatted id */
unsigned char id[GIT_OID_RAWSZ]; unsigned char id[GIT_OID_RAWSZ];
} git_oid; } git_oid;
......
...@@ -25,7 +25,7 @@ GIT_BEGIN_DECL ...@@ -25,7 +25,7 @@ GIT_BEGIN_DECL
* @param db the database objects are read from. * @param db the database objects are read from.
* @return the new traversal handle; NULL if memory is exhausted. * @return the new traversal handle; NULL if memory is exhausted.
*/ */
GIT_EXTERN(git_revpool*) gitrp_alloc(git_odb *db); GIT_EXTERN(git_revpool *) gitrp_alloc(git_odb *db);
/** /**
* Reset the traversal machinary for reuse. * Reset the traversal machinary for reuse.
...@@ -52,7 +52,7 @@ GIT_EXTERN(void) gitrp_hide(git_revpool *pool, git_commit *commit); ...@@ -52,7 +52,7 @@ GIT_EXTERN(void) gitrp_hide(git_revpool *pool, git_commit *commit);
* @param pool the pool to pop the commit from. * @param pool the pool to pop the commit from.
* @return next commit; NULL if there is no more output. * @return next commit; NULL if there is no more output.
*/ */
GIT_EXTERN(git_commit*) gitrp_next(git_revpool *pool); GIT_EXTERN(git_commit *) gitrp_next(git_revpool *pool);
/** /**
* Free a revwalk previously allocated. * Free a revwalk previously allocated.
......
#ifndef INCLUDE_mingw_compat__
#define INCLUDE_mingw_compat__
#if defined(__MINGW32__)
/* use a 64-bit file offset type */
# define off_t off64_t
# define lseek _lseeki64
# define stat _stati64
# define fstat _fstati64
#endif
#endif /* INCLUDE_mingw_compat__ */
#ifndef INCLUDE_msvc_compat__
#define INCLUDE_msvc_compat__
#if defined(_MSC_VER)
/* access() mode parameter #defines */
# define F_OK 0 /* existence check */
# define W_OK 2 /* write mode check */
# define R_OK 4 /* read mode check */
/* use a 64-bit file offset type */
typedef __int64 off64_t;
# define off_t off64_t
# define lseek _lseeki64
# define stat _stat64
# define fstat _fstat64
/* stat: file mode type testing macros */
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
/* add some missing <stdint.h> typedef's */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef long int32_t;
typedef unsigned long uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
#endif
#endif /* INCLUDE_msvc_compat__ */
...@@ -58,6 +58,6 @@ GIT_INLINE(int) git__is_sizet(off_t p) ...@@ -58,6 +58,6 @@ GIT_INLINE(int) git__is_sizet(off_t p)
alloc = alloc_nr(alloc); \ alloc = alloc_nr(alloc); \
x = xrealloc((x), alloc * sizeof(*(x))); \ x = xrealloc((x), alloc * sizeof(*(x))); \
} \ } \
} while(0) } while (0)
#endif /* INCLUDE_util_h__ */ #endif /* INCLUDE_util_h__ */
...@@ -41,6 +41,8 @@ ifneq (,$(findstring MINGW,$(uname_S))) ...@@ -41,6 +41,8 @@ ifneq (,$(findstring MINGW,$(uname_S)))
EXTRA_LIBS += -lwsock32 -lpthread EXTRA_LIBS += -lwsock32 -lpthread
endif endif
-include ../config.mak
GIT_LIB = ../libgit2.a GIT_LIB = ../libgit2.a
HDRS = $(wildcard ../src/*.h) HDRS = $(wildcard ../src/*.h)
......
...@@ -123,9 +123,9 @@ BEGIN_TEST(dot) ...@@ -123,9 +123,9 @@ BEGIN_TEST(dot)
must_pass(setup(&dot)); must_pass(setup(&dot));
must_pass(gitfo_dirent(path_buffer, must_pass(gitfo_dirent(path_buffer,
sizeof(path_buffer), sizeof(path_buffer),
one_entry, one_entry,
&dot)); &dot));
must_pass(check_counts(&dot)); must_pass(check_counts(&dot));
...@@ -148,9 +148,9 @@ BEGIN_TEST(sub) ...@@ -148,9 +148,9 @@ BEGIN_TEST(sub)
must_pass(setup(&sub)); must_pass(setup(&sub));
must_pass(gitfo_dirent(path_buffer, must_pass(gitfo_dirent(path_buffer,
sizeof(path_buffer), sizeof(path_buffer),
one_entry, one_entry,
&sub)); &sub));
must_pass(check_counts(&sub)); must_pass(check_counts(&sub));
...@@ -167,9 +167,9 @@ BEGIN_TEST(sub_slash) ...@@ -167,9 +167,9 @@ BEGIN_TEST(sub_slash)
must_pass(setup(&sub_slash)); must_pass(setup(&sub_slash));
must_pass(gitfo_dirent(path_buffer, must_pass(gitfo_dirent(path_buffer,
sizeof(path_buffer), sizeof(path_buffer),
one_entry, one_entry,
&sub_slash)); &sub_slash));
must_pass(check_counts(&sub_slash)); must_pass(check_counts(&sub_slash));
...@@ -196,17 +196,17 @@ BEGIN_TEST(empty) ...@@ -196,17 +196,17 @@ BEGIN_TEST(empty)
must_pass(setup(&empty)); must_pass(setup(&empty));
must_pass(gitfo_dirent(path_buffer, must_pass(gitfo_dirent(path_buffer,
sizeof(path_buffer), sizeof(path_buffer),
one_entry, one_entry,
&empty)); &empty));
must_pass(check_counts(&empty)); must_pass(check_counts(&empty));
/* make sure callback not called */ /* make sure callback not called */
must_pass(gitfo_dirent(path_buffer, must_pass(gitfo_dirent(path_buffer,
sizeof(path_buffer), sizeof(path_buffer),
dont_call_me, dont_call_me,
&empty)); &empty));
must_pass(knockdown(&empty)); must_pass(knockdown(&empty));
END_TEST END_TEST
...@@ -229,9 +229,9 @@ BEGIN_TEST(odd) ...@@ -229,9 +229,9 @@ BEGIN_TEST(odd)
must_pass(setup(&odd)); must_pass(setup(&odd));
must_pass(gitfo_dirent(path_buffer, must_pass(gitfo_dirent(path_buffer,
sizeof(path_buffer), sizeof(path_buffer),
one_entry, one_entry,
&odd)); &odd));
must_pass(check_counts(&odd)); must_pass(check_counts(&odd));
......
...@@ -50,7 +50,7 @@ BEGIN_TEST(invalid_string_all_chars) ...@@ -50,7 +50,7 @@ BEGIN_TEST(invalid_string_all_chars)
test_die("line %d: must accept '%s'", __LINE__, in); test_die("line %d: must accept '%s'", __LINE__, in);
if (memcmp(out.id, exp, sizeof(out.id))) if (memcmp(out.id, exp, sizeof(out.id)))
test_die("line %d: bad parse of '%s', %x != %x", 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)) } else if (!git_oid_mkstr(&out, in))
test_die("line %d: must not accept '%s'", __LINE__, in); test_die("line %d: must not accept '%s'", __LINE__, in);
} }
......
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
#include <git/odb.h> #include <git/odb.h>
BEGIN_TEST(type_to_string) 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_BAD), ""));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT1),"")); 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_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_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_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_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__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_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(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(-2), ""));
must_be_true(!strcmp(git_obj_type_to_string(8),"")); 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(1234), ""));
END_TEST END_TEST
BEGIN_TEST(string_to_type) BEGIN_TEST(string_to_type)
......
...@@ -37,8 +37,8 @@ BEGIN_TEST(exists_loose_one) ...@@ -37,8 +37,8 @@ BEGIN_TEST(exists_loose_one)
must_be_true(git_odb_exists(db, &id)); must_be_true(git_odb_exists(db, &id));
/* Test for a non-existant object */ /* Test for a non-existant object */
must_pass(git_oid_mkstr(&id2,"8b137891791fe96927ad78e64b0aad7bded08baa")); must_pass(git_oid_mkstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa"));
must_be_true(0 == git_odb_exists(db, &id2)); must_be_true(0 == git_odb_exists(db, &id2));
git_odb_close(db); git_odb_close(db);
must_pass(remove_object_files(odb_dir, &one)); must_pass(remove_object_files(odb_dir, &one));
......
...@@ -351,55 +351,54 @@ static git_obj some_obj = { ...@@ -351,55 +351,54 @@ static git_obj some_obj = {
static int make_odb_dir(void) static int make_odb_dir(void)
{ {
if (gitfo_mkdir(odb_dir, 0755) < 0) { if (gitfo_mkdir(odb_dir, 0755) < 0) {
if (errno == EEXIST) { int err = errno;
fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir); fprintf(stderr, "can't make directory \"%s\"", odb_dir);
return -1; if (err == EEXIST)
} fprintf(stderr, " (already exists)");
fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir); fprintf(stderr, "\n");
return -1; return -1;
} }
return 0;
return 0;
} }
static int remove_object_files(object_data *d) static int remove_object_files(object_data *d)
{ {
if (gitfo_unlink(d->file) < 0) { if (gitfo_unlink(d->file) < 0) {
fprintf(stderr, "can't delete object file \"%s\"\n", d->file); fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
return -1; return -1;
} }
if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) { if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir); fprintf(stderr, "can't remove directory \"%s\"\n", d->dir);
return -1; return -1;
} }
if (gitfo_rmdir(odb_dir) < 0) { if (gitfo_rmdir(odb_dir) < 0) {
fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir); fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
return -1; return -1;
} }
return 0; return 0;
} }
static int check_object_files(object_data *d) static int check_object_files(object_data *d)
{ {
if (gitfo_exists(d->dir) < 0) if (gitfo_exists(d->dir) < 0)
return -1; return -1;
if (gitfo_exists(d->file) < 0) if (gitfo_exists(d->file) < 0)
return -1; return -1;
return 0; return 0;
} }
static int cmp_objects(git_obj *o1, git_obj *o2) static int cmp_objects(git_obj *o1, git_obj *o2)
{ {
if (o1->type != o2->type) if (o1->type != o2->type)
return -1; return -1;
if (o1->len != o2->len) if (o1->len != o2->len)
return -1; return -1;
if ((o1->len > 0) && (memcmp(o1->data, o2->data, o1->len) != 0)) if ((o1->len > 0) && (memcmp(o1->data, o2->data, o1->len) != 0))
return -1; return -1;
return 0; return 0;
} }
BEGIN_TEST(write_commit) BEGIN_TEST(write_commit)
......
...@@ -29,66 +29,66 @@ ...@@ -29,66 +29,66 @@
int write_object_data(char *file, void *data, size_t len) int write_object_data(char *file, void *data, size_t len)
{ {
git_file fd; git_file fd;
int ret; int ret;
if ((fd = gitfo_creat(file, S_IREAD | S_IWRITE)) < 0) if ((fd = gitfo_creat(file, S_IREAD | S_IWRITE)) < 0)
return -1; return -1;
ret = gitfo_write(fd, data, len); ret = gitfo_write(fd, data, len);
gitfo_close(fd); gitfo_close(fd);
return ret; return ret;
} }
int write_object_files(const char *odb_dir, object_data *d) int write_object_files(const char *odb_dir, object_data *d)
{ {
if (gitfo_mkdir(odb_dir, 0755) < 0) { if (gitfo_mkdir(odb_dir, 0755) < 0) {
if (errno == EEXIST) { int err = errno;
fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir); fprintf(stderr, "can't make directory \"%s\"", odb_dir);
return -1; if (err == EEXIST)
} fprintf(stderr, " (already exists)");
fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir); fprintf(stderr, "\n");
return -1; return -1;
} }
if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) { if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
fprintf(stderr, "can't make object directory \"%s\"\n", d->dir); fprintf(stderr, "can't make object directory \"%s\"\n", d->dir);
return -1; return -1;
} }
if (write_object_data(d->file, d->bytes, d->blen) < 0) { if (write_object_data(d->file, d->bytes, d->blen) < 0) {
fprintf(stderr, "can't write object file \"%s\"\n", d->file); fprintf(stderr, "can't write object file \"%s\"\n", d->file);
return -1; return -1;
} }
return 0; return 0;
} }
int remove_object_files(const char *odb_dir, object_data *d) int remove_object_files(const char *odb_dir, object_data *d)
{ {
if (gitfo_unlink(d->file) < 0) { if (gitfo_unlink(d->file) < 0) {
fprintf(stderr, "can't delete object file \"%s\"\n", d->file); fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
return -1; return -1;
} }
if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) { if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir); fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
return -1; return -1;
} }
if (gitfo_rmdir(odb_dir) < 0) { if (gitfo_rmdir(odb_dir) < 0) {
fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir); fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
return -1; return -1;
} }
return 0; return 0;
} }
int cmp_objects(git_obj *o, object_data *d) int cmp_objects(git_obj *o, object_data *d)
{ {
if (o->type != git_obj_string_to_type(d->type)) if (o->type != git_obj_string_to_type(d->type))
return -1; return -1;
if (o->len != d->dlen) if (o->len != d->dlen)
return -1; return -1;
if ((o->len > 0) && (memcmp(o->data, d->data, o->len) != 0)) if ((o->len > 0) && (memcmp(o->data, d->data, o->len) != 0))
return -1; return -1;
return 0; return 0;
} }
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
#define GIT__NO_HIDE_MALLOC #define GIT__NO_HIDE_MALLOC
#include "test_lib.h" #include "test_lib.h"
struct test_info struct test_info {
{
struct test_info *next; struct test_info *next;
const char *test_name; const char *test_name;
const char *file_name; const char *file_name;
...@@ -40,9 +39,9 @@ static struct test_info *current_test; ...@@ -40,9 +39,9 @@ static struct test_info *current_test;
static void show_test_result(const char *status) static void show_test_result(const char *status)
{ {
fprintf(stderr, "* %-6s %5d: %s\n", fprintf(stderr, "* %-6s %5d: %s\n",
status, status,
current_test->line_no, current_test->line_no,
current_test->test_name); current_test->test_name);
} }
void test_die(const char *fmt, ...) void test_die(const char *fmt, ...)
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
* @param name C symbol to assign to this test's function. * @param name C symbol to assign to this test's function.
*/ */
#define BEGIN_TEST(name) \ #define BEGIN_TEST(name) \
void testfunc__##name (void) \ void testfunc__##name(void) \
{ \ { \
test_begin(#name, __FILE__, __LINE__); \ test_begin(#name, __FILE__, __LINE__); \
{ {
......
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