test/connect: don't rely on -EINPROGRESS being returned
If we return success, the socket is connected.
@@ -139,11 +139,7 @@ static int connect_socket(struct io_uring *ring, int fd, int *code)
if (ret)
return -1;
- if (res != -EINPROGRESS) {
- fprintf(stderr, "connect(): expected %d, got %d\n", EINPROGRESS, res);
- return -1;
- }
-
+ if (res == -EINPROGRESS) {
ret = wait_for(ring, fd, POLLOUT | POLLHUP | POLLERR);
if (ret == -1)
return -1;
@@ -159,7 +155,8 @@ static int connect_socket(struct io_uring *ring, int fd, int *code)
perror("getsockopt()");
return -1;
}
-
+ } else
+ *code = res;
return 0;
}
@@ -176,7 +173,7 @@ static int test_connect_with_no_peer(struct io_uring *ring)
if (ret == -1)
goto err;
- if (code != ECONNREFUSED) {
+ if (code != -ECONNREFUSED) {
fprintf(stderr, "connect failed with %d\n", code);
goto err;
}
