Пример #1
0
/*
 * client_msg_close_noresp -- send close request message and don't expect a
 * response
 */
static void
client_msg_close_noresp(const char *ctarget)
{
	char *target = STRDUP(ctarget);
	struct rpmem_msg_close msg = CLOSE_MSG;
	rpmem_hton_msg_close(&msg);

	int fd = clnt_connect_wait(target);

	clnt_send(fd, &msg, sizeof(msg));
	clnt_wait_disconnect(fd);
	clnt_close(fd);

	FREE(target);
}
Пример #2
0
/*
 * client_bad_msg_hdr -- test case for checking message header
 */
int
client_bad_msg_hdr(const struct test_case *tc, int argc, char *argv[])
{
	if (argc < 1)
		UT_FATAL("usage: %s <addr>[:<port>]", tc->name);

	char *target = argv[0];

	set_rpmem_cmd("server_bad_msg");

	for (int i = 0; i < BAD_MSG_HDR_COUNT; i++) {
		struct rpmem_ssh *ssh = clnt_connect(target);

		struct rpmem_msg_hdr msg = MSG_HDR;

		switch (i) {
		case 0:
			msg.size -= 1;
			break;
		case 1:
			msg.size = 0;
			break;
		case 2:
			msg.type = MAX_RPMEM_MSG_TYPE;
			break;
		case 3:
			msg.type = RPMEM_MSG_TYPE_OPEN_RESP;
			break;
		case 4:
			msg.type = RPMEM_MSG_TYPE_CREATE_RESP;
			break;
		case 5:
			msg.type = RPMEM_MSG_TYPE_CLOSE_RESP;
			break;
		default:
			UT_ASSERT(0);
		}

		rpmem_hton_msg_hdr(&msg);

		clnt_send(ssh, &msg, sizeof(msg));
		clnt_wait_disconnect(ssh);
		clnt_close(ssh);
	}

	return 1;
}
Пример #3
0
/*
 * client_msg_open_noresp -- send open request message and don't expect a
 * response
 */
static void
client_msg_open_noresp(const char *ctarget)
{
	char *target = STRDUP(ctarget);
	size_t msg_size = sizeof(OPEN_MSG) + POOL_DESC_SIZE;
	struct rpmem_msg_open *msg = MALLOC(msg_size);

	int fd = clnt_connect_wait(target);

	*msg = OPEN_MSG;
	msg->hdr.size = msg_size;
	memcpy(msg->pool_desc.desc, POOL_DESC, POOL_DESC_SIZE);

	rpmem_hton_msg_open(msg);

	clnt_send(fd, msg, msg_size);
	clnt_wait_disconnect(fd);
	clnt_close(fd);

	FREE(msg);
	FREE(target);
}
Пример #4
0
/*
 * client_bad_msg_open -- check if server detects invalid open request
 * messages
 */
static void
client_bad_msg_open(const char *ctarget)
{
	char *target = STRDUP(ctarget);
	size_t msg_size = sizeof(OPEN_MSG) + POOL_DESC_SIZE;
	struct rpmem_msg_open *msg = MALLOC(msg_size);

	for (int i = 0; i < BAD_MSG_OPEN_COUNT; i++) {
		int fd = clnt_connect_wait(target);
		*msg = OPEN_MSG;
		msg->hdr.size = msg_size;
		memcpy(msg->pool_desc.desc, POOL_DESC, POOL_DESC_SIZE);

		switch (i) {
		case 0:
			msg->provider = 0;
			break;
		case 1:
			msg->provider = MAX_RPMEM_PROV;
			break;
		case 2:
			msg->pool_desc.size -= 1;
			break;
		case 3:
			msg->pool_desc.size += 1;
			break;
		case 4:
			msg->pool_desc.size = 0;
			msg->hdr.size = sizeof(OPEN_MSG) +
				msg->pool_desc.size;
			break;
		case 5:
			msg->pool_desc.size = 1;
			msg->hdr.size = sizeof(OPEN_MSG) +
				msg->pool_desc.size;
			break;
		case 6:
			msg->pool_desc.desc[0] = '\0';
			break;
		case 7:
			msg->pool_desc.desc[POOL_DESC_SIZE / 2] = '\0';
			break;
		case 8:
			msg->pool_desc.desc[POOL_DESC_SIZE - 1] = 'E';
			break;
		case 9:
			msg->major = RPMEM_PROTO_MAJOR + 1;
			break;
		case 10:
			msg->minor = RPMEM_PROTO_MINOR + 1;
			break;
		default:
			UT_ASSERT(0);
		}

		rpmem_hton_msg_open(msg);

		clnt_send(fd, msg, msg_size);
		clnt_wait_disconnect(fd);
		clnt_close(fd);
	}

	FREE(msg);
	FREE(target);
}