summaryrefslogtreecommitdiffstats
path: root/src/seastar/fmt/test/posix-mock.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/seastar/fmt/test/posix-mock.h
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/seastar/fmt/test/posix-mock.h')
-rw-r--r--src/seastar/fmt/test/posix-mock.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/seastar/fmt/test/posix-mock.h b/src/seastar/fmt/test/posix-mock.h
new file mode 100644
index 00000000..9a4c68ff
--- /dev/null
+++ b/src/seastar/fmt/test/posix-mock.h
@@ -0,0 +1,69 @@
+// Formatting library for C++ - mocks of POSIX functions
+//
+// Copyright (c) 2012 - present, Victor Zverovich
+// All rights reserved.
+//
+// For the license information refer to format.h.
+
+#ifndef FMT_POSIX_TEST_H
+#define FMT_POSIX_TEST_H
+
+#include <errno.h>
+#include <stdio.h>
+
+#ifdef _WIN32
+# include <windows.h>
+#else
+# include <sys/param.h> // for FreeBSD version
+# include <sys/types.h> // for ssize_t
+#endif
+
+#ifndef _MSC_VER
+struct stat;
+#endif
+
+namespace test {
+
+#ifndef _MSC_VER
+// Size type for read and write.
+typedef size_t size_t;
+typedef ssize_t ssize_t;
+int open(const char *path, int oflag, int mode);
+int fstat(int fd, struct stat *buf);
+#else
+typedef unsigned size_t;
+typedef int ssize_t;
+errno_t sopen_s(
+ int* pfh, const char *filename, int oflag, int shflag, int pmode);
+#endif
+
+#ifndef _WIN32
+long sysconf(int name);
+#else
+DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
+#endif
+
+int close(int fildes);
+
+int dup(int fildes);
+int dup2(int fildes, int fildes2);
+
+FILE *fdopen(int fildes, const char *mode);
+
+ssize_t read(int fildes, void *buf, size_t nbyte);
+ssize_t write(int fildes, const void *buf, size_t nbyte);
+
+#ifndef _WIN32
+int pipe(int fildes[2]);
+#else
+int pipe(int *pfds, unsigned psize, int textmode);
+#endif
+
+FILE *fopen(const char *filename, const char *mode);
+int fclose(FILE *stream);
+int (fileno)(FILE *stream);
+} // namespace test
+
+#define FMT_SYSTEM(call) test::call
+
+#endif // FMT_POSIX_TEST_H