Changeset d53a5ab0 in mainline
- Timestamp:
- 2023-12-13T10:50:27Z (13 months ago)
- Branches:
- master, topic/simplify-dev-export
- Children:
- 381c426
- Parents:
- 4f6368c
- Location:
- uspace
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/meson.build
r4f6368c rd53a5ab0 52 52 'float/float2.c', 53 53 'vfs/vfs1.c', 54 'ipc/readwrite.c', 54 55 'ipc/sharein.c', 55 56 'ipc/starve.c', -
uspace/app/tester/tester.c
r4f6368c rd53a5ab0 68 68 #include "float/float2.def" 69 69 #include "vfs/vfs1.def" 70 #include "ipc/readwrite.def" 70 71 #include "ipc/sharein.def" 71 72 #include "ipc/starve.def" -
uspace/app/tester/tester.h
r4f6368c rd53a5ab0 99 99 extern const char *test_vfs1(void); 100 100 extern const char *test_ping_pong(void); 101 extern const char *test_readwrite(void); 101 102 extern const char *test_sharein(void); 102 103 extern const char *test_starve_ipc(void); -
uspace/lib/ipctest/include/ipc/ipc_test.h
r4f6368c rd53a5ab0 43 43 IPC_TEST_GET_RW_AREA_SIZE, 44 44 IPC_TEST_SHARE_IN_RO, 45 IPC_TEST_SHARE_IN_RW 45 IPC_TEST_SHARE_IN_RW, 46 IPC_TEST_SET_RW_BUF_SIZE, 47 IPC_TEST_READ, 48 IPC_TEST_WRITE 46 49 } ipc_test_request_t; 47 50 -
uspace/lib/ipctest/include/ipc_test.h
r4f6368c rd53a5ab0 50 50 extern errno_t ipc_test_share_in_ro(ipc_test_t *, size_t, const void **); 51 51 extern errno_t ipc_test_share_in_rw(ipc_test_t *, size_t, void **); 52 extern errno_t ipc_test_set_rw_buf_size(ipc_test_t *, size_t); 53 extern errno_t ipc_test_read(ipc_test_t *, void *, size_t); 54 extern errno_t ipc_test_write(ipc_test_t *, const void *, size_t); 52 55 53 56 #endif -
uspace/lib/ipctest/src/ipc_test.c
r4f6368c rd53a5ab0 1 1 /* 2 * Copyright (c) 20 18Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 221 221 } 222 222 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 */ 229 errno_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 */ 251 errno_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 */ 280 errno_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 223 302 /** @} 224 303 */ -
uspace/srv/test/ipc-test/main.c
r4f6368c rd53a5ab0 48 48 #include <mem.h> 49 49 #include <stdio.h> 50 #include <stdlib.h> 50 51 #include <task.h> 51 52 … … 53 54 54 55 static service_id_t svc_id; 56 57 enum { 58 max_rw_buf_size = 16384, 59 }; 55 60 56 61 /** Object in read-only memory area that will be shared. … … 67 72 */ 68 73 static char rw_data[] = "Hello, world!"; 74 75 /** Buffer for reading/writing via read/write messages. 76 * 77 * It is allocated / size is set by IPC_TEST_SET_RW_BUF_SIZE 78 */ 79 static void *rw_buf; 80 /** Read/write buffer size */ 81 size_t rw_buf_size; 69 82 70 83 static void ipc_test_get_ro_area_size_srv(ipc_call_t *icall) … … 182 195 } 183 196 197 static void ipc_test_set_rw_buf_size_srv(ipc_call_t *icall) 198 { 199 size_t size; 200 void *nbuf; 201 202 log_msg(LOG_DEFAULT, LVL_DEBUG, "ipc_test_set_rw_buf_size_srv"); 203 204 size = ipc_get_arg1(icall); 205 206 if (size == 0) { 207 async_answer_0(icall, ERANGE); 208 log_msg(LOG_DEFAULT, LVL_ERROR, 209 "Requested read/write buffer size is zero."); 210 return; 211 } 212 213 if (size > max_rw_buf_size) { 214 async_answer_0(icall, ERANGE); 215 log_msg(LOG_DEFAULT, LVL_ERROR, "Requested read/write buffer " 216 "size > %u", max_rw_buf_size); 217 return; 218 } 219 220 nbuf = realloc(rw_buf, size); 221 if (nbuf == NULL) { 222 async_answer_0(icall, ENOMEM); 223 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory."); 224 return; 225 } 226 227 rw_buf = nbuf; 228 rw_buf_size = size; 229 async_answer_0(icall, EOK); 230 } 231 232 static void ipc_test_read_srv(ipc_call_t *icall) 233 { 234 ipc_call_t call; 235 errno_t rc; 236 size_t size; 237 238 log_msg(LOG_DEFAULT, LVL_DEBUG, "ipc_test_read_srv"); 239 240 if (!async_data_read_receive(&call, &size)) { 241 async_answer_0(icall, EREFUSED); 242 log_msg(LOG_DEFAULT, LVL_ERROR, "data_read_receive failed"); 243 return; 244 } 245 246 if (size > rw_buf_size) { 247 async_answer_0(&call, EINVAL); 248 async_answer_0(icall, EINVAL); 249 log_msg(LOG_DEFAULT, LVL_ERROR, "Invalid read size."); 250 return; 251 } 252 253 rc = async_data_read_finalize(&call, rw_buf, size); 254 if (rc != EOK) { 255 log_msg(LOG_DEFAULT, LVL_ERROR, 256 "data_read_finalize failed"); 257 async_answer_0(icall, EINVAL); 258 return; 259 } 260 261 async_answer_0(icall, EOK); 262 } 263 264 static void ipc_test_write_srv(ipc_call_t *icall) 265 { 266 ipc_call_t call; 267 errno_t rc; 268 size_t size; 269 270 log_msg(LOG_DEFAULT, LVL_DEBUG, "ipc_test_write_srv"); 271 272 if (!async_data_write_receive(&call, &size)) { 273 async_answer_0(icall, EREFUSED); 274 log_msg(LOG_DEFAULT, LVL_ERROR, "data_write_receive failed"); 275 return; 276 } 277 278 if (size > rw_buf_size) { 279 async_answer_0(&call, EINVAL); 280 async_answer_0(icall, EINVAL); 281 log_msg(LOG_DEFAULT, LVL_ERROR, "Invalid write size."); 282 return; 283 } 284 285 rc = async_data_write_finalize(&call, rw_buf, size); 286 if (rc != EOK) { 287 log_msg(LOG_DEFAULT, LVL_ERROR, 288 "data_write_finalize failed"); 289 async_answer_0(icall, EINVAL); 290 return; 291 } 292 293 async_answer_0(icall, EOK); 294 } 295 184 296 static void ipc_test_connection(ipc_call_t *icall, void *arg) 185 297 { … … 211 323 case IPC_TEST_SHARE_IN_RW: 212 324 ipc_test_share_in_rw_srv(&call); 325 break; 326 case IPC_TEST_SET_RW_BUF_SIZE: 327 ipc_test_set_rw_buf_size_srv(&call); 328 break; 329 case IPC_TEST_READ: 330 ipc_test_read_srv(&call); 331 break; 332 case IPC_TEST_WRITE: 333 ipc_test_write_srv(&call); 213 334 break; 214 335 default:
Note:
See TracChangeset
for help on using the changeset viewer.