示例#1
0
int main(int argc, char *argv[])
{
	int o;
	char *test = NULL;
	int size = 0;
	uint32_t mask = 0;
	int iteration_count = 0;
	char *sysfs_prefix = "/sys/bus/greybus/devices/";
	char *debugfs_prefix = "/sys/kernel/debug/gb_loopback/";

	while ((o = getopt(argc, argv, "t:s:i:S:D:m:v::d::")) != -1) {
		switch (o) {
		case 't':
			test = optarg;
			break;
		case 's':
			size = atoi(optarg);
			break;
		case 'i':
			iteration_count = atoi(optarg);
			break;
		case 'S':
			sysfs_prefix = optarg;
			break;
		case 'D':
			debugfs_prefix = optarg;
			break;
		case 'm':
			mask = atol(optarg);
			break;
		case 'v':
			verbose = 1;
			break;
		case 'd':
			debug = 1;
			break;
		default:
			usage();
			return -EINVAL;
		}
	}

	if (test == NULL || iteration_count == 0)
		usage();

	loopback_run(test, size, iteration_count, sysfs_prefix, debugfs_prefix,
		     mask);
	if (lb_name)
		free(lb_name);
	return 0;
}
示例#2
0
int main(int argc, char *argv[])
{
	int o, ret;
	char *sysfs_prefix = "/sys/class/gb_loopback/";
	char *debugfs_prefix = "/sys/kernel/debug/gb_loopback/";

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

	while ((o = getopt(argc, argv,
			   "t:s:i:S:D:m:v::d::r::p::a::l::x::o:O:c:w:z::f::")) != -1) {
		switch (o) {
		case 't':
			snprintf(t.test_name, MAX_STR_LEN, "%s", optarg);
			break;
		case 's':
			t.size = atoi(optarg);
			break;
		case 'i':
			t.iteration_max = atoi(optarg);
			break;
		case 'S':
			snprintf(t.sysfs_prefix, MAX_SYSFS_PATH, "%s", optarg);
			break;
		case 'D':
			snprintf(t.debugfs_prefix, MAX_SYSFS_PATH, "%s", optarg);
			break;
		case 'm':
			t.mask = atol(optarg);
			break;
		case 'v':
			t.verbose = 1;
			break;
		case 'd':
			t.debug = 1;
			break;
		case 'r':
			t.raw_data_dump = 1;
			break;
		case 'p':
			t.porcelain = 1;
			break;
		case 'a':
			t.aggregate_output = 1;
			break;
		case 'l':
			t.list_devices = 1;
			break;
		case 'x':
			t.use_async = 1;
			break;
		case 'o':
			t.async_timeout = atoi(optarg);
			break;
		case 'O':
			t.poll_timeout.tv_sec = atoi(optarg);
			break;
		case 'c':
			t.async_outstanding_operations = atoi(optarg);
			break;
		case 'w':
			t.us_wait = atoi(optarg);
			break;
		case 'z':
			t.file_output = 1;
			break;
		case 'f':
			t.stop_all = 1;
			break;
		default:
			usage();
			return -EINVAL;
		}
	}

	if (!strcmp(t.sysfs_prefix, ""))
		snprintf(t.sysfs_prefix, MAX_SYSFS_PATH, "%s", sysfs_prefix);

	if (!strcmp(t.debugfs_prefix, ""))
		snprintf(t.debugfs_prefix, MAX_SYSFS_PATH, "%s", debugfs_prefix);

	ret = find_loopback_devices(&t);
	if (ret)
		return ret;
	ret = sanity_check(&t);
	if (ret)
		return ret;

	if (t.list_devices) {
		show_loopback_devices(&t);
		return 0;
	}

	if (t.test_name[0] == '\0' || t.iteration_max == 0)
		usage();

	if (t.async_timeout == 0)
		t.async_timeout = DEFAULT_ASYNC_TIMEOUT;

	loopback_run(&t);

	return 0;
}