Beispiel #1
0
Test(Player, look_empty)
{
	player_t *pl = player_create_at((vector2d_t){9, 9});
	game_t *gm = game_create(20, 20, 7, 5);

	cr_assert(pl);
	cr_assert(gm);
	game_add_team(gm, "pandas");
	pl->p_teamname = strdup("pandas");
	cr_assert_neq(game_register_player(gm, pl), -1);
	dynbuf_t *buf = player_look(pl, gm);
	cr_assert(buf);
	cr_log_info(buf->b_data);
	cr_assert(strstr(buf->b_data, "player"));
	cr_assert_eq(count_char(buf->b_data, ','), 3);
	pl->p_lvl = 2;
	dynbuf_delete(buf);
	buf = player_look(pl, gm);
	cr_log_info(buf->b_data);
	cr_assert(strstr(buf->b_data, "player"));
	cr_assert_eq(count_char(buf->b_data, ','), 8);
	dynbuf_delete(buf);
	pl->p_lvl = 3;
	buf = player_look(pl, gm);
	cr_log_info(buf->b_data);
	cr_assert(strstr(buf->b_data, "player"));
	cr_assert_eq(count_char(buf->b_data, ','), 15);
	dynbuf_delete(buf);
	game_delete(gm);
}
Beispiel #2
0
Test(Player, inventory_list_gfx)
{
	player_t *pl = player_create_at((vector2d_t){4, 7});

	player_inventory_add(pl, FOOD);
	dynbuf_t *buf = player_inventory_list(pl);
	cr_log_info(buf->b_data);
	cr_expect_neq(strstr(buf->b_data, "food 1"), 0);
	dynbuf_delete(buf);

	player_inventory_add(pl, FOOD);
	buf = player_inventory_list(pl);
	cr_log_info(buf->b_data);
	cr_expect_neq(strstr(buf->b_data, "food 2"), 0);
	dynbuf_delete(buf);

	player_inventory_add(pl, SIBUR);
	player_inventory_add(pl, SIBUR);
	player_inventory_add(pl, SIBUR);
	player_inventory_add(pl, SIBUR);
	buf = player_inventory_list_gfx(pl);
	cr_log_info(buf->b_data);
	cr_assert_str_eq(buf->b_data, "2 0 0 4 0 0 0");
	dynbuf_delete(buf);

	player_delete(pl);
}
Beispiel #3
0
Test(Player, look_up)
{
	player_t *pl = player_create_at((vector2d_t){9, 9});
	game_t *gm = game_create(20, 20, 7, 5);

	cr_assert(pl);
	cr_assert(gm);
	game_add_team(gm, "pandas");
	pl->p_teamname = strdup("pandas");
	cr_assert_neq(game_register_player(gm, pl), -1);
	pl->p_dir = (vector2d_t){0, -1};

	board_put_resource(gm->ga_board, (vector2d_t){9, 9}, SIBUR);
	board_put_resource(gm->ga_board, (vector2d_t){8, 8}, THYSTAME);
	board_put_resource(gm->ga_board, (vector2d_t){9, 8}, LINEMATE);
	board_put_resource(gm->ga_board, (vector2d_t){10, 8}, DERAUMERE);
	board_inc_food(gm->ga_board, (vector2d_t){10, 8});
	board_inc_food(gm->ga_board, (vector2d_t){10, 8});

	dynbuf_t *buf = player_look(pl, gm);
	cr_assert(buf);
	cr_log_info(buf->b_data);
	cr_assert(strstr(buf->b_data, "player"));
	cr_assert_eq(count_char(buf->b_data, ','), 3);
	cr_assert_str_eq(buf->b_data,
		"[sibur player,thystame,linemate,food food deraumere]");
	dynbuf_delete(buf);
	game_delete(gm);
}
Beispiel #4
0
static void addr_insert_test(void)
{
	int i, ret;
	fi_addr_t addresses[SIMPLE_ADDR_COUNT];

	int err[SIMPLE_ADDR_COUNT] = {0};

	cr_log_info("check for sync err flag but no context\n");
	ret = fi_av_insert(av, (void *) simple_ep_names, SIMPLE_ADDR_COUNT,
			   addresses, FI_SYNC_ERR, NULL);
	cr_assert_eq(ret, -FI_EINVAL, "%d", ret);

	ret = fi_av_insert(av, (void *) simple_ep_names, SIMPLE_ADDR_COUNT,
			   addresses, FI_SYNC_ERR, err);
	cr_assert_eq(ret, SIMPLE_ADDR_COUNT);

	cr_log_info("check for errors\n");
	for (i = 0; i < SIMPLE_ADDR_COUNT; i++) {
		cr_assert_eq(err[i], 0);
	}

	ret = fi_av_remove(av, addresses, SIMPLE_ADDR_COUNT, 0);
	cr_assert_eq(ret, FI_SUCCESS);
}
Beispiel #5
0
Test(scalablet, all)
{
	cr_log_info(BLUE "sep:FI_AV_TABLE tests:\n" COLOR_RESET);
	run_tests();
}
Beispiel #6
0
Test(scalablem, all)
{
	cr_log_info(BLUE "sep:FI_AV_MAP tests:\n" COLOR_RESET);
	run_tests();
}
Beispiel #7
0
void run_tests(void)
{
	int i, j;

	cr_log_info("sep_send_recv\n");
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_send_recv, i, 1, BUF_SZ);
	}

	cr_log_info("sep_sendv\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_sendv, i, 1, BUF_SZ);
	}

	cr_log_info("sep_recvv\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_recvv, i, 1, BUF_SZ);
	}

	cr_log_info("sep_sendmsg\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_sendmsg, i, 1, BUF_SZ);
	}

	cr_log_info("sep_sendmsgdata\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_sendmsgdata, i, 1, BUF_SZ);
	}

	cr_log_info("sep_inject\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_inject, i, 1, INJECT_SIZE);
	}

	cr_log_info("sep_senddata\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_senddata, i, 1, INJECT_SIZE);
	}

	cr_log_info("sep_injectdata\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_injectdata, i, 1, INJECT_SIZE);
	}

	cr_log_info("sep_read\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_read, i, 8, BUF_SZ);
	}

	cr_log_info("sep_readv\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_readv, i, 8, BUF_SZ);
	}

	cr_log_info("sep_readmsg\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_readmsg, i, 8, BUF_SZ);
	}

	cr_log_info("sep_write\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_write, i, 8, BUF_SZ);
	}

	cr_log_info("sep_writev\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_writev, i, 8, BUF_SZ);
	}

	cr_log_info("sep_writemsg\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_writemsg, i, 8, BUF_SZ);
	}

	cr_log_info("sep_writedata\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_writedata, i, 8, BUF_SZ);
	}

	cr_log_info("sep_atomic\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic(i);
	}

	cr_log_info("sep_atomic_v\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_v(i);
	}

	cr_log_info("sep_atomic_msg\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_msg(i);
	}

	cr_log_info("sep_atomic_rw\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_rw(i);
	}

	cr_log_info("sep_atomic_rwmsg\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_rwmsg(i);
	}

	cr_log_info("sep_atomic_compwrite\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_compwrite(i);
	}

	cr_log_info("sep_atomic_compwritev\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_compwritev(i);
	}

	cr_log_info("sep_atomic_compwritemsg\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_compwritemsg(i);
	}

	cr_log_info("sep_atomic_inject\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		sep_atomic_inject(i);
	}

	cr_log_info("sep_inject_write\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_inject_write, i, 8, INJECT_SIZE);
	}

	cr_log_info("sep_inject_writedata\n");
	sep_clear_counters();
	for (i = 0; i < ctx_cnt; i++) {
		xfer_each_size(sep_inject_writedata, i, 8, INJECT_SIZE);
	}

	cr_log_info("sep_invalid_compare_atomic\n");
	for (i = 0; i < FI_ATOMIC_OP_LAST; i++) {
		for (j = 0; j < FI_DATATYPE_LAST; j++) {
			sep_invalid_compare_atomic(j, i);
		}
	}

	cr_log_info("sep_invalid_fetch_atomic\n");
	for (i = 0; i < FI_ATOMIC_OP_LAST; i++) {
		for (j = 0; j < FI_DATATYPE_LAST; j++) {
			sep_invalid_fetch_atomic(j, i);
		}
	}
}