示例#1
0
文件: cnodeops.c 项目: BwRy/sel4test
static int
test_cnode_move(env_t env)
{
    int error;
    seL4_Word src, dest;

    /* A call that should succeed. */
    src = get_cap(&env->vka);
    dest = get_free_slot(env);
    error = cnode_move(env, src, dest);
    test_assert(!error);
    test_assert(is_slot_empty(env, src));
    test_assert(!is_slot_empty(env, dest));

    /* Move from an empty slot (should fail). */
    src = get_free_slot(env);
    dest = get_free_slot(env);
    error = cnode_move(env, src, dest);
    test_assert(error = seL4_FailedLookup);
    test_assert(is_slot_empty(env, dest));

    /* Move to an occupied slot (should fail). */
    src = get_cap(&env->vka);
    dest = get_cap(&env->vka);
    error = cnode_move(env, src, dest);
    test_assert(error == seL4_DeleteFirst);
    test_assert(!is_slot_empty(env, src));
    test_assert(!is_slot_empty(env, dest));

    return sel4test_get_result();
}
示例#2
0
void turn_end(struct board_t *board) {
	int corr;
	for(corr = 0; corr < 5; corr++) {
		if( !is_slot_empty(*board, 0, corr) && !is_slot_empty(*board, 1, corr) ) {
			attack(&board->slot[0][corr], &board->slot[1][corr]);
		} else if( !is_slot_empty(*board, 0, corr) ) {
			board->pl[1].hp -= board->slot[0][corr].atk;
		} else if( !is_slot_empty(*board, 1, corr) ) {
			board->pl[0].hp -= board->slot[1][corr].atk;
		}
	}
}
示例#3
0
文件: cnodeops.c 项目: BwRy/sel4test
static int
test_cnode_delete(env_t env)
{
    int error;
    seL4_Word slot;

    /* A call that should succeed. */
    slot = get_cap(&env->vka);
    error = cnode_delete(env, slot);
    test_assert(!error);
    test_assert(is_slot_empty(env, slot));

    /* Deleting a free slot (should succeed). */
    slot = get_free_slot(env);
    error = cnode_delete(env, slot);
    test_assert(!error);
    test_assert(is_slot_empty(env, slot));

    return sel4test_get_result();
}
示例#4
0
文件: cnodeops.c 项目: BwRy/sel4test
static int
test_cnode_revoke(env_t env)
{
    int error;
    seL4_Word slot;

    /* A call that should succeed. */
    slot = get_cap(&env->vka);
    error = cnode_revoke(env, slot);
    test_assert(!error);
    test_assert(!is_slot_empty(env, slot));

    /* Revoking a null cap (should fail). */
    slot = get_free_slot(env);
    error = cnode_revoke(env, slot);
    test_assert(!error);
    test_assert(is_slot_empty(env, slot));

    return sel4test_get_result();
}
示例#5
0
文件: cnodeops.c 项目: BwRy/sel4test
static int
test_cnode_recycle(env_t env)
{
    int error;
    seL4_Word slot;

    /* A call that should succeed. */
    slot = get_cap(&env->vka);
    error = cnode_recycle(env, slot);
    test_assert(!error);
    test_assert(!is_slot_empty(env, slot));

    /* Recycling an empty slot (should fail). */
    slot = get_free_slot(env);
    error = cnode_recycle(env, slot);
    test_assert(error == seL4_IllegalOperation);
    test_assert(is_slot_empty(env, slot));

    return sel4test_get_result();
}
示例#6
0
void print_field(struct board_t board, int side) {
	int corr;
	printf("#");
	for(corr = 0; corr < 5; corr++) {
		if( !is_slot_empty(board, side, corr) ) {
			printf("   %d|%d   #", board.slot[side][corr].atk, board.slot[side][corr].hp);
		} else {
			printf("         #");
		}
	}
	printf("\n");
}
示例#7
0
文件: cnodeops.c 项目: BwRy/sel4test
static int
test_cnode_copy(env_t env)
{
    int error;
    seL4_Word src, dest;

    /* A call that should succeed. */
    src = get_cap(&env->vka);
    dest = get_free_slot(env);
    test_assert(is_slot_empty(env, dest));
    error = cnode_copy(env, src, dest, seL4_AllRights);
    test_assert(!error);
    test_assert(!are_tcbs_distinct(src, dest));

    /* Copy to an occupied slot (should fail). */
    src = get_cap(&env->vka);
    dest = get_cap(&env->vka);
    error = cnode_copy(env, src, dest, seL4_AllRights);
    test_assert(error == seL4_DeleteFirst);
    test_assert(are_tcbs_distinct(src, dest));

    /* Copy from a free slot to an occupied slot (should fail). */
    src = get_free_slot(env);
    test_assert(is_slot_empty(env, src));
    dest = get_cap(&env->vka);
    error = cnode_copy(env, src, dest, seL4_AllRights);
    test_assert(error == seL4_DeleteFirst);
    test_assert(are_tcbs_distinct(src, dest));

    /* Copy from a free slot to a free slot (should fail). */
    src = get_free_slot(env);
    test_assert(is_slot_empty(env, src));
    dest = get_free_slot(env);
    test_assert(is_slot_empty(env, dest));
    error = cnode_copy(env, src, dest, seL4_AllRights);
    test_assert(error == seL4_FailedLookup);
    test_assert(are_tcbs_distinct(src, dest));

    return sel4test_get_result();
}
示例#8
0
static void
test_uri_parse (void)
{
	P11KitUri *uri;
	int ret;

	uri = p11_kit_uri_new ();
	assert_ptr_not_null (uri);

	ret = p11_kit_uri_parse ("pkcs11:", P11_KIT_URI_FOR_MODULE, uri);
	assert_num_eq (P11_KIT_URI_OK, ret);

	assert (is_module_empty (uri));
	assert (is_slot_empty (uri));
	assert (is_token_empty (uri));
	assert (are_attributes_empty (uri));

	p11_kit_uri_free (uri);
}
示例#9
0
文件: cnodeops.c 项目: BwRy/sel4test
static int
test_cnode_savecaller(env_t env)
{
    int error;
    seL4_Word slot;

    /* A call that should succeed. */
    slot = get_free_slot(env);
    error = cnode_savecaller(env, slot);
    test_assert(!error);

    /* Save to an occupied slot (should fail). */
    slot = get_cap(&env->vka);
    error = cnode_savecaller(env, slot);
    test_assert(error == seL4_DeleteFirst);
    test_assert(!is_slot_empty(env, slot));

    /* TODO: Test saving an actual reply capability. */

    return sel4test_get_result();
}
示例#10
0
static void
test_uri_parse_with_label (void)
{
	CK_ATTRIBUTE_PTR attr;
	P11KitUri *uri;
	int ret;

	uri = p11_kit_uri_new ();
	assert_ptr_not_null (uri);

	ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label", P11_KIT_URI_FOR_ANY, uri);
	assert_num_eq (P11_KIT_URI_OK, ret);

	assert (is_module_empty (uri));
	assert (is_slot_empty (uri));
	assert (is_token_empty (uri));

	attr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
	assert_ptr_not_null (attr);
	assert (attr->ulValueLen == strlen ("Test Label"));
	assert (memcmp (attr->pValue, "Test Label", attr->ulValueLen) == 0);

	p11_kit_uri_free (uri);
}
示例#11
0
文件: cnodeops.c 项目: BwRy/sel4test
static int
test_cnode_rotate(env_t env)
{
    int error;
    seL4_Word src, pivot, dest;

    /* A call that should succeed. */
    src = get_cap(&env->vka);
    pivot = get_cap(&env->vka);
    dest = get_free_slot(env);
    error = cnode_rotate(env, src, pivot, dest);
    test_assert(!error);
    test_assert(is_slot_empty(env, src));
    test_assert(!is_slot_empty(env, pivot));
    test_assert(!is_slot_empty(env, dest));

    /* Destination occupied (should fail). */
    src = get_cap(&env->vka);
    pivot = get_cap(&env->vka);
    dest = get_cap(&env->vka);
    error = cnode_rotate(env, src, pivot, dest);
    test_assert(error == seL4_DeleteFirst);
    test_assert(!is_slot_empty(env, src));
    test_assert(!is_slot_empty(env, pivot));
    test_assert(!is_slot_empty(env, dest));

    /* Swapping two caps (should succeed). */
    src = get_cap(&env->vka);
    pivot = get_cap(&env->vka);
    dest = src;
    error = cnode_rotate(env, src, pivot, dest);
    test_assert(!error);
    test_assert(!are_tcbs_distinct(src, dest));
    test_assert(!is_slot_empty(env, pivot));

    /* Moving a cap onto itself (should fail). */
    src = get_cap(&env->vka);
    pivot = src;
    dest = get_free_slot(env);
    error = cnode_rotate(env, src, pivot, dest);
    test_assert(error == seL4_IllegalOperation);
    test_assert(!is_slot_empty(env, src));
    test_assert(is_slot_empty(env, dest));

    /* Moving empty slots (should fail). */
    src = get_free_slot(env);
    pivot = get_free_slot(env);
    dest = get_free_slot(env);
    error = cnode_rotate(env, src, pivot, dest);
    test_assert(error == seL4_FailedLookup);
    test_assert(is_slot_empty(env, src));
    test_assert(is_slot_empty(env, pivot));
    test_assert(is_slot_empty(env, dest));

    return sel4test_get_result();
}