Ejemplo n.º 1
0
int main(void)
{
    CU_pSuite pSuite1 = NULL;
    
    if (CUE_SUCCESS != CU_initialize_registry())
    {
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    pSuite1 = CU_add_suite("Suite_1", NULL, NULL);
    if (NULL == pSuite1)
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    if (NULL == CU_add_test(pSuite1, "some test", test1))
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }

    /* TODO: set output file */

    CU_automated_run_tests();
    CU_cleanup_registry();
    
    return 0;
}
Ejemplo n.º 2
0
CU_pSuite t_init_pdu_tests(void)
{
    CU_pSuite suite[2];

    suite[0] = CU_add_suite("pdu parser", t_pdu_tests_create, t_pdu_tests_remove);
    if (!suite[0])
    { /* signal error */
        fprintf(stderr, "W: cannot add pdu parser test suite (%s)\n", CU_get_error_msg());

        return NULL;
    }

#define PDU_TEST(s,t)						      \
  if (!CU_ADD_TEST(s,t)) {					      \
    fprintf(stderr, "W: cannot add pdu parser test (%s)\n",	      \
	    CU_get_error_msg());				      \
  }

    PDU_TEST(suite[0], t_parse_pdu1);
    PDU_TEST(suite[0], t_parse_pdu2);
    PDU_TEST(suite[0], t_parse_pdu3);
    PDU_TEST(suite[0], t_parse_pdu4);
    PDU_TEST(suite[0], t_parse_pdu5);
    PDU_TEST(suite[0], t_parse_pdu6);
    PDU_TEST(suite[0], t_parse_pdu7);
    PDU_TEST(suite[0], t_parse_pdu8);
    PDU_TEST(suite[0], t_parse_pdu9);
    PDU_TEST(suite[0], t_parse_pdu10);
    PDU_TEST(suite[0], t_parse_pdu11);
    PDU_TEST(suite[0], t_parse_pdu12);
    PDU_TEST(suite[0], t_parse_pdu13);
    PDU_TEST(suite[0], t_parse_pdu14);

    suite[1] = CU_add_suite("pdu encoder", t_pdu_tests_create, t_pdu_tests_remove);
    if (suite[1])
    {
#define PDU_ENCODER_TEST(s,t)						      \
  if (!CU_ADD_TEST(s,t)) {					      \
    fprintf(stderr, "W: cannot add pdu encoder test (%s)\n",	      \
	    CU_get_error_msg());				      \
  }
        PDU_ENCODER_TEST(suite[1], t_encode_pdu1);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu2);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu3);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu4);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu5);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu6);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu7);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu8);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu9);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu10);
        PDU_ENCODER_TEST(suite[1], t_encode_pdu11);

    }
    else
        /* signal error */
        fprintf(stderr, "W: cannot add pdu parser test suite (%s)\n", CU_get_error_msg());

    return suite[0];
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
int main()
{
    CU_ErrorCode error;
    if (CUE_SUCCESS != CU_initialize_registry())
        return CU_get_error();

    error=CU_register_suites(suites);

    if (error != CUE_SUCCESS) {
        perror(CU_get_error_msg());
        CU_cleanup_registry();
        return CU_get_error();

    }



    printf("Seting OK\n");
    fflush(stdout);

    /* Run all tests using the CUnit Basic interface */
    CU_basic_set_mode(CU_BRM_VERBOSE);

    CU_basic_run_tests();

    CU_cleanup_registry();

    return CU_get_error();

}
Ejemplo n.º 5
0
int
main(int argc, char *argv[]) {
    CU_ErrorCode cu;
    CU_pSuite suite;
    const char *configpath, *mode = NULL;
    if (argc < 2) {
        fprintf(stderr, "please gives a configuration file\n");
        exit(-1);
    }

    cu = CU_initialize_registry();
    if (cu != CUE_SUCCESS) {
        fprintf(stderr, "error cunit initialization: %s\n", CU_get_error_msg());
        exit(-1);
    }
    configpath = argv[1];
    if (argc > 2)
        mode = argv[2];

    if (da_cloud_init(&config, configpath) == 0) {
        suite = CU_add_suite("da_cloud", NULL, NULL);
        CU_add_test(suite, "da_cloud_headers_test", da_cloud_headers_test);
        CU_add_test(suite, "da_cloud_simple_lookup", da_cloud_simple_lookup);
        CU_add_test(suite, "da_cloud_properties_test", da_cloud_properties_test);

        if (mode != NULL && strcasecmp(mode, "show") == 0)
            CU_basic_run_tests();
        else
            CU_automated_run_tests();
    }
    da_cloud_fini(&config);
    CU_cleanup_registry();

    return (0);
}
Ejemplo n.º 6
0
void registerJacobiTests()
{
    if (CU_register_suites(jacobi_suites) != CUE_SUCCESS) {
        fprintf(stderr, "Suite registration failed - %s\n", CU_get_error_msg());
        exit(CU_get_error());
    }
}
Ejemplo n.º 7
0
static void parse_and_add_test(char *test)
{
	if (access(test, F_OK) == 0) {
		FILE *fh;
		char t[256];

		if ((fh = fopen(test, "r")) == NULL) {
			printf("Failed to open test-list file %s\n", test);
			exit(10);
		}
		while (fgets(t, sizeof(t), fh) != NULL) {
			while (1) {
				int len = strlen(t);
				if (len == 0) {
					break;
				}
				if (!isprint(t[--len])) {
					t[len] = 0;
					continue;
				}
				break;	
			}
			parse_and_add_tests(t);
		}
		fclose(fh);
		return;
	}

	if (add_tests(test) != CUE_SUCCESS) {
		fprintf(stderr, "error: suite registration failed: %s\n",
		    CU_get_error_msg());
		exit(1);
	}
}
Ejemplo n.º 8
0
CU_pSuite t_init_sendqueue_tests(void)
{
    CU_pSuite suite;

    suite = CU_add_suite("sendqueue", t_sendqueue_tests_create, t_sendqueue_tests_remove);
    if (!suite)
    { /* signal error */
        fprintf(stderr, "W: cannot add sendqueue test suite (%s)\n", CU_get_error_msg());

        return NULL;
    }

#define SENDQUEUE_TEST(s,t)                       \
  if (!CU_ADD_TEST(s,t)) {                        \
    fprintf(stderr, "W: cannot add sendqueue test (%s)\n",        \
        CU_get_error_msg());                      \
  }

    SENDQUEUE_TEST(suite, t_sendqueue1);
    SENDQUEUE_TEST(suite, t_sendqueue2);
    SENDQUEUE_TEST(suite, t_sendqueue3);
    SENDQUEUE_TEST(suite, t_sendqueue4);
    SENDQUEUE_TEST(suite, t_sendqueue5);
    SENDQUEUE_TEST(suite, t_sendqueue6);
    SENDQUEUE_TEST(suite, t_sendqueue7);
    SENDQUEUE_TEST(suite, t_sendqueue8);
    SENDQUEUE_TEST(suite, t_sendqueue9);
    SENDQUEUE_TEST(suite, t_sendqueue10);

    return suite;
}
Ejemplo n.º 9
0
CU_pSuite
t_init_error_response_tests(void) {
  CU_pSuite suite[1];

  suite[0] = CU_add_suite("error response generator",
			  t_error_response_tests_create,
			  t_error_response_tests_remove);
  if (!suite[0]) {			/* signal error */
    fprintf(stderr, "W: cannot add error response generator test suite (%s)\n", 
	    CU_get_error_msg());

    return NULL;
  }

#define ERROR_RESPONSE_TEST(s,t)					\
  if (!CU_ADD_TEST(s,t)) {						\
    fprintf(stderr, "W: cannot add error response generator test (%s)\n", \
	    CU_get_error_msg());					\
  }

  ERROR_RESPONSE_TEST(suite[0], t_error_response1);
  ERROR_RESPONSE_TEST(suite[0], t_error_response2);
  ERROR_RESPONSE_TEST(suite[0], t_error_response3);
  ERROR_RESPONSE_TEST(suite[0], t_error_response4);
  ERROR_RESPONSE_TEST(suite[0], t_error_response5);
  ERROR_RESPONSE_TEST(suite[0], t_error_response6);
  ERROR_RESPONSE_TEST(suite[0], t_error_response7);
  ERROR_RESPONSE_TEST(suite[0], t_error_response8);

  return suite[0];
}
Ejemplo n.º 10
0
/* MAIN */
int main(void) {
	fprintf(stderr, "I'm here!\n");
	CU_pSuite ste = NULL;

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

	ste = CU_add_suite("mutable_string_suite", init_mutable_string_suite, clean_mutable_string_suite);
	if (NULL == ste) {
		CU_cleanup_registry();
		return CU_get_error();
	}
	if (CU_get_error() != CUE_SUCCESS) {
		fprintf(stderr, "Error creating suite: (%d)%s\n", CU_get_error(), CU_get_error_msg());
	}

	ADD_TEST(CU_add_test(ste, "Verify mutable_string_init()...", t_mutable_string_init));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_init_with_value()...", t_mutable_string_init_with_value));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_resize()...", t_mutable_string_resize));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_assign()...", t_mutable_string_assign));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_append()...", t_mutable_string_append));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_copy()...", t_mutable_string_copy));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_append_mutable_string()...", t_mutable_string_append_mutable_string));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_append_char()...", t_mutable_string_append_char));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_char_at()...", t_mutable_string_char_at));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_substring()...", t_mutable_string_substring));
	ADD_TEST(CU_add_test(ste, "Verify mutable_string_int64/32/16()...", t_mutable_string_parse_int));
	// if (CU_get_error() != CUE_SUCCESS) {
		fprintf(stderr, "Error creating suite: (%d)%s\n", CU_get_error(), CU_get_error_msg());
	// }

	// CU_console_run_tests();
	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_ErrorCode run_errors = CU_basic_run_suite(ste);
	if (run_errors != CUE_SUCCESS) {
		fprintf(stderr, "Error running tests: (%d)%s\n", run_errors, CU_get_error_msg());
	}

	CU_basic_show_failures(CU_get_failure_list());
	CU_cleanup_registry();

	printf("\n");
	printf("I'm done!\n");

	return CU_get_error();
}
Ejemplo n.º 11
0
void AddTests(void) {
	assert(NULL != CU_get_registry());
	assert(!CU_is_test_running());
	if(CUE_SUCCESS != CU_register_suites(suites)) {
		fprintf(stderr, "Register suites failed - %s ", CU_get_error_msg());
		exit(EXIT_FAILURE);
	}
}
Ejemplo n.º 12
0
void test_cunit_CUError(void)
{
  CU_ErrorCode old_err = CU_get_error();
  CU_ErrorAction old_action = CU_get_error_action();

  test_cunit_start_tests("CUError.c");

  /* CU_set_error() & CU_get_error() */
  CU_set_error(CUE_NOMEMORY);
  TEST(CU_get_error() != CUE_SUCCESS);
  TEST(CU_get_error() == CUE_NOMEMORY);

  CU_set_error(CUE_NOREGISTRY);
  TEST(CU_get_error() != CUE_SUCCESS);
  TEST(CU_get_error() == CUE_NOREGISTRY);

  /* CU_get_error_msg() */
  CU_set_error(CUE_SUCCESS);
  TEST(!strcmp(CU_get_error_msg(), get_error_desc(CUE_SUCCESS)));

  CU_set_error(CUE_NOTEST);
  TEST(!strcmp(CU_get_error_msg(), get_error_desc(CUE_NOTEST)));

  CU_set_error(CUE_NOMEMORY);
  TEST(!strcmp(CU_get_error_msg(), get_error_desc(CUE_NOMEMORY)));
  TEST(strcmp(CU_get_error_msg(), get_error_desc(CUE_SCLEAN_FAILED)));

  TEST(!strcmp(get_error_desc(100), "Undefined Error"));

  /* CU_set_error_action() & CU_get_error_action() */
  CU_set_error_action(CUEA_FAIL);
  TEST(CU_get_error_action() != CUEA_IGNORE);
  TEST(CU_get_error_action() == CUEA_FAIL);
  TEST(CU_get_error_action() != CUEA_ABORT);

  CU_set_error_action(CUEA_ABORT);
  TEST(CU_get_error_action() != CUEA_IGNORE);
  TEST(CU_get_error_action() != CUEA_FAIL);
  TEST(CU_get_error_action() == CUEA_ABORT);

  /* reset  values */
  CU_set_error(old_err);
  CU_set_error_action(old_action);

  test_cunit_end_tests();
}
Ejemplo n.º 13
0
int main(int argc, char** argv)
{
  CU_pFailureRecord FailureList;
  CU_RunSummary *pRunSummary;
  int FailRec;

  if(CU_initialize_registry())
  {
    fprintf(stderr, "Initialization of Test Registry failed.'n");
    return -1;
  }

  assert(CU_get_registry());
  assert(!CU_is_test_running());

  if(CU_register_suites(suites) != CUE_SUCCESS)
  {
    fprintf(stderr, "Register suites failed - %s\n", CU_get_error_msg());
    return -1;
  }

  CU_set_output_filename("lib-c");
  CU_list_tests_to_file();
  CU_automated_run_tests();

  pRunSummary = CU_get_run_summary();
  printf("Results:\n");
  printf("  Number of suites run: %d\n", pRunSummary->nSuitesRun);
  printf("  Number of suites failed: %d\n", pRunSummary->nSuitesFailed);
  printf("  Number of tests run: %d\n", pRunSummary->nTestsRun);
  printf("  Number of tests failed: %d\n", pRunSummary->nTestsFailed);
  printf("  Number of asserts: %d\n", pRunSummary->nAsserts);
  printf("  Number of asserts failed: %d\n", pRunSummary->nAssertsFailed);
  printf("  Number of failures: %d\n", pRunSummary->nFailureRecords);

  /* Print any failures */
  if (pRunSummary->nFailureRecords)
  {
    printf("\nFailures:\n");
    FailRec = 1;
    for (FailureList = CU_get_failure_list(); FailureList; FailureList = FailureList->pNext)
    {
      printf("%d. File: %s  Line: %u   Test: %s\n",
             FailRec,
             FailureList->strFileName,
             FailureList->uiLineNumber,
             (FailureList->pTest)->pName);
      printf("  %s\n",
             FailureList->strCondition);
      FailRec++;
    }
    printf("\n");
  }

  CU_cleanup_registry();

  return 0;
}
Ejemplo n.º 14
0
int main(void)
{
    CU_pSuite pSuite1 = NULL;
    
    if (CUE_SUCCESS != CU_initialize_registry())
    {
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    pSuite1 = CU_add_suite("Greater than Null", NULL, NULL);
    if (NULL == pSuite1)
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    if (NULL == CU_add_test(pSuite1, "Test positive numbers", test_positive_numbers))
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    if (NULL == CU_add_test(pSuite1, "Test zero", test_zero))
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    if (NULL == CU_add_test(pSuite1, "Test negative numbers", test_negative_numbers))
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }

    CU_automated_run_tests();
    CU_cleanup_registry();
    
    return 0;
}
Ejemplo n.º 15
0
void init_cunit() {
    if (is_init == 0) {
        is_init = 1;
        /* initialize the CUnit test registry */
        if (CUE_SUCCESS != CU_initialize_registry()) {
            fprintf(stderr, "%s\n", CU_get_error_msg());
            return;
        }
    }
}
Ejemplo n.º 16
0
static void amdgpu_disable_suites()
{
	amdgpu_device_handle device_handle;
	uint32_t major_version, minor_version, family_id;
	int i;
	int size = sizeof(suites_active_stat) / sizeof(suites_active_stat[0]);

	if (amdgpu_device_initialize(drm_amdgpu[0], &major_version,
				   &minor_version, &device_handle))
		return;

	family_id = device_handle->info.family_id;

	if (amdgpu_device_deinitialize(device_handle))
		return;

	/* Set active status for suites based on their policies */
	for (i = 0; i < size; ++i)
		if (amdgpu_set_suite_active(suites_active_stat[i].pName,
				suites_active_stat[i].pActive()))
			fprintf(stderr, "suite deactivation failed - %s\n", CU_get_error_msg());

	/* Explicitly disable specific tests due to known bugs or preferences */
	/*
	* BUG: Compute ring stalls and never recovers when the address is
	* written after the command already submitted
	*/
	if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, "compute ring block test", CU_FALSE))
		fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());

	if (amdgpu_set_test_active(BO_TESTS_STR, "Metadata", CU_FALSE))
		fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());

	if (amdgpu_set_test_active(BASIC_TESTS_STR, "bo eviction Test", CU_FALSE))
		fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());

	/* This test was ran on GFX8 and GFX9 only */
	if (family_id < AMDGPU_FAMILY_VI || family_id > AMDGPU_FAMILY_RV)
		if (amdgpu_set_test_active(BASIC_TESTS_STR, "Sync dependency Test", CU_FALSE))
			fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
}
Ejemplo n.º 17
0
int AddTests(void)
{
	ASSERT(CU_get_registry() != NULL);
	ASSERT(CU_is_test_running() == FALSE);
	
	if (CU_register_suites(test_suites) != CUE_SUCCESS)
	{
		DbgLog(__FILE__, "%d CU_register_suites failed - %s\n", __LINE__, CU_get_error_msg());
		return 1;
	}
	return 0;
}
Ejemplo n.º 18
0
Archivo: tests.c Proyecto: jjgreen/lcrp
void tests_load(void)
{
  assert(NULL != CU_get_registry());
  assert(!CU_is_test_running());

  if (CU_register_suites(suites) != CUE_SUCCESS)
    {
      fprintf(stderr, "suite registration failed - %s\n",
              CU_get_error_msg());
      exit(EXIT_FAILURE);
    }
}
Ejemplo n.º 19
0
GOS_ERROR_CODE TMR_Unit_Test_Handler(VOS_APPL_UNIT_TEST_T *ut)
{
    int i = 0;
    CU_pSuite     pSuite = NULL;

    // show all the test suites
    if (0 == ut->id)
    { 
        printf("\r\n");
        while(i < sizeof(tmr_suites)/sizeof(CU_SuiteInfo))
        {
            if (CU_INVALID_SUITE != tmr_suites[i].id)
                printf("%d:\t%s\r\n", tmr_suites[i].id, tmr_suites[i].pName);
            i++;
        }
        return GOS_OK;
    }
    
    if(CU_initialize_registry()){
               fprintf(stderr, " Initialization of Test Registry failed. ");
               return GOS_ERR_NOT_INIT;
       }else{
               /**//* shortcut regitry */
               if(CU_ALL_TEST == ut->id)
               { 
                     if(CUE_SUCCESS != CU_register_suites(&tmr_suites[0])){
                           fprintf(stderr, "Register suites failed - %s ", CU_get_error_msg());
                           return GOS_ERR_NOT_INIT;
                     }
               }
               else
               {
                   int j = ut->id - 1;
                   if ((ut->id < 1) || (ut->id >= sizeof(tmr_suites)/sizeof(CU_SuiteInfo)))
                   {
                       return GOS_ERR_NOTSUPPORT;
                   }
                   pSuite = CU_add_suite(tmr_suites[j].pName, 
                                         tmr_suites[j].pInitFunc, 
                                         tmr_suites[j].pCleanupFunc);
                   for (i = 0; NULL != tmr_suites[ut->id-1].pTests[i].pName; i++) 
                   {
                         CU_add_test(pSuite, 
                                     tmr_suites[j].pTests[i].pName, 
                                     tmr_suites[j].pTests[i].pTestFunc) ;
                   }
               }
               CU_basic_set_mode(CU_BRM_VERBOSE);                
               CU_basic_run_tests();
               CU_cleanup_registry();
       }
    return GOS_OK;
}
Ejemplo n.º 20
0
int main(void)
{
    CU_pSuite pSuite1 = NULL;
    
    if (CUE_SUCCESS != CU_initialize_registry())
    {
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    pSuite1 = CU_add_suite("Palindrom check", NULL, NULL);
    if (NULL == pSuite1)
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    if (NULL == CU_add_test(pSuite1, "Test string that are a palindrom", test_real_palindroms))
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    if (NULL == CU_add_test(pSuite1, "Test string that are not a palindrom", test_false_palindroms))
    {
        CU_cleanup_registry();
        fprintf(stderr, "%s", CU_get_error_msg());
        exit(-1);
    }
    
    CU_automated_run_tests();
    CU_cleanup_registry();
    
    return 0;
}
Ejemplo n.º 21
0
int main(void)
{

    //mkl_set_num_threads(1);
    mkl_domain_set_num_threads(1, MKL_BLAS);
    CU_pSuite pSuite = NULL;

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

    /* Create a test array */
    CU_TestInfo test_array[] = 
    {
        { "Parallel Gaussian"      , test_pfunc },
        CU_TEST_INFO_NULL,
    };

    /* Create the test suite */ 
    CU_SuiteInfo suites[] = 
    {
        { "Parallel Evaluation of Expressions", init_suite, clean_suite, NULL, NULL, test_array },
        CU_SUITE_INFO_NULL,
    }; 

    /* Register test suites */ 
    CU_ErrorCode CU_error = CU_register_suites(suites); 
    if (CU_error != CUE_SUCCESS) 
    {
        debug_body("%s", CU_get_error_msg());
        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();
   CU_cleanup_registry();
   return CU_get_error();
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
0
int main(void)
{
   CU_pSuite pSuite = NULL;
   unsigned int num_tests_failed;

   /* 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("libwslay_TestSuite", init_suite1, clean_suite1);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* add the tests to the suite */
   if(!CU_add_test(pSuite, "wslay_frame_context_init",
                   test_wslay_frame_context_init) ||
      !CU_add_test(pSuite, "wslay_frame_recv", test_wslay_frame_recv) ||
      !CU_add_test(pSuite, "wslay_frame_recv_1byte",
                   test_wslay_frame_recv_1byte) ||
      !CU_add_test(pSuite, "wslay_frame_recv_fragmented",
                   test_wslay_frame_recv_fragmented) ||
      !CU_add_test(pSuite, "wslay_frame_recv_interleaved_ctrl_frame",
                   test_wslay_frame_recv_interleaved_ctrl_frame) ||
      !CU_add_test(pSuite, "wslay_frame_recv_zero_payloadlen",
                   test_wslay_frame_recv_zero_payloadlen) ||
      !CU_add_test(pSuite, "wslay_frame_recv_too_large_payload",
                   test_wslay_frame_recv_too_large_payload) ||
      !CU_add_test(pSuite, "wslay_frame_recv_ctrl_too_large_payload",
                   test_wslay_frame_recv_ctrl_frame_too_large_payload) ||
      !CU_add_test(pSuite, "wslay_frame_recv_minimum_ext_payload16",
                   test_wslay_frame_recv_minimum_ext_payload16) ||
      !CU_add_test(pSuite, "wslay_frame_recv_minimum_ext_payload64",
                   test_wslay_frame_recv_minimum_ext_payload64) ||
      !CU_add_test(pSuite, "wslay_frame_send", test_wslay_frame_send) ||
      !CU_add_test(pSuite, "wslay_frame_send_fragmented",
                   test_wslay_frame_send_fragmented) ||
      !CU_add_test(pSuite, "wslay_frame_send_interleaved_ctrl_frame",
                   test_wslay_frame_send_interleaved_ctrl_frame) ||
      !CU_add_test(pSuite, "wslay_frame_send_1byte_masked",
                   test_wslay_frame_send_1byte_masked) ||
      !CU_add_test(pSuite, "wslay_frame_send_zero_payloadlen",
                   test_wslay_frame_send_zero_payloadlen) ||
      !CU_add_test(pSuite, "wslay_frame_send_too_large_payload",
                   test_wslay_frame_send_too_large_payload) ||
      !CU_add_test(pSuite, "wslay_frame_send_ctrl_frame_too_large_payload",
                   test_wslay_frame_send_ctrl_frame_too_large_payload) ||
      !CU_add_test(pSuite, "wslay_event_send_fragmented_msg",
                   test_wslay_event_send_fragmented_msg) ||
      !CU_add_test(pSuite, "wslay_event_send_fragmented_msg_with_ctrl",
                   test_wslay_event_send_fragmented_msg_with_ctrl) ||
      !CU_add_test(pSuite, "wslay_event_send_fragmented_msg_with_rsv1",
                   test_wslay_event_send_fragmented_msg_with_rsv1) ||
      !CU_add_test(pSuite, "wslay_event_send_msg_with_rsv1",
                   test_wslay_event_send_msg_with_rsv1) ||
      !CU_add_test(pSuite, "wslay_event_send_ctrl_msg_first",
                   test_wslay_event_send_ctrl_msg_first) ||
      !CU_add_test(pSuite, "wslay_event_send_ctrl_msg_with_rsv1",
                   test_wslay_event_send_ctrl_msg_with_rsv1) ||
      !CU_add_test(pSuite, "wslay_event_queue_close",
                   test_wslay_event_queue_close) ||
      !CU_add_test(pSuite, "wslay_event_queue_close_without_code",
                   test_wslay_event_queue_close_without_code) ||
      !CU_add_test(pSuite, "wslay_event_recv_close_without_code",
                   test_wslay_event_recv_close_without_code) ||
      !CU_add_test(pSuite, "wslay_event_reply_close",
                   test_wslay_event_reply_close) ||
      !CU_add_test(pSuite, "wslay_event_no_more_msg",
                   test_wslay_event_no_more_msg) ||
      !CU_add_test(pSuite, "wslay_event_callback_failure",
                   test_wslay_event_callback_failure) ||
      !CU_add_test(pSuite, "wslay_event_no_buffering",
                   test_wslay_event_no_buffering) ||
      !CU_add_test(pSuite, "wslay_event_recv_text_frame_with_rsv1",
                   test_wslay_event_recv_text_frame_with_rsv1) ||
      !CU_add_test(pSuite, "wslay_event_frame_too_big",
                   test_wslay_event_frame_too_big) ||
      !CU_add_test(pSuite, "wslay_event_message_too_big",
                   test_wslay_event_message_too_big) ||
      !CU_add_test(pSuite, "wslay_event_config_set_allowed_rsv_bits",
                   test_wslay_event_config_set_allowed_rsv_bits) ||
      !CU_add_test(pSuite, "wslay_queue", test_wslay_queue)) {
     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();
   num_tests_failed = CU_get_number_of_tests_failed();
   CU_cleanup_registry();
   if (CU_get_error() == CUE_SUCCESS) {
     return (int)num_tests_failed;
   } else {
     printf("CUnit Error: %s\n", CU_get_error_msg());
     return CU_get_error();
   }
}
Ejemplo n.º 24
0
/* 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(int argc, char **argv)
{
	int c;			/* Character received from getopt */
	int i = 0;
	int suite_id = -1;	/* By default run everything */
	int test_id  = -1;	/* By default run all tests in the suite */
	int pci_bus_id = -1;    /* By default PC bus ID is not specified */
	int pci_device_id = 0;  /* By default PC device ID is zero */
	int display_devices = 0;/* By default not to display devices' info */
	CU_pSuite pSuite = NULL;
	CU_pTest  pTest  = NULL;
	int test_device_index;
	int display_list = 0;
	int force_run = 0;

	for (i = 0; i < MAX_CARDS_SUPPORTED; i++)
		drm_amdgpu[i] = -1;


	/* Parse command line string */
	opterr = 0;		/* Do not print error messages from getopt */
	while ((c = getopt(argc, argv, options)) != -1) {
		switch (c) {
		case 'l':
			display_list = 1;
			break;
		case 's':
			suite_id = atoi(optarg);
			break;
		case 't':
			test_id = atoi(optarg);
			break;
		case 'b':
			pci_bus_id = atoi(optarg);
			break;
		case 'd':
			sscanf(optarg, "%x", &pci_device_id);
			break;
		case 'p':
			display_devices = 1;
			break;
		case 'r':
			open_render_node = 1;
			break;
		case 'f':
			force_run = 1;
			break;
		case '?':
		case 'h':
			fprintf(stderr, usage, argv[0]);
			exit(EXIT_SUCCESS);
		default:
			fprintf(stderr, usage, argv[0]);
			exit(EXIT_FAILURE);
		}
	}

	if (amdgpu_open_devices(open_render_node) <= 0) {
		perror("Cannot open AMDGPU device");
		exit(EXIT_FAILURE);
	}

	if (drm_amdgpu[0] < 0) {
		perror("Cannot open AMDGPU device");
		exit(EXIT_FAILURE);
	}

	if (display_devices) {
		amdgpu_print_devices();
		amdgpu_close_devices();
		exit(EXIT_SUCCESS);
	}

	if (pci_bus_id > 0 || pci_device_id) {
		/* A device was specified to run the test */
		test_device_index = amdgpu_find_device(pci_bus_id,
						       pci_device_id);

		if (test_device_index >= 0) {
			/* Most tests run on device of drm_amdgpu[0].
			 * Swap the chosen device to drm_amdgpu[0].
			 */
			i = drm_amdgpu[0];
			drm_amdgpu[0] = drm_amdgpu[test_device_index];
			drm_amdgpu[test_device_index] = i;
		} else {
			fprintf(stderr,
				"The specified GPU device does not exist.\n");
			exit(EXIT_FAILURE);
		}
	}

	/* Initialize test suites to run */

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

	/* Register suites. */
	if (CU_register_suites(suites) != CUE_SUCCESS) {
		fprintf(stderr, "suite registration failed - %s\n",
				CU_get_error_msg());
		CU_cleanup_registry();
		amdgpu_close_devices();
		exit(EXIT_FAILURE);
	}

	/* Run tests using the CUnit Basic interface */
	CU_basic_set_mode(CU_BRM_VERBOSE);

	/* Disable suites and individual tests based on misc. conditions */
	amdgpu_disable_suites();

	if (display_list) {
		display_test_suites();
		goto end;
	}

	if (suite_id != -1) {	/* If user specify particular suite? */
		pSuite = CU_get_suite_by_index((unsigned int) suite_id,
						CU_get_registry());

		if (pSuite) {

			if (force_run)
				CU_set_suite_active(pSuite, CU_TRUE);

			if (test_id != -1) {   /* If user specify test id */
				pTest = CU_get_test_by_index(
						(unsigned int) test_id,
						pSuite);
				if (pTest) {
					if (force_run)
						CU_set_test_active(pTest, CU_TRUE);

					CU_basic_run_test(pSuite, pTest);
				}
				else {
					fprintf(stderr, "Invalid test id: %d\n",
								test_id);
					CU_cleanup_registry();
					amdgpu_close_devices();
					exit(EXIT_FAILURE);
				}
			} else
				CU_basic_run_suite(pSuite);
		} else {
			fprintf(stderr, "Invalid suite id : %d\n",
					suite_id);
			CU_cleanup_registry();
			amdgpu_close_devices();
			exit(EXIT_FAILURE);
		}
	} else
		CU_basic_run_tests();

end:
	CU_cleanup_registry();
	amdgpu_close_devices();
	return CU_get_error();
}
Ejemplo n.º 25
0
/**
 * lw6scm_test_register
 *
 * @sys_context: global system context
 * @mode: test mode (bitmask)
 *
 * Registers all tests for the libscm module.
 *
 * Return value: 1 if test is successfull, 0 on error.
 */
int
lw6scm_test_register (lw6sys_context_t * sys_context, int mode)
{
  int ret = 1;
  CU_Suite *suite = NULL;

  _test_data.sys_context = sys_context;

  if (lw6sys_false ())
    {
      /*
       * Just to make sure most functions are stuffed in the binary
       */
      lw6sys_test_register (sys_context, mode);
      lw6hlp_test_register (sys_context, mode);
    }

  suite = CU_add_suite ("lw6scm", _setup_init, _setup_quit);
  if (suite)
    {
      LW6SYS_CUNIT_ADD_TEST (suite, _test_wrapper);
      LW6SYS_CUNIT_ADD_TEST (suite, _test_funcname);
      LW6SYS_CUNIT_ADD_TEST (suite, _test_utils);
      LW6SYS_CUNIT_ADD_TEST (suite, _test_coverage);
    }
  else
    {
      lw6sys_log (sys_context, LW6SYS_LOG_WARNING, _x_ ("unable to add CUnit test suite, error msg is \"%s\""), CU_get_error_msg ());
      ret = 0;
    }

  return ret;
}
Ejemplo n.º 26
0
int main(int argc, char* argv[])
{
   CU_pSuite pSuite = NULL;
   unsigned int num_tests_failed;

   /* 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("libnghttp2_TestSuite", init_suite1, clean_suite1);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* add the tests to the suite */
   if(!CU_add_test(pSuite, "pq", test_nghttp2_pq) ||
      !CU_add_test(pSuite, "pq_update", test_nghttp2_pq_update) ||
      !CU_add_test(pSuite, "map", test_nghttp2_map) ||
      !CU_add_test(pSuite, "map_functional", test_nghttp2_map_functional) ||
      !CU_add_test(pSuite, "map_each_free", test_nghttp2_map_each_free) ||
      !CU_add_test(pSuite, "queue", test_nghttp2_queue) ||
      !CU_add_test(pSuite, "buffer", test_nghttp2_buffer) ||
      !CU_add_test(pSuite, "buffer_reader", test_nghttp2_buffer_reader) ||
      !CU_add_test(pSuite, "npn", test_nghttp2_npn) ||
      !CU_add_test(pSuite, "session_recv", test_nghttp2_session_recv) ||
      !CU_add_test(pSuite, "session_recv_invalid_stream_id",
                   test_nghttp2_session_recv_invalid_stream_id) ||
      !CU_add_test(pSuite, "session_recv_invalid_frame",
                   test_nghttp2_session_recv_invalid_frame) ||
      !CU_add_test(pSuite, "session_recv_eof",
                   test_nghttp2_session_recv_eof) ||
      !CU_add_test(pSuite, "session_recv_data",
                   test_nghttp2_session_recv_data) ||
      !CU_add_test(pSuite, "session_continue", test_nghttp2_session_continue) ||
      !CU_add_test(pSuite, "session_add_frame",
                   test_nghttp2_session_add_frame) ||
      !CU_add_test(pSuite, "session_on_request_headers_received",
                   test_nghttp2_session_on_request_headers_received) ||
      !CU_add_test(pSuite, "session_on_response_headers_received",
                   test_nghttp2_session_on_response_headers_received) ||
      !CU_add_test(pSuite, "session_on_headers_received",
                   test_nghttp2_session_on_headers_received) ||
      !CU_add_test(pSuite, "session_on_push_response_headers_received",
                   test_nghttp2_session_on_push_response_headers_received) ||
      !CU_add_test(pSuite, "session_on_priority_received",
                   test_nghttp2_session_on_priority_received) ||
      !CU_add_test(pSuite, "session_on_rst_stream_received",
                   test_nghttp2_session_on_rst_stream_received) ||
      !CU_add_test(pSuite, "session_on_settings_received",
                   test_nghttp2_session_on_settings_received) ||
      !CU_add_test(pSuite, "session_on_push_promise_received",
                   test_nghttp2_session_on_push_promise_received) ||
      !CU_add_test(pSuite, "session_on_ping_received",
                   test_nghttp2_session_on_ping_received) ||
      !CU_add_test(pSuite, "session_on_goaway_received",
                   test_nghttp2_session_on_goaway_received) ||
      !CU_add_test(pSuite, "session_on_window_update_received",
                   test_nghttp2_session_on_window_update_received) ||
      !CU_add_test(pSuite, "session_on_data_received",
                   test_nghttp2_session_on_data_received) ||
      !CU_add_test(pSuite, "session_send_headers_start_stream",
                   test_nghttp2_session_send_headers_start_stream) ||
      !CU_add_test(pSuite, "session_send_headers_reply",
                   test_nghttp2_session_send_headers_reply) ||
      !CU_add_test(pSuite, "session_send_headers_header_comp_error",
                   test_nghttp2_session_send_headers_header_comp_error) ||
      !CU_add_test(pSuite, "session_send_headers_push_reply",
                   test_nghttp2_session_send_headers_push_reply) ||
      !CU_add_test(pSuite, "session_send_rst_stream",
                   test_nghttp2_session_send_rst_stream) ||
      !CU_add_test(pSuite, "session_send_push_promise",
                   test_nghttp2_session_send_push_promise) ||
      !CU_add_test(pSuite, "session_is_my_stream_id",
                   test_nghttp2_session_is_my_stream_id) ||
      !CU_add_test(pSuite, "session_upgrade", test_nghttp2_session_upgrade) ||
      !CU_add_test(pSuite, "session_reprioritize_stream",
                   test_nghttp2_session_reprioritize_stream) ||
      !CU_add_test(pSuite, "submit_request_with_data",
                   test_nghttp2_submit_request_with_data) ||
      !CU_add_test(pSuite, "submit_request_without_data",
                   test_nghttp2_submit_request_without_data) ||
      !CU_add_test(pSuite, "submit_response_with_data",
                   test_nghttp2_submit_response_with_data) ||
      !CU_add_test(pSuite, "submit_response_without_data",
                   test_nghttp2_submit_response_without_data) ||
      !CU_add_test(pSuite, "submit_headers_start_stream",
                   test_nghttp2_submit_headers_start_stream) ||
      !CU_add_test(pSuite, "submit_headers_reply",
                   test_nghttp2_submit_headers_reply) ||
      !CU_add_test(pSuite, "submit_headers_push_reply",
                   test_nghttp2_submit_headers_push_reply) ||
      !CU_add_test(pSuite, "submit_headers", test_nghttp2_submit_headers) ||
      !CU_add_test(pSuite, "submit_priority", test_nghttp2_submit_priority) ||
      !CU_add_test(pSuite, "session_submit_settings",
                   test_nghttp2_submit_settings) ||
      !CU_add_test(pSuite, "session_submit_settings_update_local_window_size",
                   test_nghttp2_submit_settings_update_local_window_size) ||
      !CU_add_test(pSuite, "session_submit_push_promise",
                   test_nghttp2_submit_push_promise) ||
      !CU_add_test(pSuite, "submit_window_update",
                   test_nghttp2_submit_window_update) ||
      !CU_add_test(pSuite, "submit_window_update_local_window_size",
                   test_nghttp2_submit_window_update_local_window_size) ||
      !CU_add_test(pSuite, "submit_invalid_nv",
                   test_nghttp2_submit_invalid_nv) ||
      !CU_add_test(pSuite, "session_open_stream",
                   test_nghttp2_session_open_stream) ||
      !CU_add_test(pSuite, "session_get_next_ob_item",
                   test_nghttp2_session_get_next_ob_item) ||
      !CU_add_test(pSuite, "session_pop_next_ob_item",
                   test_nghttp2_session_pop_next_ob_item) ||
      !CU_add_test(pSuite, "session_reply_fail",
                   test_nghttp2_session_reply_fail) ||
      !CU_add_test(pSuite, "session_max_concurrent_streams",
                   test_nghttp2_session_max_concurrent_streams) ||
      !CU_add_test(pSuite, "session_stream_close_on_headers_push",
                   test_nghttp2_session_stream_close_on_headers_push) ||
      !CU_add_test(pSuite, "session_stop_data_with_rst_stream",
                   test_nghttp2_session_stop_data_with_rst_stream) ||
      !CU_add_test(pSuite, "session_defer_data",
                   test_nghttp2_session_defer_data) ||
      !CU_add_test(pSuite, "session_flow_control",
                   test_nghttp2_session_flow_control) ||
      !CU_add_test(pSuite, "session_flow_control_disable_remote",
                   test_nghttp2_session_flow_control_disable_remote) ||
      !CU_add_test(pSuite, "session_flow_control_disable_local",
                   test_nghttp2_session_flow_control_disable_local) ||
      !CU_add_test(pSuite, "session_flow_control_data_recv",
                   test_nghttp2_session_flow_control_data_recv) ||
      !CU_add_test(pSuite, "session_data_read_temporal_failure",
                   test_nghttp2_session_data_read_temporal_failure) ||
      !CU_add_test(pSuite, "session_on_request_recv_callback",
                   test_nghttp2_session_on_request_recv_callback) ||
      !CU_add_test(pSuite, "session_on_stream_close",
                   test_nghttp2_session_on_stream_close) ||
      !CU_add_test(pSuite, "session_on_ctrl_not_send",
                   test_nghttp2_session_on_ctrl_not_send) ||
      !CU_add_test(pSuite, "session_get_outbound_queue_size",
                   test_nghttp2_session_get_outbound_queue_size) ||
      !CU_add_test(pSuite, "session_get_effective_local_window_size",
                   test_nghttp2_session_get_effective_local_window_size) ||
      !CU_add_test(pSuite, "session_set_option",
                   test_nghttp2_session_set_option) ||
      !CU_add_test(pSuite, "session_data_backoff_by_high_pri_frame",
                   test_nghttp2_session_data_backoff_by_high_pri_frame) ||
      !CU_add_test(pSuite, "pack_settings_payload",
                   test_nghttp2_pack_settings_payload) ||
      !CU_add_test(pSuite, "frame_pack_headers",
                   test_nghttp2_frame_pack_headers) ||
      !CU_add_test(pSuite, "frame_pack_headers_frame_too_large",
                   test_nghttp2_frame_pack_headers_frame_too_large) ||
      !CU_add_test(pSuite, "frame_pack_priority",
                   test_nghttp2_frame_pack_priority) ||
      !CU_add_test(pSuite, "frame_pack_rst_stream",
                   test_nghttp2_frame_pack_rst_stream) ||
      !CU_add_test(pSuite, "frame_pack_settings",
                   test_nghttp2_frame_pack_settings) ||
      !CU_add_test(pSuite, "frame_pack_push_promise",
                   test_nghttp2_frame_pack_push_promise) ||
      !CU_add_test(pSuite, "frame_pack_ping", test_nghttp2_frame_pack_ping) ||
      !CU_add_test(pSuite, "frame_pack_goaway",
                   test_nghttp2_frame_pack_goaway) ||
      !CU_add_test(pSuite, "frame_pack_window_update",
                   test_nghttp2_frame_pack_window_update) ||
      !CU_add_test(pSuite, "nv_array_check",
                   test_nghttp2_nv_array_check) ||
      !CU_add_test(pSuite, "nv_array_copy", test_nghttp2_nv_array_copy) ||
      !CU_add_test(pSuite, "iv_check", test_nghttp2_iv_check) ||
      !CU_add_test(pSuite, "hd_deflate", test_nghttp2_hd_deflate) ||
      !CU_add_test(pSuite, "hd_deflate_same_indexed_repr",
                   test_nghttp2_hd_deflate_same_indexed_repr) ||
      !CU_add_test(pSuite, "hd_deflate_common_header_eviction",
                   test_nghttp2_hd_deflate_common_header_eviction) ||
      !CU_add_test(pSuite, "hd_deflate_deflate_buffer",
                   test_nghttp2_hd_deflate_deflate_buffer) ||
      !CU_add_test(pSuite, "hd_deflate_clear_refset",
                   test_nghttp2_hd_deflate_clear_refset) ||
      !CU_add_test(pSuite, "hd_inflate_indname_noinc",
                   test_nghttp2_hd_inflate_indname_noinc) ||
      !CU_add_test(pSuite, "hd_inflate_indname_inc",
                   test_nghttp2_hd_inflate_indname_inc) ||
      !CU_add_test(pSuite, "hd_inflate_indname_inc_eviction",
                   test_nghttp2_hd_inflate_indname_inc_eviction) ||
      !CU_add_test(pSuite, "hd_inflate_newname_noinc",
                   test_nghttp2_hd_inflate_newname_noinc) ||
      !CU_add_test(pSuite, "hd_inflate_newname_inc",
                   test_nghttp2_hd_inflate_newname_inc) ||
      !CU_add_test(pSuite, "hd_inflate_clearall_inc",
                   test_nghttp2_hd_inflate_clearall_inc) ||
      !CU_add_test(pSuite, "hd_inflate_zero_length_huffman",
                   test_nghttp2_hd_inflate_zero_length_huffman) ||
      !CU_add_test(pSuite, "hd_change_table_size",
                   test_nghttp2_hd_change_table_size) ||
      !CU_add_test(pSuite, "hd_deflate_inflate",
                   test_nghttp2_hd_deflate_inflate) ||
      !CU_add_test(pSuite, "gzip_inflate", test_nghttp2_gzip_inflate) ||
      !CU_add_test(pSuite, "adjust_local_window_size",
                   test_nghttp2_adjust_local_window_size) ||
      !CU_add_test(pSuite, "check_header_name",
                   test_nghttp2_check_header_name) ||
      !CU_add_test(pSuite, "check_header_value",
                   test_nghttp2_check_header_value)
      ) {
     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();
   num_tests_failed = CU_get_number_of_tests_failed();
   CU_cleanup_registry();
   if(CU_get_error() == CUE_SUCCESS) {
     return num_tests_failed;
   } else {
     printf("CUnit Error: %s\n", CU_get_error_msg());
     return CU_get_error();
   }
}
Ejemplo n.º 27
0
int main(int argc, char* argv[])
{
   CU_pSuite pSuite = NULL;
   unsigned int num_tests_failed;

   /* 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("libspdylay_TestSuite", init_suite1, clean_suite1);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* add the tests to the suite */
   if(!CU_add_test(pSuite, "pq", test_spdylay_pq) ||
      !CU_add_test(pSuite, "map", test_spdylay_map) ||
      !CU_add_test(pSuite, "map_functional", test_spdylay_map_functional) ||
      !CU_add_test(pSuite, "map_each_free", test_spdylay_map_each_free) ||
      !CU_add_test(pSuite, "queue", test_spdylay_queue) ||
      !CU_add_test(pSuite, "buffer", test_spdylay_buffer) ||
      !CU_add_test(pSuite, "buffer_reader", test_spdylay_buffer_reader) ||
      !CU_add_test(pSuite, "zlib_spdy2", test_spdylay_zlib_spdy2) ||
      !CU_add_test(pSuite, "zlib_spdy3", test_spdylay_zlib_spdy3) ||
      !CU_add_test(pSuite, "npn", test_spdylay_npn) ||
      !CU_add_test(pSuite, "npn_get_proto_list",
                   test_spdylay_npn_get_proto_list) ||
      !CU_add_test(pSuite, "npn_get_version", test_spdylay_npn_get_version) ||
      !CU_add_test(pSuite, "session_recv", test_spdylay_session_recv) ||
      !CU_add_test(pSuite, "session_recv_invalid_stream_id",
                   test_spdylay_session_recv_invalid_stream_id) ||
      !CU_add_test(pSuite, "session_add_frame",
                   test_spdylay_session_add_frame) ||
      !CU_add_test(pSuite, "session_on_syn_stream_received",
                   test_spdylay_session_on_syn_stream_received) ||
      !CU_add_test(pSuite, "session_on_syn_stream_received_with_push",
                   test_spdylay_session_on_syn_stream_received_with_push) ||
      !CU_add_test(pSuite, "session_on_syn_reply_received",
                   test_spdylay_session_on_syn_reply_received) ||
      !CU_add_test(pSuite, "session_send_syn_stream",
                   test_spdylay_session_send_syn_stream) ||
      !CU_add_test(pSuite, "session_send_syn_reply",
                   test_spdylay_session_send_syn_reply) ||
      !CU_add_test(pSuite, "submit_response", test_spdylay_submit_response) ||
      !CU_add_test(pSuite, "submit_response_without_data",
                   test_spdylay_submit_response_with_null_data_read_callback) ||
      !CU_add_test(pSuite, "submit_request_with_data",
                   test_spdylay_submit_request_with_data) ||
      !CU_add_test(pSuite, "submit_request_without_data",
                   test_spdylay_submit_request_with_null_data_read_callback) ||
      !CU_add_test(pSuite, "submit_syn_stream",
                   test_spdylay_submit_syn_stream) ||
      !CU_add_test(pSuite, "submit_syn_reply", test_spdylay_submit_syn_reply) ||
      !CU_add_test(pSuite, "submit_headers", test_spdylay_submit_headers) ||
      !CU_add_test(pSuite, "submit_invalid_nv",
                   test_spdylay_submit_invalid_nv) ||
      !CU_add_test(pSuite, "session_reply_fail",
                   test_spdylay_session_reply_fail) ||
      !CU_add_test(pSuite, "session_on_headers_received",
                   test_spdylay_session_on_headers_received) ||
      !CU_add_test(pSuite, "session_on_window_update_received",
                   test_spdylay_session_on_window_update_received) ||
      !CU_add_test(pSuite, "session_on_ping_received",
                   test_spdylay_session_on_ping_received) ||
      !CU_add_test(pSuite, "session_on_goaway_received",
                   test_spdylay_session_on_goaway_received) ||
      !CU_add_test(pSuite, "session_on_data_received",
                   test_spdylay_session_on_data_received) ||
      !CU_add_test(pSuite, "session_on_rst_stream_received",
                   test_spdylay_session_on_rst_received) ||
      !CU_add_test(pSuite, "session_is_my_stream_id",
                   test_spdylay_session_is_my_stream_id) ||
      !CU_add_test(pSuite, "session_send_rst_stream",
                   test_spdylay_session_send_rst_stream) ||
      !CU_add_test(pSuite, "session_get_next_ob_item",
                   test_spdylay_session_get_next_ob_item) ||
      !CU_add_test(pSuite, "session_pop_next_ob_item",
                   test_spdylay_session_pop_next_ob_item) ||
      !CU_add_test(pSuite, "session_on_request_recv_callback",
                   test_spdylay_session_on_request_recv_callback) ||
      !CU_add_test(pSuite, "session_on_stream_close",
                   test_spdylay_session_on_stream_close) ||
      !CU_add_test(pSuite, "session_max_concurrent_streams",
                   test_spdylay_session_max_concurrent_streams) ||
      !CU_add_test(pSuite, "session_data_backoff_by_high_pri_frame",
                   test_spdylay_session_data_backoff_by_high_pri_frame) ||
      !CU_add_test(pSuite, "session_stop_data_with_rst_stream",
                   test_spdylay_session_stop_data_with_rst_stream) ||
      !CU_add_test(pSuite, "session_stream_close_on_syn_stream",
                   test_spdylay_session_stream_close_on_syn_stream) ||
      !CU_add_test(pSuite, "session_recv_invalid_frame",
                   test_spdylay_session_recv_invalid_frame) ||
      !CU_add_test(pSuite, "session_defer_data",
                   test_spdylay_session_defer_data) ||
      !CU_add_test(pSuite, "session_flow_control",
                   test_spdylay_session_flow_control) ||
      !CU_add_test(pSuite, "session_connection_flow_control",
                   test_spdylay_session_connection_flow_control) ||
      !CU_add_test(pSuite, "session_on_ctrl_not_send",
                   test_spdylay_session_on_ctrl_not_send) ||
      !CU_add_test(pSuite, "session_on_settings_received",
                   test_spdylay_session_on_settings_received) ||
      !CU_add_test(pSuite, "session_submit_settings",
                   test_spdylay_submit_settings) ||
      !CU_add_test(pSuite, "session_get_outbound_queue_size",
                   test_spdylay_session_get_outbound_queue_size) ||
      !CU_add_test(pSuite, "session_prep_credential",
                   test_spdylay_session_prep_credential) ||
      !CU_add_test(pSuite, "session_submit_syn_stream_with_credential",
                   test_spdylay_submit_syn_stream_with_credential) ||
      !CU_add_test(pSuite, "session_set_initial_client_cert_origin",
                   test_spdylay_session_set_initial_client_cert_origin) ||
      !CU_add_test(pSuite, "session_set_option",
                   test_spdylay_session_set_option) ||
      !CU_add_test(pSuite, "submit_window_update",
                   test_spdylay_submit_window_update) ||
      !CU_add_test(pSuite, "session_data_read_temporal_failure",
                   test_spdylay_session_data_read_temporal_failure) ||
      !CU_add_test(pSuite, "session_recv_eof",
                   test_spdylay_session_recv_eof) ||
      !CU_add_test(pSuite, "session_recv_data",
                   test_spdylay_session_recv_data) ||
      !CU_add_test(pSuite, "frame_unpack_nv_spdy2",
                   test_spdylay_frame_unpack_nv_spdy2) ||
      !CU_add_test(pSuite, "frame_unpack_nv_spdy3",
                   test_spdylay_frame_unpack_nv_spdy3) ||
      !CU_add_test(pSuite, "frame_count_nv_space",
                   test_spdylay_frame_count_nv_space) ||
      !CU_add_test(pSuite, "frame_count_unpack_nv_space",
                   test_spdylay_frame_count_unpack_nv_space) ||
      !CU_add_test(pSuite, "frame_pack_ping", test_spdylay_frame_pack_ping) ||
      !CU_add_test(pSuite, "frame_pack_goaway_spdy2",
                   test_spdylay_frame_pack_goaway_spdy2) ||
      !CU_add_test(pSuite, "frame_pack_goaway_spdy3",
                   test_spdylay_frame_pack_goaway_spdy3) ||
      !CU_add_test(pSuite, "frame_pack_syn_stream_spdy2",
                   test_spdylay_frame_pack_syn_stream_spdy2) ||
      !CU_add_test(pSuite, "frame_pack_syn_stream_spdy3",
                   test_spdylay_frame_pack_syn_stream_spdy3) ||
      !CU_add_test(pSuite, "frame_pack_syn_stream_frame_too_large",
                   test_spdylay_frame_pack_syn_stream_frame_too_large) ||
      !CU_add_test(pSuite, "frame_pack_syn_reply_spdy2",
                   test_spdylay_frame_pack_syn_reply_spdy2) ||
      !CU_add_test(pSuite, "frame_pack_syn_reply_spdy3",
                   test_spdylay_frame_pack_syn_reply_spdy3) ||
      !CU_add_test(pSuite, "frame_pack_headers_spdy2",
                   test_spdylay_frame_pack_headers_spdy2) ||
      !CU_add_test(pSuite, "frame_pack_headers_spdy3",
                   test_spdylay_frame_pack_headers_spdy3) ||
      !CU_add_test(pSuite, "frame_pack_window_update",
                   test_spdylay_frame_pack_window_update) ||
      !CU_add_test(pSuite, "frame_pack_settings_spdy2",
                   test_spdylay_frame_pack_settings_spdy2) ||
      !CU_add_test(pSuite, "frame_pack_settings_spdy3",
                   test_spdylay_frame_pack_settings_spdy3) ||
      !CU_add_test(pSuite, "frame_pack_credential",
                   test_spdylay_frame_pack_credential) ||
      !CU_add_test(pSuite, "frame_nv_sort", test_spdylay_frame_nv_sort) ||
      !CU_add_test(pSuite, "frame_nv_downcase",
                   test_spdylay_frame_nv_downcase) ||
      !CU_add_test(pSuite, "frame_pack_nv_duplicate_keys",
                   test_spdylay_frame_pack_nv_duplicate_keys) ||
      !CU_add_test(pSuite, "frame_pack_nv_empty_value_spdy2",
                   test_spdylay_frame_pack_nv_empty_value_spdy2) ||
      !CU_add_test(pSuite, "frame_pack_nv_empty_value_spdy3",
                   test_spdylay_frame_pack_nv_empty_value_spdy3) ||
      !CU_add_test(pSuite, "frame_nv_2to3", test_spdylay_frame_nv_2to3) ||
      !CU_add_test(pSuite, "frame_nv_3to2", test_spdylay_frame_nv_3to2) ||
      !CU_add_test(pSuite, "frame_unpack_nv_check_name_spdy2",
                   test_spdylay_frame_unpack_nv_check_name_spdy2) ||
      !CU_add_test(pSuite, "frame_unpack_nv_check_name_spdy3",
                   test_spdylay_frame_unpack_nv_check_name_spdy3) ||
      !CU_add_test(pSuite, "frame_unpack_nv_last_empty_value_spdy2",
                   test_spdylay_frame_unpack_nv_last_empty_value_spdy2) ||
      !CU_add_test(pSuite, "frame_unpack_nv_last_empty_value_spdy3",
                   test_spdylay_frame_unpack_nv_last_empty_value_spdy3) ||
      !CU_add_test(pSuite, "frame_nv_set_origin",
                   test_spdylay_frame_nv_set_origin) ||
      !CU_add_test(pSuite, "frame_nv_check_null",
                   test_spdylay_frame_nv_check_null) ||
      !CU_add_test(pSuite, "stream_add_pushed_stream",
                   test_spdylay_stream_add_pushed_stream) ||
      !CU_add_test(pSuite, "client_cert_vector_find",
                   test_spdylay_client_cert_vector_find) ||
      !CU_add_test(pSuite, "client_cert_vector_resize",
                   test_spdylay_client_cert_vector_resize) ||
      !CU_add_test(pSuite, "client_cert_vector_get_origin",
                   test_spdylay_client_cert_vector_get_origin) ||
      !CU_add_test(pSuite, "gzip_inflate", test_spdylay_gzip_inflate)) {
     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();
   num_tests_failed = CU_get_number_of_tests_failed();
   CU_cleanup_registry();
   if(CU_get_error() == CUE_SUCCESS) {
     return num_tests_failed;
   } else {
     printf("CUnit Error: %s\n", CU_get_error_msg());
     return CU_get_error();
   }
}