summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/socket_test_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/syscalls/linux/socket_test_util.cc')
-rw-r--r--test/syscalls/linux/socket_test_util.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_test_util.cc b/test/syscalls/linux/socket_test_util.cc
index 8d19f79ac..035087566 100644
--- a/test/syscalls/linux/socket_test_util.cc
+++ b/test/syscalls/linux/socket_test_util.cc
@@ -22,6 +22,7 @@
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include "absl/time/clock.h"
+#include "test/util/file_descriptor.h"
#include "test/util/posix_error.h"
#include "test/util/temp_path.h"
#include "test/util/thread_util.h"
@@ -463,6 +464,17 @@ SocketPairKind Reversed(SocketPairKind const& base) {
}};
}
+Creator<FileDescriptor> UnboundSocketCreator(int domain, int type,
+ int protocol) {
+ return [=]() -> PosixErrorOr<std::unique_ptr<FileDescriptor>> {
+ int sock;
+ RETURN_ERROR_IF_SYSCALL_FAIL(sock = socket(domain, type, protocol));
+ MaybeSave(); // Successful socket creation.
+
+ return absl::make_unique<FileDescriptor>(sock);
+ };
+}
+
std::vector<SocketPairKind> IncludeReversals(std::vector<SocketPairKind> vec) {
return ApplyVecToVec<SocketPairKind>(std::vector<Middleware>{NoOp, Reversed},
vec);