TEST_F(cryptoboxtest, send_ten_messages)
{
	struct device *a, *b;

	add_devices(2);

	/* Connect the 2 devices */
	connect_devices();

	a = (struct device *)devicel.head->data;
	b = (struct device *)devicel.tail->data;

	err = device_new_session(a, b);
	ASSERT_EQ(0, err);

	for (int i=0; i<5; i++) {
		size_t len = rand_u16();
		uint8_t *msg = (uint8_t *)mem_alloc(len, NULL);

		rand_bytes(msg, len);

		send_message(a, b, msg, len);

		/* reverse direction */
		send_message(b, a, msg, len);

		mem_deref(msg);
	}
}
TEST_F(cryptoboxtest, add_send_then_add_send)
{
	add_devices(2);

	connect_devices();

	send_all();

	add_devices(1);

	connect_devices();

	send_all();

	verify_devices();
}
TEST_F(cryptoboxtest, tmp)
{
#define NUM 3
	struct device *a;

	add_devices(NUM);

	connect_devices();

	//debug();

	/* number of peers is always N-1 */
	a = (struct device *)list_ledata(devicel.head);
	ASSERT_EQ(NUM-1, list_count(&a->peerl));
}
예제 #4
0
int rmd_devmgr_init()
{
	int ret;

	ret = add_drivers();
	if (ret != 0)
		return -1;

#ifndef RMD_DYNAMIC_DEVICES
	add_devices();		/* get devices info from config file */
#else
	syslog(LOG_INFO, "dynamic devices");
#endif

	return 0;
}
TEST_F(cryptoboxtest, send_one_message)
{
	struct device *a, *b;

	add_devices(2);

	/* Connect the 2 devices */
	connect_devices();

	a = (struct device *)devicel.head->data;
	b = (struct device *)devicel.tail->data;

	err = device_new_session(a, b);
	ASSERT_EQ(0, err);

	send_message(a, b, hello_msg, sizeof(hello_msg));
}
TEST_F(cryptoboxtest, performance)
{
#define NUM_MESSAGES 1000
#define MSG_SIZE 256
	uint64_t t1, t2;
	struct device *a, *b;
	size_t len = MSG_SIZE;

	add_devices(2);

	connect_devices();

	a = (struct device *)devicel.head->data;
	b = (struct device *)devicel.tail->data;

	err = device_new_session(a, b);
	ASSERT_EQ(0, err);

	uint8_t *msg = (uint8_t *)mem_alloc(len, NULL);
	rand_bytes(msg, len);

	re_printf("sending %d messages of size %zu bytes\n",
		  NUM_MESSAGES, len);

	t1 = tmr_jiffies();

	for (int i=0; i<NUM_MESSAGES; i++) {

		send_message(a, b, msg, len);
	}

	t2 = tmr_jiffies();

	re_printf("~~~ performance report ~~~\n");
	re_printf("num_messages:   %d\n", NUM_MESSAGES);
	re_printf("message_size:   %zu\n", len);
	re_printf("total_time:     %d ms\n", (int)(t2-t1));
	re_printf("average:        %.1f ms\n", 1.0*(t2-t1)/NUM_MESSAGES);
	re_printf("~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~\n");
	re_printf("\n");

	mem_deref(msg);
}
/* Test sending messages between 3 devices */
TEST_F(cryptoboxtest, three_devices)
{
	struct le *le;

	add_devices(3);

	/* Connect the devices */
	connect_devices();

	for (le = devicel.head; le; le = le->next) {

		struct device *dev = (struct device *)le->data, *other;
		struct le *next;

		next = le->next ? le->next : devicel.head;
		other = (struct device *)list_ledata(next);

		err = device_new_session(dev, other);
		ASSERT_EQ(0, err);

		send_message(dev, other, hello_msg, sizeof(hello_msg));
	}
}
예제 #8
0
CL_InputBuffer::CL_InputBuffer(CL_InputContext *ic)
: impl(new CL_InputBuffer_Generic)
{
	add_devices(ic);
	impl->add_ref();
}