Test for invalid SQE, this will cause a segmentation fault if enabled. */
| 387 | |
| 388 | /* Test for invalid SQE, this will cause a segmentation fault if enabled. */ |
| 389 | static int test_invalid_sqe(void) |
| 390 | { |
| 391 | #ifdef DESTRUCTIVE_TEST |
| 392 | struct io_uring_sqe *sqe = NULL; |
| 393 | struct io_uring_cqe *cqe = NULL; |
| 394 | struct io_uring ring; |
| 395 | |
| 396 | /* Init io-uring queue. */ |
| 397 | int ret = io_uring_queue_init(QUEUE_DEPTH, &ring, 0); |
| 398 | if (ret) { |
| 399 | fprintf(stderr, "child: ring setup failed: %d\n", ret); |
| 400 | return -1; |
| 401 | } |
| 402 | |
| 403 | /* Pass invalid SQE. */ |
| 404 | io_uring_prep_setxattr(sqe, FILENAME, KEY1, VALUE1, strlen(VALUE1), 0); |
| 405 | |
| 406 | ret = io_uring_submit(&ring); |
| 407 | if (ret != 1) { |
| 408 | fprintf(stderr, "Error io_uring_submit_and_wait: ret=%d\n", ret); |
| 409 | return -1; |
| 410 | } |
| 411 | |
| 412 | ret = io_uring_wait_cqe(&ring, &cqe); |
| 413 | if (ret) { |
| 414 | fprintf(stderr, "Error io_uring_wait_cqe: ret=%d\n", ret); |
| 415 | return -1; |
| 416 | } |
| 417 | |
| 418 | ret = cqe->res; |
| 419 | io_uring_cqe_seen(&ring, cqe); |
| 420 | |
| 421 | return ret; |
| 422 | #else |
| 423 | return 0; |
| 424 | #endif |
| 425 | } |
| 426 | |
| 427 | /* Test driver. */ |
| 428 | int main(int argc, char *argv[]) |
no test coverage detected