]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
testceph: add more tests
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 21 Apr 2011 22:41:55 +0000 (15:41 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 25 Apr 2011 18:05:43 +0000 (11:05 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/client/libceph.h
src/client/testceph.cc

index 07ef4a5628ffa4dbf3dbed0c9c89a3b138024e49..558d04f58dfdabc4c0532a0150cdf086ca8fd8ee 100644 (file)
@@ -16,6 +16,7 @@
 #define CEPH_LIB_H
 
 #include <utime.h>
+#include <sys/stat.h>
 #include <sys/types.h>
 
 struct stat_precise {
index a5b1370a9e0b6b61d41d1a0e1ab188b608a71db4..e3a55903406b93d4a6ff99675bf25d68eb1d14ca 100644 (file)
  * 
  */
 
+#include "common/errno.h"
 #include "libceph.h"
+
+#include <errno.h>
 #include <iostream>
 
 using std::cout;
@@ -46,6 +49,60 @@ int main(int argc, const char **argv)
   }
   cout << "Successfully mounted Ceph!" << std::endl;
 
+  ceph_dir_result_t *foo_dir;
+  ret = ceph_opendir(cmount, "foo", &foo_dir);
+  if (ret != -ENOENT) {
+    cerr << "ceph_opendir error: unexpected result from trying to open foo: "
+        << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+
+  ret = ceph_mkdir(cmount, "foo",  0777);
+  if (ret) {
+    cerr << "ceph_mkdir error: " << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+
+  struct stat stbuf;
+  ret = ceph_lstat(cmount, "foo", &stbuf);
+  if (ret) {
+    cerr << "ceph_lstat error: " << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+
+  if (!S_ISDIR(stbuf.st_mode)) {
+    cerr << "ceph_lstat(foo): foo is not a directory? st_mode = "
+        << stbuf.st_mode << std::endl;
+    return 1;
+  }
+
+  ret = ceph_rmdir(cmount, "foo");
+  if (ret) {
+    cerr << "ceph_rmdir error: " << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+
+  ret = ceph_mkdirs(cmount, "foo/bar/baz",  0777);
+  if (ret) {
+    cerr << "ceph_mkdirs error: " << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+  ret = ceph_rmdir(cmount, "foo/bar/baz");
+  if (ret) {
+    cerr << "ceph_rmdir error: " << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+  ret = ceph_rmdir(cmount, "foo/bar");
+  if (ret) {
+    cerr << "ceph_rmdir error: " << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+  ret = ceph_rmdir(cmount, "foo");
+  if (ret) {
+    cerr << "ceph_rmdir error: " << cpp_strerror(ret) << std::endl;
+    return 1;
+  }
+
   ceph_shutdown(cmount);
 
   return 0;