Beispiel #1
0
boost::unit_test::test_suite *register_tests(int argc, char *argv[])
{
	namespace bpo = boost::program_options;

	bpo::variables_map vm;
	bpo::options_description generic("Test options");

	std::vector<std::string> remotes;
	std::string path;

	generic.add_options()
		("help", "This help message")
		("remote", bpo::value(&remotes), "Remote elliptics server address")
		("path", bpo::value(&path), "Path where to store everything")
		 ;

	bpo::store(bpo::parse_command_line(argc, argv, generic), vm);
	bpo::notify(vm);

	if (vm.count("help")) {
		std::cerr << generic;
		return NULL;
	}

	test_suite *suite = new test_suite("Local Test Suite");

	configure_nodes(remotes, path);

	register_tests(suite, *global_data->node);

	return suite;
}
Beispiel #2
0
boost::unit_test::test_suite *register_tests(int argc, char *argv[])
{
	namespace bpo = boost::program_options;

	bpo::variables_map vm;
	bpo::options_description generic("Test options");

	std::string path;

	generic.add_options()
			("help", "This help message")
			("path", bpo::value(&path), "Path where to store everything")
			;

	bpo::store(bpo::parse_command_line(argc, argv, generic), vm);
	bpo::notify(vm);

	if (vm.count("help")) {
		std::cerr << generic;
		return nullptr;
	}

	test_suite *suite = new test_suite("crypto library test suite");
	register_tests(suite);

	return suite;
}
Beispiel #3
0
int main(int argc, char* argv[]) {
	int ret = 0;
    MU_initFramework( print_log );
    register_tests();
    register_cxx_tests();
    register_qt_tests();

	ret = MU_main(argc,argv);

	return ret;
}
Beispiel #4
0
// call this function from within your
// ios program to run all tests.
// Pass a message handler to print all messages
int run_dispatch_tests(int argc, char* argv[], MU_messageHandler handler) {
	int ret = 0;
    
    if( handler == NULL )
        handler = null_printer;
    
	MU_initFramework( handler );
    
    register_tests();
    register_cxx_tests();
    register_qt_tests();

	ret = MU_main(argc,argv);

	return ret;
}
Beispiel #5
0
int main(int argc, char* argv[])
{
    std::ostream *output = &std::cout;
    std::ofstream output_file;

    if (argc == 2) {
        output_file.open(argv[1]);
        if (!output_file) {
            std::cerr << "Unable to open " << argv[1] << " for output!\n";
            return EXIT_FAILURE;
        }
        output = &output_file;
    }
    
    register_tests();
    UnitTestManager::execute_tests(*output, "Theatre Unit Test Results");
    return UnitTestManager::test_status();
}
Beispiel #6
0
int main (int argc, char *argv[])
{
	int i;
	char *pluginname = NULL;
	char *plugindir = NULL;
	char *configfile = NULL;
	char *objtype = NULL;
	OSyncError *error = NULL;

	if (argc < 2)
		usage (argv[0], 1);

	pluginname = argv[1];
	for (i = 2; i < argc; i++) {
		char *arg = argv[i];
		if (!strcmp (arg, "--config")) {
			configfile = argv[i + 1];
			i++;
			if (!configfile)
				usage (argv[0], 1);
		} else if (!strcmp (arg, "--type")) {
			objtype = argv[i + 1];
			i++;
			if (!objtype)
				usage (argv[0], 1);
		} else if (!strcmp (arg, "--plugindir")) {
			printf("plugindir %s\n", argv[i + 1]);
			plugindir = argv[i + 1];
			i++;
			if (!plugindir)
				usage (argv[0], 1);
		} else if (!strcmp (arg, "--random")) {
			only_random = TRUE;
		} else if (!strcmp (arg, "--help")) {
			usage (argv[0], 0);
		} else {
			usage (argv[0], 1);
		}
	}

	OSyncEnv *env = osync_env_new(NULL);
	osync_env_set_option(env, "LOAD_GROUPS", "FALSE");

	if (plugindir)
		osync_env_set_option(env, "PLUGINS_DIRECTORY", plugindir);

	if (!osync_env_initialize(env, &error)) {
		printf("Unable to initialize environment: %s\n", osync_error_print(&error));
		osync_error_unref(&error);
		return 1;
	}

	char *testdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir());
	char *result = mkdtemp(testdir);

	if (result == NULL)
	{
		osync_trace(TRACE_EXIT_ERROR, "unable to create temporary dir: %s", g_strerror(errno));
		return 1;
	}

	OSyncGroup *group = osync_group_new(env);
	osync_group_set_name(group, osync_rand_str(8));
	osync_group_set_configdir(group, testdir);
	OSyncMember *member = osync_member_new(group);

	char *config = NULL;
	int size = 0;
	if (configfile) {
		if (!osync_file_read(configfile, &config, &size, &error)) {
			fprintf(stderr, "Unable to read config: %s\n", osync_error_print(&error));
			osync_error_unref(&error);
			return 1;
		}
		osync_member_set_config(member, config, size);
	}

	osync_member_set_pluginname(member, pluginname);

	OSyncMember *file = osync_member_new(group);

	localdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir());
	result = mkdtemp(localdir);

	if (result == NULL)
	{
		osync_trace(TRACE_EXIT_ERROR, "unable to create temporary dir: %s", g_strerror(errno));
		return 1;
	}

	config = g_strdup_printf("<config><path>%s</path><recursive>0</recursive></config>", localdir);
	osync_member_set_config(file, config, strlen(config) + 1);
	osync_member_set_pluginname(file, "file-sync");

	if (!osync_group_save(group, &error)) {
		printf("Error while creating syncengine: %s\n", osync_error_print(&error));
		osync_error_unref(&error);
		goto error_free_env;
	}

	if (!g_thread_supported ()) g_thread_init (NULL);

	OSyncEngine *engine = osengine_new(group, &error);
	if (!engine) {
		printf("Error while creating syncengine: %s\n", osync_error_print(&error));
		osync_error_unref(&error);
		goto error_free_env;
	}

	if (!osengine_init(engine, &error)) {
		printf("Error while initializing syncengine: %s\n", osync_error_print(&error));
		osync_error_unref(&error);
		goto error_free_engine;
	}

	int count = 0;
	if (only_random) {
		do {
			count++;
			printf("++++++++++++++++++++++++++++++\n");
			printf("Initializing new round #%i!\n", count);

			if (g_random_int_range(0, 5) == 0) {
				int i;
				OSyncFormatEnv *env = osync_group_get_format_env(group);
				for (i = 0; i < osync_conv_num_objtypes(env); i++) {
					if (g_random_int_range(0, 5) == 0) {
						OSyncObjType *type = osync_conv_nth_objtype(env, i);
						osync_group_set_slow_sync(group, osync_objtype_get_name(type), TRUE);
						printf("Requesting slow-sync for: %s\n", osync_objtype_get_name(type));
					}
				}
				osync_conv_env_free(env);
			}

			change_content();

			check_sync(engine, "Random", 1);
		} while (g_random_int_range(0, 3) != 0);

		printf("Finalizing engine\n");
		osengine_finalize(engine);
		osengine_free(engine);

		engine = osengine_new(group, &error);
		if (!engine) {
			printf("Error while creating syncengine: %s\n", osync_error_print(&error));
			osync_error_unref(&error);
			goto error_free_env;
		}

		if (!osengine_init(engine, &error)) {
			printf("Error while initializing syncengine: %s\n", osync_error_print(&error));
			osync_error_unref(&error);
			goto error_free_engine;
		}
	} else {
		register_tests();
		run_all_tests(engine, file, member, objtype);
	}

	printf("\nCompleted successfully\n");
	return 0;

error_free_engine:
	osengine_free(engine);
error_free_env:
	osync_group_free(group);
	osync_env_free(env);
	return 1;
}
Beispiel #7
0
int main(int argc, char *argv[])
{
	int c = 0;
	struct cp_test_param test_params;
	char *cipher = NULL;
	int raw = 0;
	int ret = 1;
	int i = 0;
	int alltests = 0;

	memset(&test_params, 0, sizeof(test_params));

	test_params.len = 1;
	test_params.accesstype = KCAPI_ACCESS_HEURISTIC;

	register_tests(0);

	while(1)
	{
		int opt_index = 0;
		static struct option opts[] =
		{
			{"all", 0, 0, 'a'},
			{"list", 0, 0, 'l'},
			{"cipher", 1, 0, 'c'},
			{"time", 1, 0, 't'},
			{"blocks", 1, 0, 'b'},
			{"raw", 0, 0, 'r'},
			{"sendmsg", 0, 0, 's'},
			{"vmsplice", 0, 0, 'v'},
			{"aio", 1, 0, 'o'},
			{0, 0, 0, 0}
		};
		c = getopt_long(argc, argv, "alc:t:b:rsvo:", opts, &opt_index);
		if(-1 == c)
			break;
		switch(c)
		{
			case 'a':
				alltests = 1;
				break;
			case 'l':
				for (i = 0; i < 4; i++)
					print_tests(&tests[i], 1);
				return 0;
			case 'c':
				cipher = strndup(optarg, 50);
				break;
			case 't':
				test_params.exectime = (unsigned int)atoi(optarg);
				break;
			case 'b':
				test_params.len = (unsigned int)atoi(optarg);
				break;
			case 'r':
				raw = 1;
				break;
			case 'v':
				test_params.accesstype = KCAPI_ACCESS_VMSPLICE;
				break;
			case 's':
				test_params.accesstype = KCAPI_ACCESS_SENDMSG;
				break;
			case 'o':
				test_params.aio = (unsigned int)atoi(optarg);
				break;

			default:
				usage();
				goto out;
		}
	}

	if (alltests) {
		for (i = 0; i < 4; i++)
			exec_all_tests(&tests[i], &test_params);
		return 0;
	}

	if (!cipher) {
		usage();
		goto out;
	}

	ret = exec_subset_test(cipher, raw, &test_params);

out:
	if (cipher)
		free(cipher);
	return ret;
}