Test driver for failure cases of fsetxattr and fgetxattr. */
| 293 | |
| 294 | /* Test driver for failure cases of fsetxattr and fgetxattr. */ |
| 295 | static int test_failure_fxattr(void) |
| 296 | { |
| 297 | struct io_uring ring; |
| 298 | char value[XATTR_SIZE]; |
| 299 | |
| 300 | /* Init io-uring queue. */ |
| 301 | int ret = io_uring_queue_init(QUEUE_DEPTH, &ring, 0); |
| 302 | if (ret) { |
| 303 | fprintf(stderr, "child: ring setup failed: %d\n", ret); |
| 304 | return -1; |
| 305 | } |
| 306 | |
| 307 | /* Create the test file. */ |
| 308 | int fd = open(FILENAME, O_CREAT | O_RDWR, 0644); |
| 309 | if (fd < 0) { |
| 310 | fprintf(stderr, "Error: cannot open file: ret=%d\n", fd); |
| 311 | return -1; |
| 312 | } |
| 313 | |
| 314 | /* Test writing attributes. */ |
| 315 | if (io_uring_fsetxattr(&ring, -1, KEY1, VALUE1, strlen(VALUE1), 0) >= 0) |
| 316 | return 1; |
| 317 | if (io_uring_fsetxattr(&ring, fd, NULL, VALUE1, strlen(VALUE1), 0) >= 0) |
| 318 | return 1; |
| 319 | if (io_uring_fsetxattr(&ring, fd, KEY1, NULL, strlen(VALUE1), 0) >= 0) |
| 320 | return 1; |
| 321 | if (io_uring_fsetxattr(&ring, fd, KEY1, VALUE1, 0, 0) != 0) |
| 322 | return 1; |
| 323 | if (io_uring_fsetxattr(&ring, fd, KEY1, VALUE1, -1, 0) >= 0) |
| 324 | return 1; |
| 325 | |
| 326 | /* Test reading attributes. */ |
| 327 | if (io_uring_fgetxattr(&ring, -1, KEY1, value, XATTR_SIZE) >= 0) |
| 328 | return 1; |
| 329 | if (io_uring_fgetxattr(&ring, fd, NULL, value, XATTR_SIZE) >= 0) |
| 330 | return 1; |
| 331 | if (io_uring_fgetxattr(&ring, fd, KEY1, value, 0) != 0) |
| 332 | return 1; |
| 333 | |
| 334 | /* Cleanup. */ |
| 335 | close(fd); |
| 336 | unlink(FILENAME); |
| 337 | io_uring_queue_exit(&ring); |
| 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | |
| 342 | /* Test driver for failure cases for setxattr and getxattr. */ |
no test coverage detected