int main(
        const int argc,
        const char* const * argv)
{
    int exitCode = 1;
    const char* progname = basename((char*) argv[0]);

    if (-1 == openulog(progname, 0, LOG_LOCAL0, "-")) {
        (void) fprintf(stderr, "Couldn't open logging system\n");
    }
    else {
        if (CUE_SUCCESS == CU_initialize_registry()) {
            CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown);

            if (NULL != testSuite) {
                if (CU_ADD_TEST(testSuite, test_msm_init)
                        && CU_ADD_TEST(testSuite, test_locking)
                        && CU_ADD_TEST(testSuite, test_msm_put)
                        && CU_ADD_TEST(testSuite, test_msm_getPid)
                        && CU_ADD_TEST(testSuite, test_msm_removePid)
                        && CU_ADD_TEST(testSuite, test_msm_destroy)
                        ) {
                    CU_basic_set_mode(CU_BRM_VERBOSE);
                    (void) CU_basic_run_tests();
                }
            }

            exitCode = CU_get_number_of_tests_failed();
            CU_cleanup_registry();
        }
    }

    return exitCode;
}
Beispiel #2
0
int main(
        const int argc,
        const char* const * argv)
{
    int exitCode = 1;
    const char* progname = basename((char*) argv[0]);

    (void)log_init(progname);

    if (CUE_SUCCESS == CU_initialize_registry()) {
        CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown);

        if (NULL != testSuite) {
            if (CU_ADD_TEST(testSuite, test_exe_new) &&
                    CU_ADD_TEST(testSuite, test_exe_submit) &&
                    CU_ADD_TEST(testSuite, test_exe_shutdown_empty) &&
                    CU_ADD_TEST(testSuite, test_exe_shutdown) &&
                    CU_ADD_TEST(testSuite, test_submit_while_shutdown) &&
                    CU_ADD_TEST(testSuite, test_exe_clear)) {
                CU_basic_set_mode(CU_BRM_VERBOSE);
                (void) CU_basic_run_tests();
            }
        }

        exitCode = CU_get_number_of_tests_failed();
        CU_cleanup_registry();
    }

    log_free();

    return exitCode;
}
Beispiel #3
0
int
main(
    const int           argc,
    const char* const*  argv)
{
    int         exitCode = EXIT_FAILURE;

    if (log_init(argv[0])) {
        (void)fprintf(stderr, "Couldn't initialize logging system\n");
    }
    else {
        if (CUE_SUCCESS == CU_initialize_registry()) {
            CU_Suite*       testSuite = CU_add_suite(__FILE__, setup,
                teardown);

            if (NULL != testSuite) {
                CU_ADD_TEST(testSuite, test_add_get);
                CU_ADD_TEST(testSuite, test_order);

                if (CU_basic_run_tests() == CUE_SUCCESS)
                    exitCode = CU_get_number_of_suites_failed() +
                            CU_get_number_of_tests_failed();
            }

            CU_cleanup_registry();
        } /* CUnit registery allocated */

        log_free();
    } /* logging system initialized */

    return exitCode;
}
Beispiel #4
0
void TcuExecute(void)
{
    if (TestGetAutomatic()) {
        if (TestGetFilename()) {
            CU_set_output_filename(TestGetFilename());
        }
        CU_automated_run_tests();
    }
    else if (TestGetBasic()) {
        CU_basic_set_mode(CU_BRM_VERBOSE);
        (void) CU_basic_run_tests();
    }
    else if (TestGetConsole()) {
        CU_console_run_tests();
    }
    else if (TestGetList()) {
        if (TestGetFilename()) {
            CU_set_output_filename(TestGetFilename());
        }
        (void) CU_list_tests_to_file();
    }

	if (CU_get_number_of_tests_failed()) {
		return;
	}

    /* Clean up the registry */

    CU_cleanup_registry();
}
Beispiel #5
0
int main(
        const int argc,
        const char* const * argv)
{
    int exitCode = 1; // Failure default
    int status = log_init(argv[0]);

    if (status) {
        (void) fprintf(stderr, "Couldn't initialize logging system\n");
    }
    else {
        if (CUE_SUCCESS == CU_initialize_registry()) {
            CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown);

            if (NULL != testSuite) {
                if (CU_ADD_TEST(testSuite, test_fq_new) &&
                        CU_ADD_TEST(testSuite, test_fq_shutdown) &&
                        CU_ADD_TEST(testSuite, test_write_then_read) &&
                        CU_ADD_TEST(testSuite, test_concurrency)) {
                    CU_basic_set_mode(CU_BRM_VERBOSE);
                    (void) CU_basic_run_tests();
                }
            }

            exitCode = CU_get_number_of_tests_failed();
            CU_cleanup_registry();
        }
    }

    log_fini();
    return exitCode;
}
int main() {
    if (CU_initialize_registry() != CUE_SUCCESS)
        return CU_get_error();

    unsigned int tests_failed = 0;
    CU_pSuite suite = CU_add_suite("Shunting Yard", NULL, NULL);
    if (!suite)
        goto exit;

    if (!CU_add_test(suite, "addition", test_addition) ||
            !CU_add_test(suite, "subtraction", test_subtraction) ||
            !CU_add_test(suite, "multiplication", test_multiplication) ||
            !CU_add_test(suite, "division", test_division) ||
            !CU_add_test(suite, "modulus", test_modulus) ||
            !CU_add_test(suite, "exponentiation", test_exponentiation) ||
            !CU_add_test(suite, "factorials", test_factorials) ||
            !CU_add_test(suite, "functions", test_functions) ||
            !CU_add_test(suite, "constants", test_constants) ||
            !CU_add_test(suite, "operator precedence", test_precedence) ||
            !CU_add_test(suite, "error handling", test_errors))
        goto exit;

    CU_basic_set_mode(CU_BRM_NORMAL);
    CU_basic_run_tests();
    tests_failed = CU_get_number_of_tests_failed();
exit:
    CU_cleanup_registry();
    return tests_failed ? EXIT_FAILURE : CU_get_error();
}
int liblinphone_tester_run_tests(const char *suite_name, const char *test_name) {
	int i;
	int ret;
	/* initialize the CUnit test registry */
	if (CUE_SUCCESS != CU_initialize_registry())
		return CU_get_error();

	for (i = 0; i < liblinphone_tester_nb_test_suites(); i++) {
		run_test_suite(test_suite[i]);
	}

	if (suite_name){
		CU_pSuite suite;
		CU_basic_set_mode(CU_BRM_VERBOSE);
		suite=CU_get_suite(suite_name);
		if (!suite) {
			ms_error("Could not find suite '%s'. Available suites are:", suite_name);
			liblinphone_tester_list_suites();
			return -1;
		} else if (test_name) {
			CU_pTest test=CU_get_test_by_name(test_name, suite);
			if (!test) {
				ms_error("Could not find test '%s' in suite '%s'. Available tests are:", test_name, suite_name);
				// do not use suite_name here, since this method is case sentisitive
				liblinphone_tester_list_suite_tests(suite->pName);
				return -2;
			} else {
				CU_ErrorCode err= CU_basic_run_test(suite, test);
				if (err != CUE_SUCCESS) ms_error("CU_basic_run_test error %d", err);
			}
		} else {
			CU_basic_run_suite(suite);
		}
	} else
	{
#if HAVE_CU_CURSES
		if (curses) {
			/* Run tests using the CUnit curses interface */
			CU_curses_run_tests();
		}
		else
#endif
		{
			/* Run all tests using the CUnit Basic interface */
			CU_basic_set_mode(CU_BRM_VERBOSE);
			CU_basic_run_tests();
		}
	}

	ret=CU_get_number_of_tests_failed()!=0;

	/* Redisplay list of failed tests on end */
	if (CU_get_number_of_failure_records()){
		CU_basic_show_failures(CU_get_failure_list());
		printf("\n");
	}

	CU_cleanup_registry();
	return ret;
}
Beispiel #8
0
int main(
        const int argc,
        const char* const * argv)
{
    int exitCode = 1;

    if (log_init(argv[0])) {
        log_syserr("Couldn't initialize logging module");
        exitCode = EXIT_FAILURE;
    }
    else {
        if (CUE_SUCCESS == CU_initialize_registry()) {
            CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown);

            if (NULL != testSuite) {
                if (CU_ADD_TEST(testSuite, test_socketpair)) {
                    CU_basic_set_mode(CU_BRM_VERBOSE);
                    (void) CU_basic_run_tests();
                }
            }

            exitCode = CU_get_number_of_tests_failed();
            CU_cleanup_registry();
        }

        log_fini();
    }

    return exitCode;
}
Beispiel #9
0
int main(
        const int argc,
        const char* const * argv)
{
    int exitCode = 1;
    const char* progname = basename((char*) argv[0]);

    if (log_init(progname)) {
        (void) fprintf(stderr, "Couldn't open logging system\n");
        exitCode = 1;
    }
    else {
        if (CUE_SUCCESS == CU_initialize_registry()) {
            CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown);

            if (NULL != testSuite) {
                if (CU_ADD_TEST(testSuite, test_null_buffer) &&
                        CU_ADD_TEST(testSuite, test_ft_format_none) &&
                        CU_ADD_TEST(testSuite, test_ft_format_any) &&
                        CU_ADD_TEST(testSuite, test_ft_format_ids_ddplus) &&
                        CU_ADD_TEST(testSuite, test_ps_format) &&
                        CU_ADD_TEST(testSuite, test_ts_format) &&
                        CU_ADD_TEST(testSuite, test_pc_format)) {
                    CU_basic_set_mode(CU_BRM_VERBOSE);
                    (void) CU_basic_run_tests();
                }
            }

            exitCode = CU_get_number_of_tests_failed();
            CU_cleanup_registry();
        }
    }

    return exitCode;
}
Beispiel #10
0
int main() {
  // Set the library error handler to the custom one
  gmcmc_error_handler = cu_error_handler;

  // Initialise the CUnit test registry
  CU_ErrorCode error;
  if ((error = CU_initialize_registry()) != CUE_SUCCESS) {
    fprintf(stderr, "failed to initialise test registry: %s\n", CU_get_error_msg());
    return error;
  }
  
  // Create a test suite within the registry
  CU_pSuite suite;
  if ((suite = CU_add_suite("prior", NULL, NULL)) == NULL) {
    fprintf(stderr, "failed to create test suite: %s\n", CU_get_error_msg());
    return error;
  }
  
  // Add the tests to the suite
  if (CU_ADD_TEST(suite, test_prior_create) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }
  if (CU_ADD_TEST(suite, test_prior_sample) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }
  if (CU_ADD_TEST(suite, test_prior_evaluate) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }
  if (CU_ADD_TEST(suite, test_prior_evaluate_1st_order) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }
  if (CU_ADD_TEST(suite, test_prior_evaluate_2nd_order) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }

  // Run the test suites using the CUnit basic interface
  if ((error = CU_basic_run_tests()) != CUE_SUCCESS) {
    fprintf(stderr, "failed to run tests: %s\n", CU_get_error_msg());
    return error;
  }

  // Display any failures (plus hack for newline afterwards)
  CU_basic_show_failures(CU_get_failure_list());
  if (CU_get_number_of_failure_records() > 0) printf("\n");

  // Get the number of tests that failed
  unsigned int failures = CU_get_number_of_tests_failed();

  // Cleanup the test registry
  CU_cleanup_registry();

  // Return the number of test failures
  return (int)failures;
}
Beispiel #11
0
int
main(int argc, char *argv[])
{
        CU_pSuite kvstore_suite = NULL;
        unsigned int fails = 0;
        printf("starting tests for kvstore...\n");

        if (!CUE_SUCCESS == CU_initialize_registry()) {
                fprintf(stderr, "error initialising CUnit test registry!\n");
                return EXIT_FAILURE;
        }

        /*
         * set up the suite
         */
        kvstore_suite = CU_add_suite("kvstore_tests", initialise_kvstore_test,
                                 cleanup_kvstore_test);

        if (NULL == kvstore_suite)
                destroy_test_registry();

        if (NULL == CU_add_test(kvstore_suite, "lifecycle",
                    test_kvstore_new))
                destroy_test_registry();

        if (NULL == CU_add_test(kvstore_suite, "double refcount check",
                    test_kvstore_refcount))
                destroy_test_registry();

        if (NULL == CU_add_test(kvstore_suite, "many refcounts check",
                    test_kvstore_many_refcounts))
                destroy_test_registry();

        if (NULL == CU_add_test(kvstore_suite, "kvstore set",
                    test_kvstore_set))
                destroy_test_registry();

        if (NULL == CU_add_test(kvstore_suite, "kvstore update",
                    test_kvstore_update))
                destroy_test_registry();

        if (NULL == CU_add_test(kvstore_suite, "kvstore delete",
                    test_kvstore_del))
                destroy_test_registry();

        if (NULL == CU_add_test(kvstore_suite, "multikey test",
                    test_kvstore_multikey))
                destroy_test_registry();

        CU_basic_set_mode(CU_BRM_VERBOSE);
        CU_basic_run_tests();
        fails = CU_get_number_of_tests_failed();

        CU_cleanup_registry();
        return fails;
}
Beispiel #12
0
int main(int argc, char *argv[])
{
   CU_ErrorCode cuStatus = CU_initialize_registry();
   if (CUE_SUCCESS != cuStatus)
   {
      fprintf(stderr, "could not create CUnit test registry\n");
      return -1;
   }

   gcstl_test_testStartPrint();

   CU_TestInfo test_gcstl_destroy[] =
      {
         { "test_gcstl_destroy_default", test_gcstl_destroy_default },
         CU_TEST_INFO_NULL
      };

   CU_TestInfo test_gcstl_rbtree[] =
      {
         { "test_gcstl_rbtree_insert", test_gcstl_rbtree_insert },
         { "test_gcstl_rbtree_remove", test_gcstl_rbtree_remove },
         CU_TEST_INFO_NULL
      };

   CU_SuiteInfo gcstl_test_suites[] =
      {
         { "test_gcstl_destroy", NULL, NULL, test_gcstl_destroy},
         { "test_gcstl_rbtree", NULL, NULL, test_gcstl_rbtree },
         CU_SUITE_INFO_NULL
      };

   cuStatus = CU_register_suites(gcstl_test_suites);
   if (CUE_SUCCESS != cuStatus)
   {
      fprintf(stderr, "could register CUnit test suites\n");
      return -1;
   }

   CU_basic_run_tests();
   if (CUE_SUCCESS != cuStatus)
   {
      gcstl_test_testFailedToCompletePrint();
      return -1;
   }
   else if (0 != CU_get_number_of_tests_failed())
   {
      gcstl_test_testCompleteWithFailuresPrint();
      return -1;
   }

   gcstl_test_testCompleteSuccessfullyPrint();

   CU_cleanup_registry();

   return 0;
}
Beispiel #13
0
int main(int argc, char **argv) {

    if (argc == 2 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)) {
        fprintf(stderr, "usage %s [test prefix]\n\ntest options:\n", argv[0]);
        for (test_case_t *p = test_cases; p != NULL; p = p->next) {
            fprintf(stderr, " %s\n", p->description);
        }
        return EXIT_FAILURE;
    }

    if (CU_initialize_registry() != CUE_SUCCESS) {
        CU_ErrorCode err = CU_get_error();
        fprintf(stderr, "failed to initialise CUnit registry\n");
        return err;
    }

    CU_pSuite suite = CU_add_suite("passwand", NULL, NULL);
    if (suite == NULL) {
        CU_ErrorCode err = CU_get_error();
        CU_cleanup_registry();
        fprintf(stderr, "failed to add suite\n");
        return err;
    }

    unsigned total = 0;
    for (test_case_t *p = test_cases; p != NULL; p = p->next) {
        if (argc == 1 || strncmp(argv[1], p->description, strlen(argv[1])) == 0) {
            if (CU_add_test(suite, p->description, p->function) == NULL) {
                CU_ErrorCode err = CU_get_error();
                fprintf(stderr, "failed to add test \"%s\"\n", p->description);
                CU_cleanup_registry();
                return err;
            }
            total++;
        }
    }

    if (total == 0) {
        fprintf(stderr, "no tests found\n");
        return EXIT_FAILURE;
    }

    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();

    unsigned failed = CU_get_number_of_tests_failed();

    CU_cleanup_registry();

    printf("%u/%u passed\n", total - failed, total);

    return failed > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
static int clean_quit(void) {
    
    int failures = (int)CU_get_number_of_tests_failed();
    
    CU_cleanup_registry();
    /* return CU_get_error(); */
    
    /* return number of failures so runs launched by Makefile
     * will stop when error is encountered 
     */
    return failures;
}
Beispiel #15
0
/*
 * Main
 */
int
main(void)
{
	CU_pSuite ptr_suite = NULL;
	int nr_of_failed_tests = 0;
	int nr_of_failed_suites = 0;

	/* Initialize the CUnit test registry */
	if (CUE_SUCCESS != CU_initialize_registry())
		return CU_get_error();

	/* add a suite to the registry */
	ptr_suite = CU_add_suite("ofp port config", init_suite, clean_suite);
	if (NULL == ptr_suite) {
		CU_cleanup_registry();
		return CU_get_error();
	}

	if (NULL == CU_ADD_TEST(ptr_suite,
				test_sinlge_port_basic)) {
		CU_cleanup_registry();
		return CU_get_error();
	}

	if (NULL == CU_ADD_TEST(ptr_suite,
				test_two_ports_vlan)) {
		CU_cleanup_registry();
		return CU_get_error();
	}

	if (NULL == CU_ADD_TEST(ptr_suite,
				test_gre_port)) {
		CU_cleanup_registry();
		return CU_get_error();
	}

#if OFP_TESTMODE_AUTO
	CU_set_output_filename("CUnit-Port-conf");
	CU_automated_run_tests();
#else
	/* Run all tests using the CUnit Basic interface */
	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();
#endif

	nr_of_failed_tests = CU_get_number_of_tests_failed();
	nr_of_failed_suites = CU_get_number_of_suites_failed();
	CU_cleanup_registry();

	return (nr_of_failed_suites > 0 ?
		nr_of_failed_suites : nr_of_failed_tests);
}
/* The main() function for setting up and running the tests.
 * Returns a CUE_SUCCESS on successful running, another
 * CUnit error code on failure.
 */
int main()
{
  trn_init();
  CU_pSuite Suite_grid = NULL;
  CU_pSuite Suite_game = NULL;
  CU_pSuite suitePiece = NULL;
  CU_pSuite suiteFunctional = NULL;


  /* initialize the CUnit test registry */
  if (CUE_SUCCESS != CU_initialize_registry())
    return CU_get_error();

  /* Create TrnGrid test suite */
  ADD_SUITE_TO_REGISTRY(Suite_grid);
  ADD_TEST_TO_SUITE(Suite_grid, test_grid_new_destroy);
  ADD_TEST_TO_SUITE(Suite_grid, test_grid_set_get_cell);
  ADD_TEST_TO_SUITE(Suite_grid, test_piece_position_in_grid);
  ADD_TEST_TO_SUITE(Suite_grid, test_grid_set_cells_with_piece);
  ADD_TEST_TO_SUITE(Suite_grid, TestGridCellIsInGrid);
  ADD_TEST_TO_SUITE(Suite_grid, TestGridCellIsInGridAndIsVoid);
  ADD_TEST_TO_SUITE(Suite_grid, TestGridCanSetCellsWithPiece);
  ADD_TEST_TO_SUITE(Suite_grid, test_grid_pop_row_and_make_above_fall);
  ADD_TEST_TO_SUITE(Suite_grid, test_grid_find_last_complete_row_index);
  ADD_TEST_TO_SUITE(Suite_grid, test_clear_row);
  ADD_TEST_TO_SUITE(Suite_grid, test_set_grid_to_zero);

    /* Create TrnGame test suite */
  ADD_SUITE_TO_REGISTRY(Suite_game);
  ADD_TEST_TO_SUITE(Suite_game, test_game_update_score);
  ADD_TEST_TO_SUITE(Suite_game, test_complete_rows);

    /* Create TrnPiece test suite */
  ADD_SUITE_TO_REGISTRY(suitePiece );
  ADD_TEST_TO_SUITE(suitePiece, test_piece_move_to_left);
  ADD_TEST_TO_SUITE(suitePiece, test_piece_move_to_right);
  ADD_TEST_TO_SUITE(suitePiece, test_piece_move_to_bottom);
  ADD_TEST_TO_SUITE(suitePiece, test_piece_rotate_clockwise);

    /* Create functional test suite */
  ADD_SUITE_TO_REGISTRY(suiteFunctional);
  ADD_TEST_TO_SUITE(suiteFunctional, stack_some_pieces);

    /* Run all tests using the CUnit Basic interface */
    CU_basic_set_mode(CU_BRM_VERBOSE);
  CU_basic_run_tests();
  int number_of_tests_failed = CU_get_number_of_tests_failed();
  CU_cleanup_registry();

  return number_of_tests_failed;
}
Beispiel #17
0
int main() {
    unsigned int result;
    CU_pSuite pSuite = NULL;

    /* Initialize the CUnit test registry */
    if (CUE_SUCCESS != CU_initialize_registry())
        return CU_get_error();

    /* Add a suite to the registry */
    pSuite = CU_add_suite("SCPI Utils", init_suite, clean_suite);
    if (NULL == pSuite) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* Add the tests to the suite */
    if (0
            || (NULL == CU_add_test(pSuite, "strnpbrk", test_strnpbrk))
            || (NULL == CU_add_test(pSuite, "Int32ToStr", test_Int32ToStr))
            || (NULL == CU_add_test(pSuite, "UInt32ToStrBase", test_UInt32ToStrBase))
            || (NULL == CU_add_test(pSuite, "Int64ToStr", test_Int64ToStr))
            || (NULL == CU_add_test(pSuite, "UInt64ToStrBase", test_UInt64ToStrBase))
            || (NULL == CU_add_test(pSuite, "SCPI_dtostre", test_scpi_dtostre))
            || (NULL == CU_add_test(pSuite, "floatToStr", test_floatToStr))
            || (NULL == CU_add_test(pSuite, "doubleToStr", test_doubleToStr))
            || (NULL == CU_add_test(pSuite, "strBaseToInt32", test_strBaseToInt32))
            || (NULL == CU_add_test(pSuite, "strBaseToUInt32", test_strBaseToUInt32))
            || (NULL == CU_add_test(pSuite, "strBaseToInt64", test_strBaseToInt64))
            || (NULL == CU_add_test(pSuite, "strBaseToUInt64", test_strBaseToUInt64))
            || (NULL == CU_add_test(pSuite, "strToDouble", test_strToDouble))
            || (NULL == CU_add_test(pSuite, "compareStr", test_compareStr))
            || (NULL == CU_add_test(pSuite, "compareStrAndNum", test_compareStrAndNum))
            || (NULL == CU_add_test(pSuite, "matchPattern", test_matchPattern))
            || (NULL == CU_add_test(pSuite, "matchCommand", test_matchCommand))
            || (NULL == CU_add_test(pSuite, "composeCompoundCommand", test_composeCompoundCommand))
            || (NULL == CU_add_test(pSuite, "swap", test_swap))
#if USE_DEVICE_DEPENDENT_ERROR_INFORMATION && !USE_MEMORY_ALLOCATION_FREE
            || (NULL == CU_add_test(pSuite, "heap", test_heap))
#endif
            ) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* Run all tests using the CUnit Basic interface */
    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    result = CU_get_number_of_tests_failed();
    CU_cleanup_registry();
    return result ? result : CU_get_error();
}
Beispiel #18
0
int main() {
  // Initialise the CUnit test registry
  CU_ErrorCode error;
  if ((error = CU_initialize_registry()) != CUE_SUCCESS) {
    fprintf(stderr, "failed to initialise test registry: %s\n", CU_get_error_msg());
    return error;
  }

  // Create a test suite within the registry
  CU_pSuite suite;
  if ((suite = CU_add_suite("lognormal", test_init, test_cleanup)) == NULL) {
    fprintf(stderr, "failed to create test suite: %s\n", CU_get_error_msg());
    return error;
  }

  // Add the tests to the suite
  if (CU_ADD_TEST(suite, test_params) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }
  if (CU_ADD_TEST(suite, test_evaluation) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }
  if (CU_ADD_TEST(suite, test_statistics) == NULL) {
    fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg());
    return error;
  }

  // Run the test suites using the CUnit basic interface
  if ((error = CU_basic_run_tests()) != CUE_SUCCESS) {
    fprintf(stderr, "failed to run tests: %s\n", CU_get_error_msg());
    return error;
  }

  // Display any failures (plus hack for newline afterwards)
  CU_basic_show_failures(CU_get_failure_list());
  if (CU_get_number_of_failure_records() > 0) printf("\n");

  // Get the number of tests that failed
  unsigned int failures = CU_get_number_of_tests_failed();

  // Cleanup the test registry
  CU_cleanup_registry();

  // Return the number of test failures
  return (int)failures;
}
Beispiel #19
0
int main() {
	printf("Testing DAGDB\n");
	CU_initialize_registry();
	//CU_basic_set_mode(CU_BRM_SILENT);
	CU_basic_set_mode(CU_BRM_NORMAL);
	//CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_register_suites(error_suites);
	CU_register_suites(bitarray_suites);
	CU_register_suites(mem_suites);
	CU_register_suites(base_suites);
	CU_register_suites(api_suites);
	CU_basic_run_tests();
	int result = CU_get_number_of_tests_failed();
	CU_cleanup_registry();
	return result; 
}
/*
 * Set up and run tests.
 *
 * @return CUE_SUCCESS if successful, else a CUnit error code if
 * any problems arise.
 */
int main()
{
  int	r;

  r = 0;
    if (CUE_SUCCESS != CU_initialize_registry())
    {
        return CU_get_error();
    }

    CU_pSuite suite = 
        CU_add_suite("Fibonacci Suite", initialise_suite, cleanup_suite);
    if (NULL == suite) 
    {
        CU_cleanup_registry();
        return CU_get_error();
    }

    if ((NULL == CU_add_test(suite, "test_fibonacci_1", test_fibonacci_1)) ||
        (NULL == CU_add_test(suite, "test_fibonacci_2", test_fibonacci_2)) ||
        (NULL == CU_add_test(suite, "test_fibonacci_3", test_fibonacci_3)) ||
        (NULL == CU_add_test(suite, "test_fibonacci_30", test_fibonacci_30)))
    {
        CU_cleanup_registry();
        return CU_get_error();
    }

    // Run all tests using CUnit Basic interface which outputs
    // results to command-line.
    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    r = CU_get_number_of_tests_failed();
    // Run all tests using CUnit Automated interface which outputs
    // results to a file, default name CUnitAutomated-Results.xml.
    // DTD CUnit-Run.dtd and and XSL stylesheet CUnit-Run.xsl in Share/
    // Uncomment this line to override default output file prefix.
    // CU_set_output_filename("Test");
    //CU_list_tests_to_file();

    // Output listing of tests in suites to a file, default name
    // CUnitAutomated-Listing.xml
    // DTD CUnit-List.dtd and and XSL stylesheet CUnit-List.xsl in Share/
    //CU_automated_run_tests();

    CU_cleanup_registry();
    return r;
}
Beispiel #21
0
int main()
{
    CU_pSuite pSuite = NULL;
    unsigned int    fails;

    /* initialize the CUnit test registry */
    if (CUE_SUCCESS != CU_initialize_registry())
        return CU_get_error();

    /* add a suite to the registry */
    pSuite = CU_add_suite("dcap_url", init_suite, clean_suite);
    if (NULL == pSuite) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* add the tests to the suite */
    if (
            (NULL == CU_add_test(pSuite, "not a url", test_not_a_url))
            ||
            (NULL == CU_add_test(pSuite, "well formated url", test_url))
            ||
            (NULL == CU_add_test(pSuite, "well formated url with prefix", test_url_with_prefix))
            ||
            (NULL == CU_add_test(pSuite, "url without port number", test_url_no_port))
            ||
            (NULL == CU_add_test(pSuite, "url with ipv4", test_url_ipv4))
            ||
            (NULL == CU_add_test(pSuite, "url with ipv4, no port number", test_url_ipv4_no_port))
            ||
            (NULL == CU_add_test(pSuite, "url with ipv6", test_url_ipv6))
            ||
            (NULL == CU_add_test(pSuite, "url with ipv6, no port", test_url_ipv6_no_port))
            ||
            (NULL == CU_add_test(pSuite, "bad formated url", test_bad_formated))
            ) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* Run all tests using the CUnit Basic interface */
    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    fails = CU_get_number_of_tests_failed();
    CU_cleanup_registry();
    return fails;
}
Beispiel #22
0
/*
 * The main function sets up the test suite, registers the test cases,
 * runs through them, and hopefully doesn't explode.
 */
int
main(void)
{
	CU_pSuite       tsuite = NULL;
	unsigned int    fails;

	if (!(CUE_SUCCESS == CU_initialize_registry())) {
		errx(EX_CONFIG, "failed to initialise test registry");
		return EXIT_FAILURE;
	}

	tsuite = CU_add_suite("strongbox_test", init_test, cleanup_test);
	if (NULL == tsuite)
		fireball();

	if (NULL == CU_add_test(tsuite, "opening box", test_decrypt))
		fireball();
	if (NULL == CU_add_test(tsuite, "basic checks", test_identity))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #1", test_vector1))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #2", test_vector2))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #3", test_vector3))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #4", test_vector4))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #5", test_vector5))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #6", test_vector6))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #7", test_vector7))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #8", test_vector8))
		fireball();
	if (NULL == CU_add_test(tsuite, "test vector #9", test_vector9))
		fireball();

	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();
	fails = CU_get_number_of_tests_failed();
	warnx("%u tests failed", fails);

	CU_cleanup_registry();
	return fails;
}
Beispiel #23
0
int main(int argc, char **argv) {
  CU_pSuite suite;
  int ret, failed_num;
  pid_t pid;

  signal(SIGPIPE, SIG_IGN);

  // preprocessing of tests
  test_init();

  pid = start_newtd();
  if(pid > 0) {
    CU_initialize_registry();

    ADD_TESTS(test_optparse);
    ADD_TESTS(test_config);
    ADD_TESTS(test_signal);
    ADD_TESTS(test_daemon);
    ADD_TESTS(test_frame);
    ADD_TESTS(test_stomp);
    ADD_TESTS(test_queue);
    ADD_TESTS(test_transaction);
    ADD_TESTS(test_persistent);
    ADD_TESTS(test_proto_connect);
    ADD_TESTS(test_proto_disconnect);
    ADD_TESTS(test_proto_subscribe);
    ADD_TESTS(test_proto_reply_to);
    ADD_TESTS(test_proto_topic);
    ADD_TESTS(test_proto_begin);
    ADD_TESTS(test_proto_error);
    ADD_TESTS(test_newtctl_worker);

    CU_basic_run_tests();

    failed_num = CU_get_number_of_tests_failed();

    CU_cleanup_registry();


    kill(pid, SIGINT);
    wait(NULL);
  }

  return failed_num;
}
Beispiel #24
0
int main(int argc, char** argv)
{
	CU_initialize_registry();

	CU_pSuite suite_memory = CU_add_suite("Memory", NULL, NULL);
	CU_ADD_TEST(suite_memory, test_phalcon_alloc_zval);
	CU_ADD_TEST(suite_memory, test_phalcon_init_var);
	CU_ADD_TEST(suite_memory, test_phalcon_init_nvar);
	CU_ADD_TEST(suite_memory, test_phalcon_init_nvar_pnull);
	CU_ADD_TEST(suite_memory, test_phalcon_cpy_wrt);
	CU_ADD_TEST(suite_memory, test_phalcon_cpy_wrt_ctor);
	CU_ADD_TEST(suite_memory, test_phalcon_obs_var);
	CU_ADD_TEST(suite_memory, test_phalcon_obs_nvar);
	CU_ADD_TEST(suite_memory, test_phalcon_separate);
	CU_ADD_TEST(suite_memory, test_phalcon_separate_param);

	CU_pSuite suite_assert = CU_add_suite("Assert", setup_assert, teardown_assert);
	CU_ADD_TEST(suite_assert, test_phalcon_assert_class);

	CU_pSuite suite_array = CU_add_suite("Array", NULL, NULL);
	CU_ADD_TEST(suite_array, test_phalcon_array_unshift);
	CU_ADD_TEST(suite_array, test_phalcon_array_values);
	CU_ADD_TEST(suite_array, test_phalcon_array_key_exists);

	CU_pSuite suite_variables = CU_add_suite("Variables", NULL, NULL);
	CU_ADD_TEST(suite_variables, test_phalcon_serialize);
	CU_ADD_TEST(suite_variables, test_phalcon_unserialize);

	CU_pSuite suite_testbed = CU_add_suite("Testbed", NULL, NULL);
	CU_ADD_TEST(suite_testbed, test_increment);
	CU_ADD_TEST(suite_testbed, test_phalcon_mvc_router_route__construct);
	CU_ADD_TEST(suite_testbed, test_array_mess);
	CU_ADD_TEST(suite_testbed, test_exceptions);
	CU_ADD_TEST(suite_testbed, test_unclean_shutdown);

	initialize_embed_wrapper();

	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();

	CU_cleanup_registry();
	return CU_get_number_of_tests_failed() ? EXIT_FAILURE : EXIT_SUCCESS;
}
Beispiel #25
0
/** Handler function called at completion of each test.
 * @param pTest   The test being run.
 * @param pSuite  The suite containing the test.
 * @param pFailure Pointer to the 1st failure record for this test.
 */
static void curses_test_complete_message_handler(const CU_pTest pTest,
                                                 const CU_pSuite pSuite,
                                                 const CU_pFailureRecord pFailure)
{
  /* Not used in curses implementation - quiet compiler warning */
  CU_UNREFERENCED_PARAMETER(pTest);
  CU_UNREFERENCED_PARAMETER(pSuite);
  CU_UNREFERENCED_PARAMETER(pFailure);

  f_uiTestsRun++;
  if (CU_get_number_of_tests_failed() != f_uiTestsFailed) {
    f_uiTestsFailed++;
  }
  else {
    f_uiTestsRunSuccessful++;
  }

  refresh_summary_window();
  refresh_progress_window();
}
Beispiel #26
0
int main(void)
{
	CU_pSuite ptr_suite = NULL;
	int nr_of_failed_tests = 0;
	int nr_of_failed_suites = 0;

	/* Initialize the CUnit test registry */
	if (CUE_SUCCESS != CU_initialize_registry())
		return CU_get_error();

	/* add a suite to the registry */
	ptr_suite = CU_add_suite("ofp errno", init_suite, NULL);
	if (NULL == ptr_suite) {
		CU_cleanup_registry();
		return CU_get_error();
	}
	if (NULL == CU_ADD_TEST(ptr_suite, test_strerrno)) {
		CU_cleanup_registry();
		return CU_get_error();
	}
	if (NULL == CU_ADD_TEST(ptr_suite, test_tls_errno)) {
		CU_cleanup_registry();
		return CU_get_error();
	}

#if defined(OFP_TESTMODE_AUTO)
	CU_set_output_filename("CUnit-Util");
	CU_automated_run_tests();
#else
	/* Run all tests using the CUnit Basic interface */
	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();
#endif

	nr_of_failed_tests = CU_get_number_of_tests_failed();
	nr_of_failed_suites = CU_get_number_of_suites_failed();
	CU_cleanup_registry();

	return (nr_of_failed_suites > 0 ?
		nr_of_failed_suites : nr_of_failed_tests);
}
Beispiel #27
0
int liblinphone_tester_run_tests(const char *suite_name, const char *test_name) {
	int i;
	int ret;
	/* initialize the CUnit test registry */
	if (CUE_SUCCESS != CU_initialize_registry())
		return CU_get_error();

	for (i = 0; i < liblinphone_tester_nb_test_suites(); i++) {
		run_test_suite(test_suite[i]);
	}

	if (suite_name){
		CU_pSuite suite;
		CU_basic_set_mode(CU_BRM_VERBOSE);
		suite=CU_get_suite_by_name(suite_name, CU_get_registry());
		if (test_name) {
			CU_pTest test=CU_get_test_by_name(test_name, suite);
			CU_ErrorCode err= CU_basic_run_test(suite, test);
			if (err != CUE_SUCCESS) ms_error("CU_basic_run_test error %d", err);
		} else
			CU_basic_run_suite(suite);
	} else
	{
#if HAVE_CU_CURSES
		if (curses) {
			/* Run tests using the CUnit curses interface */
			CU_curses_run_tests();
		}
		else
#endif
		{
			/* Run all tests using the CUnit Basic interface */
			CU_basic_set_mode(CU_BRM_VERBOSE);
			CU_basic_run_tests();
		}
	}

	ret=CU_get_number_of_tests_failed()!=0;
	CU_cleanup_registry();
	return ret;
}
Beispiel #28
0
void cleanup()
    {
    char cmd[MAXBUF];

    ops_crypto_finish();

    if (CU_get_number_of_tests_failed())
	{
	fprintf(stderr, "Test directory %s retained, "
		"because one or more tests failed.\n", dir);
	}
    else
        {
        /* Remove test dir and files */
        snprintf(cmd, sizeof cmd, "rm -rf %s", dir);
        if (run(cmd))
            {
            perror("Can't delete test directory ");
            return;
            }
        }
    }
Beispiel #29
0
int main(
        const int          argc,
        const char* const* argv)
{
    int exitCode = 1;

    if (CUE_SUCCESS == CU_initialize_registry()) {
        CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown);

        if (NULL != testSuite) {
            if (CU_ADD_TEST(testSuite, test_cond_wait)) {
                CU_basic_set_mode(CU_BRM_VERBOSE);
                (void)CU_basic_run_tests();
            }
        }

        exitCode = CU_get_number_of_suites_failed() +
                CU_get_number_of_tests_failed();
        CU_cleanup_registry();
    }

    return exitCode;
}
Beispiel #30
0
int
main(void)
{
    CU_pSuite card_suite = NULL;
    unsigned int fails = 0;

    printf("starting tests for card...\n");

    if (! CUE_SUCCESS == CU_initialize_registry()) {
        fprintf(stderr, "error initialising CUnit test registry!\n");
        return EXIT_FAILURE;
    }

    /* set up the suite */
    card_suite = CU_add_suite("card_tests", initialise_card_test,
                                            cleanup_card_test);
    if (NULL == card_suite)
        destroy_test_registry();

    /* add tests */
    if (NULL == CU_add_test(card_suite, "test of card_read", test_card_read))
        destroy_test_registry();
    if (NULL == CU_add_test(card_suite, "test of card_str", test_card_str))
        destroy_test_registry();



    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    fails = CU_get_number_of_tests_failed();

    CU_cleanup_registry();

    /* should never get here! */
    return fails;
}