diff options
author | Glen Barber <gjb@FreeBSD.org> | 2016-04-04 23:55:32 +0000 |
---|---|---|
committer | Glen Barber <gjb@FreeBSD.org> | 2016-04-04 23:55:32 +0000 |
commit | d60840138f6292c1ceeb177ebe797eca0b2749da (patch) | |
tree | a027fe5a27446f32854d6a07b34b5f2a992bf283 /tests | |
parent | b0b644948c7ed5773b80b8060bb08cb39c024ef5 (diff) | |
parent | 8e8df7d50ad7f2b0bb1cb0b8c18242ca511635c3 (diff) | |
download | src-d60840138f6292c1ceeb177ebe797eca0b2749da.tar.gz src-d60840138f6292c1ceeb177ebe797eca0b2749da.zip |
MFH
Sponsored by: The FreeBSD Foundation
Notes
Notes:
svn path=/projects/release-pkg/; revision=297567
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sys/aio/aio_test.c | 74 | ||||
-rw-r--r-- | tests/sys/geom/class/geom_subr.sh | 10 |
2 files changed, 78 insertions, 6 deletions
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c index 607f46db5acb..5515161ee489 100644 --- a/tests/sys/aio/aio_test.c +++ b/tests/sys/aio/aio_test.c @@ -649,6 +649,79 @@ ATF_TC_BODY(aio_md_test, tc) aio_md_cleanup(&arg); } +ATF_TC_WITHOUT_HEAD(aio_large_read_test); +ATF_TC_BODY(aio_large_read_test, tc) +{ + char pathname[PATH_MAX]; + struct aiocb cb, *cbp; + ssize_t nread; + size_t len; + int fd; +#ifdef __LP64__ + int clamped; +#endif + + ATF_REQUIRE_KERNEL_MODULE("aio"); + ATF_REQUIRE_UNSAFE_AIO(); + +#ifdef __LP64__ + len = sizeof(clamped); + if (sysctlbyname("debug.iosize_max_clamp", &clamped, &len, NULL, 0) == + -1) + atf_libc_error(errno, "Failed to read debug.iosize_max_clamp"); +#endif + + /* Determine the maximum supported read(2) size. */ + len = SSIZE_MAX; +#ifdef __LP64__ + if (clamped) + len = INT_MAX; +#endif + + strcpy(pathname, PATH_TEMPLATE); + fd = mkstemp(pathname); + ATF_REQUIRE_MSG(fd != -1, "mkstemp failed: %s", strerror(errno)); + + unlink(pathname); + + memset(&cb, 0, sizeof(cb)); + cb.aio_nbytes = len; + cb.aio_fildes = fd; + cb.aio_buf = NULL; + if (aio_read(&cb) == -1) + atf_tc_fail("aio_read() of maximum read size failed: %s", + strerror(errno)); + + nread = aio_waitcomplete(&cbp, NULL); + if (nread == -1) + atf_tc_fail("aio_waitcomplete() failed: %s", strerror(errno)); + if (nread != 0) + atf_tc_fail("aio_read() from empty file returned data: %zd", + nread); + + memset(&cb, 0, sizeof(cb)); + cb.aio_nbytes = len + 1; + cb.aio_fildes = fd; + cb.aio_buf = NULL; + if (aio_read(&cb) == -1) { + if (errno == EINVAL) + goto finished; + atf_tc_fail("aio_read() of too large read size failed: %s", + strerror(errno)); + } + + nread = aio_waitcomplete(&cbp, NULL); + if (nread == -1) { + if (errno == EINVAL) + goto finished; + atf_tc_fail("aio_waitcomplete() failed: %s", strerror(errno)); + } + atf_tc_fail("aio_read() of too large read size returned: %zd", nread); + +finished: + close(fd); +} + ATF_TP_ADD_TCS(tp) { @@ -658,6 +731,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, aio_pty_test); ATF_TP_ADD_TC(tp, aio_pipe_test); ATF_TP_ADD_TC(tp, aio_md_test); + ATF_TP_ADD_TC(tp, aio_large_read_test); return (atf_no_error()); } diff --git a/tests/sys/geom/class/geom_subr.sh b/tests/sys/geom/class/geom_subr.sh index b437183efede..b03ee434c4e8 100644 --- a/tests/sys/geom/class/geom_subr.sh +++ b/tests/sys/geom/class/geom_subr.sh @@ -35,16 +35,14 @@ geom_test_cleanup() } if [ $(id -u) -ne 0 ]; then - echo 'Tests must be run as root' - echo 'Bail out!' - exit 1 + echo '1..0 # SKIP tests must be run as root' + exit 0 fi # If the geom class isn't already loaded, try loading it. if ! kldstat -q -m g_${class}; then if ! geom ${class} load; then - echo "Could not load module for geom class=${class}" - echo 'Bail out!' - exit 1 + echo "1..0 # SKIP could not load module for geom class=${class}" + exit 0 fi fi |