tty-write-dpoll.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "../config-host.h"
  2. /* SPDX-License-Identifier: MIT */
  3. /*
  4. * Test double poll tty write. A test case for the regression fixed by:
  5. *
  6. * commit 6e295a664efd083ac9a5c1a8130c45be1db0cde7
  7. * Author: Jens Axboe <axboe@kernel.dk>
  8. * Date: Tue Mar 22 13:11:28 2022 -0600
  9. *
  10. * io_uring: fix assuming triggered poll waitqueue is the single poll
  11. *
  12. */
  13. #include <errno.h>
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include <unistd.h>
  17. #include <fcntl.h>
  18. #include "liburing.h"
  19. #include "helpers.h"
  20. #define SQES 128
  21. #define BUFSIZE 512
  22. int main(int argc, char *argv[])
  23. {
  24. static char buf[BUFSIZE];
  25. struct iovec vecs[SQES];
  26. struct io_uring ring;
  27. int ret, i, fd;
  28. if (argc > 1)
  29. return 0;
  30. fd = open("/dev/ttyS0", O_RDWR | O_NONBLOCK);
  31. if (fd < 0)
  32. return 0;
  33. ret = t_create_ring(SQES, &ring, 0);
  34. if (ret == T_SETUP_SKIP)
  35. return 0;
  36. else if (ret < 0)
  37. return 1;
  38. for (i = 0; i < SQES; i++) {
  39. struct io_uring_sqe *sqe;
  40. sqe = io_uring_get_sqe(&ring);
  41. vecs[i].iov_base = buf;
  42. vecs[i].iov_len = sizeof(buf);
  43. io_uring_prep_writev(sqe, fd, &vecs[i], 1, 0);
  44. }
  45. ret = io_uring_submit(&ring);
  46. if (ret != SQES) {
  47. fprintf(stderr, "submit: %d\n", ret);
  48. return 1;
  49. }
  50. return 0;
  51. }