bool setup_list_test(void) { /* add a suite to the registry */ CU_pSuite pSuite = CU_add_suite_with_setup_and_teardown("List Suite", NULL, NULL, list_test_setup, list_test_teardown); if (pSuite == NULL) { return false; } /* add the tests to the suite */ if ((CU_add_test(pSuite, "List Append", list_test_append) == NULL) || (CU_add_test(pSuite, "List Insert", list_test_insert) == NULL) || (CU_add_test(pSuite, "List Extend", list_test_extend) == NULL) || (CU_add_test(pSuite, "List Get", list_test_get) == NULL) || (CU_add_test(pSuite, "List Remove", list_test_remove) == NULL) || (CU_add_test(pSuite, "List Remove by Index", list_test_remove_index) == NULL) || (CU_add_test(pSuite, "List Get Index", list_test_index) == NULL) || (CU_add_test(pSuite, "List Pop", list_test_pop) == NULL) || (CU_add_test(pSuite, "List Reverse", list_test_reverse) == NULL) || (CU_add_test(pSuite, "List Clear", list_test_clear) == NULL) || (CU_add_test(pSuite, "List Enqueue/Dequeue", list_test_queue) == NULL) || (CU_add_test(pSuite, "List Iterator", list_test_iter) == NULL)) { return false; } return true; }
bool setup_array_tests(void) { /* add a suite to the registry */ CU_pSuite pSuite = CU_add_suite_with_setup_and_teardown("Array Suite", NULL, NULL, array_test_setup, array_test_teardown); if (pSuite == NULL) { return false; } /* add the tests to the suite */ if ((CU_add_test(pSuite, "Array Literal", array_test_literal) == NULL) || (CU_add_test(pSuite, "Array Append", array_test_append) == NULL) || (CU_add_test(pSuite, "Array Insert", array_test_insert) == NULL) || (CU_add_test(pSuite, "Array Extend", array_test_extend) == NULL) || (CU_add_test(pSuite, "Array Get", array_test_get) == NULL) || (CU_add_test(pSuite, "Array Top", array_test_top) == NULL) || (CU_add_test(pSuite, "Array Remove", array_test_remove) == NULL) || (CU_add_test(pSuite, "Array Remove by Index", array_test_remove_index) == NULL) || (CU_add_test(pSuite, "Array Get Index", array_test_index) == NULL) || (CU_add_test(pSuite, "Array Pop", array_test_pop) == NULL) || (CU_add_test(pSuite, "Array Resize", array_test_resize) == NULL) || (CU_add_test(pSuite, "Array Reverse", array_test_reverse) == NULL) || (CU_add_test(pSuite, "Array Clear", array_test_clear) == NULL) || (CU_add_test(pSuite, "Array Sort", array_test_sort) == NULL) || (CU_add_test(pSuite, "Array Iterator", array_test_iter) == NULL)) { return false; } return true; }
bool setup_dict_tests(void) { /* add a suite to the registry */ CU_pSuite pSuite = CU_add_suite_with_setup_and_teardown("Dictionary Suite", NULL, NULL, dict_test_setup, dict_test_teardown); if (pSuite == NULL) { return false; } /* add the tests to the suite */ if ((CU_add_test(pSuite, "Dict Put", dict_test_put) == NULL) || (CU_add_test(pSuite, "Dict Key Collision", dict_test_collision) == NULL) || (CU_add_test(pSuite, "Dict Get", dict_test_get) == NULL) || (CU_add_test(pSuite, "Dict Del", dict_test_del) == NULL) || (CU_add_test(pSuite, "Dict Resize", dict_test_resize) == NULL) || (CU_add_test(pSuite, "Dict Iterator", dict_test_iter) == NULL)) { return false; } return true; }
bool setup_buffer_tests(void) { /* add a suite to the registry */ CU_pSuite pSuite = CU_add_suite_with_setup_and_teardown("Character Buffer Suite", NULL, NULL, buf_test_setup, buf_test_teardown); if (pSuite == NULL) { return false; } /* add the tests to the suite */ if ((CU_add_test(pSuite, "Buffer Append", buf_test_append) == NULL) || (CU_add_test(pSuite, "Buffer Append Char", buf_test_append_char) == NULL) || (CU_add_test(pSuite, "Buffer Append Str", buf_test_append_str) == NULL) || (CU_add_test(pSuite, "Buffer Char At", buf_test_char_at) == NULL) || (CU_add_test(pSuite, "Buffer Duplicate", buf_test_dup) == NULL) || (CU_add_test(pSuite, "Buffer Substring", buf_test_substr) == NULL) || (CU_add_test(pSuite, "Buffer Equals", buf_test_equals) == NULL) || (CU_add_test(pSuite, "Buffer Equals Char*", buf_test_equals_char) == NULL) || (CU_add_test(pSuite, "Buffer To Char*", buf_test_to_char_array) == NULL) || (CU_add_test(pSuite, "Buffer Compare", buf_test_compare) == NULL) || (CU_add_test(pSuite, "Buffer Compare as UTF-8", buf_test_compare_utf8) == NULL)) { return false; } return true; }
static CU_ErrorCode add_tests(const char *testname_re) { char *family_re = NULL; char *suite_re = NULL; char *test_re = NULL; char *cp; struct test_family *fp; libiscsi_suite_info *sp; CU_TestInfo *tp; /* if not testname(s) register all tests */ if (!testname_re) { family_re = strdup("*"); suite_re = strdup("*"); test_re = strdup("*"); } else { /* * break testname_re into family/suite/test * * syntax is: FAMILY[.SUITE[.TEST]] */ family_re = strdup(testname_re); if ((cp = strchr(family_re, '.')) != NULL) { *cp++ = 0; suite_re = strdup(cp); if ((cp = strchr(suite_re, '.')) != NULL) { *cp++ = 0; test_re = strdup(cp); } } if (!suite_re) suite_re = strdup("*"); if (!test_re) test_re = strdup("*"); if (!family_re) { fprintf(stderr, "error: can't parse test family name: %s\n", family_re); return CUE_NOTEST; } } /* * cycle through the test families/suites/tests, adding * ones that match */ for (fp = families; fp->name; fp++) { if (fnmatch(family_re, fp->name, 0) != 0) continue; for (sp = fp->suites; sp->pName != NULL; sp++) { int suite_added = 0; CU_pSuite pSuite = NULL; if (fnmatch(suite_re, sp->pName, 0) != 0) continue; for (tp = sp->pTests; tp->pName != NULL; tp++) { if (fnmatch(test_re, tp->pName, 0) != 0) { continue; } if (!suite_added) { suite_added++; #ifdef HAVE_CU_SUITEINFO_PSETUPFUNC pSuite = CU_add_suite_with_setup_and_teardown(sp->pName, sp->pInitFunc, sp->pCleanupFunc, sp->pSetUpFunc, sp->pTearDownFunc); #else pSuite = CU_add_suite(sp->pName, sp->pInitFunc, sp->pCleanupFunc); #endif } CU_add_test(pSuite, tp->pName, tp->pTestFunc); } } } /* all done -- clean up */ free(family_re); free(suite_re); free(test_re); return CUE_SUCCESS; }