summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-12-13 16:31:02 -0800
committerSage Weil <sage@newdream.net>2011-12-13 16:31:02 -0800
commit5804477b20f89a2b02218b518a44e73073b393c9 (patch)
tree8a3da9958152d5a1677ee444ab0153a378517ded /qa
parent207c40b08a1c4138a983de6d7c1a9f7906e0d396 (diff)
downloadceph-5804477b20f89a2b02218b518a44e73073b393c9.tar.gz
qa: trivial_libceph test
This currently fails... see #1827 Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'qa')
-rw-r--r--qa/libceph/Makefile11
-rw-r--r--qa/libceph/trivial_libceph.c69
2 files changed, 80 insertions, 0 deletions
diff --git a/qa/libceph/Makefile b/qa/libceph/Makefile
new file mode 100644
index 00000000000..05a0696cb14
--- /dev/null
+++ b/qa/libceph/Makefile
@@ -0,0 +1,11 @@
+CFLAGS = -Wall -Wextra -D_GNU_SOURCE -lcephfs -L../../src/.libs
+
+TARGETS = trivial_libceph
+
+.c:
+ $(CC) $(CFLAGS) $@.c -o $@
+
+all: $(TARGETS)
+
+clean:
+ rm $(TARGETS)
diff --git a/qa/libceph/trivial_libceph.c b/qa/libceph/trivial_libceph.c
new file mode 100644
index 00000000000..fff6eae25a7
--- /dev/null
+++ b/qa/libceph/trivial_libceph.c
@@ -0,0 +1,69 @@
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/statvfs.h>
+#include "../../src/include/cephfs/libcephfs.h"
+
+#define MB64 (1<<26)
+
+int main(int argc, const char **argv)
+{
+ struct ceph_mount_info *cmount;
+ int ret, fd, len;
+ char buf[1024];
+
+ if (argc < 3) {
+ fprintf(stderr, "usage: ./%s <conf> <file>\n", argv[0]);
+ exit(1);
+ }
+
+ ret = ceph_create(&cmount, NULL);
+ if (ret) {
+ fprintf(stderr, "ceph_create=%d\n", ret);
+ exit(1);
+ }
+
+ ret = ceph_conf_read_file(cmount, argv[1]);
+ if (ret) {
+ fprintf(stderr, "ceph_conf_read_file=%d\n", ret);
+ exit(1);
+ }
+
+ ret = ceph_conf_parse_argv(cmount, argc, argv);
+ if (ret) {
+ fprintf(stderr, "ceph_conf_parse_argv=%d\n", ret);
+ exit(1);
+ }
+
+ ret = ceph_mount(cmount, NULL);
+ if (ret) {
+ fprintf(stderr, "ceph_mount=%d\n", ret);
+ exit(1);
+ }
+
+ ret = ceph_chdir(cmount, "/");
+ if (ret) {
+ fprintf(stderr, "ceph_chdir=%d\n", ret);
+ exit(1);
+ }
+
+ fd = ceph_open(cmount, argv[2], O_CREAT|O_TRUNC, 0777);
+ if (fd < 0) {
+ fprintf(stderr, "ceph_open=%d\n", fd);
+ exit(1);
+ }
+
+ memset(buf, 'a', sizeof(buf));
+
+ len = ceph_write(cmount, fd, buf, sizeof(buf), 0);
+
+ fprintf(stdout, "wrote %d bytes\n", len);
+
+ ceph_shutdown(cmount);
+
+ return 0;
+}