mirror of
git://sourceware.org/git/lvm2.git
synced 2025-04-23 22:50:44 +03:00
const: tests
This commit is contained in:
parent
edbc0ed447
commit
c48cc22b18
@ -427,7 +427,7 @@ static void test_block_size_must_be_positive(void *fixture)
|
||||
|
||||
static void test_block_size_must_be_multiple_of_page_size(void *fixture)
|
||||
{
|
||||
static unsigned _bad_examples[] = {3, 9, 13, 1025};
|
||||
static const unsigned _bad_examples[] = {3, 9, 13, 1025};
|
||||
|
||||
unsigned i;
|
||||
|
||||
|
@ -3,13 +3,13 @@ struct check_item {
|
||||
int expected;
|
||||
};
|
||||
|
||||
static const char *dev_patterns[] = {
|
||||
static const char * const dev_patterns[] = {
|
||||
"loop/[0-9]+",
|
||||
"hd[a-d][0-5]+",
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *nonprint_patterns[] = {
|
||||
static const char * const nonprint_patterns[] = {
|
||||
"foo\x80" "bar",
|
||||
"foo\xc2" "b",
|
||||
"\x80",
|
||||
@ -24,7 +24,7 @@ static const struct check_item nonprint[] = {
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static const char *random_patterns[] = {
|
||||
static const char * const random_patterns[] = {
|
||||
"(((a?)(([Ub]*)|z))((([qr]|X)+)([Qn]*)))+",
|
||||
"[HZejtuw]*",
|
||||
"((B|s)*)|(((([Fv]l)(N+))(([el]|C)(tJ)))?)",
|
||||
@ -128,7 +128,7 @@ static const char *random_patterns[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
struct check_item devices[] = {
|
||||
static const struct check_item devices[] = {
|
||||
{ "/dev", 0 },
|
||||
{ "/dev/.devfsd", 0 },
|
||||
{ "/dev/cpu", 0 },
|
||||
|
@ -34,7 +34,7 @@ static void _mem_exit(void *mem)
|
||||
dm_pool_destroy(mem);
|
||||
}
|
||||
|
||||
static struct dm_regex *make_scanner(struct dm_pool *mem, const char **rx)
|
||||
static struct dm_regex *make_scanner(struct dm_pool *mem, const char * const *rx)
|
||||
{
|
||||
struct dm_regex *scanner;
|
||||
int nrx = 0;
|
||||
@ -75,11 +75,11 @@ static void test_matching(void *fixture)
|
||||
static void test_kabi_query(void *fixture)
|
||||
{
|
||||
// Remember, matches regexes from last to first.
|
||||
static const char *_patterns[] = {
|
||||
static const char * const _patterns[] = {
|
||||
".*", ".*/dev/md.*", "loop"
|
||||
};
|
||||
|
||||
static struct {
|
||||
static const struct {
|
||||
const char *input;
|
||||
int r;
|
||||
} _cases[] = {
|
||||
@ -93,7 +93,7 @@ static void test_kabi_query(void *fixture)
|
||||
int r;
|
||||
unsigned i;
|
||||
struct dm_pool *mem = fixture;
|
||||
struct dm_regex *scanner;
|
||||
struct dm_regex *scanner;
|
||||
|
||||
scanner = dm_regex_create(mem, _patterns, DM_ARRAY_SIZE(_patterns));
|
||||
T_ASSERT(scanner != NULL);
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
static bool _status_eq(struct dm_vdo_status *lhs, struct dm_vdo_status *rhs)
|
||||
static bool _status_eq(const struct dm_vdo_status *lhs, const struct dm_vdo_status *rhs)
|
||||
{
|
||||
return !strcmp(lhs->device, rhs->device) &&
|
||||
(lhs->operating_mode == rhs->operating_mode) &&
|
||||
@ -83,12 +83,12 @@ struct example_good {
|
||||
struct dm_vdo_status status;
|
||||
};
|
||||
|
||||
static void _check_good(struct example_good *es, unsigned count)
|
||||
static void _check_good(const struct example_good *es, unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
struct example_good *e = es + i;
|
||||
const struct example_good *e = es + i;
|
||||
struct dm_vdo_status_parse_result pr;
|
||||
|
||||
T_ASSERT(dm_vdo_status_parse(NULL, e->input, &pr));
|
||||
@ -109,12 +109,12 @@ struct example_bad {
|
||||
const char *reason;
|
||||
};
|
||||
|
||||
static void _check_bad(struct example_bad *es, unsigned count)
|
||||
static void _check_bad(const struct example_bad *es, unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
struct example_bad *e = es + i;
|
||||
const struct example_bad *e = es + i;
|
||||
struct dm_vdo_status_parse_result pr;
|
||||
|
||||
T_ASSERT(!dm_vdo_status_parse(NULL, e->input, &pr));
|
||||
@ -124,7 +124,7 @@ static void _check_bad(struct example_bad *es, unsigned count)
|
||||
|
||||
static void _test_device_names_good(void *fixture)
|
||||
{
|
||||
static struct example_good _es[] = {
|
||||
static const struct example_good _es[] = {
|
||||
{"foo1234 read-only - error online 0 1234",
|
||||
{(char *) "foo1234", DM_VDO_MODE_READ_ONLY, false, DM_VDO_INDEX_ERROR, DM_VDO_COMPRESSION_ONLINE, 0, 1234}},
|
||||
{"f read-only - error online 0 1234",
|
||||
@ -136,7 +136,7 @@ static void _test_device_names_good(void *fixture)
|
||||
|
||||
static void _test_operating_mode_good(void *fixture)
|
||||
{
|
||||
static struct example_good _es[] = {
|
||||
static const struct example_good _es[] = {
|
||||
{"device-name recovering - error online 0 1234",
|
||||
{(char *) "device-name", DM_VDO_MODE_RECOVERING, false, DM_VDO_INDEX_ERROR, DM_VDO_COMPRESSION_ONLINE, 0, 1234}},
|
||||
{"device-name read-only - error online 0 1234",
|
||||
@ -150,7 +150,7 @@ static void _test_operating_mode_good(void *fixture)
|
||||
|
||||
static void _test_operating_mode_bad(void *fixture)
|
||||
{
|
||||
static struct example_bad _es[] = {
|
||||
static const struct example_bad _es[] = {
|
||||
{"device-name investigating - error online 0 1234",
|
||||
"couldn't parse 'operating mode'"}};
|
||||
|
||||
@ -159,7 +159,7 @@ static void _test_operating_mode_bad(void *fixture)
|
||||
|
||||
static void _test_recovering_good(void *fixture)
|
||||
{
|
||||
static struct example_good _es[] = {
|
||||
static const struct example_good _es[] = {
|
||||
{"device-name recovering - error online 0 1234",
|
||||
{(char *) "device-name", DM_VDO_MODE_RECOVERING, false, DM_VDO_INDEX_ERROR, DM_VDO_COMPRESSION_ONLINE, 0, 1234}},
|
||||
{"device-name read-only recovering error online 0 1234",
|
||||
@ -171,7 +171,7 @@ static void _test_recovering_good(void *fixture)
|
||||
|
||||
static void _test_recovering_bad(void *fixture)
|
||||
{
|
||||
static struct example_bad _es[] = {
|
||||
static const struct example_bad _es[] = {
|
||||
{"device-name normal fish error online 0 1234",
|
||||
"couldn't parse 'recovering'"}};
|
||||
|
||||
@ -180,7 +180,7 @@ static void _test_recovering_bad(void *fixture)
|
||||
|
||||
static void _test_index_state_good(void *fixture)
|
||||
{
|
||||
static struct example_good _es[] = {
|
||||
static const struct example_good _es[] = {
|
||||
{"device-name recovering - error online 0 1234",
|
||||
{(char *) "device-name", DM_VDO_MODE_RECOVERING, false, DM_VDO_INDEX_ERROR, DM_VDO_COMPRESSION_ONLINE, 0, 1234}},
|
||||
{"device-name recovering - closed online 0 1234",
|
||||
@ -202,7 +202,7 @@ static void _test_index_state_good(void *fixture)
|
||||
|
||||
static void _test_index_state_bad(void *fixture)
|
||||
{
|
||||
static struct example_bad _es[] = {
|
||||
static const struct example_bad _es[] = {
|
||||
{"device-name normal - fish online 0 1234",
|
||||
"couldn't parse 'index state'"}};
|
||||
|
||||
@ -211,7 +211,7 @@ static void _test_index_state_bad(void *fixture)
|
||||
|
||||
static void _test_compression_state_good(void *fixture)
|
||||
{
|
||||
static struct example_good _es[] = {
|
||||
static const struct example_good _es[] = {
|
||||
{"device-name recovering - error online 0 1234",
|
||||
{(char *) "device-name", DM_VDO_MODE_RECOVERING, false, DM_VDO_INDEX_ERROR, DM_VDO_COMPRESSION_ONLINE, 0, 1234}},
|
||||
{"device-name read-only - error offline 0 1234",
|
||||
@ -223,7 +223,7 @@ static void _test_compression_state_good(void *fixture)
|
||||
|
||||
static void _test_compression_state_bad(void *fixture)
|
||||
{
|
||||
static struct example_bad _es[] = {
|
||||
static const struct example_bad _es[] = {
|
||||
{"device-name normal - error fish 0 1234",
|
||||
"couldn't parse 'compression state'"}};
|
||||
|
||||
@ -232,7 +232,7 @@ static void _test_compression_state_bad(void *fixture)
|
||||
|
||||
static void _test_used_blocks_good(void *fixture)
|
||||
{
|
||||
static struct example_good _es[] = {
|
||||
static const struct example_good _es[] = {
|
||||
{"device-name recovering - error online 0 1234",
|
||||
{(char *) "device-name", DM_VDO_MODE_RECOVERING, false, DM_VDO_INDEX_ERROR, DM_VDO_COMPRESSION_ONLINE, 0, 1234}},
|
||||
{"device-name read-only - error offline 1 1234",
|
||||
@ -248,7 +248,7 @@ static void _test_used_blocks_good(void *fixture)
|
||||
|
||||
static void _test_used_blocks_bad(void *fixture)
|
||||
{
|
||||
static struct example_bad _es[] = {
|
||||
static const struct example_bad _es[] = {
|
||||
{"device-name normal - error online fish 1234",
|
||||
"couldn't parse 'used blocks'"}};
|
||||
|
||||
@ -257,7 +257,7 @@ static void _test_used_blocks_bad(void *fixture)
|
||||
|
||||
static void _test_total_blocks_good(void *fixture)
|
||||
{
|
||||
static struct example_good _es[] = {
|
||||
static const struct example_good _es[] = {
|
||||
{"device-name recovering - error online 0 1234",
|
||||
{(char *) "device-name", DM_VDO_MODE_RECOVERING, false, DM_VDO_INDEX_ERROR, DM_VDO_COMPRESSION_ONLINE, 0, 1234}},
|
||||
{"device-name recovering - error online 0 1",
|
||||
@ -271,7 +271,7 @@ static void _test_total_blocks_good(void *fixture)
|
||||
|
||||
static void _test_total_blocks_bad(void *fixture)
|
||||
{
|
||||
static struct example_bad _es[] = {
|
||||
static const struct example_bad _es[] = {
|
||||
{"device-name normal - error online 0 fish",
|
||||
"couldn't parse 'total blocks'"}};
|
||||
|
||||
@ -280,7 +280,7 @@ static void _test_total_blocks_bad(void *fixture)
|
||||
|
||||
static void _test_status_bad(void *fixture)
|
||||
{
|
||||
struct example_bad _bad[] = {
|
||||
static const struct example_bad _bad[] = {
|
||||
{"", "couldn't get token for device"},
|
||||
{"device-name read-only - error online 0 1000 lksd", "too many tokens"}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user