1 /*- 2 * Copyright (c) 2004 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 /* 30 * Regression test to do some very basic AIO exercising on several types of 31 * file descriptors. Currently, the tests consist of initializing a fixed 32 * size buffer with pseudo-random data, writing it to one fd using AIO, then 33 * reading it from a second descriptor using AIO. For some targets, the same 34 * fd is used for write and read (i.e., file, md device), but for others the 35 * operation is performed on a peer (pty, socket, fifo, etc). For each file 36 * descriptor type, several completion methods are tested. This test program 37 * does not attempt to exercise error cases or more subtle asynchronous 38 * behavior, just make sure that the basic operations work on some basic object 39 * types. 40 */ 41 42 #include <sys/param.h> 43 #include <sys/mdioctl.h> 44 #include <sys/module.h> 45 #include <sys/resource.h> 46 #include <sys/socket.h> 47 #include <sys/stat.h> 48 #include <sys/un.h> 49 50 #include <aio.h> 51 #include <err.h> 52 #include <errno.h> 53 #include <fcntl.h> 54 #include <libutil.h> 55 #include <limits.h> 56 #include <semaphore.h> 57 #include <stdint.h> 58 #include <stdio.h> 59 #include <stdlib.h> 60 #include <string.h> 61 #include <termios.h> 62 #include <unistd.h> 63 64 #include <atf-c.h> 65 66 #include "freebsd_test_suite/macros.h" 67 #include "local.h" 68 69 /* 70 * GLOBAL_MAX sets the largest usable buffer size to be read and written, as 71 * it sizes ac_buffer in the aio_context structure. It is also the default 72 * size for file I/O. For other types, we use smaller blocks or we risk 73 * blocking (and we run in a single process/thread so that would be bad). 74 */ 75 #define GLOBAL_MAX 16384 76 77 #define BUFFER_MAX GLOBAL_MAX 78 79 /* 80 * A completion function will block until the aio has completed, then return 81 * the result of the aio. errno will be set appropriately. 82 */ 83 typedef ssize_t (*completion)(struct aiocb*); 84 85 struct aio_context { 86 int ac_read_fd, ac_write_fd; 87 long ac_seed; 88 char ac_buffer[GLOBAL_MAX]; 89 int ac_buflen; 90 int ac_seconds; 91 }; 92 93 static sem_t completions; 94 95 96 /* 97 * Fill a buffer given a seed that can be fed into srandom() to initialize 98 * the PRNG in a repeatable manner. 99 */ 100 static void 101 aio_fill_buffer(char *buffer, int len, long seed) 102 { 103 char ch; 104 int i; 105 106 srandom(seed); 107 for (i = 0; i < len; i++) { 108 ch = random() & 0xff; 109 buffer[i] = ch; 110 } 111 } 112 113 /* 114 * Test that a buffer matches a given seed. See aio_fill_buffer(). Return 115 * (1) on a match, (0) on a mismatch. 116 */ 117 static int 118 aio_test_buffer(char *buffer, int len, long seed) 119 { 120 char ch; 121 int i; 122 123 srandom(seed); 124 for (i = 0; i < len; i++) { 125 ch = random() & 0xff; 126 if (buffer[i] != ch) 127 return (0); 128 } 129 return (1); 130 } 131 132 /* 133 * Initialize a testing context given the file descriptors provided by the 134 * test setup. 135 */ 136 static void 137 aio_context_init(struct aio_context *ac, int read_fd, 138 int write_fd, int buflen) 139 { 140 141 ATF_REQUIRE_MSG(buflen <= BUFFER_MAX, 142 "aio_context_init: buffer too large (%d > %d)", 143 buflen, BUFFER_MAX); 144 bzero(ac, sizeof(*ac)); 145 ac->ac_read_fd = read_fd; 146 ac->ac_write_fd = write_fd; 147 ac->ac_buflen = buflen; 148 srandomdev(); 149 ac->ac_seed = random(); 150 aio_fill_buffer(ac->ac_buffer, buflen, ac->ac_seed); 151 ATF_REQUIRE_MSG(aio_test_buffer(ac->ac_buffer, buflen, 152 ac->ac_seed) != 0, "aio_test_buffer: internal error"); 153 } 154 155 static ssize_t 156 poll(struct aiocb *aio) 157 { 158 int error; 159 160 while ((error = aio_error(aio)) == EINPROGRESS) 161 usleep(25000); 162 if (error) 163 return (error); 164 else 165 return (aio_return(aio)); 166 } 167 168 static void 169 sigusr1_handler(int sig __unused) 170 { 171 ATF_REQUIRE_EQ(0, sem_post(&completions)); 172 } 173 174 static void 175 thr_handler(union sigval sv __unused) 176 { 177 ATF_REQUIRE_EQ(0, sem_post(&completions)); 178 } 179 180 static ssize_t 181 poll_signaled(struct aiocb *aio) 182 { 183 int error; 184 185 ATF_REQUIRE_EQ(0, sem_wait(&completions)); 186 error = aio_error(aio); 187 switch (error) { 188 case EINPROGRESS: 189 errno = EINTR; 190 return (-1); 191 case 0: 192 return (aio_return(aio)); 193 default: 194 return (error); 195 } 196 } 197 198 /* 199 * Setup a signal handler for signal delivery tests 200 * This isn't thread safe, but it's ok since ATF runs each testcase in a 201 * separate process 202 */ 203 static struct sigevent* 204 setup_signal(void) 205 { 206 static struct sigevent sev; 207 208 ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); 209 sev.sigev_notify = SIGEV_SIGNAL; 210 sev.sigev_signo = SIGUSR1; 211 ATF_REQUIRE(SIG_ERR != signal(SIGUSR1, sigusr1_handler)); 212 return (&sev); 213 } 214 215 /* 216 * Setup a thread for thread delivery tests 217 * This isn't thread safe, but it's ok since ATF runs each testcase in a 218 * separate process 219 */ 220 static struct sigevent* 221 setup_thread(void) 222 { 223 static struct sigevent sev; 224 225 ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); 226 sev.sigev_notify = SIGEV_THREAD; 227 sev.sigev_notify_function = thr_handler; 228 sev.sigev_notify_attributes = NULL; 229 return (&sev); 230 } 231 232 static ssize_t 233 suspend(struct aiocb *aio) 234 { 235 const struct aiocb *const iocbs[] = {aio}; 236 int error; 237 238 error = aio_suspend(iocbs, 1, NULL); 239 if (error == 0) 240 return (aio_return(aio)); 241 else 242 return (error); 243 } 244 245 static ssize_t 246 waitcomplete(struct aiocb *aio) 247 { 248 struct aiocb *aiop; 249 ssize_t ret; 250 251 ret = aio_waitcomplete(&aiop, NULL); 252 ATF_REQUIRE_EQ(aio, aiop); 253 return (ret); 254 } 255 256 /* 257 * Perform a simple write test of our initialized data buffer to the provided 258 * file descriptor. 259 */ 260 static void 261 aio_write_test(struct aio_context *ac, completion comp, struct sigevent *sev) 262 { 263 struct aiocb aio; 264 ssize_t len; 265 266 bzero(&aio, sizeof(aio)); 267 aio.aio_buf = ac->ac_buffer; 268 aio.aio_nbytes = ac->ac_buflen; 269 aio.aio_fildes = ac->ac_write_fd; 270 aio.aio_offset = 0; 271 if (sev) 272 aio.aio_sigevent = *sev; 273 274 if (aio_write(&aio) < 0) 275 atf_tc_fail("aio_write failed: %s", strerror(errno)); 276 277 len = comp(&aio); 278 if (len < 0) 279 atf_tc_fail("aio failed: %s", strerror(errno)); 280 281 if (len != ac->ac_buflen) 282 atf_tc_fail("aio short write (%jd)", (intmax_t)len); 283 } 284 285 /* 286 * Perform a vectored I/O test of our initialized data buffer to the provided 287 * file descriptor. 288 * 289 * To vectorize the linear buffer, chop it up into two pieces of dissimilar 290 * size, and swap their offsets. 291 */ 292 static void 293 aio_writev_test(struct aio_context *ac, completion comp, struct sigevent *sev) 294 { 295 struct aiocb aio; 296 struct iovec iov[2]; 297 size_t len0, len1; 298 ssize_t len; 299 300 bzero(&aio, sizeof(aio)); 301 302 aio.aio_fildes = ac->ac_write_fd; 303 aio.aio_offset = 0; 304 len0 = ac->ac_buflen * 3 / 4; 305 len1 = ac->ac_buflen / 4; 306 iov[0].iov_base = ac->ac_buffer + len1; 307 iov[0].iov_len = len0; 308 iov[1].iov_base = ac->ac_buffer; 309 iov[1].iov_len = len1; 310 aio.aio_iov = iov; 311 aio.aio_iovcnt = 2; 312 if (sev) 313 aio.aio_sigevent = *sev; 314 315 if (aio_writev(&aio) < 0) 316 atf_tc_fail("aio_writev failed: %s", strerror(errno)); 317 318 len = comp(&aio); 319 if (len < 0) 320 atf_tc_fail("aio failed: %s", strerror(errno)); 321 322 if (len != ac->ac_buflen) 323 atf_tc_fail("aio short write (%jd)", (intmax_t)len); 324 } 325 326 /* 327 * Perform a simple read test of our initialized data buffer from the 328 * provided file descriptor. 329 */ 330 static void 331 aio_read_test(struct aio_context *ac, completion comp, struct sigevent *sev) 332 { 333 struct aiocb aio; 334 ssize_t len; 335 336 bzero(ac->ac_buffer, ac->ac_buflen); 337 bzero(&aio, sizeof(aio)); 338 aio.aio_buf = ac->ac_buffer; 339 aio.aio_nbytes = ac->ac_buflen; 340 aio.aio_fildes = ac->ac_read_fd; 341 aio.aio_offset = 0; 342 if (sev) 343 aio.aio_sigevent = *sev; 344 345 if (aio_read(&aio) < 0) 346 atf_tc_fail("aio_read failed: %s", strerror(errno)); 347 348 len = comp(&aio); 349 if (len < 0) 350 atf_tc_fail("aio failed: %s", strerror(errno)); 351 352 ATF_REQUIRE_EQ_MSG(len, ac->ac_buflen, 353 "aio short read (%jd)", (intmax_t)len); 354 355 if (aio_test_buffer(ac->ac_buffer, ac->ac_buflen, ac->ac_seed) == 0) 356 atf_tc_fail("buffer mismatched"); 357 } 358 359 static void 360 aio_readv_test(struct aio_context *ac, completion comp, struct sigevent *sev) 361 { 362 struct aiocb aio; 363 struct iovec iov[2]; 364 size_t len0, len1; 365 ssize_t len; 366 367 bzero(ac->ac_buffer, ac->ac_buflen); 368 bzero(&aio, sizeof(aio)); 369 aio.aio_fildes = ac->ac_read_fd; 370 aio.aio_offset = 0; 371 len0 = ac->ac_buflen * 3 / 4; 372 len1 = ac->ac_buflen / 4; 373 iov[0].iov_base = ac->ac_buffer + len1; 374 iov[0].iov_len = len0; 375 iov[1].iov_base = ac->ac_buffer; 376 iov[1].iov_len = len1; 377 aio.aio_iov = iov; 378 aio.aio_iovcnt = 2; 379 if (sev) 380 aio.aio_sigevent = *sev; 381 382 if (aio_readv(&aio) < 0) 383 atf_tc_fail("aio_read failed: %s", strerror(errno)); 384 385 len = comp(&aio); 386 if (len < 0) 387 atf_tc_fail("aio failed: %s", strerror(errno)); 388 389 ATF_REQUIRE_EQ_MSG(len, ac->ac_buflen, 390 "aio short read (%jd)", (intmax_t)len); 391 392 if (aio_test_buffer(ac->ac_buffer, ac->ac_buflen, ac->ac_seed) == 0) 393 atf_tc_fail("buffer mismatched"); 394 } 395 396 /* 397 * Series of type-specific tests for AIO. For now, we just make sure we can 398 * issue a write and then a read to each type. We assume that once a write 399 * is issued, a read can follow. 400 */ 401 402 /* 403 * Test with a classic file. Assumes we can create a moderate size temporary 404 * file. 405 */ 406 #define FILE_LEN GLOBAL_MAX 407 #define FILE_PATHNAME "testfile" 408 409 static void 410 aio_file_test(completion comp, struct sigevent *sev, bool vectored) 411 { 412 struct aio_context ac; 413 int fd; 414 415 ATF_REQUIRE_KERNEL_MODULE("aio"); 416 ATF_REQUIRE_UNSAFE_AIO(); 417 418 fd = open(FILE_PATHNAME, O_RDWR | O_CREAT, 0600); 419 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 420 421 aio_context_init(&ac, fd, fd, FILE_LEN); 422 if (vectored) { 423 aio_writev_test(&ac, comp, sev); 424 aio_readv_test(&ac, comp, sev); 425 } else { 426 aio_write_test(&ac, comp, sev); 427 aio_read_test(&ac, comp, sev); 428 } 429 close(fd); 430 } 431 432 ATF_TC_WITHOUT_HEAD(file_poll); 433 ATF_TC_BODY(file_poll, tc) 434 { 435 aio_file_test(poll, NULL, false); 436 } 437 438 ATF_TC_WITHOUT_HEAD(file_signal); 439 ATF_TC_BODY(file_signal, tc) 440 { 441 aio_file_test(poll_signaled, setup_signal(), false); 442 } 443 444 ATF_TC_WITHOUT_HEAD(file_suspend); 445 ATF_TC_BODY(file_suspend, tc) 446 { 447 aio_file_test(suspend, NULL, false); 448 } 449 450 ATF_TC_WITHOUT_HEAD(file_thread); 451 ATF_TC_BODY(file_thread, tc) 452 { 453 aio_file_test(poll_signaled, setup_thread(), false); 454 } 455 456 ATF_TC_WITHOUT_HEAD(file_waitcomplete); 457 ATF_TC_BODY(file_waitcomplete, tc) 458 { 459 aio_file_test(waitcomplete, NULL, false); 460 } 461 462 #define FIFO_LEN 256 463 #define FIFO_PATHNAME "testfifo" 464 465 static void 466 aio_fifo_test(completion comp, struct sigevent *sev) 467 { 468 int error, read_fd = -1, write_fd = -1; 469 struct aio_context ac; 470 471 ATF_REQUIRE_KERNEL_MODULE("aio"); 472 ATF_REQUIRE_UNSAFE_AIO(); 473 474 ATF_REQUIRE_MSG(mkfifo(FIFO_PATHNAME, 0600) != -1, 475 "mkfifo failed: %s", strerror(errno)); 476 477 read_fd = open(FIFO_PATHNAME, O_RDONLY | O_NONBLOCK); 478 if (read_fd == -1) { 479 error = errno; 480 errno = error; 481 atf_tc_fail("read_fd open failed: %s", 482 strerror(errno)); 483 } 484 485 write_fd = open(FIFO_PATHNAME, O_WRONLY); 486 if (write_fd == -1) { 487 error = errno; 488 errno = error; 489 atf_tc_fail("write_fd open failed: %s", 490 strerror(errno)); 491 } 492 493 aio_context_init(&ac, read_fd, write_fd, FIFO_LEN); 494 aio_write_test(&ac, comp, sev); 495 aio_read_test(&ac, comp, sev); 496 497 close(read_fd); 498 close(write_fd); 499 } 500 501 ATF_TC_WITHOUT_HEAD(fifo_poll); 502 ATF_TC_BODY(fifo_poll, tc) 503 { 504 aio_fifo_test(poll, NULL); 505 } 506 507 ATF_TC_WITHOUT_HEAD(fifo_signal); 508 ATF_TC_BODY(fifo_signal, tc) 509 { 510 aio_fifo_test(poll_signaled, setup_signal()); 511 } 512 513 ATF_TC_WITHOUT_HEAD(fifo_suspend); 514 ATF_TC_BODY(fifo_suspend, tc) 515 { 516 aio_fifo_test(suspend, NULL); 517 } 518 519 ATF_TC_WITHOUT_HEAD(fifo_thread); 520 ATF_TC_BODY(fifo_thread, tc) 521 { 522 aio_fifo_test(poll_signaled, setup_thread()); 523 } 524 525 ATF_TC_WITHOUT_HEAD(fifo_waitcomplete); 526 ATF_TC_BODY(fifo_waitcomplete, tc) 527 { 528 aio_fifo_test(waitcomplete, NULL); 529 } 530 531 #define UNIX_SOCKETPAIR_LEN 256 532 static void 533 aio_unix_socketpair_test(completion comp, struct sigevent *sev, bool vectored) 534 { 535 struct aio_context ac; 536 struct rusage ru_before, ru_after; 537 int sockets[2]; 538 539 ATF_REQUIRE_KERNEL_MODULE("aio"); 540 541 ATF_REQUIRE_MSG(socketpair(PF_UNIX, SOCK_STREAM, 0, sockets) != -1, 542 "socketpair failed: %s", strerror(errno)); 543 544 aio_context_init(&ac, sockets[0], sockets[1], UNIX_SOCKETPAIR_LEN); 545 ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_before) != -1, 546 "getrusage failed: %s", strerror(errno)); 547 if (vectored) { 548 aio_writev_test(&ac, comp, sev); 549 aio_readv_test(&ac, comp, sev); 550 } else { 551 aio_write_test(&ac, comp, sev); 552 aio_read_test(&ac, comp, sev); 553 } 554 ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_after) != -1, 555 "getrusage failed: %s", strerror(errno)); 556 ATF_REQUIRE(ru_after.ru_msgsnd == ru_before.ru_msgsnd + 1); 557 ATF_REQUIRE(ru_after.ru_msgrcv == ru_before.ru_msgrcv + 1); 558 559 close(sockets[0]); 560 close(sockets[1]); 561 } 562 563 ATF_TC_WITHOUT_HEAD(socket_poll); 564 ATF_TC_BODY(socket_poll, tc) 565 { 566 aio_unix_socketpair_test(poll, NULL, false); 567 } 568 569 ATF_TC_WITHOUT_HEAD(socket_signal); 570 ATF_TC_BODY(socket_signal, tc) 571 { 572 aio_unix_socketpair_test(poll_signaled, setup_signal(), false); 573 } 574 575 ATF_TC_WITHOUT_HEAD(socket_suspend); 576 ATF_TC_BODY(socket_suspend, tc) 577 { 578 aio_unix_socketpair_test(suspend, NULL, false); 579 } 580 581 ATF_TC_WITHOUT_HEAD(socket_thread); 582 ATF_TC_BODY(socket_thread, tc) 583 { 584 aio_unix_socketpair_test(poll_signaled, setup_thread(), false); 585 } 586 587 ATF_TC_WITHOUT_HEAD(socket_waitcomplete); 588 ATF_TC_BODY(socket_waitcomplete, tc) 589 { 590 aio_unix_socketpair_test(waitcomplete, NULL, false); 591 } 592 593 struct aio_pty_arg { 594 int apa_read_fd; 595 int apa_write_fd; 596 }; 597 598 #define PTY_LEN 256 599 static void 600 aio_pty_test(completion comp, struct sigevent *sev) 601 { 602 struct aio_context ac; 603 int read_fd, write_fd; 604 struct termios ts; 605 int error; 606 607 ATF_REQUIRE_KERNEL_MODULE("aio"); 608 ATF_REQUIRE_UNSAFE_AIO(); 609 610 ATF_REQUIRE_MSG(openpty(&read_fd, &write_fd, NULL, NULL, NULL) == 0, 611 "openpty failed: %s", strerror(errno)); 612 613 614 if (tcgetattr(write_fd, &ts) < 0) { 615 error = errno; 616 errno = error; 617 atf_tc_fail("tcgetattr failed: %s", strerror(errno)); 618 } 619 cfmakeraw(&ts); 620 if (tcsetattr(write_fd, TCSANOW, &ts) < 0) { 621 error = errno; 622 errno = error; 623 atf_tc_fail("tcsetattr failed: %s", strerror(errno)); 624 } 625 aio_context_init(&ac, read_fd, write_fd, PTY_LEN); 626 627 aio_write_test(&ac, comp, sev); 628 aio_read_test(&ac, comp, sev); 629 630 close(read_fd); 631 close(write_fd); 632 } 633 634 ATF_TC_WITHOUT_HEAD(pty_poll); 635 ATF_TC_BODY(pty_poll, tc) 636 { 637 aio_pty_test(poll, NULL); 638 } 639 640 ATF_TC_WITHOUT_HEAD(pty_signal); 641 ATF_TC_BODY(pty_signal, tc) 642 { 643 aio_pty_test(poll_signaled, setup_signal()); 644 } 645 646 ATF_TC_WITHOUT_HEAD(pty_suspend); 647 ATF_TC_BODY(pty_suspend, tc) 648 { 649 aio_pty_test(suspend, NULL); 650 } 651 652 ATF_TC_WITHOUT_HEAD(pty_thread); 653 ATF_TC_BODY(pty_thread, tc) 654 { 655 aio_pty_test(poll_signaled, setup_thread()); 656 } 657 658 ATF_TC_WITHOUT_HEAD(pty_waitcomplete); 659 ATF_TC_BODY(pty_waitcomplete, tc) 660 { 661 aio_pty_test(waitcomplete, NULL); 662 } 663 664 #define PIPE_LEN 256 665 static void 666 aio_pipe_test(completion comp, struct sigevent *sev) 667 { 668 struct aio_context ac; 669 int pipes[2]; 670 671 ATF_REQUIRE_KERNEL_MODULE("aio"); 672 ATF_REQUIRE_UNSAFE_AIO(); 673 674 ATF_REQUIRE_MSG(pipe(pipes) != -1, 675 "pipe failed: %s", strerror(errno)); 676 677 aio_context_init(&ac, pipes[0], pipes[1], PIPE_LEN); 678 aio_write_test(&ac, comp, sev); 679 aio_read_test(&ac, comp, sev); 680 681 close(pipes[0]); 682 close(pipes[1]); 683 } 684 685 ATF_TC_WITHOUT_HEAD(pipe_poll); 686 ATF_TC_BODY(pipe_poll, tc) 687 { 688 aio_pipe_test(poll, NULL); 689 } 690 691 ATF_TC_WITHOUT_HEAD(pipe_signal); 692 ATF_TC_BODY(pipe_signal, tc) 693 { 694 aio_pipe_test(poll_signaled, setup_signal()); 695 } 696 697 ATF_TC_WITHOUT_HEAD(pipe_suspend); 698 ATF_TC_BODY(pipe_suspend, tc) 699 { 700 aio_pipe_test(suspend, NULL); 701 } 702 703 ATF_TC_WITHOUT_HEAD(pipe_thread); 704 ATF_TC_BODY(pipe_thread, tc) 705 { 706 aio_pipe_test(poll_signaled, setup_thread()); 707 } 708 709 ATF_TC_WITHOUT_HEAD(pipe_waitcomplete); 710 ATF_TC_BODY(pipe_waitcomplete, tc) 711 { 712 aio_pipe_test(waitcomplete, NULL); 713 } 714 715 #define MD_LEN GLOBAL_MAX 716 #define MDUNIT_LINK "mdunit_link" 717 718 static int 719 aio_md_setup(void) 720 { 721 int error, fd, mdctl_fd, unit; 722 char pathname[PATH_MAX]; 723 struct md_ioctl mdio; 724 char buf[80]; 725 726 ATF_REQUIRE_KERNEL_MODULE("aio"); 727 728 mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0); 729 ATF_REQUIRE_MSG(mdctl_fd != -1, 730 "opening /dev/%s failed: %s", MDCTL_NAME, strerror(errno)); 731 732 bzero(&mdio, sizeof(mdio)); 733 mdio.md_version = MDIOVERSION; 734 mdio.md_type = MD_MALLOC; 735 mdio.md_options = MD_AUTOUNIT | MD_COMPRESS; 736 mdio.md_mediasize = GLOBAL_MAX; 737 mdio.md_sectorsize = 512; 738 strlcpy(buf, __func__, sizeof(buf)); 739 mdio.md_label = buf; 740 741 if (ioctl(mdctl_fd, MDIOCATTACH, &mdio) < 0) { 742 error = errno; 743 errno = error; 744 atf_tc_fail("ioctl MDIOCATTACH failed: %s", strerror(errno)); 745 } 746 close(mdctl_fd); 747 748 /* Store the md unit number in a symlink for future cleanup */ 749 unit = mdio.md_unit; 750 snprintf(buf, sizeof(buf), "%d", unit); 751 ATF_REQUIRE_EQ(0, symlink(buf, MDUNIT_LINK)); 752 snprintf(pathname, PATH_MAX, "/dev/md%d", unit); 753 fd = open(pathname, O_RDWR); 754 ATF_REQUIRE_MSG(fd != -1, 755 "opening %s failed: %s", pathname, strerror(errno)); 756 757 return (fd); 758 } 759 760 static void 761 aio_md_cleanup(void) 762 { 763 struct md_ioctl mdio; 764 int mdctl_fd, n, unit; 765 char buf[80]; 766 767 mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0); 768 if (mdctl_fd < 0) { 769 fprintf(stderr, "opening /dev/%s failed: %s\n", MDCTL_NAME, 770 strerror(errno)); 771 return; 772 } 773 n = readlink(MDUNIT_LINK, buf, sizeof(buf) - 1); 774 if (n > 0) { 775 buf[n] = '\0'; 776 if (sscanf(buf, "%d", &unit) == 1 && unit >= 0) { 777 bzero(&mdio, sizeof(mdio)); 778 mdio.md_version = MDIOVERSION; 779 mdio.md_unit = unit; 780 if (ioctl(mdctl_fd, MDIOCDETACH, &mdio) == -1) { 781 fprintf(stderr, 782 "ioctl MDIOCDETACH unit %d failed: %s\n", 783 unit, strerror(errno)); 784 } 785 } 786 } 787 788 close(mdctl_fd); 789 } 790 791 static void 792 aio_md_test(completion comp, struct sigevent *sev, bool vectored) 793 { 794 struct aio_context ac; 795 int fd; 796 797 fd = aio_md_setup(); 798 aio_context_init(&ac, fd, fd, MD_LEN); 799 if (vectored) { 800 aio_writev_test(&ac, comp, sev); 801 aio_readv_test(&ac, comp, sev); 802 } else { 803 aio_write_test(&ac, comp, sev); 804 aio_read_test(&ac, comp, sev); 805 } 806 807 close(fd); 808 } 809 810 ATF_TC_WITH_CLEANUP(md_poll); 811 ATF_TC_HEAD(md_poll, tc) 812 { 813 814 atf_tc_set_md_var(tc, "require.user", "root"); 815 } 816 ATF_TC_BODY(md_poll, tc) 817 { 818 aio_md_test(poll, NULL, false); 819 } 820 ATF_TC_CLEANUP(md_poll, tc) 821 { 822 aio_md_cleanup(); 823 } 824 825 ATF_TC_WITH_CLEANUP(md_signal); 826 ATF_TC_HEAD(md_signal, tc) 827 { 828 829 atf_tc_set_md_var(tc, "require.user", "root"); 830 } 831 ATF_TC_BODY(md_signal, tc) 832 { 833 aio_md_test(poll_signaled, setup_signal(), false); 834 } 835 ATF_TC_CLEANUP(md_signal, tc) 836 { 837 aio_md_cleanup(); 838 } 839 840 ATF_TC_WITH_CLEANUP(md_suspend); 841 ATF_TC_HEAD(md_suspend, tc) 842 { 843 844 atf_tc_set_md_var(tc, "require.user", "root"); 845 } 846 ATF_TC_BODY(md_suspend, tc) 847 { 848 aio_md_test(suspend, NULL, false); 849 } 850 ATF_TC_CLEANUP(md_suspend, tc) 851 { 852 aio_md_cleanup(); 853 } 854 855 ATF_TC_WITH_CLEANUP(md_thread); 856 ATF_TC_HEAD(md_thread, tc) 857 { 858 859 atf_tc_set_md_var(tc, "require.user", "root"); 860 } 861 ATF_TC_BODY(md_thread, tc) 862 { 863 aio_md_test(poll_signaled, setup_thread(), false); 864 } 865 ATF_TC_CLEANUP(md_thread, tc) 866 { 867 aio_md_cleanup(); 868 } 869 870 ATF_TC_WITH_CLEANUP(md_waitcomplete); 871 ATF_TC_HEAD(md_waitcomplete, tc) 872 { 873 874 atf_tc_set_md_var(tc, "require.user", "root"); 875 } 876 ATF_TC_BODY(md_waitcomplete, tc) 877 { 878 aio_md_test(waitcomplete, NULL, false); 879 } 880 ATF_TC_CLEANUP(md_waitcomplete, tc) 881 { 882 aio_md_cleanup(); 883 } 884 885 #define ZVOL_VDEV_PATHNAME "test_vdev" 886 #define POOL_SIZE (1 << 28) /* 256 MB */ 887 #define ZVOL_SIZE "64m" 888 #define POOL_NAME "aio_testpool" 889 #define ZVOL_NAME "aio_testvol" 890 891 static int 892 aio_zvol_setup(void) 893 { 894 FILE *pidfile; 895 int fd; 896 pid_t pid; 897 char pool_name[80]; 898 char cmd[160]; 899 char zvol_name[160]; 900 char devname[160]; 901 902 ATF_REQUIRE_KERNEL_MODULE("aio"); 903 ATF_REQUIRE_KERNEL_MODULE("zfs"); 904 905 fd = open(ZVOL_VDEV_PATHNAME, O_RDWR | O_CREAT, 0600); 906 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 907 ATF_REQUIRE_EQ_MSG(0, 908 ftruncate(fd, POOL_SIZE), "ftruncate failed: %s", strerror(errno)); 909 close(fd); 910 911 pid = getpid(); 912 pidfile = fopen("pidfile", "w"); 913 ATF_REQUIRE_MSG(NULL != pidfile, "fopen: %s", strerror(errno)); 914 fprintf(pidfile, "%d", pid); 915 fclose(pidfile); 916 917 snprintf(pool_name, sizeof(pool_name), POOL_NAME ".%d", pid); 918 snprintf(zvol_name, sizeof(zvol_name), "%s/" ZVOL_NAME, pool_name); 919 snprintf(cmd, sizeof(cmd), "zpool create %s $PWD/" ZVOL_VDEV_PATHNAME, 920 pool_name); 921 ATF_REQUIRE_EQ_MSG(0, system(cmd), 922 "zpool create failed: %s", strerror(errno)); 923 snprintf(cmd, sizeof(cmd), 924 "zfs create -o volblocksize=8192 -o volmode=dev -V " 925 ZVOL_SIZE " %s", zvol_name); 926 ATF_REQUIRE_EQ_MSG(0, system(cmd), 927 "zfs create failed: %s", strerror(errno)); 928 929 snprintf(devname, sizeof(devname), "/dev/zvol/%s", zvol_name); 930 do { 931 fd = open(devname, O_RDWR); 932 } while (fd == -1 && errno == EINTR) ; 933 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 934 return (fd); 935 } 936 937 static void 938 aio_zvol_cleanup(void) 939 { 940 FILE *pidfile; 941 pid_t testpid; 942 char cmd[160]; 943 944 pidfile = fopen("pidfile", "r"); 945 if (pidfile == NULL && errno == ENOENT) { 946 /* Setup probably failed */ 947 return; 948 } 949 ATF_REQUIRE_MSG(NULL != pidfile, "fopen: %s", strerror(errno)); 950 ATF_REQUIRE_EQ(1, fscanf(pidfile, "%d", &testpid)); 951 fclose(pidfile); 952 953 snprintf(cmd, sizeof(cmd), "zpool destroy " POOL_NAME ".%d", testpid); 954 system(cmd); 955 } 956 957 958 ATF_TC_WITHOUT_HEAD(aio_large_read_test); 959 ATF_TC_BODY(aio_large_read_test, tc) 960 { 961 struct aiocb cb, *cbp; 962 ssize_t nread; 963 size_t len; 964 int fd; 965 #ifdef __LP64__ 966 int clamped; 967 #endif 968 969 ATF_REQUIRE_KERNEL_MODULE("aio"); 970 ATF_REQUIRE_UNSAFE_AIO(); 971 972 #ifdef __LP64__ 973 len = sizeof(clamped); 974 if (sysctlbyname("debug.iosize_max_clamp", &clamped, &len, NULL, 0) == 975 -1) 976 atf_libc_error(errno, "Failed to read debug.iosize_max_clamp"); 977 #endif 978 979 /* Determine the maximum supported read(2) size. */ 980 len = SSIZE_MAX; 981 #ifdef __LP64__ 982 if (clamped) 983 len = INT_MAX; 984 #endif 985 986 fd = open(FILE_PATHNAME, O_RDWR | O_CREAT, 0600); 987 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 988 989 unlink(FILE_PATHNAME); 990 991 memset(&cb, 0, sizeof(cb)); 992 cb.aio_nbytes = len; 993 cb.aio_fildes = fd; 994 cb.aio_buf = NULL; 995 if (aio_read(&cb) == -1) 996 atf_tc_fail("aio_read() of maximum read size failed: %s", 997 strerror(errno)); 998 999 nread = aio_waitcomplete(&cbp, NULL); 1000 if (nread == -1) 1001 atf_tc_fail("aio_waitcomplete() failed: %s", strerror(errno)); 1002 if (nread != 0) 1003 atf_tc_fail("aio_read() from empty file returned data: %zd", 1004 nread); 1005 1006 memset(&cb, 0, sizeof(cb)); 1007 cb.aio_nbytes = len + 1; 1008 cb.aio_fildes = fd; 1009 cb.aio_buf = NULL; 1010 if (aio_read(&cb) == -1) { 1011 if (errno == EINVAL) 1012 goto finished; 1013 atf_tc_fail("aio_read() of too large read size failed: %s", 1014 strerror(errno)); 1015 } 1016 1017 nread = aio_waitcomplete(&cbp, NULL); 1018 if (nread == -1) { 1019 if (errno == EINVAL) 1020 goto finished; 1021 atf_tc_fail("aio_waitcomplete() failed: %s", strerror(errno)); 1022 } 1023 atf_tc_fail("aio_read() of too large read size returned: %zd", nread); 1024 1025 finished: 1026 close(fd); 1027 } 1028 1029 /* 1030 * This tests for a bug where arriving socket data can wakeup multiple 1031 * AIO read requests resulting in an uncancellable request. 1032 */ 1033 ATF_TC_WITHOUT_HEAD(aio_socket_two_reads); 1034 ATF_TC_BODY(aio_socket_two_reads, tc) 1035 { 1036 struct ioreq { 1037 struct aiocb iocb; 1038 char buffer[1024]; 1039 } ioreq[2]; 1040 struct aiocb *iocb; 1041 unsigned i; 1042 int s[2]; 1043 char c; 1044 1045 ATF_REQUIRE_KERNEL_MODULE("aio"); 1046 #if __FreeBSD_version < 1100101 1047 aft_tc_skip("kernel version %d is too old (%d required)", 1048 __FreeBSD_version, 1100101); 1049 #endif 1050 1051 ATF_REQUIRE(socketpair(PF_UNIX, SOCK_STREAM, 0, s) != -1); 1052 1053 /* Queue two read requests. */ 1054 memset(&ioreq, 0, sizeof(ioreq)); 1055 for (i = 0; i < nitems(ioreq); i++) { 1056 ioreq[i].iocb.aio_nbytes = sizeof(ioreq[i].buffer); 1057 ioreq[i].iocb.aio_fildes = s[0]; 1058 ioreq[i].iocb.aio_buf = ioreq[i].buffer; 1059 ATF_REQUIRE(aio_read(&ioreq[i].iocb) == 0); 1060 } 1061 1062 /* Send a single byte. This should complete one request. */ 1063 c = 0xc3; 1064 ATF_REQUIRE(write(s[1], &c, sizeof(c)) == 1); 1065 1066 ATF_REQUIRE(aio_waitcomplete(&iocb, NULL) == 1); 1067 1068 /* Determine which request completed and verify the data was read. */ 1069 if (iocb == &ioreq[0].iocb) 1070 i = 0; 1071 else 1072 i = 1; 1073 ATF_REQUIRE(ioreq[i].buffer[0] == c); 1074 1075 i ^= 1; 1076 1077 /* 1078 * Try to cancel the other request. On broken systems this 1079 * will fail and the process will hang on exit. 1080 */ 1081 ATF_REQUIRE(aio_error(&ioreq[i].iocb) == EINPROGRESS); 1082 ATF_REQUIRE(aio_cancel(s[0], &ioreq[i].iocb) == AIO_CANCELED); 1083 1084 close(s[1]); 1085 close(s[0]); 1086 } 1087 1088 static void 1089 aio_socket_blocking_short_write_test(bool vectored) 1090 { 1091 struct aiocb iocb, *iocbp; 1092 struct iovec iov[2]; 1093 char *buffer[2]; 1094 ssize_t done, r; 1095 int buffer_size, sb_size; 1096 socklen_t len; 1097 int s[2]; 1098 1099 ATF_REQUIRE_KERNEL_MODULE("aio"); 1100 1101 ATF_REQUIRE(socketpair(PF_UNIX, SOCK_STREAM, 0, s) != -1); 1102 1103 len = sizeof(sb_size); 1104 ATF_REQUIRE(getsockopt(s[0], SOL_SOCKET, SO_RCVBUF, &sb_size, &len) != 1105 -1); 1106 ATF_REQUIRE(len == sizeof(sb_size)); 1107 buffer_size = sb_size; 1108 1109 ATF_REQUIRE(getsockopt(s[1], SOL_SOCKET, SO_SNDBUF, &sb_size, &len) != 1110 -1); 1111 ATF_REQUIRE(len == sizeof(sb_size)); 1112 if (sb_size > buffer_size) 1113 buffer_size = sb_size; 1114 1115 /* 1116 * Use twice the size of the MAX(receive buffer, send buffer) 1117 * to ensure that the write is split up into multiple writes 1118 * internally. 1119 */ 1120 buffer_size *= 2; 1121 1122 buffer[0] = malloc(buffer_size); 1123 ATF_REQUIRE(buffer[0] != NULL); 1124 buffer[1] = malloc(buffer_size); 1125 ATF_REQUIRE(buffer[1] != NULL); 1126 1127 srandomdev(); 1128 aio_fill_buffer(buffer[1], buffer_size, random()); 1129 1130 memset(&iocb, 0, sizeof(iocb)); 1131 iocb.aio_fildes = s[1]; 1132 if (vectored) { 1133 iov[0].iov_base = buffer[1]; 1134 iov[0].iov_len = buffer_size / 2 + 1; 1135 iov[1].iov_base = buffer[1] + buffer_size / 2 + 1; 1136 iov[1].iov_len = buffer_size / 2 - 1; 1137 iocb.aio_iov = iov; 1138 iocb.aio_iovcnt = 2; 1139 r = aio_writev(&iocb); 1140 ATF_CHECK_EQ_MSG(0, r, "aio_writev returned %zd", r); 1141 } else { 1142 iocb.aio_buf = buffer[1]; 1143 iocb.aio_nbytes = buffer_size; 1144 r = aio_write(&iocb); 1145 ATF_CHECK_EQ_MSG(0, r, "aio_writev returned %zd", r); 1146 } 1147 1148 done = recv(s[0], buffer[0], buffer_size, MSG_WAITALL); 1149 ATF_REQUIRE(done == buffer_size); 1150 1151 done = aio_waitcomplete(&iocbp, NULL); 1152 ATF_REQUIRE(iocbp == &iocb); 1153 ATF_REQUIRE(done == buffer_size); 1154 1155 ATF_REQUIRE(memcmp(buffer[0], buffer[1], buffer_size) == 0); 1156 1157 close(s[1]); 1158 close(s[0]); 1159 } 1160 1161 /* 1162 * This test ensures that aio_write() on a blocking socket of a "large" 1163 * buffer does not return a short completion. 1164 */ 1165 ATF_TC_WITHOUT_HEAD(aio_socket_blocking_short_write); 1166 ATF_TC_BODY(aio_socket_blocking_short_write, tc) 1167 { 1168 aio_socket_blocking_short_write_test(false); 1169 } 1170 1171 /* 1172 * Like aio_socket_blocking_short_write, but also tests that partially 1173 * completed vectored sends can be retried correctly. 1174 */ 1175 ATF_TC_WITHOUT_HEAD(aio_socket_blocking_short_write_vectored); 1176 ATF_TC_BODY(aio_socket_blocking_short_write_vectored, tc) 1177 { 1178 aio_socket_blocking_short_write_test(true); 1179 } 1180 1181 /* 1182 * Verify that AIO requests fail when applied to a listening socket. 1183 */ 1184 ATF_TC_WITHOUT_HEAD(aio_socket_listen_fail); 1185 ATF_TC_BODY(aio_socket_listen_fail, tc) 1186 { 1187 struct aiocb iocb; 1188 struct sockaddr_un sun; 1189 char buf[16]; 1190 int s; 1191 1192 s = socket(AF_LOCAL, SOCK_STREAM, 0); 1193 ATF_REQUIRE(s != -1); 1194 1195 memset(&sun, 0, sizeof(sun)); 1196 snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", "listen.XXXXXX"); 1197 mktemp(sun.sun_path); 1198 sun.sun_family = AF_LOCAL; 1199 sun.sun_len = SUN_LEN(&sun); 1200 1201 ATF_REQUIRE(bind(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) == 0); 1202 ATF_REQUIRE(listen(s, 5) == 0); 1203 1204 memset(buf, 0, sizeof(buf)); 1205 memset(&iocb, 0, sizeof(iocb)); 1206 iocb.aio_fildes = s; 1207 iocb.aio_buf = buf; 1208 iocb.aio_nbytes = sizeof(buf); 1209 1210 ATF_REQUIRE_ERRNO(EINVAL, aio_read(&iocb) == -1); 1211 ATF_REQUIRE_ERRNO(EINVAL, aio_write(&iocb) == -1); 1212 1213 ATF_REQUIRE(unlink(sun.sun_path) == 0); 1214 close(s); 1215 } 1216 1217 /* 1218 * Verify that listen(2) fails if a socket has pending AIO requests. 1219 */ 1220 ATF_TC_WITHOUT_HEAD(aio_socket_listen_pending); 1221 ATF_TC_BODY(aio_socket_listen_pending, tc) 1222 { 1223 struct aiocb iocb; 1224 struct sockaddr_un sun; 1225 char buf[16]; 1226 int s; 1227 1228 s = socket(AF_LOCAL, SOCK_STREAM, 0); 1229 ATF_REQUIRE(s != -1); 1230 1231 memset(&sun, 0, sizeof(sun)); 1232 snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", "listen.XXXXXX"); 1233 mktemp(sun.sun_path); 1234 sun.sun_family = AF_LOCAL; 1235 sun.sun_len = SUN_LEN(&sun); 1236 1237 ATF_REQUIRE(bind(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) == 0); 1238 1239 memset(buf, 0, sizeof(buf)); 1240 memset(&iocb, 0, sizeof(iocb)); 1241 iocb.aio_fildes = s; 1242 iocb.aio_buf = buf; 1243 iocb.aio_nbytes = sizeof(buf); 1244 ATF_REQUIRE(aio_read(&iocb) == 0); 1245 1246 ATF_REQUIRE_ERRNO(EINVAL, listen(s, 5) == -1); 1247 1248 ATF_REQUIRE(aio_cancel(s, &iocb) != -1); 1249 1250 ATF_REQUIRE(unlink(sun.sun_path) == 0); 1251 close(s); 1252 } 1253 1254 /* 1255 * This test verifies that cancelling a partially completed socket write 1256 * returns a short write rather than ECANCELED. 1257 */ 1258 ATF_TC_WITHOUT_HEAD(aio_socket_short_write_cancel); 1259 ATF_TC_BODY(aio_socket_short_write_cancel, tc) 1260 { 1261 struct aiocb iocb, *iocbp; 1262 char *buffer[2]; 1263 ssize_t done; 1264 int buffer_size, sb_size; 1265 socklen_t len; 1266 int s[2]; 1267 1268 ATF_REQUIRE_KERNEL_MODULE("aio"); 1269 1270 ATF_REQUIRE(socketpair(PF_UNIX, SOCK_STREAM, 0, s) != -1); 1271 1272 len = sizeof(sb_size); 1273 ATF_REQUIRE(getsockopt(s[0], SOL_SOCKET, SO_RCVBUF, &sb_size, &len) != 1274 -1); 1275 ATF_REQUIRE(len == sizeof(sb_size)); 1276 buffer_size = sb_size; 1277 1278 ATF_REQUIRE(getsockopt(s[1], SOL_SOCKET, SO_SNDBUF, &sb_size, &len) != 1279 -1); 1280 ATF_REQUIRE(len == sizeof(sb_size)); 1281 if (sb_size > buffer_size) 1282 buffer_size = sb_size; 1283 1284 /* 1285 * Use three times the size of the MAX(receive buffer, send 1286 * buffer) for the write to ensure that the write is split up 1287 * into multiple writes internally. The recv() ensures that 1288 * the write has partially completed, but a remaining size of 1289 * two buffers should ensure that the write has not completed 1290 * fully when it is cancelled. 1291 */ 1292 buffer[0] = malloc(buffer_size); 1293 ATF_REQUIRE(buffer[0] != NULL); 1294 buffer[1] = malloc(buffer_size * 3); 1295 ATF_REQUIRE(buffer[1] != NULL); 1296 1297 srandomdev(); 1298 aio_fill_buffer(buffer[1], buffer_size * 3, random()); 1299 1300 memset(&iocb, 0, sizeof(iocb)); 1301 iocb.aio_fildes = s[1]; 1302 iocb.aio_buf = buffer[1]; 1303 iocb.aio_nbytes = buffer_size * 3; 1304 ATF_REQUIRE(aio_write(&iocb) == 0); 1305 1306 done = recv(s[0], buffer[0], buffer_size, MSG_WAITALL); 1307 ATF_REQUIRE(done == buffer_size); 1308 1309 ATF_REQUIRE(aio_error(&iocb) == EINPROGRESS); 1310 ATF_REQUIRE(aio_cancel(s[1], &iocb) == AIO_NOTCANCELED); 1311 1312 done = aio_waitcomplete(&iocbp, NULL); 1313 ATF_REQUIRE(iocbp == &iocb); 1314 ATF_REQUIRE(done >= buffer_size && done <= buffer_size * 2); 1315 1316 ATF_REQUIRE(memcmp(buffer[0], buffer[1], buffer_size) == 0); 1317 1318 close(s[1]); 1319 close(s[0]); 1320 } 1321 1322 /* 1323 * test aio_fsync's behavior with bad inputs 1324 */ 1325 ATF_TC_WITHOUT_HEAD(aio_fsync_errors); 1326 ATF_TC_BODY(aio_fsync_errors, tc) 1327 { 1328 int fd; 1329 struct aiocb iocb; 1330 1331 ATF_REQUIRE_KERNEL_MODULE("aio"); 1332 ATF_REQUIRE_UNSAFE_AIO(); 1333 1334 fd = open(FILE_PATHNAME, O_RDWR | O_CREAT, 0600); 1335 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 1336 unlink(FILE_PATHNAME); 1337 1338 /* aio_fsync should return EINVAL unless op is O_SYNC or O_DSYNC */ 1339 memset(&iocb, 0, sizeof(iocb)); 1340 iocb.aio_fildes = fd; 1341 ATF_CHECK_EQ(-1, aio_fsync(666, &iocb)); 1342 ATF_CHECK_EQ(EINVAL, errno); 1343 1344 /* aio_fsync should return EBADF if fd is not a valid descriptor */ 1345 memset(&iocb, 0, sizeof(iocb)); 1346 iocb.aio_fildes = 666; 1347 ATF_CHECK_EQ(-1, aio_fsync(O_SYNC, &iocb)); 1348 ATF_CHECK_EQ(EBADF, errno); 1349 1350 /* aio_fsync should return EINVAL if sigev_notify is invalid */ 1351 memset(&iocb, 0, sizeof(iocb)); 1352 iocb.aio_fildes = fd; 1353 iocb.aio_sigevent.sigev_notify = 666; 1354 ATF_CHECK_EQ(-1, aio_fsync(666, &iocb)); 1355 ATF_CHECK_EQ(EINVAL, errno); 1356 } 1357 1358 /* 1359 * This test just performs a basic test of aio_fsync(). 1360 */ 1361 static void 1362 aio_fsync_test(int op) 1363 { 1364 struct aiocb synccb, *iocbp; 1365 struct { 1366 struct aiocb iocb; 1367 bool done; 1368 char *buffer; 1369 } buffers[16]; 1370 struct stat sb; 1371 ssize_t rval; 1372 unsigned i; 1373 int fd; 1374 1375 ATF_REQUIRE_KERNEL_MODULE("aio"); 1376 ATF_REQUIRE_UNSAFE_AIO(); 1377 1378 fd = open(FILE_PATHNAME, O_RDWR | O_CREAT, 0600); 1379 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 1380 unlink(FILE_PATHNAME); 1381 1382 ATF_REQUIRE(fstat(fd, &sb) == 0); 1383 ATF_REQUIRE(sb.st_blksize != 0); 1384 ATF_REQUIRE(ftruncate(fd, sb.st_blksize * nitems(buffers)) == 0); 1385 1386 /* 1387 * Queue several asynchronous write requests. Hopefully this 1388 * forces the aio_fsync() request to be deferred. There is no 1389 * reliable way to guarantee that however. 1390 */ 1391 srandomdev(); 1392 for (i = 0; i < nitems(buffers); i++) { 1393 buffers[i].done = false; 1394 memset(&buffers[i].iocb, 0, sizeof(buffers[i].iocb)); 1395 buffers[i].buffer = malloc(sb.st_blksize); 1396 aio_fill_buffer(buffers[i].buffer, sb.st_blksize, random()); 1397 buffers[i].iocb.aio_fildes = fd; 1398 buffers[i].iocb.aio_buf = buffers[i].buffer; 1399 buffers[i].iocb.aio_nbytes = sb.st_blksize; 1400 buffers[i].iocb.aio_offset = sb.st_blksize * i; 1401 ATF_REQUIRE(aio_write(&buffers[i].iocb) == 0); 1402 } 1403 1404 /* Queue the aio_fsync request. */ 1405 memset(&synccb, 0, sizeof(synccb)); 1406 synccb.aio_fildes = fd; 1407 ATF_REQUIRE(aio_fsync(op, &synccb) == 0); 1408 1409 /* Wait for requests to complete. */ 1410 for (;;) { 1411 next: 1412 rval = aio_waitcomplete(&iocbp, NULL); 1413 ATF_REQUIRE(iocbp != NULL); 1414 if (iocbp == &synccb) { 1415 ATF_REQUIRE(rval == 0); 1416 break; 1417 } 1418 1419 for (i = 0; i < nitems(buffers); i++) { 1420 if (iocbp == &buffers[i].iocb) { 1421 ATF_REQUIRE(buffers[i].done == false); 1422 ATF_REQUIRE(rval == sb.st_blksize); 1423 buffers[i].done = true; 1424 goto next; 1425 } 1426 } 1427 1428 ATF_REQUIRE_MSG(false, "unmatched AIO request"); 1429 } 1430 1431 for (i = 0; i < nitems(buffers); i++) 1432 ATF_REQUIRE_MSG(buffers[i].done, 1433 "AIO request %u did not complete", i); 1434 1435 close(fd); 1436 } 1437 1438 ATF_TC_WITHOUT_HEAD(aio_fsync_sync_test); 1439 ATF_TC_BODY(aio_fsync_sync_test, tc) 1440 { 1441 aio_fsync_test(O_SYNC); 1442 } 1443 1444 ATF_TC_WITHOUT_HEAD(aio_fsync_dsync_test); 1445 ATF_TC_BODY(aio_fsync_dsync_test, tc) 1446 { 1447 aio_fsync_test(O_DSYNC); 1448 } 1449 1450 /* 1451 * We shouldn't be able to DoS the system by setting iov_len to an insane 1452 * value 1453 */ 1454 ATF_TC_WITHOUT_HEAD(aio_writev_dos_iov_len); 1455 ATF_TC_BODY(aio_writev_dos_iov_len, tc) 1456 { 1457 struct aiocb aio; 1458 const struct aiocb *const iocbs[] = {&aio}; 1459 const char *wbuf = "Hello, world!"; 1460 struct iovec iov[1]; 1461 ssize_t len, r; 1462 int fd; 1463 1464 ATF_REQUIRE_KERNEL_MODULE("aio"); 1465 ATF_REQUIRE_UNSAFE_AIO(); 1466 1467 fd = open("testfile", O_RDWR | O_CREAT, 0600); 1468 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 1469 1470 len = strlen(wbuf); 1471 iov[0].iov_base = __DECONST(void*, wbuf); 1472 iov[0].iov_len = 1 << 30; 1473 bzero(&aio, sizeof(aio)); 1474 aio.aio_fildes = fd; 1475 aio.aio_offset = 0; 1476 aio.aio_iov = iov; 1477 aio.aio_iovcnt = 1; 1478 1479 r = aio_writev(&aio); 1480 ATF_CHECK_EQ_MSG(0, r, "aio_writev returned %zd", r); 1481 ATF_REQUIRE_EQ(0, aio_suspend(iocbs, 1, NULL)); 1482 r = aio_return(&aio); 1483 ATF_CHECK_EQ_MSG(-1, r, "aio_return returned %zd", r); 1484 ATF_CHECK_MSG(errno == EFAULT || errno == EINVAL, 1485 "aio_writev: %s", strerror(errno)); 1486 1487 close(fd); 1488 } 1489 1490 /* 1491 * We shouldn't be able to DoS the system by setting aio_iovcnt to an insane 1492 * value 1493 */ 1494 ATF_TC_WITHOUT_HEAD(aio_writev_dos_iovcnt); 1495 ATF_TC_BODY(aio_writev_dos_iovcnt, tc) 1496 { 1497 struct aiocb aio; 1498 const char *wbuf = "Hello, world!"; 1499 struct iovec iov[1]; 1500 ssize_t len; 1501 int fd; 1502 1503 ATF_REQUIRE_KERNEL_MODULE("aio"); 1504 ATF_REQUIRE_UNSAFE_AIO(); 1505 1506 fd = open("testfile", O_RDWR | O_CREAT, 0600); 1507 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 1508 1509 len = strlen(wbuf); 1510 iov[0].iov_base = __DECONST(void*, wbuf); 1511 iov[0].iov_len = len; 1512 bzero(&aio, sizeof(aio)); 1513 aio.aio_fildes = fd; 1514 aio.aio_offset = 0; 1515 aio.aio_iov = iov; 1516 aio.aio_iovcnt = 1 << 30; 1517 1518 ATF_REQUIRE_EQ(-1, aio_writev(&aio)); 1519 ATF_CHECK_EQ(EINVAL, errno); 1520 1521 close(fd); 1522 } 1523 1524 ATF_TC_WITH_CLEANUP(aio_writev_efault); 1525 ATF_TC_HEAD(aio_writev_efault, tc) 1526 { 1527 atf_tc_set_md_var(tc, "descr", 1528 "Vectored AIO should gracefully handle invalid addresses"); 1529 atf_tc_set_md_var(tc, "require.user", "root"); 1530 } 1531 ATF_TC_BODY(aio_writev_efault, tc) 1532 { 1533 struct aiocb aio; 1534 ssize_t buflen; 1535 char *buffer; 1536 struct iovec iov[2]; 1537 long seed; 1538 int fd; 1539 1540 ATF_REQUIRE_KERNEL_MODULE("aio"); 1541 ATF_REQUIRE_UNSAFE_AIO(); 1542 1543 fd = aio_md_setup(); 1544 1545 seed = random(); 1546 buflen = 4096; 1547 buffer = malloc(buflen); 1548 aio_fill_buffer(buffer, buflen, seed); 1549 iov[0].iov_base = buffer; 1550 iov[0].iov_len = buflen; 1551 iov[1].iov_base = (void*)-1; /* Invalid! */ 1552 iov[1].iov_len = buflen; 1553 bzero(&aio, sizeof(aio)); 1554 aio.aio_fildes = fd; 1555 aio.aio_offset = 0; 1556 aio.aio_iov = iov; 1557 aio.aio_iovcnt = nitems(iov); 1558 1559 ATF_REQUIRE_EQ(-1, aio_writev(&aio)); 1560 ATF_CHECK_EQ(EFAULT, errno); 1561 1562 close(fd); 1563 } 1564 ATF_TC_CLEANUP(aio_writev_efault, tc) 1565 { 1566 aio_md_cleanup(); 1567 } 1568 1569 ATF_TC_WITHOUT_HEAD(aio_writev_empty_file_poll); 1570 ATF_TC_BODY(aio_writev_empty_file_poll, tc) 1571 { 1572 struct aiocb aio; 1573 int fd; 1574 1575 ATF_REQUIRE_KERNEL_MODULE("aio"); 1576 ATF_REQUIRE_UNSAFE_AIO(); 1577 1578 fd = open("testfile", O_RDWR | O_CREAT, 0600); 1579 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 1580 1581 bzero(&aio, sizeof(aio)); 1582 aio.aio_fildes = fd; 1583 aio.aio_offset = 0; 1584 aio.aio_iovcnt = 0; 1585 1586 ATF_REQUIRE_EQ(0, aio_writev(&aio)); 1587 ATF_REQUIRE_EQ(0, suspend(&aio)); 1588 1589 close(fd); 1590 } 1591 1592 ATF_TC_WITHOUT_HEAD(aio_writev_empty_file_signal); 1593 ATF_TC_BODY(aio_writev_empty_file_signal, tc) 1594 { 1595 struct aiocb aio; 1596 int fd; 1597 1598 ATF_REQUIRE_KERNEL_MODULE("aio"); 1599 ATF_REQUIRE_UNSAFE_AIO(); 1600 1601 fd = open("testfile", O_RDWR | O_CREAT, 0600); 1602 ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); 1603 1604 bzero(&aio, sizeof(aio)); 1605 aio.aio_fildes = fd; 1606 aio.aio_offset = 0; 1607 aio.aio_iovcnt = 0; 1608 aio.aio_sigevent = *setup_signal(); 1609 1610 ATF_REQUIRE_EQ(0, aio_writev(&aio)); 1611 ATF_REQUIRE_EQ(0, poll_signaled(&aio)); 1612 1613 close(fd); 1614 } 1615 1616 // aio_writev and aio_readv should still work even if the iovcnt is greater 1617 // than the number of buffered AIO operations permitted per process. 1618 ATF_TC_WITH_CLEANUP(vectored_big_iovcnt); 1619 ATF_TC_HEAD(vectored_big_iovcnt, tc) 1620 { 1621 atf_tc_set_md_var(tc, "descr", 1622 "Vectored AIO should still work even if the iovcnt is greater than " 1623 "the number of buffered AIO operations permitted by the process"); 1624 atf_tc_set_md_var(tc, "require.user", "root"); 1625 } 1626 ATF_TC_BODY(vectored_big_iovcnt, tc) 1627 { 1628 struct aiocb aio; 1629 struct iovec *iov; 1630 ssize_t len, buflen; 1631 char *buffer; 1632 const char *oid = "vfs.aio.max_buf_aio"; 1633 long seed; 1634 int max_buf_aio; 1635 int fd, i; 1636 ssize_t sysctl_len = sizeof(max_buf_aio); 1637 1638 ATF_REQUIRE_KERNEL_MODULE("aio"); 1639 ATF_REQUIRE_UNSAFE_AIO(); 1640 1641 if (sysctlbyname(oid, &max_buf_aio, &sysctl_len, NULL, 0) == -1) 1642 atf_libc_error(errno, "Failed to read %s", oid); 1643 1644 seed = random(); 1645 buflen = 512 * (max_buf_aio + 1); 1646 buffer = malloc(buflen); 1647 aio_fill_buffer(buffer, buflen, seed); 1648 iov = calloc(max_buf_aio + 1, sizeof(struct iovec)); 1649 1650 fd = aio_md_setup(); 1651 1652 bzero(&aio, sizeof(aio)); 1653 aio.aio_fildes = fd; 1654 aio.aio_offset = 0; 1655 for (i = 0; i < max_buf_aio + 1; i++) { 1656 iov[i].iov_base = &buffer[i * 512]; 1657 iov[i].iov_len = 512; 1658 } 1659 aio.aio_iov = iov; 1660 aio.aio_iovcnt = max_buf_aio + 1; 1661 1662 if (aio_writev(&aio) < 0) 1663 atf_tc_fail("aio_writev failed: %s", strerror(errno)); 1664 1665 len = poll(&aio); 1666 if (len < 0) 1667 atf_tc_fail("aio failed: %s", strerror(errno)); 1668 1669 if (len != buflen) 1670 atf_tc_fail("aio short write (%jd)", (intmax_t)len); 1671 1672 bzero(&aio, sizeof(aio)); 1673 aio.aio_fildes = fd; 1674 aio.aio_offset = 0; 1675 aio.aio_iov = iov; 1676 aio.aio_iovcnt = max_buf_aio + 1; 1677 1678 if (aio_readv(&aio) < 0) 1679 atf_tc_fail("aio_readv failed: %s", strerror(errno)); 1680 1681 len = poll(&aio); 1682 if (len < 0) 1683 atf_tc_fail("aio failed: %s", strerror(errno)); 1684 1685 if (len != buflen) 1686 atf_tc_fail("aio short read (%jd)", (intmax_t)len); 1687 1688 if (aio_test_buffer(buffer, buflen, seed) == 0) 1689 atf_tc_fail("buffer mismatched"); 1690 1691 close(fd); 1692 } 1693 ATF_TC_CLEANUP(vectored_big_iovcnt, tc) 1694 { 1695 aio_md_cleanup(); 1696 } 1697 1698 ATF_TC_WITHOUT_HEAD(vectored_file_poll); 1699 ATF_TC_BODY(vectored_file_poll, tc) 1700 { 1701 aio_file_test(poll, NULL, true); 1702 } 1703 1704 ATF_TC_WITHOUT_HEAD(vectored_thread); 1705 ATF_TC_BODY(vectored_thread, tc) 1706 { 1707 aio_file_test(poll_signaled, setup_thread(), true); 1708 } 1709 1710 ATF_TC_WITH_CLEANUP(vectored_md_poll); 1711 ATF_TC_HEAD(vectored_md_poll, tc) 1712 { 1713 atf_tc_set_md_var(tc, "require.user", "root"); 1714 } 1715 ATF_TC_BODY(vectored_md_poll, tc) 1716 { 1717 aio_md_test(poll, NULL, true); 1718 } 1719 ATF_TC_CLEANUP(vectored_md_poll, tc) 1720 { 1721 aio_md_cleanup(); 1722 } 1723 1724 ATF_TC_WITHOUT_HEAD(vectored_socket_poll); 1725 ATF_TC_BODY(vectored_socket_poll, tc) 1726 { 1727 aio_unix_socketpair_test(poll, NULL, true); 1728 } 1729 1730 // aio_writev and aio_readv should still work even if the iov contains elements 1731 // that aren't a multiple of the device's sector size, and even if the total 1732 // amount if I/O _is_ a multiple of the device's sector size. 1733 ATF_TC_WITH_CLEANUP(vectored_unaligned); 1734 ATF_TC_HEAD(vectored_unaligned, tc) 1735 { 1736 atf_tc_set_md_var(tc, "descr", 1737 "Vectored AIO should still work even if the iov contains elements " 1738 "that aren't a multiple of the sector size."); 1739 atf_tc_set_md_var(tc, "require.user", "root"); 1740 } 1741 ATF_TC_BODY(vectored_unaligned, tc) 1742 { 1743 struct aio_context ac; 1744 struct aiocb aio; 1745 struct iovec iov[3]; 1746 ssize_t len, total_len; 1747 int fd; 1748 1749 ATF_REQUIRE_KERNEL_MODULE("aio"); 1750 ATF_REQUIRE_UNSAFE_AIO(); 1751 1752 /* 1753 * Use a zvol with volmode=dev, so it will allow .d_write with 1754 * unaligned uio. geom devices use physio, which doesn't allow that. 1755 */ 1756 fd = aio_zvol_setup(); 1757 aio_context_init(&ac, fd, fd, FILE_LEN); 1758 1759 /* Break the buffer into 3 parts: 1760 * * A 4kB part, aligned to 4kB 1761 * * Two other parts that add up to 4kB: 1762 * - 256B 1763 * - 4kB - 256B 1764 */ 1765 iov[0].iov_base = ac.ac_buffer; 1766 iov[0].iov_len = 4096; 1767 iov[1].iov_base = (void*)((uintptr_t)iov[0].iov_base + iov[0].iov_len); 1768 iov[1].iov_len = 256; 1769 iov[2].iov_base = (void*)((uintptr_t)iov[1].iov_base + iov[1].iov_len); 1770 iov[2].iov_len = 4096 - iov[1].iov_len; 1771 total_len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len; 1772 bzero(&aio, sizeof(aio)); 1773 aio.aio_fildes = ac.ac_write_fd; 1774 aio.aio_offset = 0; 1775 aio.aio_iov = iov; 1776 aio.aio_iovcnt = 3; 1777 1778 if (aio_writev(&aio) < 0) 1779 atf_tc_fail("aio_writev failed: %s", strerror(errno)); 1780 1781 len = poll(&aio); 1782 if (len < 0) 1783 atf_tc_fail("aio failed: %s", strerror(errno)); 1784 1785 if (len != total_len) 1786 atf_tc_fail("aio short write (%jd)", (intmax_t)len); 1787 1788 bzero(&aio, sizeof(aio)); 1789 aio.aio_fildes = ac.ac_read_fd; 1790 aio.aio_offset = 0; 1791 aio.aio_iov = iov; 1792 aio.aio_iovcnt = 3; 1793 1794 if (aio_readv(&aio) < 0) 1795 atf_tc_fail("aio_readv failed: %s", strerror(errno)); 1796 len = poll(&aio); 1797 1798 ATF_REQUIRE_MSG(aio_test_buffer(ac.ac_buffer, total_len, 1799 ac.ac_seed) != 0, "aio_test_buffer: internal error"); 1800 1801 close(fd); 1802 } 1803 ATF_TC_CLEANUP(vectored_unaligned, tc) 1804 { 1805 aio_zvol_cleanup(); 1806 } 1807 1808 static void 1809 aio_zvol_test(completion comp, struct sigevent *sev, bool vectored) 1810 { 1811 struct aio_context ac; 1812 int fd; 1813 1814 fd = aio_zvol_setup(); 1815 aio_context_init(&ac, fd, fd, MD_LEN); 1816 if (vectored) { 1817 aio_writev_test(&ac, comp, sev); 1818 aio_readv_test(&ac, comp, sev); 1819 } else { 1820 aio_write_test(&ac, comp, sev); 1821 aio_read_test(&ac, comp, sev); 1822 } 1823 1824 close(fd); 1825 } 1826 1827 /* 1828 * Note that unlike md, the zvol is not a geom device, does not allow unmapped 1829 * buffers, and does not use physio. 1830 */ 1831 ATF_TC_WITH_CLEANUP(vectored_zvol_poll); 1832 ATF_TC_HEAD(vectored_zvol_poll, tc) 1833 { 1834 atf_tc_set_md_var(tc, "require.user", "root"); 1835 } 1836 ATF_TC_BODY(vectored_zvol_poll, tc) 1837 { 1838 aio_zvol_test(poll, NULL, true); 1839 } 1840 ATF_TC_CLEANUP(vectored_zvol_poll, tc) 1841 { 1842 aio_zvol_cleanup(); 1843 } 1844 1845 ATF_TP_ADD_TCS(tp) 1846 { 1847 1848 ATF_TP_ADD_TC(tp, file_poll); 1849 ATF_TP_ADD_TC(tp, file_signal); 1850 ATF_TP_ADD_TC(tp, file_suspend); 1851 ATF_TP_ADD_TC(tp, file_thread); 1852 ATF_TP_ADD_TC(tp, file_waitcomplete); 1853 ATF_TP_ADD_TC(tp, fifo_poll); 1854 ATF_TP_ADD_TC(tp, fifo_signal); 1855 ATF_TP_ADD_TC(tp, fifo_suspend); 1856 ATF_TP_ADD_TC(tp, fifo_thread); 1857 ATF_TP_ADD_TC(tp, fifo_waitcomplete); 1858 ATF_TP_ADD_TC(tp, socket_poll); 1859 ATF_TP_ADD_TC(tp, socket_signal); 1860 ATF_TP_ADD_TC(tp, socket_suspend); 1861 ATF_TP_ADD_TC(tp, socket_thread); 1862 ATF_TP_ADD_TC(tp, socket_waitcomplete); 1863 ATF_TP_ADD_TC(tp, pty_poll); 1864 ATF_TP_ADD_TC(tp, pty_signal); 1865 ATF_TP_ADD_TC(tp, pty_suspend); 1866 ATF_TP_ADD_TC(tp, pty_thread); 1867 ATF_TP_ADD_TC(tp, pty_waitcomplete); 1868 ATF_TP_ADD_TC(tp, pipe_poll); 1869 ATF_TP_ADD_TC(tp, pipe_signal); 1870 ATF_TP_ADD_TC(tp, pipe_suspend); 1871 ATF_TP_ADD_TC(tp, pipe_thread); 1872 ATF_TP_ADD_TC(tp, pipe_waitcomplete); 1873 ATF_TP_ADD_TC(tp, md_poll); 1874 ATF_TP_ADD_TC(tp, md_signal); 1875 ATF_TP_ADD_TC(tp, md_suspend); 1876 ATF_TP_ADD_TC(tp, md_thread); 1877 ATF_TP_ADD_TC(tp, md_waitcomplete); 1878 ATF_TP_ADD_TC(tp, aio_fsync_errors); 1879 ATF_TP_ADD_TC(tp, aio_fsync_sync_test); 1880 ATF_TP_ADD_TC(tp, aio_fsync_dsync_test); 1881 ATF_TP_ADD_TC(tp, aio_large_read_test); 1882 ATF_TP_ADD_TC(tp, aio_socket_two_reads); 1883 ATF_TP_ADD_TC(tp, aio_socket_blocking_short_write); 1884 ATF_TP_ADD_TC(tp, aio_socket_blocking_short_write_vectored); 1885 ATF_TP_ADD_TC(tp, aio_socket_listen_fail); 1886 ATF_TP_ADD_TC(tp, aio_socket_listen_pending); 1887 ATF_TP_ADD_TC(tp, aio_socket_short_write_cancel); 1888 ATF_TP_ADD_TC(tp, aio_writev_dos_iov_len); 1889 ATF_TP_ADD_TC(tp, aio_writev_dos_iovcnt); 1890 ATF_TP_ADD_TC(tp, aio_writev_efault); 1891 ATF_TP_ADD_TC(tp, aio_writev_empty_file_poll); 1892 ATF_TP_ADD_TC(tp, aio_writev_empty_file_signal); 1893 ATF_TP_ADD_TC(tp, vectored_big_iovcnt); 1894 ATF_TP_ADD_TC(tp, vectored_file_poll); 1895 ATF_TP_ADD_TC(tp, vectored_md_poll); 1896 ATF_TP_ADD_TC(tp, vectored_zvol_poll); 1897 ATF_TP_ADD_TC(tp, vectored_unaligned); 1898 ATF_TP_ADD_TC(tp, vectored_socket_poll); 1899 ATF_TP_ADD_TC(tp, vectored_thread); 1900 1901 return (atf_no_error()); 1902 } 1903