3 * Copyright (C) 2018 Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
9 #include "./unittest.h"
11 /* XXX workaround lib/memalign.c's dependency on smalloc.c */
12 void *smalloc(size_t size)
22 CU_ErrorCode fio_unittest_add_suite(const char *name, CU_InitializeFunc initfn,
23 CU_CleanupFunc cleanfn, struct fio_unittest_entry *tvec)
26 struct fio_unittest_entry *t;
28 pSuite = CU_add_suite(name, initfn, cleanfn);
30 CU_cleanup_registry();
31 return CU_get_error();
35 while (t && t->name) {
36 if (!CU_add_test(pSuite, t->name, t->fn)) {
37 CU_cleanup_registry();
38 return CU_get_error();
46 static void fio_unittest_register(CU_ErrorCode (*fn)(void))
48 if (fn && fn() != CUE_SUCCESS) {
49 fprintf(stderr, "%s\n", CU_get_error_msg());
56 if (CU_initialize_registry() != CUE_SUCCESS) {
57 fprintf(stderr, "%s\n", CU_get_error_msg());
61 fio_unittest_register(fio_unittest_lib_memalign);
62 fio_unittest_register(fio_unittest_lib_strntol);
63 fio_unittest_register(fio_unittest_oslib_strlcat);
64 fio_unittest_register(fio_unittest_oslib_strndup);
65 fio_unittest_register(fio_unittest_oslib_strcasestr);
66 fio_unittest_register(fio_unittest_oslib_strsep);
68 CU_basic_set_mode(CU_BRM_VERBOSE);
70 CU_cleanup_registry();
72 return CU_get_error();