mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
ccc35e2647
The device-mapper directory now holds a copy of libdm source. At the moment this code is identical to libdm. Over time code will migrate out to appropriate places (see doc/refactoring.txt). The libdm directory still exists, and contains the source for the libdevmapper shared library, which we will continue to ship (though not neccessarily update). All code using libdm should now use the version in device-mapper.
50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
#ifndef TEST_UNIT_FRAMEWORK_H
|
|
#define TEST_UNIT_FRAMEWORK_H
|
|
|
|
#include "device_mapper/libdevmapper.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <setjmp.h>
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
// A test suite gathers a set of tests with a common fixture together.
|
|
struct test_suite {
|
|
struct dm_list list;
|
|
|
|
void *(*fixture_init)(void);
|
|
void (*fixture_exit)(void *);
|
|
struct dm_list tests;
|
|
};
|
|
|
|
struct test_details {
|
|
struct test_suite *parent;
|
|
struct dm_list list;
|
|
|
|
const char *path;
|
|
const char *desc;
|
|
void (*fn)(void *);
|
|
};
|
|
|
|
struct test_suite *test_suite_create(void *(*fixture_init)(void),
|
|
void (*fixture_exit)(void *));
|
|
void test_suite_destroy(struct test_suite *ts);
|
|
|
|
bool register_test(struct test_suite *ts,
|
|
const char *path, const char *desc, void (*fn)(void *));
|
|
|
|
void test_fail(const char *fmt, ...)
|
|
__attribute__((noreturn, format (printf, 1, 2)));
|
|
|
|
#define T_ASSERT(e) do {if (!(e)) {test_fail("assertion failed: '%s'", # e);} } while(0)
|
|
#define T_ASSERT_EQUAL(x, y) T_ASSERT((x) == (y))
|
|
#define T_ASSERT_NOT_EQUAL(x, y) T_ASSERT((x) != (y))
|
|
|
|
extern jmp_buf test_k;
|
|
#define TEST_FAILED 1
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
#endif
|