Changeset cdf5361 in mainline
- Timestamp:
- 2023-04-25T11:48:50Z (18 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aace43d8
- Parents:
- 97d3d9d
- git-author:
- Jiri Svoboda <jiri@…> (2023-04-24 17:48:39)
- git-committer:
- Jiri Svoboda <jiri@…> (2023-04-25 11:48:50)
- Location:
- uspace
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/display-cfg/test/seats.c
r97d3d9d rcdf5361 27 27 */ 28 28 29 #include <async.h> 30 #include <dispcfg.h> 31 #include <dispcfg_srv.h> 29 32 #include <errno.h> 30 33 #include <pcut/pcut.h> 34 #include <testdc.h> 31 35 #include "../display-cfg.h" 32 36 #include "../seats.h" … … 35 39 36 40 PCUT_TEST_SUITE(seats); 41 42 static const char *test_dispcfg_server = "test-dispcfg"; 43 static const char *test_dispcfg_svc = "test/dispcfg"; 37 44 38 45 /** Test dcfg_seats_create() and dcfg_seats_destroy() */ … … 81 88 PCUT_TEST(seats_list_populate) 82 89 { 90 errno_t rc; 91 service_id_t sid; 92 dispcfg_t *dispcfg = NULL; 93 test_response_t resp; 94 95 async_set_fallback_port_handler(test_dispcfg_conn, &resp); 96 97 // FIXME This causes this test to be non-reentrant! 98 rc = loc_server_register(test_dispcfg_server); 99 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 100 101 rc = loc_service_register(test_dispcfg_svc, &sid); 102 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 103 104 rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg); 105 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 106 PCUT_ASSERT_NOT_NULL(dispcfg); 107 108 dispcfg_close(dispcfg); 109 rc = loc_service_unregister(sid); 110 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 83 111 } 84 112 -
uspace/lib/dispcfg/include/dispcfg.h
r97d3d9d rcdf5361 27 27 */ 28 28 29 /** @addtogroup lib wndmgt29 /** @addtogroup libdispcfg 30 30 * @{ 31 31 */ -
uspace/lib/dispcfg/include/types/dispcfg.h
r97d3d9d rcdf5361 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Display configuration protocol types 33 33 */ 34 34 -
uspace/lib/dispcfg/meson.build
r97d3d9d rcdf5361 30 30 'src/dispcfg.c', 31 31 'src/dispcfg_srv.c', 32 'src/testdc.c' 32 33 ) 33 34 34 35 test_src = files( 35 36 'test/main.c', 36 'test/dispcfg.c' ,37 'test/dispcfg.c' 37 38 ) -
uspace/lib/dispcfg/test/dispcfg.c
r97d3d9d rcdf5361 35 35 #include <pcut/pcut.h> 36 36 #include <str.h> 37 #include <testdc.h> 37 38 #include "../private/dispcfg.h" 38 39 … … 43 44 static const char *test_dispcfg_server = "test-dispcfg"; 44 45 static const char *test_dispcfg_svc = "test/dispcfg"; 45 46 static void test_dispcfg_conn(ipc_call_t *, void *);47 48 static errno_t test_get_seat_list(void *, dispcfg_seat_list_t **);49 static errno_t test_get_seat_info(void *, sysarg_t, dispcfg_seat_info_t **);50 static errno_t test_seat_create(void *, const char *, sysarg_t *);51 static errno_t test_seat_delete(void *, sysarg_t);52 static errno_t test_dev_assign(void *, sysarg_t, sysarg_t);53 static errno_t test_dev_unassign(void *, sysarg_t);54 static errno_t test_get_asgn_dev_list(void *, sysarg_t, dispcfg_dev_list_t **);55 static errno_t test_get_event(void *, dispcfg_ev_t *);56 57 static void test_seat_added(void *, sysarg_t);58 static void test_seat_removed(void *, sysarg_t);59 60 static dispcfg_ops_t test_dispcfg_srv_ops = {61 .get_seat_list = test_get_seat_list,62 .get_seat_info = test_get_seat_info,63 .seat_create = test_seat_create,64 .seat_delete = test_seat_delete,65 .dev_assign = test_dev_assign,66 .dev_unassign = test_dev_unassign,67 .get_asgn_dev_list = test_get_asgn_dev_list,68 .get_event = test_get_event69 };70 71 static dispcfg_cb_t test_dispcfg_cb = {72 .seat_added = test_seat_added,73 .seat_removed = test_seat_removed74 };75 76 /** Describes to the server how to respond to our request and pass tracking77 * data back to the client.78 */79 typedef struct {80 errno_t rc;81 sysarg_t seat_id;82 dispcfg_ev_t event;83 dispcfg_ev_t revent;84 int event_cnt;85 86 bool get_seat_list_called;87 dispcfg_seat_list_t *get_seat_list_rlist;88 89 bool get_seat_info_called;90 sysarg_t get_seat_info_seat_id;91 dispcfg_seat_info_t *get_seat_info_rinfo;92 93 bool seat_create_called;94 char *seat_create_name;95 sysarg_t seat_create_seat_id;96 97 bool seat_delete_called;98 sysarg_t seat_delete_seat_id;99 100 bool dev_assign_called;101 sysarg_t dev_assign_svc_id;102 sysarg_t dev_assign_seat_id;103 104 bool dev_unassign_called;105 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;110 111 bool get_event_called;112 113 bool seat_added_called;114 sysarg_t seat_added_seat_id;115 116 bool seat_removed_called;117 sysarg_t seat_removed_seat_id;118 119 bool seat_changed_called;120 sysarg_t seat_changed_seat_id;121 122 fibril_condvar_t event_cv;123 fibril_mutex_t event_lock;124 dispcfg_srv_t *srv;125 } test_response_t;126 46 127 47 /** dispcfg_open(), dispcfg_close() work for valid seat management service */ … … 790 710 } 791 711 792 /** Test seat management service connection. */793 static void test_dispcfg_conn(ipc_call_t *icall, void *arg)794 {795 test_response_t *resp = (test_response_t *) arg;796 dispcfg_srv_t srv;797 798 /* Set up protocol structure */799 dispcfg_srv_initialize(&srv);800 srv.ops = &test_dispcfg_srv_ops;801 srv.arg = arg;802 resp->srv = &srv;803 804 /* Handle connection */805 dispcfg_conn(icall, &srv);806 807 resp->srv = NULL;808 }809 810 static void test_seat_added(void *arg, sysarg_t seat_id)811 {812 test_response_t *resp = (test_response_t *) arg;813 814 resp->revent.etype = dcev_seat_added;815 816 fibril_mutex_lock(&resp->event_lock);817 resp->seat_added_called = true;818 resp->seat_added_seat_id = seat_id;819 fibril_condvar_broadcast(&resp->event_cv);820 fibril_mutex_unlock(&resp->event_lock);821 }822 823 static void test_seat_removed(void *arg, sysarg_t seat_id)824 {825 test_response_t *resp = (test_response_t *) arg;826 827 resp->revent.etype = dcev_seat_removed;828 829 fibril_mutex_lock(&resp->event_lock);830 resp->seat_removed_called = true;831 resp->seat_removed_seat_id = seat_id;832 fibril_condvar_broadcast(&resp->event_cv);833 fibril_mutex_unlock(&resp->event_lock);834 }835 836 static errno_t test_get_seat_list(void *arg, dispcfg_seat_list_t **rlist)837 {838 test_response_t *resp = (test_response_t *) arg;839 840 resp->get_seat_list_called = true;841 842 if (resp->rc != EOK)843 return resp->rc;844 845 *rlist = resp->get_seat_list_rlist;846 return EOK;847 }848 849 static errno_t test_get_seat_info(void *arg, sysarg_t seat_id,850 dispcfg_seat_info_t **rinfo)851 {852 test_response_t *resp = (test_response_t *) arg;853 854 resp->get_seat_info_called = true;855 resp->get_seat_info_seat_id = seat_id;856 857 if (resp->rc != EOK)858 return resp->rc;859 860 *rinfo = resp->get_seat_info_rinfo;861 return EOK;862 }863 864 static errno_t test_seat_create(void *arg, const char *name, sysarg_t *rseat_id)865 {866 test_response_t *resp = (test_response_t *) arg;867 868 resp->seat_create_called = true;869 resp->seat_create_name = str_dup(name);870 *rseat_id = resp->seat_create_seat_id;871 return resp->rc;872 }873 874 static errno_t test_seat_delete(void *arg, sysarg_t seat_id)875 {876 test_response_t *resp = (test_response_t *) arg;877 878 resp->seat_delete_called = true;879 resp->seat_delete_seat_id = seat_id;880 return resp->rc;881 }882 883 static errno_t test_dev_assign(void *arg, sysarg_t svc_id, sysarg_t seat_id)884 {885 test_response_t *resp = (test_response_t *) arg;886 887 resp->dev_assign_called = true;888 resp->dev_assign_svc_id = svc_id;889 resp->dev_assign_seat_id = seat_id;890 return resp->rc;891 }892 893 static errno_t test_dev_unassign(void *arg, sysarg_t svc_id)894 {895 test_response_t *resp = (test_response_t *) arg;896 897 resp->dev_unassign_called = true;898 resp->dev_unassign_svc_id = svc_id;899 return resp->rc;900 }901 902 static 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 917 static errno_t test_get_event(void *arg, dispcfg_ev_t *event)918 {919 test_response_t *resp = (test_response_t *) arg;920 921 resp->get_event_called = true;922 if (resp->event_cnt > 0) {923 --resp->event_cnt;924 *event = resp->event;925 return EOK;926 }927 928 return ENOENT;929 }930 931 712 PCUT_EXPORT(dispcfg);
Note:
See TracChangeset
for help on using the changeset viewer.