unix/dgram tests: match the kernel behavior

In CURRENT for some time an overflowed unix/dgram socket would
return EAGAIN if it has O_NONBLOCK set.  This proved to be
undesired.  See 71e70c25c0 for details.  Update tests to match
the "new" behavior, which actually is the historical behavior.
This commit is contained in:
Gleb Smirnoff 2023-02-22 20:44:46 -08:00
parent 3ff497061b
commit a170657108
2 changed files with 10 additions and 2 deletions

View File

@ -156,10 +156,13 @@ ATF_TC_BODY(basic, tc)
ATF_REQUIRE(send(fd[0], buf, maxdgram, 0) == -1);
ATF_REQUIRE(errno == ENOBUFS);
/* Fail with EAGAIN with O_NONBLOCK set. */
/*
* Fail with ENOBUFS with O_NONBLOCK set, too. See 71e70c25c00
* for explanation why this behavior needs to be preserved.
*/
ATF_REQUIRE(fcntl(fd[0], F_SETFL, O_NONBLOCK) != -1);
ATF_REQUIRE(send(fd[0], buf, maxdgram, 0) == -1);
ATF_REQUIRE(errno == EAGAIN);
ATF_REQUIRE(errno == ENOBUFS);
/* Remote side closed -> ECONNRESET. */
close(fd[1]);

View File

@ -532,8 +532,13 @@ ATF_TC_BODY(send_overflow, tc)
nfiles = openfiles();
tempfile(&putfd);
len = sendfd_payload(fd[0], putfd, buf, sendspace);
#if TEST_PROTO == SOCK_STREAM
ATF_REQUIRE_MSG(len == -1 && errno == EAGAIN,
"sendmsg: %zu bytes sent, errno %d", len, errno);
#elif TEST_PROTO == SOCK_DGRAM
ATF_REQUIRE_MSG(len == -1 && errno == ENOBUFS,
"sendmsg: %zu bytes sent, errno %d", len, errno);
#endif
close(putfd);
ATF_REQUIRE(nfiles == openfiles());
closesocketpair(fd);