HelenOS sources
This source file includes following definitions.
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
#include <async.h>
#include <errno.h>
#include <dispcfg.h>
#include <dispcfg_srv.h>
#include <fibril_synch.h>
#include <loc.h>
#include <pcut/pcut.h>
#include <str.h>
#include <testdc.h>
#include "../private/dispcfg.h"
PCUT_INIT;
PCUT_TEST_SUITE(dispcfg);
static const char *test_dispcfg_server = "test-dispcfg";
static const char *test_dispcfg_svc = "test/dispcfg";
PCUT_TEST(open_close)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(get_seat_list_failure)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
dispcfg_seat_list_t *list;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
resp.rc = ENOMEM;
resp.get_seat_list_called = false;
rc = dispcfg_get_seat_list(dispcfg, &list);
PCUT_ASSERT_TRUE(resp.get_seat_list_called);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(get_seat_list_success)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
dispcfg_seat_list_t *list;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
resp.rc = EOK;
resp.get_seat_list_called = false;
resp.get_seat_list_rlist = calloc(1, sizeof(dispcfg_seat_list_t));
PCUT_ASSERT_NOT_NULL(resp.get_seat_list_rlist);
resp.get_seat_list_rlist->nseats = 2;
resp.get_seat_list_rlist->seats = calloc(2, sizeof(sysarg_t));
PCUT_ASSERT_NOT_NULL(resp.get_seat_list_rlist->seats);
resp.get_seat_list_rlist->seats[0] = 42;
resp.get_seat_list_rlist->seats[1] = 43;
rc = dispcfg_get_seat_list(dispcfg, &list);
PCUT_ASSERT_TRUE(resp.get_seat_list_called);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
PCUT_ASSERT_INT_EQUALS(2, list->nseats);
PCUT_ASSERT_INT_EQUALS(42, list->seats[0]);
PCUT_ASSERT_INT_EQUALS(43, list->seats[1]);
dispcfg_free_seat_list(list);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(get_seat_info_failure)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t seat_id;
dispcfg_seat_info_t *info;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
resp.rc = ENOMEM;
resp.get_seat_info_called = false;
seat_id = 1;
rc = dispcfg_get_seat_info(dispcfg, seat_id, &info);
PCUT_ASSERT_TRUE(resp.get_seat_info_called);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_seat_info_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(get_seat_info_success)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t seat_id;
dispcfg_seat_info_t *info;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
resp.rc = EOK;
resp.get_seat_info_called = false;
resp.get_seat_info_rinfo = calloc(1, sizeof(dispcfg_seat_info_t));
PCUT_ASSERT_NOT_NULL(resp.get_seat_info_rinfo);
resp.get_seat_info_rinfo->name = str_dup("Hello");
PCUT_ASSERT_NOT_NULL(resp.get_seat_info_rinfo->name);
seat_id = 1;
rc = dispcfg_get_seat_info(dispcfg, seat_id, &info);
PCUT_ASSERT_TRUE(resp.get_seat_info_called);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_seat_info_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
PCUT_ASSERT_STR_EQUALS("Hello", info->name);
dispcfg_free_seat_info(info);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(seat_create_failure)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
seat_id = 13;
seat_id = 42;
resp.rc = ENOMEM;
resp.seat_create_called = false;
rc = dispcfg_seat_create(dispcfg, "Alice", &seat_id);
PCUT_ASSERT_TRUE(resp.seat_create_called);
PCUT_ASSERT_STR_EQUALS("Alice", resp.seat_create_name);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
free(resp.seat_create_name);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(seat_create_success)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
resp.rc = EOK;
resp.seat_create_called = false;
resp.seat_create_seat_id = 42;
rc = dispcfg_seat_create(dispcfg, "Alice", &seat_id);
PCUT_ASSERT_TRUE(resp.seat_create_called);
PCUT_ASSERT_STR_EQUALS("Alice", resp.seat_create_name);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.seat_create_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
free(resp.seat_create_name);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(seat_delete_failure)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
seat_id = 42;
resp.rc = ENOMEM;
resp.seat_delete_called = false;
rc = dispcfg_seat_delete(dispcfg, seat_id);
PCUT_ASSERT_TRUE(resp.seat_delete_called);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.seat_delete_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(seat_delete_success)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
seat_id = 42;
resp.rc = EOK;
resp.seat_delete_called = false;
rc = dispcfg_seat_delete(dispcfg, seat_id);
PCUT_ASSERT_TRUE(resp.seat_delete_called);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.seat_delete_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(dev_assign_failure)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t svc_id;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
svc_id = 12;
seat_id = 13;
resp.rc = ENOMEM;
resp.dev_assign_called = false;
rc = dispcfg_dev_assign(dispcfg, svc_id, seat_id);
PCUT_ASSERT_TRUE(resp.dev_assign_called);
PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_assign_svc_id);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.dev_assign_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(dev_assign_success)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t svc_id;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
svc_id = 12;
seat_id = 13;
resp.rc = EOK;
resp.dev_assign_called = false;
rc = dispcfg_dev_assign(dispcfg, svc_id, seat_id);
PCUT_ASSERT_TRUE(resp.dev_assign_called);
PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_assign_svc_id);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.dev_assign_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(dev_unassign_failure)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t svc_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
svc_id = 12;
resp.rc = ENOMEM;
resp.dev_unassign_called = false;
rc = dispcfg_dev_unassign(dispcfg, svc_id);
PCUT_ASSERT_TRUE(resp.dev_unassign_called);
PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_unassign_svc_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(dev_unassign_success)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
sysarg_t svc_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
svc_id = 12;
resp.rc = EOK;
resp.dev_unassign_called = false;
rc = dispcfg_dev_unassign(dispcfg, svc_id);
PCUT_ASSERT_TRUE(resp.dev_unassign_called);
PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_unassign_svc_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(get_asgn_dev_list_failure)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
dispcfg_dev_list_t *list;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
resp.rc = ENOMEM;
resp.get_asgn_dev_list_called = false;
seat_id = 42;
rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &list);
PCUT_ASSERT_TRUE(resp.get_asgn_dev_list_called);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_asgn_dev_list_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(get_asgn_dev_list_success)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
dispcfg_dev_list_t *list;
sysarg_t seat_id;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
resp.rc = EOK;
resp.get_asgn_dev_list_called = false;
resp.get_asgn_dev_list_rlist = calloc(1, sizeof(dispcfg_dev_list_t));
PCUT_ASSERT_NOT_NULL(resp.get_asgn_dev_list_rlist);
resp.get_asgn_dev_list_rlist->ndevs = 2;
resp.get_asgn_dev_list_rlist->devs = calloc(2, sizeof(sysarg_t));
PCUT_ASSERT_NOT_NULL(resp.get_asgn_dev_list_rlist->devs);
resp.get_asgn_dev_list_rlist->devs[0] = 11;
resp.get_asgn_dev_list_rlist->devs[1] = 12;
seat_id = 42;
rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &list);
PCUT_ASSERT_TRUE(resp.get_asgn_dev_list_called);
PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_asgn_dev_list_seat_id);
PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
PCUT_ASSERT_INT_EQUALS(2, list->ndevs);
PCUT_ASSERT_INT_EQUALS(11, list->devs[0]);
PCUT_ASSERT_INT_EQUALS(12, list->devs[1]);
dispcfg_free_dev_list(list);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(seat_added_deliver)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, &test_dispcfg_cb, &resp, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
PCUT_ASSERT_NOT_NULL(resp.srv);
resp.event_cnt = 1;
resp.event.etype = dcev_seat_added;
resp.event.seat_id = 42;
resp.seat_added_called = false;
fibril_mutex_initialize(&resp.event_lock);
fibril_condvar_initialize(&resp.event_cv);
dispcfg_srv_ev_pending(resp.srv);
fibril_mutex_lock(&resp.event_lock);
while (!resp.seat_added_called) {
fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
}
fibril_mutex_unlock(&resp.event_lock);
PCUT_ASSERT_INT_EQUALS(resp.event.etype,
resp.revent.etype);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_TEST(seat_removed_deliver)
{
errno_t rc;
service_id_t sid;
dispcfg_t *dispcfg = NULL;
test_response_t resp;
loc_srv_t *srv;
async_set_fallback_port_handler(test_dispcfg_conn, &resp);
rc = loc_server_register(test_dispcfg_server, &srv);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = loc_service_register(srv, test_dispcfg_svc, &sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = dispcfg_open(test_dispcfg_svc, &test_dispcfg_cb, &resp, &dispcfg);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(dispcfg);
PCUT_ASSERT_NOT_NULL(resp.srv);
resp.event_cnt = 1;
resp.event.etype = dcev_seat_removed;
resp.event.seat_id = 42;
resp.seat_removed_called = false;
fibril_mutex_initialize(&resp.event_lock);
fibril_condvar_initialize(&resp.event_cv);
dispcfg_srv_ev_pending(resp.srv);
fibril_mutex_lock(&resp.event_lock);
while (!resp.seat_removed_called) {
fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
}
fibril_mutex_unlock(&resp.event_lock);
PCUT_ASSERT_INT_EQUALS(resp.event.etype,
resp.revent.etype);
dispcfg_close(dispcfg);
rc = loc_service_unregister(srv, sid);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
loc_server_unregister(srv);
}
PCUT_EXPORT(dispcfg);
HelenOS homepage, sources at GitHub