Changeset c0757e1f in mainline for uspace/lib/dispcfg/test/dispcfg.c


Ignore:
Timestamp:
2023-04-19T11:13:06Z (20 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
37087c8
Parents:
ec8ef12
Message:

UI display configuration utility

In addition to the command-line utility 'disp', we introduce its UI
equivalent 'display-cfg'. Currently this allows the user to configure
seats in a very comfortable way.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/dispcfg/test/dispcfg.c

    rec8ef12 rc0757e1f  
    5252static errno_t test_dev_assign(void *, sysarg_t, sysarg_t);
    5353static errno_t test_dev_unassign(void *, sysarg_t);
     54static errno_t test_get_asgn_dev_list(void *, sysarg_t, dispcfg_dev_list_t **);
    5455static errno_t test_get_event(void *, dispcfg_ev_t *);
    5556
     
    6465        .dev_assign = test_dev_assign,
    6566        .dev_unassign = test_dev_unassign,
     67        .get_asgn_dev_list = test_get_asgn_dev_list,
    6668        .get_event = test_get_event
    6769};
     
    102104        bool dev_unassign_called;
    103105        sysarg_t dev_unassign_svc_id;
     106
     107        bool get_asgn_dev_list_called;
     108        sysarg_t get_asgn_dev_list_seat_id;
     109        dispcfg_dev_list_t *get_asgn_dev_list_rlist;
    104110
    105111        bool get_event_called;
     
    604610}
    605611
     612/** dispcfg_get_asgn_dev_list() with server returning error response works */
     613PCUT_TEST(get_asgn_dev_list_failure)
     614{
     615        errno_t rc;
     616        service_id_t sid;
     617        dispcfg_t *dispcfg = NULL;
     618        dispcfg_dev_list_t *list;
     619        sysarg_t seat_id;
     620        test_response_t resp;
     621
     622        async_set_fallback_port_handler(test_dispcfg_conn, &resp);
     623
     624        // FIXME This causes this test to be non-reentrant!
     625        rc = loc_server_register(test_dispcfg_server);
     626        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     627
     628        rc = loc_service_register(test_dispcfg_svc, &sid);
     629        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     630
     631        rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
     632        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     633        PCUT_ASSERT_NOT_NULL(dispcfg);
     634
     635        resp.rc = ENOMEM;
     636        resp.get_asgn_dev_list_called = false;
     637        seat_id = 42;
     638
     639        rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &list);
     640        PCUT_ASSERT_TRUE(resp.get_asgn_dev_list_called);
     641        PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_asgn_dev_list_seat_id);
     642        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     643
     644        dispcfg_close(dispcfg);
     645        rc = loc_service_unregister(sid);
     646        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     647}
     648
     649/** dispcfg_get_asgn_dev_list() with server returning success response works */
     650PCUT_TEST(get_asgn_dev_list_success)
     651{
     652        errno_t rc;
     653        service_id_t sid;
     654        dispcfg_t *dispcfg = NULL;
     655        dispcfg_dev_list_t *list;
     656        sysarg_t seat_id;
     657        test_response_t resp;
     658
     659        async_set_fallback_port_handler(test_dispcfg_conn, &resp);
     660
     661        // FIXME This causes this test to be non-reentrant!
     662        rc = loc_server_register(test_dispcfg_server);
     663        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     664
     665        rc = loc_service_register(test_dispcfg_svc, &sid);
     666        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     667
     668        rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
     669        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     670        PCUT_ASSERT_NOT_NULL(dispcfg);
     671
     672        resp.rc = EOK;
     673        resp.get_asgn_dev_list_called = false;
     674        resp.get_asgn_dev_list_rlist = calloc(1, sizeof(dispcfg_dev_list_t));
     675        PCUT_ASSERT_NOT_NULL(resp.get_asgn_dev_list_rlist);
     676        resp.get_asgn_dev_list_rlist->ndevs = 2;
     677        resp.get_asgn_dev_list_rlist->devs = calloc(2, sizeof(sysarg_t));
     678        PCUT_ASSERT_NOT_NULL(resp.get_asgn_dev_list_rlist->devs);
     679        resp.get_asgn_dev_list_rlist->devs[0] = 11;
     680        resp.get_asgn_dev_list_rlist->devs[1] = 12;
     681        seat_id = 42;
     682
     683        rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &list);
     684        PCUT_ASSERT_TRUE(resp.get_asgn_dev_list_called);
     685        PCUT_ASSERT_INT_EQUALS(seat_id, resp.get_asgn_dev_list_seat_id);
     686        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     687
     688        PCUT_ASSERT_INT_EQUALS(2, list->ndevs);
     689        PCUT_ASSERT_INT_EQUALS(11, list->devs[0]);
     690        PCUT_ASSERT_INT_EQUALS(12, list->devs[1]);
     691
     692        dispcfg_free_dev_list(list);
     693        dispcfg_close(dispcfg);
     694        rc = loc_service_unregister(sid);
     695        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     696}
     697
    606698/** Window added event can be delivered from server to client callback function */
    607699PCUT_TEST(seat_added_deliver)
     
    808900}
    809901
     902static errno_t test_get_asgn_dev_list(void *arg, sysarg_t seat_id,
     903    dispcfg_dev_list_t **rlist)
     904{
     905        test_response_t *resp = (test_response_t *) arg;
     906
     907        resp->get_asgn_dev_list_called = true;
     908        resp->get_asgn_dev_list_seat_id = seat_id;
     909
     910        if (resp->rc != EOK)
     911                return resp->rc;
     912
     913        *rlist = resp->get_asgn_dev_list_rlist;
     914        return EOK;
     915}
     916
    810917static errno_t test_get_event(void *arg, dispcfg_ev_t *event)
    811918{
Note: See TracChangeset for help on using the changeset viewer.