From: Haomai Wang Date: Thu, 30 Apr 2015 16:39:53 +0000 (+0800) Subject: test_libcephfs: Add tests to cover zero length write X-Git-Tag: v9.0.1~30^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F4516%2Fhead;p=ceph.git test_libcephfs: Add tests to cover zero length write Signed-off-by: Haomai Wang --- diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 3a1385c86001..bdc192275a6a 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -886,6 +886,24 @@ TEST(LibCephFS, HardlinkNoOriginal) { ceph_shutdown(cmount); } +TEST(LibCephFS, BadArgument) { + struct ceph_mount_info *cmount; + ASSERT_EQ(ceph_create(&cmount, NULL), 0); + ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL)); + ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0); + ASSERT_EQ(ceph_mount(cmount, NULL), 0); + + int fd = ceph_open(cmount, "test_file", O_CREAT|O_RDWR, 0666); + ASSERT_GT(fd, 0); + char buf[100]; + ASSERT_EQ(ceph_write(cmount, fd, buf, sizeof(buf), 0), (int)sizeof(buf)); + ASSERT_EQ(ceph_read(cmount, fd, buf, 5, 0), 0); + ceph_close(cmount, fd); + ASSERT_EQ(ceph_unlink(cmount, "test_file"), 0); + + ceph_shutdown(cmount); +} + TEST(LibCephFS, BadFileDesc) { struct ceph_mount_info *cmount; ASSERT_EQ(ceph_create(&cmount, NULL), 0);