1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-23 07:31:31 +00:00

aio_md_test: fix cleanup

ATF cleanup functions cannot use functions such as ATF_REQUIRE
and atf_tc_fail.  These functions assert that a test case is
currently running, which is not true during cleanup, so the
process aborts.  Change the cleanup function to simply print
to stderr and return.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Eric van Gyzen 2021-07-23 08:24:52 -05:00
parent a93941b439
commit c6f92e64b6

View File

@ -758,11 +758,15 @@ static void
aio_md_cleanup(void)
{
struct md_ioctl mdio;
int mdctl_fd, error, n, unit;
int mdctl_fd, n, unit;
char buf[80];
mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
ATF_REQUIRE(mdctl_fd >= 0);
if (mdctl_fd < 0) {
fprintf(stderr, "opening /dev/%s failed: %s\n", MDCTL_NAME,
strerror(errno));
return;
}
n = readlink(MDUNIT_LINK, buf, sizeof(buf));
if (n > 0) {
if (sscanf(buf, "%d", &unit) == 1 && unit >= 0) {
@ -770,11 +774,9 @@ aio_md_cleanup(void)
mdio.md_version = MDIOVERSION;
mdio.md_unit = unit;
if (ioctl(mdctl_fd, MDIOCDETACH, &mdio) == -1) {
error = errno;
close(mdctl_fd);
errno = error;
atf_tc_fail("ioctl MDIOCDETACH failed: %s",
strerror(errno));
fprintf(stderr,
"ioctl MDIOCDETACH unit %d failed: %s\n",
unit, strerror(errno));
}
}
}