Changeset c0757e1f in mainline for uspace/lib/dispcfg/test/dispcfg.c
- Timestamp:
- 2023-04-19T11:13:06Z (21 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37087c8
- Parents:
- ec8ef12
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/dispcfg/test/dispcfg.c
rec8ef12 rc0757e1f 52 52 static errno_t test_dev_assign(void *, sysarg_t, sysarg_t); 53 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 **); 54 55 static errno_t test_get_event(void *, dispcfg_ev_t *); 55 56 … … 64 65 .dev_assign = test_dev_assign, 65 66 .dev_unassign = test_dev_unassign, 67 .get_asgn_dev_list = test_get_asgn_dev_list, 66 68 .get_event = test_get_event 67 69 }; … … 102 104 bool dev_unassign_called; 103 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; 104 110 105 111 bool get_event_called; … … 604 610 } 605 611 612 /** dispcfg_get_asgn_dev_list() with server returning error response works */ 613 PCUT_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 */ 650 PCUT_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 606 698 /** Window added event can be delivered from server to client callback function */ 607 699 PCUT_TEST(seat_added_deliver) … … 808 900 } 809 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 810 917 static errno_t test_get_event(void *arg, dispcfg_ev_t *event) 811 918 {
Note:
See TracChangeset
for help on using the changeset viewer.