From: Colin Patrick McCabe Date: Thu, 21 Apr 2011 22:41:55 +0000 (-0700) Subject: testceph: add more tests X-Git-Tag: v0.28~139^2~52 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f7e515504a62c37a357ff4accf7df1c4ade80338;p=ceph.git testceph: add more tests Signed-off-by: Colin McCabe --- diff --git a/src/client/libceph.h b/src/client/libceph.h index 07ef4a5628ff..558d04f58dfd 100644 --- a/src/client/libceph.h +++ b/src/client/libceph.h @@ -16,6 +16,7 @@ #define CEPH_LIB_H #include +#include #include struct stat_precise { diff --git a/src/client/testceph.cc b/src/client/testceph.cc index a5b1370a9e0b..e3a55903406b 100644 --- a/src/client/testceph.cc +++ b/src/client/testceph.cc @@ -12,7 +12,10 @@ * */ +#include "common/errno.h" #include "libceph.h" + +#include #include 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;