2
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3
* Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
5
* This file is part of LVM2.
7
* This copyrighted material is made available to anyone wishing to use,
8
* modify, copy, or redistribute it subject to the terms and conditions
9
* of the GNU General Public License v.2.
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software Foundation,
13
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
#include "libdevmapper.h"
22
#include <sys/types.h>
28
#include <CUnit/CUnit.h>
29
#include "matcher_data.h"
34
static struct dm_pool *mem = NULL;
36
int regex_init(void) {
37
mem = dm_pool_create("bitset test", 1024);
41
int regex_fini(void) {
46
static struct dm_regex *make_scanner(const char **rx)
48
struct dm_regex *scanner;
50
for (; rx[nrx]; ++nrx);
52
scanner = dm_regex_create(mem, rx, nrx);
53
CU_ASSERT_FATAL(scanner != NULL);
57
static void test_fingerprints(void) {
58
struct dm_regex *scanner;
60
scanner = make_scanner(dev_patterns);
61
CU_ASSERT_EQUAL(dm_regex_fingerprint(scanner), 0x7f556c09);
63
scanner = make_scanner(random_patterns);
64
CU_ASSERT_EQUAL(dm_regex_fingerprint(scanner), 0x9f11076c);
67
static void test_matching(void) {
68
struct dm_regex *scanner;
71
scanner = make_scanner(dev_patterns);
72
for (i = 0; devices[i].str; ++i)
73
CU_ASSERT_EQUAL(dm_regex_match(scanner, devices[i].str), devices[i].expected - 1);
75
scanner = make_scanner(nonprint_patterns);
76
for (i = 0; nonprint[i].str; ++i)
77
CU_ASSERT_EQUAL(dm_regex_match(scanner, nonprint[i].str), nonprint[i].expected - 1);
80
CU_TestInfo regex_list[] = {
81
{ (char*)"fingerprints", test_fingerprints },
82
{ (char*)"matching", test_matching },