Changes in uspace/lib/system/test/system.c [f35749e:a72f3b8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/system/test/system.c
rf35749e ra72f3b8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 46 46 void test_system_conn(ipc_call_t *, void *); 47 47 48 static errno_t test_poweroff(void *); 49 static errno_t test_restart(void *); 48 static errno_t test_shutdown(void *); 50 49 51 50 static void test_sys_shutdown_complete(void *); … … 53 52 54 53 static system_ops_t test_system_srv_ops = { 55 .poweroff = test_poweroff, 56 .restart = test_restart 54 .shutdown = test_shutdown 57 55 }; 58 56 … … 68 66 errno_t rc; 69 67 70 bool poweroff_called; 71 bool restart_called; 68 bool shutdown_called; 72 69 bool shutdown_complete_called; 73 70 bool shutdown_failed_called; … … 106 103 } 107 104 108 /** system_ poweroff() with server returning error response works */109 PCUT_TEST( poweroff_failure)105 /** system_shutdown() with server returning error response works */ 106 PCUT_TEST(shutdown_failure) 110 107 { 111 108 errno_t rc; … … 129 126 130 127 resp.rc = ENOMEM; 131 resp. poweroff_called = false;132 133 rc = system_ poweroff(system);134 PCUT_ASSERT_TRUE(resp. poweroff_called);128 resp.shutdown_called = false; 129 130 rc = system_shutdown(system); 131 PCUT_ASSERT_TRUE(resp.shutdown_called); 135 132 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 136 133 … … 141 138 } 142 139 143 /** system_ poweroff() with server returning success response works */144 PCUT_TEST( poweroff_success)140 /** system_shutdown() with server returning success response works */ 141 PCUT_TEST(shutdown_success) 145 142 { 146 143 errno_t rc; … … 164 161 165 162 resp.rc = EOK; 166 resp.poweroff_called = false; 167 168 rc = system_poweroff(system); 169 PCUT_ASSERT_TRUE(resp.poweroff_called); 170 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 171 172 system_close(system); 173 rc = loc_service_unregister(srv, sid); 174 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 175 loc_server_unregister(srv); 176 } 177 178 /** system_restart() with server returning error response works */ 179 PCUT_TEST(restart_failure) 180 { 181 errno_t rc; 182 service_id_t sid; 183 system_t *system = NULL; 184 test_response_t resp; 185 loc_srv_t *srv; 186 187 async_set_fallback_port_handler(test_system_conn, &resp); 188 189 // FIXME This causes this test to be non-reentrant! 190 rc = loc_server_register(test_system_server, &srv); 191 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 192 193 rc = loc_service_register(srv, test_system_svc, &sid); 194 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 195 196 rc = system_open(test_system_svc, NULL, NULL, &system); 197 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 198 PCUT_ASSERT_NOT_NULL(system); 199 200 resp.rc = ENOMEM; 201 resp.restart_called = false; 202 203 rc = system_restart(system); 204 PCUT_ASSERT_TRUE(resp.restart_called); 205 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 206 207 system_close(system); 208 rc = loc_service_unregister(srv, sid); 209 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 210 loc_server_unregister(srv); 211 } 212 213 /** system_restart() with server returning success response works */ 214 PCUT_TEST(restart_success) 215 { 216 errno_t rc; 217 service_id_t sid; 218 system_t *system = NULL; 219 test_response_t resp; 220 loc_srv_t *srv; 221 222 async_set_fallback_port_handler(test_system_conn, &resp); 223 224 // FIXME This causes this test to be non-reentrant! 225 rc = loc_server_register(test_system_server, &srv); 226 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 227 228 rc = loc_service_register(srv, test_system_svc, &sid); 229 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 230 231 rc = system_open(test_system_svc, NULL, NULL, &system); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 PCUT_ASSERT_NOT_NULL(system); 234 235 resp.rc = EOK; 236 resp.restart_called = false; 237 238 rc = system_restart(system); 239 PCUT_ASSERT_TRUE(resp.restart_called); 163 resp.shutdown_called = false; 164 165 rc = system_shutdown(system); 166 PCUT_ASSERT_TRUE(resp.shutdown_called); 240 167 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 241 168 … … 352 279 } 353 280 354 /** Test system poweroff.281 /** Test system shutdown. 355 282 * 356 283 * @param arg Argument (test_response_t *) 357 284 */ 358 static errno_t test_ poweroff(void *arg)285 static errno_t test_shutdown(void *arg) 359 286 { 360 287 test_response_t *resp = (test_response_t *)arg; 361 288 362 resp->poweroff_called = true; 363 return resp->rc; 364 } 365 366 /** Test system restart. 367 * 368 * @param arg Argument (test_response_t *) 369 */ 370 static errno_t test_restart(void *arg) 371 { 372 test_response_t *resp = (test_response_t *)arg; 373 374 resp->restart_called = true; 289 resp->shutdown_called = true; 375 290 return resp->rc; 376 291 }
Note:
See TracChangeset
for help on using the changeset viewer.