Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fvbe.git;a=commitdiff;h=bdaee77c2006ad95c1360c12aad5f8814b494958
commit bdaee77c2006ad95c1360c12aad5f8814b494958 Author: James Buren <[email protected]> Date: Fri May 10 07:02:06 2013 -0500 re2ctest: make it usable diff --git a/src/re2ctest.c b/src/re2ctest.c index ac68629..bb88e60 100644 --- a/src/re2ctest.c +++ b/src/re2ctest.c @@ -18,5 +18,66 @@ static struct re2ctest root[] = { "/@", false }, { "/etc", true }, { "^", false }, - { 0, false }, + { 0, false } }; + +static struct re2ctest raid[] = +{ + { "md0", true }, + { "md60", true }, + { "md200", true }, + { "hda", false }, + { "vdb", false }, + { "sda", false }, + { 0, false } +}; + +static struct re2ctest disk[] = +{ + { "hda", true }, + { "sda", true }, + { "vda", true }, + { "hdb", true }, + { "sdb", true }, + { "vdb", true }, + { "md0", false }, + { "md60", false }, + { "md200", false }, + { 0, false } +}; + +static inline bool re2ctest(struct re2ctest *p,bool (*f) (const char *)) +{ + for( ; p->pattern != 0 ; ++p ) + { + bool result = f(p->pattern); + + if(result != p->result) + { + printf("pattern '%s' does not match as it should\n",p->pattern); + return false; + } + } + + return true; +} + +#define RE2CTEST(A,B) \ +if(!re2ctest(A,B)) \ +{ \ + printf("%s failed the re2ctest\n",#B); \ + return EXIT_FAILURE; \ +} + +extern int main(int argc,char **argv) +{ + RE2CTEST(root,is_root_path); + + RE2CTEST(raid,is_raid_device); + + RE2CTEST(disk,is_disk_device); + + printf("re2c has passed all tests\n"); + + return EXIT_SUCCESS; +} _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
