summaryrefslogtreecommitdiffstats
path: root/tests/basic
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2014-08-08 06:12:04 +0200
committerVijay Bellur <vbellur@redhat.com>2014-08-31 22:28:37 -0700
commit4ae887db6b770584219fab484dec027d278baef9 (patch)
treedc23eb9ae28414c99a9e088fb73d5035d0218a41 /tests/basic
parent11a4d37571253ce2cb18f36bb0ee18d1946be315 (diff)
Regression test portability: mknod
Linux mknod(2) is able to create fifo and named sockets. NetBSD and FreeBSD use mkfifo(2) and socket(2)/bind(2) for that. BUG: 764655 Change-Id: I1d3969e3fcb6afdbd184c28bd268ffa2da7ae202 Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Reviewed-on: http://review.gluster.org/8433 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests/basic')
-rw-r--r--tests/basic/fops-sanity.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/basic/fops-sanity.c b/tests/basic/fops-sanity.c
index 4dbb42fd82b..4f35a46e219 100644
--- a/tests/basic/fops-sanity.c
+++ b/tests/basic/fops-sanity.c
@@ -27,6 +27,12 @@
#include <string.h>
#include <dirent.h>
+#ifndef linux
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#endif
+
/* for fd based fops after unlink */
int fd_based_fops_1 (char *filename);
/* for fd based fops before unlink */
@@ -452,7 +458,11 @@ path_based_fops (char *filename)
}
unlink("bspecial");
+#ifdef linux
ret = mknod ("fifo", S_IFIFO|S_IRWXU|S_IRWXG, 0);
+#else
+ ret = mkfifo ("fifo", 0);
+#endif
if (ret < 0) {
fprintf (stderr, "fifo mknod failed: %s\n",
strerror(errno));
@@ -460,12 +470,31 @@ path_based_fops (char *filename)
}
unlink("fifo");
+#ifdef linux
ret = mknod ("sock", S_IFSOCK|S_IRWXU|S_IRWXG, 0);
if (ret < 0) {
fprintf (stderr, "sock mknod failed: %s\n",
strerror(errno));
result |= ret;
}
+#else
+ {
+ int s;
+ const char *pathname = "sock";
+ struct sockaddr_un addr;
+
+ s = socket(PF_LOCAL, SOCK_STREAM, 0);
+ memset(&addr, 0, sizeof(addr));
+ strncpy(addr.sun_path, pathname, sizeof(addr.sun_path));
+ ret = bind(s, (const struct sockaddr *)&addr, SUN_LEN(&addr));
+ if (ret < 0) {
+ fprintf (stderr, "fifo mknod failed: %s\n",
+ strerror(errno));
+ result |= ret;
+ }
+ close(s);
+ }
+#endif
unlink("sock");
strcpy (newfilename, filename);