Changeset d53a5ab0 in mainline for uspace/lib/ipctest/src/ipc_test.c


Ignore:
Timestamp:
2023-12-13T10:50:27Z (13 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, topic/simplify-dev-export
Children:
381c426
Parents:
4f6368c
Message:

Add IPC read/write test to libipctest/ipc test server + tester

Now really if IPC read/write didn't work, nothing would work.
Tester's readwrite test is mostly for sanity checking that
the read/write test in libipctest / ipc-test server work as intended.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ipctest/src/ipc_test.c

    r4f6368c rd53a5ab0  
    11/*
    2  * Copyright (c) 2018 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    221221}
    222222
     223/** Set server-side read/write buffer size.
     224 *
     225 * @param test IPC test service
     226 * @param size Requested read/write buffer size
     227 * @return EOK on success or an error code
     228 */
     229errno_t ipc_test_set_rw_buf_size(ipc_test_t *test, size_t size)
     230{
     231        async_exch_t *exch;
     232        errno_t retval;
     233
     234        exch = async_exchange_begin(test->sess);
     235        retval = async_req_1_0(exch, IPC_TEST_SET_RW_BUF_SIZE, size);
     236        async_exchange_end(exch);
     237
     238        if (retval != EOK)
     239                return retval;
     240
     241        return EOK;
     242}
     243
     244/** Test IPC read.
     245 *
     246 * @param test IPC test service
     247 * @param dest Destination buffer
     248 * @param size Number of bytes to read / size of destination buffer
     249 * @return EOK on success or an error code
     250 */
     251errno_t ipc_test_read(ipc_test_t *test, void *dest, size_t size)
     252{
     253        async_exch_t *exch;
     254        ipc_call_t answer;
     255        aid_t req;
     256        errno_t rc;
     257
     258        exch = async_exchange_begin(test->sess);
     259        req = async_send_0(exch, IPC_TEST_READ, &answer);
     260
     261        rc = async_data_read_start(exch, dest, size);
     262        if (rc != EOK) {
     263                async_exchange_end(exch);
     264                async_forget(req);
     265                return rc;
     266        }
     267
     268        async_exchange_end(exch);
     269        async_wait_for(req, NULL);
     270        return EOK;
     271}
     272
     273/** Test IPC write.
     274 *
     275 * @param test IPC test service
     276 * @param data Source buffer
     277 * @param size Number of bytes to write
     278 * @return EOK on success or an error code
     279 */
     280errno_t ipc_test_write(ipc_test_t *test, const void *data, size_t size)
     281{
     282        async_exch_t *exch;
     283        ipc_call_t answer;
     284        aid_t req;
     285        errno_t rc;
     286
     287        exch = async_exchange_begin(test->sess);
     288        req = async_send_0(exch, IPC_TEST_WRITE, &answer);
     289
     290        rc = async_data_write_start(exch, data, size);
     291        if (rc != EOK) {
     292                async_exchange_end(exch);
     293                async_forget(req);
     294                return rc;
     295        }
     296
     297        async_exchange_end(exch);
     298        async_wait_for(req, NULL);
     299        return EOK;
     300}
     301
    223302/** @}
    224303 */
Note: See TracChangeset for help on using the changeset viewer.