/* 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() {
    ks3_global_init();

    int ret = load_ak_sk();
    if (ret != 0) {
        printf("[ERROR] load ak, sk failed\n");
        return ret;
    }

    ret = CreateBucket(host, bucket);
    if (ret != 0) {
        printf("[ERROR] create bucket failed\n");
        return ret;
    }
    
    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("Suite_1", init_suite1, clean_suite1);
    if (NULL == pSuite) {
        CU_cleanup_registry();
        ks3_global_destroy();
        return CU_get_error();
    }

    /* add the tests to the suite */
    if (NULL == CU_add_test(pSuite, "test complete multipart para null\n", TEST_COMPLETE_MULTIPART_UPLOAD_ALL_NULL)
        || NULL == CU_add_test(pSuite, "test complete multipart para return code null\n", TEST_COMPLETE_MULTIPART_UPLOAD_RETURNCODE_NULL)
        || NULL == CU_add_test(pSuite, "test complete multipart para host\n", TEST_COMPLETE_MULTIPART_UPLOAD_HOST)
        || NULL == CU_add_test(pSuite, "test complete multipart para bucket\n", TEST_COMPLETE_MULTIPART_UPLOAD_BUCKET)
        || NULL == CU_add_test(pSuite, "test complete multipart para object\n", TEST_COMPLETE_MULTIPART_UPLOAD_OBJECT)
        || NULL == CU_add_test(pSuite, "test complete multipart para key\n", TEST_COMPLETE_MULTIPART_UPLOAD_KEY)
        || NULL == CU_add_test(pSuite, "test complete multipart para data buf\n", TEST_COMPLETE_MULTIPART_UPLOAD_BUFDATAPARA)
        || NULL == CU_add_test(pSuite, "test complete multipart para query\n", TEST_COMPLETE_MULTIPART_UPLOAD_QUERYPARA)
        || NULL == CU_add_test(pSuite, "test complete multipart para header\n", TEST_COMPLETE_MULTIPART_UPLOAD_HEADERPARA)) {
        CU_cleanup_registry();
        ks3_global_destroy();
        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();

    ret = DeleteBucket(host, bucket);
    if (ret != 0) {
        printf("[ERROR] delete bucket failed\n");
    }
    
    ks3_global_destroy();
    return CU_get_error();
}
示例#2
0
int main(int argc, char **argv) {
	// use CUnit test framework
	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("Header", NULL, NULL);
   if(!pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

	// add the tests to the suite
   if(!CU_add_test(pSuite, "First header byte construction", testHeaderFirstByteConstruction)) {
      CU_cleanup_registry();
      return CU_get_error();
	}

   if(!CU_add_test(pSuite, "Method codes", testMethodCodes)) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   if(!CU_add_test(pSuite, "Message ID", testMessageID)) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   if(!CU_add_test(pSuite, "Token insertion", testTokenInsertion)) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   if(!CU_add_test(pSuite, "Option insertion", testOptionInsertion)) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   if(!CU_add_test(pSuite, "URI setting", testURISetting)) {
      CU_cleanup_registry();
      return CU_get_error();
   }

	CU_pTest payloadTest = CU_add_test(pSuite, "Payload setting", testPayload);
   if(!payloadTest) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   // Run all tests using the CUnit Basic interface
   CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_set_error_action(CUEA_ABORT);
   CU_basic_run_tests();
   CU_cleanup_registry();
	//optionInsertionTest();
   return CU_get_error();
}
示例#3
0
int run_unit_tests()
{
   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("File Scanning", NULL, NULL);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

#ifdef SUPER
//		ms_set_log_level(DEBUG);
//     av_log_set_level(AV_LOG_DEBUG);
   /* add the tests to the ms_scan suite */
   if (
	   NULL == CU_add_test(pSuite, "Simple test of ms_scan()", test_ms_scan) ||
	   NULL == CU_add_test(pSuite, "Test ms_scan() with no paths", test_ms_scan_2) ||
	   NULL == CU_add_test(pSuite, "Test of ms_scan() with too many paths", test_ms_scan_3) ||
	   NULL == CU_add_test(pSuite, "Test of ms_scan() with a bad directory", test_ms_scan_4) ||
// TODO: The following test fails due to the scanner freezing up.
//	   NULL == CU_add_test(pSuite, "Test of ms_scan() with strange path slashes", test_ms_scan_5) ||
	   NULL == CU_add_test(pSuite, "Test of ms_scan()'s progress notifications", test_ms_scan_6) ||
	   NULL == CU_add_test(pSuite, "Test of ms_file_scan()", test_ms_file_scan_1) ||
//NULL == CU_add_test(pSuite, "Test of scanning LOTS of files", test_ms_large_directory) ||
	   NULL == CU_add_test(pSuite, "Test of misc functions", test_ms_misc_functions) ||
  	   NULL == CU_add_test(pSuite, "Simple test of ASF audio file", test_ms_file_asf_audio) ||
   	   NULL == CU_add_test(pSuite, "Test Berkeley database functionality", test_ms_db)

	   )
   {
      CU_cleanup_registry();
      return CU_get_error();
   }
#endif

//   setupbackground_tests();
   setupdefect_tests();
//   setupimage_tests();
//	 setup_thumbnail_tests();

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

   CU_cleanup_registry();
   return CU_get_error();
} /* run_unit_tests() */
示例#4
0
static void
test_main(spdk_event_t event)
{
	CU_pSuite suite = NULL;
	unsigned int num_failures;

	if (bdevio_construct_targets() < 0) {
		spdk_app_stop(-1);
		return;
	}

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

	suite = CU_add_suite("components_suite", NULL, NULL);
	if (suite == NULL) {
		CU_cleanup_registry();
		spdk_app_stop(CU_get_error());
		return;
	}

	if (
		CU_add_test(suite, "blockdev write read 4k", blockdev_write_read_4k) == NULL
		|| CU_add_test(suite, "blockdev write read 512 bytes",
			       blockdev_write_read_512Bytes) == NULL
		|| CU_add_test(suite, "blockdev write read size > 128k",
			       blockdev_write_read_size_gt_128k) == NULL
		|| CU_add_test(suite, "blockdev write read invalid size",
			       blockdev_write_read_invalid_size) == NULL
		|| CU_add_test(suite, "blockdev write read offset + nbytes == size of blockdev",
			       blockdev_write_read_offset_plus_nbytes_equals_bdev_size) == NULL
		|| CU_add_test(suite, "blockdev write read offset + nbytes > size of blockdev",
			       blockdev_write_read_offset_plus_nbytes_gt_bdev_size) == NULL
		|| CU_add_test(suite, "blockdev write read max offset",
			       blockdev_write_read_max_offset) == NULL
		|| CU_add_test(suite, "blockdev write read 8k on overlapped address offset",
			       blockdev_overlapped_write_read_8k) == NULL
	) {
		CU_cleanup_registry();
		spdk_app_stop(CU_get_error());
		return;
	}

	pthread_mutex_init(&g_test_mutex, NULL);
	pthread_cond_init(&g_test_cond, NULL);
	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();
	num_failures = CU_get_number_of_failures();
	CU_cleanup_registry();
	spdk_app_stop(num_failures);
}
示例#5
0
int main(int argc, char *argv[]) {
	CU_ErrorCode error;

	/**
	 * Definizione dei test array
	 * NOTA ? L?ORDINE DI INSERIMENTO E? IMPORTANTE
	 */
	CU_TestInfo test_array_conta_parole_bis[] = { {
			"test di conta_parole_bis()", test_conta_parole_bis },
			CU_TEST_INFO_NULL, };

	/**
	 * crea le suite e vi aggiunge i test array
	 * NOTA ? L?ORDINE DI INSERIMENTO E? IMPORTANTE
	 */
	CU_SuiteInfo suites[] = { { "test suite per conta_parole_bis ",
			suite_void_init, suite_void_cleanup, test_array_conta_parole_bis },

	CU_SUITE_INFO_NULL, };

	/* inizializza registro ? e? la prima istruzione */
	if (CUE_SUCCESS != CU_initialize_registry()) {
		error = CU_get_error();
		system("PAUSE");
		return -1;
	}

	// add the suites to the registry
	error = CU_register_suites(suites);

	if (CUE_SUCCESS != error) {
		CU_cleanup_registry();
		error = CU_get_error();
		system("PAUSE");
		return -1;
	}

	/**
	 * Esegue tutti i casi di test con output sulla console
	 */
	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();

	/**
	 * Pulisce il registro e termina lo unit test
	 **/

	CU_cleanup_registry();

	//system("PAUSE");

	return error;
}
示例#6
0
文件: main.c 项目: Smattr/passwand
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;
}
示例#7
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);
}
示例#8
0
int main()
{
    CU_pSuite pSuite = NULL;

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

    /* Add suite to the registry */
    pSuite = CU_add_suite("yee_common", init_testsuite1, clean_testsuite1);
    if (!pSuite) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* Add the tests to the suite */
    if (!CU_add_test(pSuite, "py_alloc_field", test_alloc_field)
        || !CU_add_test(pSuite, "py_set_grid", test_set_grid)
        || !CU_add_test(pSuite, "py_vec_func", test_vec_func)
        || !CU_add_test(pSuite, "py_vec_func2d", test_vec_func2d)
        || !CU_add_test(pSuite, "py_apply_func", test_apply_func)
        || !CU_add_test(pSuite, "py_init_acoustic_field",
                        test_init_acoustic_field)
        || !CU_add_test(pSuite, "py_init_local_acoustic_field",
                        test_init_local_acoustic_field)
        || !CU_add_test(pSuite, "py_assign_to, get_from",
                        test_assign_and_get)
        || !CU_add_test(pSuite, "py_set_boundary", test_set_boundary)
        || !CU_add_test(pSuite, "py_leapfrog", test_leapfrog)
        || !CU_add_test(pSuite, "py_partition_grid", test_partition_grid)
        || !CU_add_test(pSuite, "py_get_partition_coords",
                        test_get_partition_coords)
        /*|| !CU_add_test(pSuite, "py_expand_indices", test_expand_indices) */
        /*|| !CU_add_test(pSuite, "py_verify_grid_integrity", test_verify_grid) */
        /*|| !CU_add_test(pSuite, "py_set_local_index", test_set_local_index) */
        || !CU_add_test(pSuite, "py_parse_cmdline", test_parse_cmdline)
        || !CU_add_test(pSuite, "py_zero", test_zero)
        || !CU_add_test(pSuite, "py_zero2d", test_zero2d)
        || !CU_add_test(pSuite, "py_identity", test_identity)
        || !CU_add_test(pSuite, "py_identity2d", test_identity)
        || !CU_add_test(pSuite, "py_round_up_divide",
                        test_round_up_divide)) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    /* Run all the tests using the CUnit Basic interface */
    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    CU_cleanup_registry();
    return CU_get_error();
}
示例#9
0
文件: us894.c 项目: DDvO/libest
/* The main() function for setting up and running the tests.
 * Returns a CUE_SUCCESS on successful running, another
 * CUnit error code on failure.
 */
int us894_add_suite (void)
{
#ifdef HAVE_CUNIT
   CU_pSuite pSuite = NULL;

   /* add a suite to the registry */
   pSuite = CU_add_suite("us894_proxy_cacerts", 
	                  us894_init_suite, 
			  us894_destroy_suite);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* add the tests to the suite */
   /* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */
   if ((NULL == CU_add_test(pSuite, "HTTP Basic Auth", us894_test1)) ||
       (NULL == CU_add_test(pSuite, "HTTP Basic Auth Fail", us894_test2)) ||
       (NULL == CU_add_test(pSuite, "HTTP Digest Auth", us894_test3)) ||
       (NULL == CU_add_test(pSuite, "HTTP Digest Auth Fail", us894_test4)) ||
       (NULL == CU_add_test(pSuite, "Get CA Certificates", us894_test5)) ||
       (NULL == CU_add_test(pSuite, "SSL 3.0 Fail", us894_test6)) ||
       (NULL == CU_add_test(pSuite, "TLS 1.0 Fail", us894_test7)) ||
       (NULL == CU_add_test(pSuite, "TLS 1.1", us894_test8)) ||
       (NULL == CU_add_test(pSuite, "TLS 1.2", us894_test9)) || 
       (NULL == CU_add_test(pSuite, "Certificate auth - explicit cert chain", us894_test10)) ||
       (NULL == CU_add_test(pSuite, "Certificate auth - implicit cert chain", us894_test11)) || 
       (NULL == CU_add_test(pSuite, "Certificate auth - revoked cert", us894_test12)) || 
       (NULL == CU_add_test(pSuite, "Certificate auth - self-signed cert", us894_test13)) ||
       (NULL == CU_add_test(pSuite, "Anon cipher suite disabled", us894_test14)) || 
       (NULL == CU_add_test(pSuite, "NULL Realm", us894_test15)) ||
       (NULL == CU_add_test(pSuite, "NULL server cert", us894_test16)) ||
       (NULL == CU_add_test(pSuite, "NULL server key", us894_test17)) ||
       (NULL == CU_add_test(pSuite, "NULL local CA chain", us894_test18)) || 
       (NULL == CU_add_test(pSuite, "Corrupted local CA chain", us894_test19)) || 
       (NULL == CU_add_test(pSuite, "HTTP POST cacerts", us894_test20)) ||
       (NULL == CU_add_test(pSuite, "SimpleEnroll - good HTTP auth/good Cert", us894_test21)) ||
       (NULL == CU_add_test(pSuite, "SimpleEnroll - bad HTTP auth/good Cert", us894_test22)) ||
       (NULL == CU_add_test(pSuite, "SimpleEnroll - no HTTP auth/no Cert", us894_test23)) ||
       (NULL == CU_add_test(pSuite, "Set Server Invalid parameters", us894_test24)) ||
       (NULL == CU_add_test(pSuite, "Set Auth Mode Invalid parameters", us894_test25)) ||
       (NULL == CU_add_test(pSuite, "Optional CA Chain Response", us894_test26)) ||
       (NULL == CU_add_test(pSuite, "Bad userid/password for proxy init", us894_test27)))
   {
      CU_cleanup_registry();
      return CU_get_error();
   }

   return CUE_SUCCESS;
#endif
}
示例#10
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();
}
示例#11
0
CU_ErrorCode test_string(CU_pSuite suite){
    suite = CU_add_suite("CryString Tests (test_string.c)", before_all_test_string, after_all_test_string);
    if(suite == NULL){
       CU_cleanup_registry();
       return CU_get_error();
    }

    if( (CU_add_test(suite, "String's tests are not done yet!", test_missing_strings_tests ) == NULL ) ){
       CU_cleanup_registry();
       return CU_get_error();
    }

    return CUE_SUCCESS;
}
示例#12
0
int main (void)
{

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

   /* add the tests to the suite */

   if ((NULL == CU_add_test(pSuite, " 1: Requesting a single record in a compressed warc file", test1)) ||
       (NULL == CU_add_test(pSuite, " 2: Requesting a whole warc file", test2)) ||
       (NULL == CU_add_test(pSuite, " 3: sending a bad request", test3)) ||
       (NULL == CU_add_test(pSuite,"  4: sending a filter request", test4)) ||
       (NULL == CU_add_test(pSuite,"  5: sending a List request with severral output format", test5)))
   {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* Run all tests using the automated interface*/ 
    switch (menu()) 
  {
        case 1: {CU_console_run_tests(); break;} 
	case 2:  {
                       
                           case 21: {CU_basic_set_mode(CU_BRM_NORMAL); CU_basic_run_tests(); break;}
                            case 22:{CU_basic_set_mode(CU_BRM_VERBOSE ); CU_basic_run_tests(); break;}
                             case 23:{CU_basic_set_mode(CU_BRM_SILENT); CU_basic_run_tests(); break;}  

                              }
        case 3:{
                CU_set_output_filename("./utest/outputs/client");
    		CU_set_output_filename("./utest/outputs/client" );
  		CU_automated_run_tests();
   		CU_list_tests_to_file();
           	break;}
   }

   CU_cleanup_registry();
   return CU_get_error();
}
示例#13
0
文件: init_ut.c 项目: spdk/spdk
int
main(int argc, char **argv)
{
	CU_pSuite	suite = NULL;
	unsigned int 	num_failures;

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

	suite = CU_add_suite("scsi_suite", null_init, null_clean);
	if (suite == NULL) {
		CU_cleanup_registry();
		return CU_get_error();
	}

	if (
		CU_add_test(suite, "scsi init - set default scsi params", \
			    scsi_init_sp_null) == NULL
		|| CU_add_test(suite, "scsi init - set max_unmap_lba_count", \
			       scsi_init_set_max_unmap_lba_count_config_param) == NULL
		|| CU_add_test(suite, "scsi init - set max_unmap_block_descriptor_count", \
			       scsi_init_set_max_unmap_block_descriptor_count_config_param) == NULL
		|| CU_add_test(suite, "scsi init - set optimal_unmap_granularity", \
			       scsi_init_set_optimal_unmap_granularity_config_param) == NULL
		|| CU_add_test(suite, "scsi init - set unmap_granularity_alignment", \
			       scsi_init_set_unmap_granularity_alignment_config_param) == NULL
		|| CU_add_test(suite, "scsi init - ugavalid value yes", \
			       scsi_init_ugavalid_yes) == NULL
		|| CU_add_test(suite, "scsi init - ugavalid value no", \
			       scsi_init_ugavalid_no) == NULL
		|| CU_add_test(suite, "scsi init - ugavalid unknown value", \
			       scsi_init_ugavalid_unknown_value_failure) == NULL
		|| CU_add_test(suite, "scsi init - set max_write_same_length", \
			       scsi_init_max_write_same_length) == NULL
		|| CU_add_test(suite, "scsi init - read config scsi parameters", \
			       scsi_init_read_config_scsi_params) == NULL
		|| CU_add_test(suite, "scsi init - success", scsi_init_success) == NULL
	) {
		CU_cleanup_registry();
		return CU_get_error();
	}

	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();
	num_failures = CU_get_number_of_failures();
	CU_cleanup_registry();
	return num_failures;
}
int
main(int argc, char **argv)
{
  CU_pSuite pSuite = NULL;

  putenv("LC_ALL=C");
  putenv("LANG=C");
  
  /* initialize the CUnit test registry */
  if(CUE_SUCCESS != CU_initialize_registry()){
    return CU_get_error();
  }

  /* remove a suite to the registry */
  pSuite = CU_add_suite("AgsConnectableTest", ags_connectable_test_init_suite, ags_connectable_test_clean_suite);
  
  if(pSuite == NULL){
    CU_cleanup_registry();
    
    return CU_get_error();
  }

  /* remove the tests to the suite */
  if((CU_add_test(pSuite, "test of AgsConnectable get uuid", ags_connectable_test_get_uuid) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable has resource", ags_connectable_test_has_resource) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable is ready", ags_connectable_test_is_ready) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable add to registry", ags_connectable_test_add_to_registry) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable remove from registry", ags_connectable_test_remove_from_registry) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable list resource", ags_connectable_test_list_resource) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable xml compose", ags_connectable_test_xml_compose) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable xml parse", ags_connectable_test_xml_parse) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable is connected", ags_connectable_test_is_connected) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable connect", ags_connectable_test_connect) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable disconnect", ags_connectable_test_disconnect) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable connect connection", ags_connectable_test_connect_connection) == NULL) ||
     (CU_add_test(pSuite, "test of AgsConnectable disconnect connection", ags_connectable_test_disconnect_connection) == NULL)){
    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());
}
示例#15
0
int hello_test_register(CU_pSuite pSuite)
{
   /* add a suite to the registry */
   pSuite = CU_add_suite("Suite_hello", hello_test_init_suite, hello_test_clean_suite);
   if (NULL == pSuite) {
      CU_cleanup_registry();
      return CU_get_error();
   }

   if ((NULL == CU_add_test(pSuite, "hello::get_msg", hello_test_get_msg)))
   {
      CU_cleanup_registry();
      return CU_get_error();
   }
}
示例#16
0
int main(int argc, char **argv) {
    CU_pSuite suite = NULL;

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

    // Init suite
    suite = CU_add_suite("Shadowdive", NULL, NULL);
    if(suite == NULL) {
        goto end;
    }
    
    // Add tests
    if(CU_add_test(suite, "test of sd_bk_create", test_sd_bk_create) == NULL) { goto end; }
    if(CU_add_test(suite, "test of sd_bk_delete", test_sd_bk_delete) == NULL) { goto end; }
    if(CU_add_test(suite, "test of sd_af_create", test_sd_af_create) == NULL) { goto end; }
    if(CU_add_test(suite, "test of sd_af_delete", test_sd_af_delete) == NULL) { goto end; }

    // Run tests
    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
   
end:
    CU_cleanup_registry();
    return CU_get_error();
}
示例#17
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;
}
示例#18
0
void bc_tester_uninit() {
	/* Redisplay list of failed tests on end */
	if (CU_get_number_of_failure_records()){
		CU_basic_show_failures(CU_get_failure_list());
	}
	CU_cleanup_registry();
	/*add missing final newline*/
	bc_tester_printf(bc_printf_verbosity_info,"");

	if( xml_enabled ){
		/*create real xml file only if tester did not crash*/
		size_t size = strlen(xml_file) + strlen(".tmp-Results.xml") + 1;
		char * xml_tmp_file = malloc(sizeof(char) * size);
		snprintf(xml_tmp_file, size, "%s.tmp-Results.xml", xml_file);
		rename(xml_tmp_file, xml_file);
		free(xml_tmp_file);
	}

	if (test_suite != NULL) {
		free(test_suite);
		test_suite = NULL;
		nb_test_suites = 0;
	}

	if (bc_tester_resource_dir_prefix != NULL) {
		free(bc_tester_resource_dir_prefix);
		bc_tester_resource_dir_prefix = NULL;
	}
	if (bc_tester_writable_dir_prefix != NULL) {
		free(bc_tester_writable_dir_prefix);
		bc_tester_writable_dir_prefix = NULL;
	}
}
示例#19
0
int
main(
    const int     argc,
    char* const*  argv)
{
    int         exitCode = EXIT_FAILURE;

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

        if (NULL != testSuite) {
            CU_ADD_TEST(testSuite, test_getDottedDecimal);
#           if WANT_MULTICAST
            CU_ADD_TEST(testSuite, test_sa_getInetSockAddr);
            CU_ADD_TEST(testSuite, test_sa_getInet6SockAddr);
            CU_ADD_TEST(testSuite, test_sa_parse);
            CU_ADD_TEST(testSuite, test_sa_parseWithDefaults);
#           endif

            if (log_init(argv[0])) {
                (void)fprintf(stderr, "Couldn't open logging system\n");
            }
            else {
                if (CU_basic_run_tests() == CUE_SUCCESS) {
                    if (0 == CU_get_number_of_failures())
                        exitCode = EXIT_SUCCESS;
                }
            }
        }

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

    return exitCode;
}
示例#20
0
文件: main.c 项目: FlexCOS/code
/* 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 err_code = 0;

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

	/* create suites, order is important */
	if ( (err_code = build_suite__types())       ||
	     (err_code = build_suite__stub_memdev()) ||
	     (err_code = build_suite__somefs())      ||
	     (err_code = build_suite__smartfs())     ||
	     (err_code = build_suite__flxio())       ||
	     (err_code = build_suite__apdu()))
	{
		return err_code;
	}

	/* 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();
}
示例#21
0
int main(void) {
	CU_initialize_registry();

	CU_pSuite pSuite_cf_surname, pSuite_cf_name, pSuite_cf_date,
	          pSuite_cf_ctrl_code, pSuite_cf_generator;

	pSuite_cf_surname = CU_add_suite("cf_surname", init_suite_default,
			clean_suite_default);

	pSuite_cf_name = CU_add_suite("cf_name",init_suite_default,
				clean_suite_default);
	pSuite_cf_date = CU_add_suite("cf_date",init_suite_default,
				clean_suite_default);
	pSuite_cf_ctrl_code = CU_add_suite("cf_ctrl_code",init_suite_default,
				clean_suite_default);
	pSuite_cf_generator = CU_add_suite("cf_generator",init_suite_default,
				clean_suite_default);

	CU_add_test(pSuite_cf_surname, "surname2code()",
			test_surname2code);
	CU_add_test(pSuite_cf_name, "name2code()", test_name2code);
	CU_add_test(pSuite_cf_date, "date2code()", test_date2code);
	CU_add_test(pSuite_cf_ctrl_code, "cf_ctrl_code()",
			test_cf_ctrl_code);
	CU_add_test(pSuite_cf_generator, "cf_generator()",
			test_cf_generator);

	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();
	CU_cleanup_registry();

	return CU_get_error();
}
示例#22
0
文件: jotto.c 项目: dblack/cjotto
int main() {
    CU_BasicRunMode mode = CU_BRM_VERBOSE;
    CU_ErrorAction error_action = CUEA_IGNORE;
  
    CU_ErrorCode cue = CU_initialize_registry();
    if (cue != CUE_SUCCESS) { 
	printf("ERROR in CU_initialize_registry\n");
	return;
    }
    CU_basic_set_mode(mode);
    CU_set_error_action(error_action);
  
    CU_pSuite hitCounting, wordAdding, wordChomping, wordChecking;

    hitCounting = CU_add_suite("Hit counting", my_suite_init, my_suite_clean);
    wordAdding = CU_add_suite("Word adding", my_suite_init, my_suite_clean);
    wordChecking = CU_add_suite("Word checking", my_suite_init, my_suite_clean);

    CU_ADD_TEST(hitCounting, test_5_hits);  
    CU_ADD_TEST(hitCounting, test_1_hits);  
    CU_ADD_TEST(hitCounting, test_no_hits);  
    CU_ADD_TEST(hitCounting, test_hits_out_of_order_do_not_count);


    CU_ADD_TEST(wordChecking, test_check_for_word_in_jdict);
    CU_ADD_TEST(wordChecking, test_winnowing_jdict);
  
    CU_basic_run_tests();
    CU_cleanup_registry();
}
示例#23
0
/**
* @brief The main function for unitary tests.
* @param argc - The number of aruments provided to the function.
* @param argv - A string table that corresponds to the value of arguments.
* @return An integer value. 0 if everything is OK.
*/
int main(int argc, char** argv) {
    CU_pSuite pSuite[7] = {};

    CU_initialize_registry();

    pSuite[0] = CU_add_suite("Verify formatName()", NULL, NULL);                /*Verify formatName funtion.*/
    CU_ADD_TEST(pSuite[0], verifyFormatName);

    pSuite[1] = CU_add_suite("Verify cleanGrid()", NULL, NULL);                 /*Verify cleanGrid funtion.*/
    CU_ADD_TEST(pSuite[1], verifyCleanGrid);

    pSuite[2] = CU_add_suite("Verify generateItems()", NULL, NULL);             /*Verify generateItems function.*/
    CU_ADD_TEST(pSuite[2], verifyGenerateItems);

    pSuite[3] = CU_add_suite("Verify initGrid()", NULL, NULL);                  /*Verify initGrid funtion.*/
    CU_ADD_TEST(pSuite[3], verifyInitGrid);

    pSuite[4] = CU_add_suite("Verify searchAndReplace()", NULL, NULL);          /*Verify searchAndReplace function.*/
    CU_ADD_TEST(pSuite[4], verifySearchAndReplace);

    pSuite[5] = CU_add_suite("Verify movePlayer()", NULL, NULL);                /*Verify movePlayer funtion.*/
    CU_ADD_TEST(pSuite[5], verifyMovePlayer);
    CU_ADD_TEST(pSuite[5], verifyPlayerCantMove);

    pSuite[6] = CU_add_suite("Verify reorderHighscore()", NULL, NULL);          /*Verify reorderHighscore function.*/
    CU_ADD_TEST(pSuite[6], reorderHighscore);


    CU_basic_run_tests();
    CU_cleanup_registry();

    return CU_get_error();
}
示例#24
0
文件: main.c 项目: jjgreen/pia
int main(void)
{
  CU_BasicRunMode mode = CU_BRM_VERBOSE;
  CU_ErrorAction error_action = CUEA_IGNORE;
  setvbuf(stdout, NULL, _IONBF, 0);

  if (CU_initialize_registry())
    {
      fprintf(stderr,"failed to initialise registry\n");
      return EXIT_FAILURE;
    }

  tests_load();
  CU_basic_set_mode(mode);
  CU_set_error_action(error_action);

  int
    status = CU_basic_run_tests(),
    nfail = CU_get_number_of_failures();

  CU_cleanup_registry();
  printf("\nSuite returned %d.\n", status);

  return (nfail > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
示例#25
0
文件: test_rng.c 项目: UCL/GMCMC
int main() {
  CU_ErrorCode error = CU_initialize_registry();
  if (error != CUE_SUCCESS)
    CUNIT_ERROR("Failed to initialise test registry");


  TEST(mt19937);
  TEST(mt19937_64);
  TEST(dcmt521);
  TEST(dcmt607);
  TEST(dcmt1279);
  TEST(dcmt2203);
  TEST(dcmt2281);
  TEST(dcmt3217);
  TEST(dcmt4253);
  TEST(dcmt9689);

  error = CU_basic_run_tests();
  if (error != CUE_SUCCESS)
    CUNIT_ERROR("Failed to run tests");

  CU_cleanup_registry();

  return 0;
}
示例#26
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;
}
示例#27
0
void bc_tester_uninit(void) {
	/* Redisplay list of failed tests on end */
	/*BUG: do not display list of failures on mingw, it crashes mysteriously*/
#if !defined(WIN32) && !defined(_MSC_VER)
	/* Redisplay list of failed tests on end */
	if (CU_get_number_of_failure_records()){
		CU_basic_show_failures(CU_get_failure_list());
	}
#endif
	CU_cleanup_registry();
	/*add missing final newline*/
	bc_tester_printf(bc_printf_verbosity_info,"");

	if( xml_enabled ){
		/*create real xml file only if tester did not crash*/
		char * xml_tmp_file = bc_sprintf("%s.tmp-Results.xml", xml_file);
		rename(xml_tmp_file, xml_file);
		free(xml_tmp_file);
	}

	if (test_suite != NULL) {
		free(test_suite);
		test_suite = NULL;
		nb_test_suites = 0;
	}

	if (bc_tester_resource_dir_prefix != NULL) {
		free(bc_tester_resource_dir_prefix);
		bc_tester_resource_dir_prefix = NULL;
	}
	if (bc_tester_writable_dir_prefix != NULL) {
		free(bc_tester_writable_dir_prefix);
		bc_tester_writable_dir_prefix = NULL;
	}
}
示例#28
0
int
main (int argc, const char *argv[])
{
  int ret = 0;
  lw6sys_context_t *sys_context = NULL;
  int mode = 0;

  LW6SYS_MAIN_BEGIN (sys_context);

  lw6sys_log_clear (sys_context, NULL);
  mode = lw6sys_arg_test_mode (sys_context, argc, argv);

  if (CU_initialize_registry () == CUE_SUCCESS)
    {
      if (lw6sim_test_register (sys_context, mode))
	{
	  ret = lw6sim_test_run (sys_context, mode);
	}
      CU_cleanup_registry ();
    }

  LW6SYS_TEST_OUTPUT;

  LW6SYS_MAIN_END (sys_context);

  return (!ret);
}
int runTestSuite() {
	CU_basic_set_mode(CU_BRM_VERBOSE);
	CU_basic_run_tests();

	CU_cleanup_registry();
	return CU_get_error();
}
示例#30
0
int
main(
    const int           argc,
    const char* const*  argv)
{
    int         exitCode = EXIT_FAILURE;

    if (-1 == openulog(basename(argv[0]), 0, LOG_LOCAL0, "-")) {
        (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_failures();
            }

            CU_cleanup_registry();
        } /* CUnit registery allocated */
    } /* logging system initialized */

    return exitCode;
}