Unit tests for chain_xattr.cc #40

Merged
merged 1 commit into from Feb 14, 2013

Conversation

Projects
None yet
2 participants
Owner

dachary commented Feb 8, 2013

Create a new test file covering most (> 97%) of src/os/chain_xattr.{cc,h}
lines of code. The following functions are tested:

int chain_getxattr(const char *fn, const char *name, void *val, size_t size);
int chain_fgetxattr(int fd, const char *name, void *val, size_t size);
int chain_setxattr(const char *fn, const char *name, const void *val, size_t size);
int chain_fsetxattr(int fd, const char *name, const void *val, size_t size);
int chain_listxattr(const char *fn, char *names, size_t len);
int chain_flistxattr(int fd, char *names, size_t len);
int chain_removexattr(const char *fn, const char *name);
int chain_fremovexattr(int fd, const char *name);

The function translate_raw_name substitutes @@ into @. When the trailing
character is a @, it breaks. However, such an occurence cannot be created by
chain_setxattr because it always create pairs of @. Instead of silently
breaking the loop, the function should probably return on error so that the
caller can ignore it.

The function chain_fgetxattr_len may return on error if fgetxattr
returns on error. However, it is only called after another attr function
returned success and the tests cannot create the conditions under which
it would fail.

The function chain_fsetxattr may leak attributes when used to override
an existing attribute. This leak is not tested or fixed, it is just
discussed in http://marc.info/?l=ceph-devel&m=136027076615853&w=4

If the file system in which the tests are run does not support extended
attributes, the tests are not run. The detection uses the same logic as
the one implemented in FileStore::_detect_fs

The output of the tests are silenced to reduce the output when testing
assertions ( except for the dout_emergency function which cannot be
controlled).

@dachary dachary Unit tests for chain_xattr.cc
Create a new test file covering most (> 97%) of src/os/chain_xattr.{cc,h}
lines of code. The following functions are tested:

int chain_getxattr(const char *fn, const char *name, void *val, size_t size);
int chain_fgetxattr(int fd, const char *name, void *val, size_t size);
int chain_setxattr(const char *fn, const char *name, const void *val, size_t size);
int chain_fsetxattr(int fd, const char *name, const void *val, size_t size);
int chain_listxattr(const char *fn, char *names, size_t len);
int chain_flistxattr(int fd, char *names, size_t len);
int chain_removexattr(const char *fn, const char *name);
int chain_fremovexattr(int fd, const char *name);

The function translate_raw_name substitutes @@ into @. When the trailing
character is a @, it breaks. However, such an occurence cannot be created by
chain_setxattr because it always create pairs of @. Instead of silently
breaking the loop, the function should probably return on error so that the
caller can ignore it.

The function chain_fgetxattr_len may return on error if fgetxattr
returns on error. However, it is only called after another attr function
returned success and the tests cannot create the conditions under which
it would fail.

The function chain_fsetxattr may leak attributes when used to override
an existing attribute. This leak is not tested or fixed, it is just
discussed in http://marc.info/?l=ceph-devel&m=136027076615853&w=4

If the file system in which the tests are run does not support extended
attributes, the tests are not run. The detection uses the same logic as
the one implemented in FileStore::_detect_fs

The output of the tests are silenced to reduce the output when testing
assertions ( except for the dout_emergency function which cannot be
controlled).
a62d519
Owner

liewegas commented Feb 14, 2013

Hi Loic-

Are there changes you want/need to make to this given the email conversation about removing chained xattrs, or is this ready as-is?

Owner

dachary commented Feb 14, 2013

If you are refering to the http://marc.info/?l=ceph-devel&m=136027076615853&w=4 email conversation, I already amended the tests accordingly. Is there another discussion related to obseleting chained xattrs entirely ?

Owner

liewegas commented Feb 14, 2013

Great, just checking. Thanks!

@liewegas liewegas added a commit that referenced this pull request Feb 14, 2013

@liewegas liewegas Merge pull request #40 from dachary/master
Unit tests for chain_xattr.cc

Reviewed-by: Sage Weil <sage@inktank.com>
61eb0e9

@liewegas liewegas merged commit 61eb0e9 into ceph:master Feb 14, 2013

@theanalyst theanalyst pushed a commit to theanalyst/ceph that referenced this pull request May 23, 2016

@ddiss ddiss Merge pull request #40 from ddiss/ses3_cmpext_writesame_opcode_upgrade
rados cmpext and writesame opcode upgrade
bcd73de

@smithfarm smithfarm pushed a commit to smithfarm/ceph that referenced this pull request Jun 22, 2017

wusui Merge pull request #40 from ceph/wip-teutharm-wusui
Wip teutharm wusui
042d8e6

@smithfarm smithfarm pushed a commit to smithfarm/ceph that referenced this pull request Jun 23, 2017

wusui Merge pull request #40 from ceph/wip-teutharm-wusui
Wip teutharm wusui
442a36c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment